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";
161 args.
AddOption(&mesh_file,
"-m",
"--mesh",
162 "Mesh file to use.");
163 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
164 "Number of times to refine the mesh uniformly in serial.");
165 args.
AddOption(&par_ref_levels,
"-rp",
"--refine-parallel",
166 "Number of times to refine the mesh uniformly in parallel.");
168 "Order (degree) of the finite elements.");
169 args.
AddOption(&ode_solver_type,
"-s",
"--ode-solver",
170 "ODE solver: 1 - Backward Euler, 2 - SDIRK2, 3 - SDIRK3\n\t."
171 "\t 22 - Mid-Point, 23 - SDIRK23, 34 - SDIRK34.");
172 args.
AddOption(&t_final,
"-tf",
"--t-final",
173 "Final time; start time is 0.");
174 args.
AddOption(&dt,
"-dt",
"--time-step",
177 "Magnetic permeability coefficient.");
179 "Conductivity coefficient.");
181 "Frequency of oscillation.");
182 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
183 "--no-visualization",
184 "Enable or disable GLVis visualization.");
185 args.
AddOption(&visit,
"-visit",
"--visit",
"-no-visit",
"--no-visit",
186 "Enable or disable VisIt visualization.");
187 args.
AddOption(&vis_steps,
"-vs",
"--visualization-steps",
188 "Visualize every n-th timestep.");
189 args.
AddOption(&basename,
"-k",
"--outputfilename",
190 "Name of the visit dump files");
191 args.
AddOption(&gfprint,
"-print",
"--print",
192 "Print results (grid functions) to disk.");
196 "Enable static condensation");
197 args.
AddOption(&debug,
"-debug",
"--debug",
198 "Print matrices and vectors to disk");
200 "Hypre print level");
202 "Name of problem to run");
203 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
224 cout <<
"\nSkin depth sqrt(2.0/(wj*mj*sj)) = " << sqrt(2.0/(wj_*mj_*sj_))
225 <<
"\nSkin depth sqrt(2.0*dt/(mj*sj)) = " << sqrt(2.0*dt/(mj_*sj_))
238 std::map<int, real_t> sigmaMap, InvTcondMap, TcapMap, InvTcapMap;
244 sigmaAir = 1.0e-6 *
sigma;
245 TcondAir = 1.0e6 * Tconductivity;
246 TcapAir = 1.0 * Tcapacity;
250 cerr <<
"Problem " <<
problem <<
" not recognized\n";
257 sigmaMap.insert(pair<int, real_t>(1,
sigma));
258 sigmaMap.insert(pair<int, real_t>(2, sigmaAir));
259 sigmaMap.insert(pair<int, real_t>(3, sigmaAir));
261 InvTcondMap.insert(pair<int, real_t>(1, 1.0/Tconductivity));
262 InvTcondMap.insert(pair<int, real_t>(2, 1.0/TcondAir));
263 InvTcondMap.insert(pair<int, real_t>(3, 1.0/TcondAir));
265 TcapMap.insert(pair<int, real_t>(1, Tcapacity));
266 TcapMap.insert(pair<int, real_t>(2, TcapAir));
267 TcapMap.insert(pair<int, real_t>(3, TcapAir));
269 InvTcapMap.insert(pair<int, real_t>(1, 1.0/Tcapacity));
270 InvTcapMap.insert(pair<int, real_t>(2, 1.0/TcapAir));
271 InvTcapMap.insert(pair<int, real_t>(3, 1.0/TcapAir));
275 cerr <<
"Problem " <<
problem <<
" not recognized\n";
283 mesh =
new Mesh(mesh_file, 1, 1);
306 thermal_ess_bdr[2] = 1;
312 poisson_ess_bdr[0] = 1;
313 poisson_ess_bdr[1] = 1;
316 else if (strcmp(
problem,
"rod")==0)
331 thermal_ess_bdr[0] = 1;
332 thermal_ess_bdr[1] = 1;
338 poisson_ess_bdr[0] = 1;
339 poisson_ess_bdr[1] = 1;
344 cerr <<
"Problem " <<
problem <<
" not recognized\n";
355 switch (ode_solver_type)
368 cout <<
"Unknown ODE solver type: " << ode_solver_type <<
'\n';
377 for (
int lev = 0; lev < ser_ref_levels; lev++)
387 for (
int lev = 0; lev < par_ref_levels; lev++)
400 int numElems = pmesh->
GetNE();
401 for (
int ielem = 0; ielem < numElems; ielem++)
458 cout <<
"Number of Temperature Flux unknowns: " << glob_size_rt << endl;
459 cout <<
"Number of Temperature unknowns: " << glob_size_l2 << endl;
460 cout <<
"Number of Electric Field unknowns: " << glob_size_nd << endl;
461 cout <<
"Number of Magnetic Field unknowns: " << glob_size_rt << endl;
462 cout <<
"Number of Electrostatic unknowns: " << glob_size_h1 << endl;
465 int Vsize_l2 = L2FESpace.
GetVSize();
466 int Vsize_nd = HCurlFESpace.
GetVSize();
467 int Vsize_rt = HDivFESpace.
GetVSize();
468 int Vsize_h1 = HGradFESpace.
GetVSize();
481 true_offset[1] = true_offset[0] + Vsize_l2;
482 true_offset[2] = true_offset[1] + Vsize_rt;
483 true_offset[3] = true_offset[2] + Vsize_h1;
484 true_offset[4] = true_offset[3] + Vsize_nd;
485 true_offset[5] = true_offset[4] + Vsize_rt;
486 true_offset[6] = true_offset[5] + Vsize_l2;
495 T_gf.
MakeRef(&L2FESpace,F, true_offset[0]);
496 F_gf.
MakeRef(&HDivFESpace,F, true_offset[1]);
497 P_gf.
MakeRef(&HGradFESpace,F,true_offset[2]);
498 E_gf.
MakeRef(&HCurlFESpace,F,true_offset[3]);
499 B_gf.
MakeRef(&HDivFESpace,F, true_offset[4]);
500 w_gf.
MakeRef(&L2FESpace,F, true_offset[5]);
515 HDivFESpace, HGradFESpace,
516 ess_bdr, thermal_ess_bdr, poisson_ess_bdr,
517 mu, sigmaMap, TcapMap, InvTcapMap,
538 int Ww = 350,
Wh = 350;
542 P_gf,
"Electric Potential (Phi)",
Wx,
Wy,
Ww,
Wh);
546 E_gf,
"Electric Field (E)",
Wx,
Wy,
Ww,
Wh);
550 B_gf,
"Magnetic Field (B)",
Wx,
Wy,
Ww,
Wh);
555 w_gf,
"Joule Heating",
Wx,
Wy,
Ww,
Wh);
560 T_gf,
"Temperature",
Wx,
Wy,
Ww,
Wh);
585 ode_solver->
Init(oper);
588 bool last_step =
false;
589 for (
int ti = 1; !last_step; ti++)
591 if (t + dt >= t_final - dt/2)
598 ode_solver->
Step(F, t, dt);
602 oper.
Debug(basename,t);
607 ostringstream T_name, E_name, B_name, F_name, w_name, P_name, mesh_name;
608 T_name << basename <<
"_" << setfill(
'0') << setw(6) << t <<
"_"
609 <<
"T." << setfill(
'0') << setw(6) << myid;
610 E_name << basename <<
"_" << setfill(
'0') << setw(6) << t <<
"_"
611 <<
"E." << setfill(
'0') << setw(6) << myid;
612 B_name << basename <<
"_" << setfill(
'0') << setw(6) << t <<
"_"
613 <<
"B." << setfill(
'0') << setw(6) << myid;
614 F_name << basename <<
"_" << setfill(
'0') << setw(6) << t <<
"_"
615 <<
"F." << setfill(
'0') << setw(6) << myid;
616 w_name << basename <<
"_" << setfill(
'0') << setw(6) << t <<
"_"
617 <<
"w." << setfill(
'0') << setw(6) << myid;
618 P_name << basename <<
"_" << setfill(
'0') << setw(6) << t <<
"_"
619 <<
"P." << setfill(
'0') << setw(6) << myid;
620 mesh_name << basename <<
"_" << setfill(
'0') << setw(6) << t <<
"_"
621 <<
"mesh." << setfill(
'0') << setw(6) << myid;
623 ofstream mesh_ofs(mesh_name.str().c_str());
624 mesh_ofs.precision(8);
625 pmesh->
Print(mesh_ofs);
628 ofstream T_ofs(T_name.str().c_str());
633 ofstream E_ofs(E_name.str().c_str());
638 ofstream B_ofs(B_name.str().c_str());
643 ofstream F_ofs(F_name.str().c_str());
648 ofstream P_ofs(P_name.str().c_str());
653 ofstream w_ofs(w_name.str().c_str());
659 if (last_step || (ti % vis_steps) == 0)
666 cout <<
"step " << setw(6) << ti <<
",\tt = " << setw(6)
667 << setprecision(3) << t
668 <<
",\tdot(E, J) = " << setprecision(8) << el << endl;
678 int Ww = 350,
Wh = 350;
682 P_gf,
"Electric Potential (Phi)",
Wx,
Wy,
Ww,
Wh);
686 E_gf,
"Electric Field (E)",
Wx,
Wy,
Ww,
Wh);
690 B_gf,
"Magnetic Field (B)",
Wx,
Wy,
Ww,
Wh);
696 w_gf,
"Joule Heating",
Wx,
Wy,
Ww,
Wh);
701 T_gf,
"Temperature",
Wx,
Wy,
Ww,
Wh);