MFEM v4.8.0
Finite element discretization library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
ex9.cpp
Go to the documentation of this file.
1// MFEM Example 9
2// SUNDIALS Modification
3//
4// Compile with:
5// make ex9 (GNU make)
6// make sundials_ex9 (CMake)
7//
8// Sample runs:
9// ex9 -m ../../data/periodic-segment.mesh -p 0 -r 2 -s 7 -dt 0.005
10// ex9 -m ../../data/periodic-square.mesh -p 1 -r 2 -s 8 -dt 0.005 -tf 9
11// ex9 -m ../../data/periodic-hexagon.mesh -p 0 -r 2 -s 7 -dt 0.0018 -vs 25
12// ex9 -m ../../data/periodic-hexagon.mesh -p 0 -r 2 -s 9 -dt 0.01 -vs 15
13// ex9 -m ../../data/amr-quad.mesh -p 1 -r 2 -s 9 -dt 0.002 -tf 9
14// ex9 -m ../../data/star-q3.mesh -p 1 -r 2 -s 9 -dt 0.005 -tf 9
15// ex9 -m ../../data/disc-nurbs.mesh -p 1 -r 3 -s 7 -dt 0.005 -tf 9
16// ex9 -m ../../data/periodic-cube.mesh -p 0 -r 2 -s 8 -dt 0.02 -tf 8 -o 2
17//
18// Device sample runs:
19// ex9 -pa
20// ex9 -ea
21// ex9 -fa
22// ex9 -pa -m ../../data/periodic-cube.mesh
23// ex9 -pa -m ../../data/periodic-cube.mesh -d cuda
24// ex9 -ea -m ../../data/periodic-cube.mesh -d cuda
25// ex9 -fa -m ../../data/periodic-cube.mesh -d cuda
26//
27// Description: This example code solves the time-dependent advection equation
28// du/dt + v.grad(u) = 0, where v is a given fluid velocity, and
29// u0(x)=u(0,x) is a given initial condition.
30//
31// The example demonstrates the use of Discontinuous Galerkin (DG)
32// bilinear forms in MFEM (face integrators), the use of implicit
33// and explicit ODE time integrators, the definition of periodic
34// boundary conditions through periodic meshes, as well as the use
35// of GLVis for persistent visualization of a time-evolving
36// solution. The saving of time-dependent data files for external
37// visualization with VisIt (visit.llnl.gov) and ParaView
38// (paraview.org) is also illustrated.
39
40#include "mfem.hpp"
41#include <fstream>
42#include <iostream>
43#include <algorithm>
44
45#ifndef MFEM_USE_SUNDIALS
46#error This example requires that MFEM is built with MFEM_USE_SUNDIALS=YES
47#endif
48
49using namespace std;
50using namespace mfem;
51
52// Choice for the problem setup. The fluid velocity, initial condition and
53// inflow boundary condition are chosen based on this parameter.
55
56// Velocity coefficient
57void velocity_function(const Vector &x, Vector &v);
58
59// Initial condition
60double u0_function(const Vector &x);
61
62// Inflow boundary condition
63double inflow_function(const Vector &x);
64
65// Mesh bounding box
67
68class DG_Solver : public Solver
69{
70private:
71 SparseMatrix &M, &K, A;
72 GMRESSolver linear_solver;
73 BlockILU prec;
74 double dt;
75public:
76 DG_Solver(SparseMatrix &M_, SparseMatrix &K_, const FiniteElementSpace &fes)
77 : M(M_),
78 K(K_),
79 prec(fes.GetTypicalFE()->GetDof(),
80 BlockILU::Reordering::MINIMUM_DISCARDED_FILL),
81 dt(-1.0)
82 {
83 linear_solver.iterative_mode = false;
84 linear_solver.SetRelTol(1e-9);
85 linear_solver.SetAbsTol(0.0);
86 linear_solver.SetMaxIter(100);
87 linear_solver.SetPrintLevel(0);
88 linear_solver.SetPreconditioner(prec);
89 }
90
91 void SetTimeStep(double dt_)
92 {
93 if (dt_ != dt)
94 {
95 dt = dt_;
96 // Form operator A = M - dt*K
97 A = K;
98 A *= -dt;
99 A += M;
100
101 // this will also call SetOperator on the preconditioner
102 linear_solver.SetOperator(A);
103 }
104 }
105
106 void SetOperator(const Operator &op)
107 {
108 linear_solver.SetOperator(op);
109 }
110
111 virtual void Mult(const Vector &x, Vector &y) const
112 {
113 linear_solver.Mult(x, y);
114 }
115};
116
117/** A time-dependent operator for the right-hand side of the ODE. The DG weak
118 form of du/dt = -v.grad(u) is M du/dt = K u + b, where M and K are the mass
119 and advection matrices, and b describes the flow on the boundary. This can
120 be written as a general ODE, du/dt = M^{-1} (K u + b), and this class is
121 used to evaluate the right-hand side. */
122class FE_Evolution : public TimeDependentOperator
123{
124private:
125 BilinearForm &M, &K;
126 const Vector &b;
127 Solver *M_prec;
128 CGSolver M_solver;
129 DG_Solver *dg_solver;
130
131 mutable Vector z;
132
133public:
134 FE_Evolution(BilinearForm &M_, BilinearForm &K_, const Vector &b_);
135
136 virtual void Mult(const Vector &x, Vector &y) const;
137 virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
138
139 virtual ~FE_Evolution();
140};
141
142
143int main(int argc, char *argv[])
144{
145 // 0. Initialize SUNDIALS.
147
148 // 1. Parse command-line options.
149 problem = 0;
150 const char *mesh_file = "../../data/periodic-hexagon.mesh";
151 int ref_levels = 2;
152 int order = 3;
153 bool pa = false;
154 bool ea = false;
155 bool fa = false;
156 const char *device_config = "cpu";
157 int ode_solver_type = 7;
158 double t_final = 10.0;
159 double dt = 0.01;
160 bool visualization = false;
161 bool visit = false;
162 bool paraview = false;
163 bool binary = false;
164 int vis_steps = 5;
165
166 // Relative and absolute tolerances for CVODE and ARKODE.
167 const double reltol = 1e-2, abstol = 1e-2;
168
169 int precision = 8;
170 cout.precision(precision);
171
172 OptionsParser args(argc, argv);
173 args.AddOption(&mesh_file, "-m", "--mesh",
174 "Mesh file to use.");
175 args.AddOption(&problem, "-p", "--problem",
176 "Problem setup to use. See options in velocity_function().");
177 args.AddOption(&ref_levels, "-r", "--refine",
178 "Number of times to refine the mesh uniformly.");
179 args.AddOption(&order, "-o", "--order",
180 "Order (degree) of the finite elements.");
181 args.AddOption(&pa, "-pa", "--partial-assembly", "-no-pa",
182 "--no-partial-assembly", "Enable Partial Assembly.");
183 args.AddOption(&ea, "-ea", "--element-assembly", "-no-ea",
184 "--no-element-assembly", "Enable Element Assembly.");
185 args.AddOption(&fa, "-fa", "--full-assembly", "-no-fa",
186 "--no-full-assembly", "Enable Full Assembly.");
187 args.AddOption(&device_config, "-d", "--device",
188 "Device configuration string, see Device::Configure().");
189 args.AddOption(&ode_solver_type, "-s", "--ode-solver",
190 "ODE solver:\n\t"
191 "1 - Forward Euler,\n\t"
192 "2 - RK2 SSP,\n\t"
193 "3 - RK3 SSP,\n\t"
194 "4 - RK4,\n\t"
195 "6 - RK6,\n\t"
196 "7 - CVODE (adaptive order implicit Adams),\n\t"
197 "8 - ARKODE default (4th order) explicit,\n\t"
198 "9 - ARKODE RK8.");
199 args.AddOption(&t_final, "-tf", "--t-final",
200 "Final time; start time is 0.");
201 args.AddOption(&dt, "-dt", "--time-step",
202 "Time step.");
203 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
204 "--no-visualization",
205 "Enable or disable GLVis visualization.");
206 args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit",
207 "--no-visit-datafiles",
208 "Save data files for VisIt (visit.llnl.gov) visualization.");
209 args.AddOption(&paraview, "-paraview", "--paraview-datafiles", "-no-paraview",
210 "--no-paraview-datafiles",
211 "Save data files for ParaView (paraview.org) visualization.");
212 args.AddOption(&binary, "-binary", "--binary-datafiles", "-ascii",
213 "--ascii-datafiles",
214 "Use binary (Sidre) or ascii format for VisIt data files.");
215 args.AddOption(&vis_steps, "-vs", "--visualization-steps",
216 "Visualize every n-th timestep.");
217 args.Parse();
218 if (!args.Good())
219 {
220 args.PrintUsage(cout);
221 return 1;
222 }
223 // check for valid ODE solver option
224 if (ode_solver_type < 1 || ode_solver_type > 9)
225 {
226 cout << "Unknown ODE solver type: " << ode_solver_type << '\n';
227 return 3;
228 }
229 args.PrintOptions(cout);
230
231 Device device(device_config);
232 device.Print();
233
234 // 2. Read the mesh from the given mesh file. We can handle geometrically
235 // periodic meshes in this code.
236 Mesh mesh(mesh_file, 1, 1);
237 int dim = mesh.Dimension();
238
239 // 3. Refine the mesh to increase the resolution. In this example we do
240 // 'ref_levels' of uniform refinement, where 'ref_levels' is a
241 // command-line parameter. If the mesh is of NURBS type, we convert it to
242 // a (piecewise-polynomial) high-order mesh.
243 for (int lev = 0; lev < ref_levels; lev++)
244 {
245 mesh.UniformRefinement();
246 }
247 if (mesh.NURBSext)
248 {
249 mesh.SetCurvature(max(order, 1));
250 }
251 mesh.GetBoundingBox(bb_min, bb_max, max(order, 1));
252
253 // 4. Define the discontinuous DG finite element space of the given
254 // polynomial order on the refined mesh.
256 FiniteElementSpace fes(&mesh, &fec);
257
258 cout << "Number of unknowns: " << fes.GetVSize() << endl;
259
260 // 5. Set up and assemble the bilinear and linear forms corresponding to the
261 // DG discretization. The DGTraceIntegrator involves integrals over mesh
262 // interior faces.
266
267 BilinearForm m(&fes);
268 BilinearForm k(&fes);
269 if (pa)
270 {
271 m.SetAssemblyLevel(AssemblyLevel::PARTIAL);
272 k.SetAssemblyLevel(AssemblyLevel::PARTIAL);
273 }
274 else if (ea)
275 {
276 m.SetAssemblyLevel(AssemblyLevel::ELEMENT);
277 k.SetAssemblyLevel(AssemblyLevel::ELEMENT);
278 }
279 else if (fa)
280 {
281 m.SetAssemblyLevel(AssemblyLevel::FULL);
282 k.SetAssemblyLevel(AssemblyLevel::FULL);
283 }
285 constexpr double alpha = -1.0;
291
292 LinearForm b(&fes);
293 b.AddBdrFaceIntegrator(
294 new BoundaryFlowIntegrator(inflow, velocity, alpha));
295
296 m.Assemble();
297 int skip_zeros = 0;
298 k.Assemble(skip_zeros);
299 b.Assemble();
300 m.Finalize();
301 k.Finalize(skip_zeros);
302
303 // 6. Define the initial conditions, save the corresponding grid function to
304 // a file and (optionally) save data in the VisIt format and initialize
305 // GLVis visualization.
306 GridFunction u(&fes);
307 u.ProjectCoefficient(u0);
308
309 {
310 ofstream omesh("ex9.mesh");
311 omesh.precision(precision);
312 mesh.Print(omesh);
313 ofstream osol("ex9-init.gf");
314 osol.precision(precision);
315 u.Save(osol);
316 }
317
318 // Create data collection for solution output: either VisItDataCollection for
319 // ascii data files, or SidreDataCollection for binary data files.
320 DataCollection *dc = NULL;
321 if (visit)
322 {
323 if (binary)
324 {
325#ifdef MFEM_USE_SIDRE
326 dc = new SidreDataCollection("Example9", &mesh);
327#else
328 MFEM_ABORT("Must build with MFEM_USE_SIDRE=YES for binary output.");
329#endif
330 }
331 else
332 {
333 dc = new VisItDataCollection("Example9", &mesh);
334 dc->SetPrecision(precision);
335 }
336 dc->RegisterField("solution", &u);
337 dc->SetCycle(0);
338 dc->SetTime(0.0);
339 dc->Save();
340 }
341
342 ParaViewDataCollection *pd = NULL;
343 if (paraview)
344 {
345 pd = new ParaViewDataCollection("Example9", &mesh);
346 pd->SetPrefixPath("ParaView");
347 pd->RegisterField("solution", &u);
348 pd->SetLevelsOfDetail(order);
349 pd->SetDataFormat(VTKFormat::BINARY);
350 pd->SetHighOrderOutput(true);
351 pd->SetCycle(0);
352 pd->SetTime(0.0);
353 pd->Save();
354 }
355
356 socketstream sout;
357 if (visualization)
358 {
359 char vishost[] = "localhost";
360 int visport = 19916;
361 sout.open(vishost, visport);
362 if (!sout)
363 {
364 cout << "Unable to connect to GLVis server at "
365 << vishost << ':' << visport << endl;
366 visualization = false;
367 cout << "GLVis visualization disabled.\n";
368 }
369 else
370 {
371 sout.precision(precision);
372 sout << "solution\n" << mesh << u;
373 sout << "pause\n";
374 sout << flush;
375 cout << "GLVis visualization paused."
376 << " Press space (in the GLVis window) to resume it.\n";
377 }
378 }
379
380 // 7. Define the time-dependent evolution operator describing the ODE
381 // right-hand side, and define the ODE solver used for time integration.
382 FE_Evolution adv(m, k, b);
383
384 double t = 0.0;
385 adv.SetTime(t);
386
387 // Create the time integrator
388 ODESolver *ode_solver = NULL;
389 CVODESolver *cvode = NULL;
390 ARKStepSolver *arkode = NULL;
391 switch (ode_solver_type)
392 {
393 case 1: ode_solver = new ForwardEulerSolver; break;
394 case 2: ode_solver = new RK2Solver(1.0); break;
395 case 3: ode_solver = new RK3SSPSolver; break;
396 case 4: ode_solver = new RK4Solver; break;
397 case 6: ode_solver = new RK6Solver; break;
398 case 7:
399 cvode = new CVODESolver(CV_ADAMS);
400 cvode->Init(adv);
401 cvode->SetSStolerances(reltol, abstol);
402 cvode->SetMaxStep(dt);
404 ode_solver = cvode; break;
405 case 8:
407 arkode->Init(adv);
408 arkode->SetSStolerances(reltol, abstol);
409 arkode->SetMaxStep(dt);
410 arkode->SetOrder(4);
411 ode_solver = arkode; break;
412 case 9:
414 arkode->Init(adv);
415 arkode->SetSStolerances(reltol, abstol);
416 arkode->SetMaxStep(dt);
418 ode_solver = arkode; break;
419 }
420
421 // Initialize MFEM integrators, SUNDIALS integrators are initialized above
422 if (ode_solver_type < 7) { ode_solver->Init(adv); }
423
424 // 8. Perform time-integration (looping over the time iterations, ti,
425 // with a time-step dt).
426 bool done = false;
427 for (int ti = 0; !done; )
428 {
429 double dt_real = min(dt, t_final - t);
430 ode_solver->Step(u, t, dt_real);
431 ti++;
432
433 done = (t >= t_final - 1e-8*dt);
434
435 if (done || ti % vis_steps == 0)
436 {
437 cout << "time step: " << ti << ", time: " << t << endl;
438 if (cvode) { cvode->PrintInfo(); }
439 if (arkode) { arkode->PrintInfo(); }
440
441 if (visualization)
442 {
443 sout << "solution\n" << mesh << u << flush;
444 }
445
446 if (visit)
447 {
448 dc->SetCycle(ti);
449 dc->SetTime(t);
450 dc->Save();
451 }
452
453 if (paraview)
454 {
455 pd->SetCycle(ti);
456 pd->SetTime(t);
457 pd->Save();
458 }
459 }
460 }
461
462 // 9. Save the final solution. This output can be viewed later using GLVis:
463 // "glvis -m ex9.mesh -g ex9-final.gf".
464 {
465 ofstream osol("ex9-final.gf");
466 osol.precision(precision);
467 u.Save(osol);
468 }
469
470 // 10. Free the used memory.
471 delete ode_solver;
472 delete pd;
473 delete dc;
474
475 return 0;
476}
477
478
479// Implementation of class FE_Evolution
480FE_Evolution::FE_Evolution(BilinearForm &M_, BilinearForm &K_, const Vector &b_)
481 : TimeDependentOperator(M_.FESpace()->GetTrueVSize()),
482 M(M_), K(K_), b(b_), z(height)
483{
484 Array<int> ess_tdof_list;
485 if (M.GetAssemblyLevel() == AssemblyLevel::LEGACY)
486 {
487 M_prec = new DSmoother(M.SpMat());
488 M_solver.SetOperator(M.SpMat());
489 dg_solver = new DG_Solver(M.SpMat(), K.SpMat(), *M.FESpace());
490 }
491 else
492 {
493 M_prec = new OperatorJacobiSmoother(M, ess_tdof_list);
494 M_solver.SetOperator(M);
495 dg_solver = NULL;
496 }
497 M_solver.SetPreconditioner(*M_prec);
498 M_solver.iterative_mode = false;
499 M_solver.SetRelTol(1e-9);
500 M_solver.SetAbsTol(0.0);
501 M_solver.SetMaxIter(100);
502 M_solver.SetPrintLevel(0);
503}
504
505void FE_Evolution::Mult(const Vector &x, Vector &y) const
506{
507 // y = M^{-1} (K x + b)
508 K.Mult(x, z);
509 z += b;
510 M_solver.Mult(z, y);
511}
512
513void FE_Evolution::ImplicitSolve(const double dt, const Vector &x, Vector &k)
514{
515 MFEM_VERIFY(dg_solver != NULL,
516 "Implicit time integration is not supported with partial assembly");
517 K.Mult(x, z);
518 z += b;
519 dg_solver->SetTimeStep(dt);
520 dg_solver->Mult(z, k);
521}
522
523FE_Evolution::~FE_Evolution()
524{
525 delete M_prec;
526 delete dg_solver;
527}
528
529// Velocity coefficient
531{
532 int dim = x.Size();
533
534 // map to the reference [-1,1] domain
535 Vector X(dim);
536 for (int i = 0; i < dim; i++)
537 {
538 double center = (bb_min[i] + bb_max[i]) * 0.5;
539 X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
540 }
541
542 switch (problem)
543 {
544 case 0:
545 {
546 // Translations in 1D, 2D, and 3D
547 switch (dim)
548 {
549 case 1: v(0) = 1.0; break;
550 case 2: v(0) = sqrt(2./3.); v(1) = sqrt(1./3.); break;
551 case 3: v(0) = sqrt(3./6.); v(1) = sqrt(2./6.); v(2) = sqrt(1./6.);
552 break;
553 }
554 break;
555 }
556 case 1:
557 case 2:
558 {
559 // Clockwise rotation in 2D around the origin
560 const double w = M_PI/2;
561 switch (dim)
562 {
563 case 1: v(0) = 1.0; break;
564 case 2: v(0) = w*X(1); v(1) = -w*X(0); break;
565 case 3: v(0) = w*X(1); v(1) = -w*X(0); v(2) = 0.0; break;
566 }
567 break;
568 }
569 case 3:
570 {
571 // Clockwise twisting rotation in 2D around the origin
572 const double w = M_PI/2;
573 double d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
574 d = d*d;
575 switch (dim)
576 {
577 case 1: v(0) = 1.0; break;
578 case 2: v(0) = d*w*X(1); v(1) = -d*w*X(0); break;
579 case 3: v(0) = d*w*X(1); v(1) = -d*w*X(0); v(2) = 0.0; break;
580 }
581 break;
582 }
583 }
584}
585
586// Initial condition
587double u0_function(const Vector &x)
588{
589 int dim = x.Size();
590
591 // map to the reference [-1,1] domain
592 Vector X(dim);
593 for (int i = 0; i < dim; i++)
594 {
595 double center = (bb_min[i] + bb_max[i]) * 0.5;
596 X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
597 }
598
599 switch (problem)
600 {
601 case 0:
602 case 1:
603 {
604 switch (dim)
605 {
606 case 1:
607 return exp(-40.*pow(X(0)-0.5,2));
608 case 2:
609 case 3:
610 {
611 double rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
612 if (dim == 3)
613 {
614 const double s = (1. + 0.25*cos(2*M_PI*X(2)));
615 rx *= s;
616 ry *= s;
617 }
618 return ( erfc(w*(X(0)-cx-rx))*erfc(-w*(X(0)-cx+rx)) *
619 erfc(w*(X(1)-cy-ry))*erfc(-w*(X(1)-cy+ry)) )/16;
620 }
621 }
622 }
623 case 2:
624 {
625 double x_ = X(0), y_ = X(1), rho, phi;
626 rho = hypot(x_, y_);
627 phi = atan2(y_, x_);
628 return pow(sin(M_PI*rho),2)*sin(3*phi);
629 }
630 case 3:
631 {
632 const double f = M_PI;
633 return sin(f*X(0))*sin(f*X(1));
634 }
635 }
636 return 0.0;
637}
638
639// Inflow boundary condition (zero for the problems considered in this example)
640double inflow_function(const Vector &x)
641{
642 switch (problem)
643 {
644 case 0:
645 case 1:
646 case 2:
647 case 3: return 0.0;
648 }
649 return 0.0;
650}
Interface to ARKode's ARKStep module – additive Runge-Kutta methods.
Definition sundials.hpp:711
void SetMaxStep(double dt_max)
Set the maximum time step.
void PrintInfo() const
Print various ARKStep statistics.
void SetOrder(int order)
Chooses integration order for all explicit / implicit / IMEX methods.
@ EXPLICIT
Explicit RK method.
Definition sundials.hpp:716
void Init(TimeDependentOperator &f_) override
Initialize ARKode: calls ARKStepCreate() to create the ARKStep memory and set some defaults.
void SetERKTableNum(ARKODE_ERKTableID table_id)
Choose a specific Butcher table for an explicit RK method.
void SetSStolerances(double reltol, double abstol)
Set the scalar relative and scalar absolute tolerances.
@ GaussLobatto
Closed type.
Definition fe_base.hpp:36
A "square matrix" operator for the associated FE space and BLFIntegrators The sum of all the BLFInteg...
void SetAssemblyLevel(AssemblyLevel assembly_level)
Set the desired assembly level.
void AddDomainIntegrator(BilinearFormIntegrator *bfi)
Adds new Domain Integrator. Assumes ownership of bfi.
void Finalize(int skip_zeros=1) override
Finalizes the matrix initialization if the AssemblyLevel is AssemblyLevel::LEGACY....
void Assemble(int skip_zeros=1)
Assembles the form i.e. sums over all domain/bdr integrators.
void AddBdrFaceIntegrator(BilinearFormIntegrator *bfi)
Adds new boundary Face Integrator. Assumes ownership of bfi.
void Mult(const Vector &x, Vector &y) const override
Matrix vector multiplication: .
void AddInteriorFaceIntegrator(BilinearFormIntegrator *bfi)
Adds new interior Face Integrator. Assumes ownership of bfi.
Conjugate gradient method.
Definition solvers.hpp:538
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the Conjugate Gradient method.
Definition solvers.cpp:751
Interface to the CVODE library – linear multi-step methods.
Definition sundials.hpp:420
void SetSStolerances(double reltol, double abstol)
Set the scalar relative and scalar absolute tolerances.
Definition sundials.cpp:901
void Init(TimeDependentOperator &f_) override
Initialize CVODE: calls CVodeCreate() to create the CVODE memory and set some defaults.
Definition sundials.cpp:735
void SetMaxStep(double dt_max)
Set the maximum time step.
Definition sundials.cpp:919
void PrintInfo() const
Print various CVODE statistics.
Definition sundials.cpp:945
void UseSundialsLinearSolver()
Attach SUNDIALS GMRES linear solver to CVODE.
Definition sundials.cpp:881
Data type for scaled Jacobi-type smoother of sparse matrix.
void SetPrecision(int prec)
Set the precision (number of digits) used for the text output of doubles.
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
void SetTime(real_t t)
Set physical time (for time-dependent simulations)
void SetPrefixPath(const std::string &prefix)
Set the path where the DataCollection will be saved.
virtual void Save()
Save the collection to disk.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
Definition device.hpp:123
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
Definition device.cpp:297
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Definition fespace.hpp:848
const FiniteElement * GetTypicalFE() const
Return GetFE(0) if the local mesh is not empty; otherwise return a typical FE based on the Geometry t...
Definition fespace.cpp:3871
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Definition fe_base.hpp:334
The classical forward Euler method.
Definition ode.hpp:226
A general function coefficient.
GMRES method.
Definition solvers.hpp:572
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the GMRES method.
Definition solvers.cpp:1016
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.cpp:180
void SetRelTol(real_t rtol)
Definition solvers.hpp:229
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Definition solvers.cpp:174
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
Definition solvers.cpp:72
void SetMaxIter(int max_it)
Definition solvers.hpp:231
void SetAbsTol(real_t atol)
Definition solvers.hpp:230
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:346
Vector with associated FE space and LinearFormIntegrators.
Mesh data type.
Definition mesh.hpp:64
NURBSExtension * NURBSext
Optional NURBS mesh extension.
Definition mesh.hpp:298
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
Definition mesh.hpp:2433
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
Definition mesh.cpp:138
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1216
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Set the curvature of the mesh nodes using the given polynomial degree.
Definition mesh.cpp:6484
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:11295
Abstract class for solving systems of ODEs: dx/dt = f(x,t)
Definition ode.hpp:110
virtual void Init(TimeDependentOperator &f_)
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:161
virtual void Step(Vector &x, real_t &t, real_t &dt)=0
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
Jacobi smoothing for a given bilinear form (no matrix necessary).
Definition solvers.hpp:333
Abstract operator.
Definition operator.hpp:25
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
Definition optparser.hpp:82
bool Good() const
Return true if the command line options were parsed successfully.
Helper class for ParaView visualization data.
void SetHighOrderOutput(bool high_order_output_)
void SetLevelsOfDetail(int levels_of_detail_)
void SetDataFormat(VTKFormat fmt)
Third-order, strong stability preserving (SSP) Runge-Kutta method.
Definition ode.hpp:259
The classical explicit forth-order Runge-Kutta method, RK4.
Definition ode.hpp:272
Data collection with Sidre routines following the Conduit mesh blueprint specification.
Base class for solvers.
Definition operator.hpp:780
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
Definition operator.hpp:783
Data type sparse matrix.
Definition sparsemat.hpp:51
static void Init()
Definition sundials.cpp:174
Base abstract class for first order time dependent operators.
Definition operator.hpp:332
virtual void SetTime(const real_t t_)
Set the current time.
Definition operator.hpp:394
A general vector function coefficient.
Vector data type.
Definition vector.hpp:82
int Size() const
Returns the size of the vector.
Definition vector.hpp:226
Data collection with VisIt I/O routines.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
const real_t alpha
Definition ex15.cpp:369
int dim
Definition ex24.cpp:53
int main()
real_t b
Definition lissajous.cpp:42
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30
const char vishost[]
void velocity_function(const Vector &x, Vector &v)
Definition ex9.cpp:530
double u0_function(const Vector &x)
Definition ex9.cpp:587
int problem
Definition ex9.cpp:54
double inflow_function(const Vector &x)
Definition ex9.cpp:640
Vector bb_min
Definition ex9.cpp:66
Vector bb_max
Definition ex9.cpp:66
constexpr ARKODE_ERKTableID ARKODE_FEHLBERG_13_7_8
Definition sundials.hpp:69