127int main(
int argc,
char *argv[])
138 const char *mesh_file =
"cylinder-hex.mesh";
139 int ser_ref_levels = 0;
140 int par_ref_levels = 0;
142 int ode_solver_type = 1;
148 real_t Tconductivity = 0.01;
150 bool visualization =
true;
154 const char *basename =
"Joule";
160 args.
AddOption(&mesh_file,
"-m",
"--mesh",
161 "Mesh file to use.");
162 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
163 "Number of times to refine the mesh uniformly in serial.");
164 args.
AddOption(&par_ref_levels,
"-rp",
"--refine-parallel",
165 "Number of times to refine the mesh uniformly in parallel.");
167 "Order (degree) of the finite elements.");
168 args.
AddOption(&ode_solver_type,
"-s",
"--ode-solver",
169 "ODE solver: 1 - Backward Euler, 2 - SDIRK2, 3 - SDIRK3\n\t."
170 "\t 22 - Mid-Point, 23 - SDIRK23, 34 - SDIRK34.");
171 args.
AddOption(&t_final,
"-tf",
"--t-final",
172 "Final time; start time is 0.");
173 args.
AddOption(&dt,
"-dt",
"--time-step",
176 "Magnetic permeability coefficient.");
178 "Conductivity coefficient.");
180 "Frequency of oscillation.");
181 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
182 "--no-visualization",
183 "Enable or disable GLVis visualization.");
184 args.
AddOption(&visit,
"-visit",
"--visit",
"-no-visit",
"--no-visit",
185 "Enable or disable VisIt visualization.");
186 args.
AddOption(&vis_steps,
"-vs",
"--visualization-steps",
187 "Visualize every n-th timestep.");
188 args.
AddOption(&basename,
"-k",
"--outputfilename",
189 "Name of the visit dump files");
190 args.
AddOption(&gfprint,
"-print",
"--print",
191 "Print results (grid functions) to disk.");
195 "Enable static condensation");
196 args.
AddOption(&debug,
"-debug",
"--debug",
197 "Print matrices and vectors to disk");
199 "Hypre print level");
201 "Name of problem to run");
222 cout <<
"\nSkin depth sqrt(2.0/(wj*mj*sj)) = " << sqrt(2.0/(wj_*mj_*sj_))
223 <<
"\nSkin depth sqrt(2.0*dt/(mj*sj)) = " << sqrt(2.0*dt/(mj_*sj_))
236 std::map<int, real_t> sigmaMap, InvTcondMap, TcapMap, InvTcapMap;
242 sigmaAir = 1.0e-6 *
sigma;
243 TcondAir = 1.0e6 * Tconductivity;
244 TcapAir = 1.0 * Tcapacity;
248 cerr <<
"Problem " <<
problem <<
" not recognized\n";
255 sigmaMap.insert(pair<int, real_t>(1,
sigma));
256 sigmaMap.insert(pair<int, real_t>(2, sigmaAir));
257 sigmaMap.insert(pair<int, real_t>(3, sigmaAir));
259 InvTcondMap.insert(pair<int, real_t>(1, 1.0/Tconductivity));
260 InvTcondMap.insert(pair<int, real_t>(2, 1.0/TcondAir));
261 InvTcondMap.insert(pair<int, real_t>(3, 1.0/TcondAir));
263 TcapMap.insert(pair<int, real_t>(1, Tcapacity));
264 TcapMap.insert(pair<int, real_t>(2, TcapAir));
265 TcapMap.insert(pair<int, real_t>(3, TcapAir));
267 InvTcapMap.insert(pair<int, real_t>(1, 1.0/Tcapacity));
268 InvTcapMap.insert(pair<int, real_t>(2, 1.0/TcapAir));
269 InvTcapMap.insert(pair<int, real_t>(3, 1.0/TcapAir));
273 cerr <<
"Problem " <<
problem <<
" not recognized\n";
281 mesh =
new Mesh(mesh_file, 1, 1);
304 thermal_ess_bdr[2] = 1;
310 poisson_ess_bdr[0] = 1;
311 poisson_ess_bdr[1] = 1;
314 else if (strcmp(
problem,
"rod")==0)
329 thermal_ess_bdr[0] = 1;
330 thermal_ess_bdr[1] = 1;
336 poisson_ess_bdr[0] = 1;
337 poisson_ess_bdr[1] = 1;
342 cerr <<
"Problem " <<
problem <<
" not recognized\n";
353 switch (ode_solver_type)
366 cout <<
"Unknown ODE solver type: " << ode_solver_type <<
'\n';
375 for (
int lev = 0; lev < ser_ref_levels; lev++)
385 for (
int lev = 0; lev < par_ref_levels; lev++)
398 int numElems = pmesh->
GetNE();
399 for (
int ielem = 0; ielem < numElems; ielem++)
456 cout <<
"Number of Temperature Flux unknowns: " << glob_size_rt << endl;
457 cout <<
"Number of Temperature unknowns: " << glob_size_l2 << endl;
458 cout <<
"Number of Electric Field unknowns: " << glob_size_nd << endl;
459 cout <<
"Number of Magnetic Field unknowns: " << glob_size_rt << endl;
460 cout <<
"Number of Electrostatic unknowns: " << glob_size_h1 << endl;
463 int Vsize_l2 = L2FESpace.
GetVSize();
464 int Vsize_nd = HCurlFESpace.
GetVSize();
465 int Vsize_rt = HDivFESpace.
GetVSize();
466 int Vsize_h1 = HGradFESpace.
GetVSize();
479 true_offset[1] = true_offset[0] + Vsize_l2;
480 true_offset[2] = true_offset[1] + Vsize_rt;
481 true_offset[3] = true_offset[2] + Vsize_h1;
482 true_offset[4] = true_offset[3] + Vsize_nd;
483 true_offset[5] = true_offset[4] + Vsize_rt;
484 true_offset[6] = true_offset[5] + Vsize_l2;
493 T_gf.
MakeRef(&L2FESpace,F, true_offset[0]);
494 F_gf.
MakeRef(&HDivFESpace,F, true_offset[1]);
495 P_gf.
MakeRef(&HGradFESpace,F,true_offset[2]);
496 E_gf.
MakeRef(&HCurlFESpace,F,true_offset[3]);
497 B_gf.
MakeRef(&HDivFESpace,F, true_offset[4]);
498 w_gf.
MakeRef(&L2FESpace,F, true_offset[5]);
513 HDivFESpace, HGradFESpace,
514 ess_bdr, thermal_ess_bdr, poisson_ess_bdr,
515 mu, sigmaMap, TcapMap, InvTcapMap,
537 int Ww = 350,
Wh = 350;
541 P_gf,
"Electric Potential (Phi)",
Wx,
Wy,
Ww,
Wh);
545 E_gf,
"Electric Field (E)",
Wx,
Wy,
Ww,
Wh);
549 B_gf,
"Magnetic Field (B)",
Wx,
Wy,
Ww,
Wh);
554 w_gf,
"Joule Heating",
Wx,
Wy,
Ww,
Wh);
559 T_gf,
"Temperature",
Wx,
Wy,
Ww,
Wh);
584 ode_solver->
Init(oper);
587 bool last_step =
false;
588 for (
int ti = 1; !last_step; ti++)
590 if (
t + dt >= t_final - dt/2)
597 ode_solver->
Step(F,
t, dt);
606 ostringstream T_name, E_name, B_name, F_name, w_name, P_name, mesh_name;
607 T_name << basename <<
"_" << setfill(
'0') << setw(6) <<
t <<
"_"
608 <<
"T." << setfill(
'0') << setw(6) << myid;
609 E_name << basename <<
"_" << setfill(
'0') << setw(6) <<
t <<
"_"
610 <<
"E." << setfill(
'0') << setw(6) << myid;
611 B_name << basename <<
"_" << setfill(
'0') << setw(6) <<
t <<
"_"
612 <<
"B." << setfill(
'0') << setw(6) << myid;
613 F_name << basename <<
"_" << setfill(
'0') << setw(6) <<
t <<
"_"
614 <<
"F." << setfill(
'0') << setw(6) << myid;
615 w_name << basename <<
"_" << setfill(
'0') << setw(6) <<
t <<
"_"
616 <<
"w." << setfill(
'0') << setw(6) << myid;
617 P_name << basename <<
"_" << setfill(
'0') << setw(6) <<
t <<
"_"
618 <<
"P." << setfill(
'0') << setw(6) << myid;
619 mesh_name << basename <<
"_" << setfill(
'0') << setw(6) <<
t <<
"_"
620 <<
"mesh." << setfill(
'0') << setw(6) << myid;
622 ofstream mesh_ofs(mesh_name.str().c_str());
623 mesh_ofs.precision(8);
624 pmesh->
Print(mesh_ofs);
627 ofstream T_ofs(T_name.str().c_str());
632 ofstream E_ofs(E_name.str().c_str());
637 ofstream B_ofs(B_name.str().c_str());
642 ofstream F_ofs(F_name.str().c_str());
647 ofstream P_ofs(P_name.str().c_str());
652 ofstream w_ofs(w_name.str().c_str());
658 if (last_step || (ti % vis_steps) == 0)
665 cout <<
"step " << setw(6) << ti <<
",\tt = " << setw(6)
666 << setprecision(3) <<
t
667 <<
",\tdot(E, J) = " << setprecision(8) << el << endl;
677 int Ww = 350,
Wh = 350;
681 P_gf,
"Electric Potential (Phi)",
Wx,
Wy,
Ww,
Wh);
685 E_gf,
"Electric Field (E)",
Wx,
Wy,
Ww,
Wh);
689 B_gf,
"Magnetic Field (B)",
Wx,
Wy,
Ww,
Wh);
695 w_gf,
"Joule Heating",
Wx,
Wy,
Ww,
Wh);
700 T_gf,
"Temperature",
Wx,
Wy,
Ww,
Wh);