MFEM v4.8.0
Finite element discretization library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
ex16.cpp
Go to the documentation of this file.
1// MFEM Example 16
2// SUNDIALS Modification
3//
4// Compile with:
5// make ex16 (GNU make)
6// make sundials_ex16 (CMake)
7//
8// Sample runs: ex16
9// ex16 -m ../../data/inline-tri.mesh
10// ex16 -m ../../data/disc-nurbs.mesh -tf 2
11// ex16 -s 12 -a 0.0 -k 1.0
12// ex16 -s 15 -a 0.0 -k 1.0
13// ex16 -s 8 -a 1.0 -k 0.0 -dt 1e-4 -tf 5e-2 -vs 25
14// ex16 -s 11 -a 1.0 -k 0.0 -dt 1e-4 -tf 5e-2 -vs 25
15// ex16 -s 9 -a 0.5 -k 0.5 -o 4 -dt 1e-4 -tf 2e-2 -vs 25
16// ex16 -s 12 -a 0.5 -k 0.5 -o 4 -dt 1e-4 -tf 2e-2 -vs 25
17// ex16 -s 10 -dt 1.0e-4 -tf 4.0e-2 -vs 40
18// ex16 -s 13 -dt 1.0e-4 -tf 4.0e-2 -vs 40
19// ex16 -m ../../data/fichera-q2.mesh
20// ex16 -m ../../data/escher.mesh
21// ex16 -m ../../data/beam-tet.mesh -tf 10 -dt 0.1
22// ex16 -m ../../data/amr-quad.mesh -o 4 -r 0
23// ex16 -m ../../data/amr-hex.mesh -o 2 -r 0
24//
25// Description: This example solves a time dependent nonlinear heat equation
26// problem of the form du/dt = C(u), with a non-linear diffusion
27// operator C(u) = \nabla \cdot (\kappa + \alpha u) \nabla u.
28//
29// The example demonstrates the use of nonlinear operators (the
30// class ConductionOperator defining C(u)), as well as their
31// implicit time integration. Note that implementing the method
32// ConductionOperator::ImplicitSolve is the only requirement for
33// high-order implicit (SDIRK) time integration. By default, this
34// example uses the SUNDIALS ODE solvers from CVODE and ARKODE.
35//
36// We recommend viewing examples 2, 9 and 10 before viewing this
37// example.
38
39#include "mfem.hpp"
40#include <fstream>
41#include <iostream>
42
43using namespace std;
44using namespace mfem;
45
46/** After spatial discretization, the conduction model is expressed as
47 *
48 * M du/dt = - K(u) u
49 *
50 * where u is the vector representing the temperature, M is the mass matrix,
51 * and K(u) is the diffusion operator with diffusivity depending on u:
52 * (\kappa + \alpha u).
53 *
54 * Class ConductionOperatorOperator represents the above ODE operator in the
55 * general form F(u, k, t) = G(u, t) where
56 *
57 * 1. F(u, du/dt, t) = du/dt (ODE is expressed in EXPLICIT form)
58 * G(u, t) = - inv(M) K(u) u
59 * 2. F(u, du/dt, t) = M du/dt (ODE is expressed in IMPLICIT form)
60 * G(u, t) = - K(u) u
61 */
62class ConductionOperator : public TimeDependentOperator
63{
64 FiniteElementSpace &fespace;
65 Array<int> ess_tdof_list; // this list remains empty for pure Neumann b.c.
66
68 SparseMatrix Mmat;
69
70 const real_t alpha, kappa;
71 std::unique_ptr<BilinearForm> K;
72 SparseMatrix Kmat;
73
74 std::unique_ptr<SparseMatrix> T; // T = M + gam K(u)
75
76 CGSolver M_solver; // Krylov solver for inverting the mass matrix M
77 DSmoother M_prec; // Preconditioner for the mass matrix M
78
79 CGSolver T_solver; // Implicit solver for T = M + gam K(u)
80 DSmoother T_prec; // Preconditioner for the implicit solver
81
82 mutable Vector z; // auxiliary vector
83
84public:
85
86 ConductionOperator(FiniteElementSpace &f, const real_t alpha,
87 const real_t kappa, const Vector &u,
88 const Type &ode_expression_type);
89
90 // Compute K(u_n) for use as an approximation in - K(u) u
91 void SetConductionTensor(const Vector &u);
92
93 /** Compute G(u, t) as defined in the IMPLICIT expression form of the ODE
94 operator, i.e., @a v = - K(u_n) @a u. Note that K(u_n) is an
95 approximation to K(u). */
96 void ExplicitMult(const Vector &u, Vector &v) const override;
97
98 /** Solve for k in F(u, k, t) = G(u, t) for either EXPLICIT or IMPLICIT
99 expression forms of the ODE operator, i.e., @a k = - inv(M) K(u_n) @a u.
100 Note that K(u_n) is an approximation to K(u). */
101 void Mult(const Vector &u, Vector &k) const override;
102
103 /** Solve for k in F(u + gam*k, k, t) = G(u + gam*k, t) for either EXPLICIT
104 or IMPLICIT expression forms of the ODE operator, i.e.,
105 [ M + @a gam K(u_n) ] @a k = - K(u_n) @a u . Note that K(u_n) is an
106 approximation to K(u). */
107 void ImplicitSolve(const real_t gam, const Vector &u, Vector &k) override;
108
109 /** Setup to solve for dk in [dF/dk + gam*dF/du - gam*dG/du] dk = G - F for
110 either EXPLICIT or IMPLICIT expression forms of the ODE operator, i.e.,
111 [M - @a gam Jf(u)] dk = G - F, where Jf(u) is an approximation of the
112 Jacobian of -K(u) u. The approximation chosen here is Jf(u) = -K(u_n). */
113 int SUNImplicitSetup(const Vector &u, const Vector &fu, int jok, int *jcur,
114 real_t gam) override;
115
116 /** Solve for @a dk in the system in SUNImplicitSetup to the given tolerance,
117 with the residual @a r providing either
118 1. @a r = G - F = inv(M) f(u) - k (EXPLICIT expression form)
119 1. @a r = G - F = f(u) - M k (IMPLICIT expression form)
120 */
121 int SUNImplicitSolve(const Vector &r, Vector &dk, real_t tol) override;
122
123 int SUNMassSetup() override;
124
125 int SUNMassSolve(const Vector &b, Vector &x, real_t tol) override;
126
127 int SUNMassMult(const Vector &x, Vector &v) override;
128};
129
131{
132 if (x.Norml2() < 0.5)
133 {
134 return 2.0;
135 }
136 else
137 {
138 return 1.0;
139 }
140}
141
142
143int main(int argc, char *argv[])
144{
145 // 0. Initialize SUNDIALS.
147
148 // 1. Parse command-line options.
149 const char *mesh_file = "../../data/star.mesh";
150 int ref_levels = 2;
151 int order = 2;
152 int ode_solver_type = 9; // CVODE implicit BDF
153 real_t t_final = 0.5;
154 real_t dt = 1.0e-2;
155 real_t alpha = 1.0e-2;
156 real_t kappa = 0.5;
157 bool visualization = true;
158 bool visit = false;
159 int vis_steps = 5;
160
161 // Relative and absolute tolerances for CVODE and ARKODE.
162 const real_t reltol = 1e-4, abstol = 1e-4;
163
164 int precision = 8;
165 cout.precision(precision);
166
167 OptionsParser args(argc, argv);
168 args.AddOption(&mesh_file, "-m", "--mesh",
169 "Mesh file to use.");
170 args.AddOption(&ref_levels, "-r", "--refine",
171 "Number of times to refine the mesh uniformly.");
172 args.AddOption(&order, "-o", "--order",
173 "Order (degree) of the finite elements.");
174 args.AddOption(&ode_solver_type, "-s", "--ode-solver",
175 "ODE solver:\n\t"
176 "1 - Forward Euler,\n\t"
177 "2 - RK2,\n\t"
178 "3 - RK3 SSP,\n\t"
179 "4 - RK4,\n\t"
180 "5 - Backward Euler,\n\t"
181 "6 - SDIRK 2,\n\t"
182 "7 - SDIRK 3,\n\t"
183 "8 - CVODE (implicit Adams),\n\t"
184 "9 - CVODE (implicit BDF),\n\t"
185 "10 - ARKODE (default explicit),\n\t"
186 "11 - ARKODE (explicit Fehlberg-6-4-5),\n\t"
187 "12 - ARKODE (default implicit),\n\t"
188 "13 - ARKODE (default explicit with MFEM mass solve),\n\t"
189 "14 - ARKODE (explicit Fehlberg-6-4-5 with MFEM mass solve),\n\t"
190 "15 - ARKODE (default implicit with MFEM mass solve).");
191 args.AddOption(&t_final, "-tf", "--t-final",
192 "Final time; start time is 0.");
193 args.AddOption(&dt, "-dt", "--time-step",
194 "Time step.");
195 args.AddOption(&alpha, "-a", "--alpha",
196 "Alpha coefficient.");
197 args.AddOption(&kappa, "-k", "--kappa",
198 "Kappa coefficient offset.");
199 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
200 "--no-visualization",
201 "Enable or disable GLVis visualization.");
202 args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit",
203 "--no-visit-datafiles",
204 "Save data files for VisIt (visit.llnl.gov) visualization.");
205 args.AddOption(&vis_steps, "-vs", "--visualization-steps",
206 "Visualize every n-th timestep.");
207 args.Parse();
208 if (!args.Good())
209 {
210 args.PrintUsage(cout);
211 return 1;
212 }
213 args.PrintOptions(cout);
214
215 bool use_mass_solver = ode_solver_type >= 13;
216
217 // 2. Read the mesh from the given mesh file. We can handle triangular,
218 // quadrilateral, tetrahedral and hexahedral meshes with the same code.
219 std::unique_ptr<Mesh> mesh(new Mesh(mesh_file, 1, 1));
220 int dim = mesh->Dimension();
221
222 // 3. Refine the mesh to increase the resolution. In this example we do
223 // 'ref_levels' of uniform refinement, where 'ref_levels' is a
224 // command-line parameter.
225 for (int lev = 0; lev < ref_levels; lev++)
226 {
227 mesh->UniformRefinement();
228 }
229
230 // 4. Define the vector finite element space representing the current and the
231 // initial temperature, u_ref.
232 H1_FECollection fe_coll(order, dim);
233 FiniteElementSpace fespace(mesh.get(), &fe_coll);
234
235 int fe_size = fespace.GetTrueVSize();
236 cout << "Number of temperature unknowns: " << fe_size << endl;
237
238 GridFunction u_gf(&fespace);
239
240 // 5. Set the initial conditions for u. All boundaries are considered
241 // natural.
243 u_gf.ProjectCoefficient(u_0);
244 Vector u;
245 u_gf.GetTrueDofs(u);
246
247 // 6. Initialize the conduction ODE operator and the visualization.
248 ConductionOperator::Type ode_expression_type;
249 if (use_mass_solver)
250 {
251 ode_expression_type = ConductionOperator::Type::IMPLICIT;
252 }
253 else
254 {
255 ode_expression_type = ConductionOperator::Type::EXPLICIT;
256 }
257 ConductionOperator oper(fespace, alpha, kappa, u, ode_expression_type);
258
259 u_gf.SetFromTrueDofs(u);
260 {
261 ofstream omesh("ex16.mesh");
262 omesh.precision(precision);
263 mesh->Print(omesh);
264 ofstream osol("ex16-init.gf");
265 osol.precision(precision);
266 u_gf.Save(osol);
267 }
268
269 VisItDataCollection visit_dc("Example16", mesh.get());
270 visit_dc.RegisterField("temperature", &u_gf);
271 if (visit)
272 {
273 visit_dc.SetCycle(0);
274 visit_dc.SetTime(0.0);
275 visit_dc.Save();
276 }
277
278 socketstream sout;
279 if (visualization)
280 {
281 char vishost[] = "localhost";
282 int visport = 19916;
283 sout.open(vishost, visport);
284 if (!sout)
285 {
286 cout << "Unable to connect to GLVis server at "
287 << vishost << ':' << visport << endl;
288 visualization = false;
289 cout << "GLVis visualization disabled.\n";
290 }
291 else
292 {
293 sout.precision(precision);
294 sout << "solution\n" << *mesh << u_gf;
295 sout << "pause\n";
296 sout << flush;
297 cout << "GLVis visualization paused."
298 << " Press space (in the GLVis window) to resume it.\n";
299 }
300 }
301
302 // 7. Define the ODE solver used for time integration.
303 real_t t = 0.0;
304 std::unique_ptr<ODESolver> ode_solver;
305 switch (ode_solver_type)
306 {
307 // MFEM explicit methods
308 case 1: ode_solver = std::make_unique<ForwardEulerSolver>(); break;
309 case 2: ode_solver = std::make_unique<RK2Solver>(0.5); break; // midpoint method
310 case 3: ode_solver = std::make_unique<RK3SSPSolver>(); break;
311 case 4: ode_solver = std::make_unique<RK4Solver>(); break;
312 // MFEM implicit L-stable methods
313 case 5: ode_solver = std::make_unique<BackwardEulerSolver>(); break;
314 case 6: ode_solver = std::make_unique<SDIRK23Solver>(2); break;
315 case 7: ode_solver = std::make_unique<SDIRK33Solver>(); break;
316 // CVODE
317 case 8:
318 case 9:
319 {
320 int cvode_solver_type;
321 if (ode_solver_type == 8)
322 {
323 cvode_solver_type = CV_ADAMS;
324 }
325 else
326 {
327 cvode_solver_type = CV_BDF;
328 }
329 std::unique_ptr<CVODESolver> cvode(new CVODESolver(cvode_solver_type));
330 cvode->Init(oper);
331 cvode->SetSStolerances(reltol, abstol);
332 cvode->SetMaxStep(dt);
333 ode_solver = std::move(cvode);
334 break;
335 }
336 // ARKODE
337 case 10:
338 case 11:
339 case 12:
340 case 13:
341 case 14:
342 case 15:
343 {
344 ARKStepSolver::Type arkode_solver_type;
345 if (ode_solver_type == 12 || ode_solver_type == 15)
346 {
347 arkode_solver_type = ARKStepSolver::IMPLICIT;
348 }
349 else
350 {
351 arkode_solver_type = ARKStepSolver::EXPLICIT;
352 }
353 std::unique_ptr<ARKStepSolver> arkode(
354 new ARKStepSolver(arkode_solver_type));
355 arkode->Init(oper);
356 arkode->SetSStolerances(reltol, abstol);
357 arkode->SetMaxStep(dt);
358 if (ode_solver_type == 11 || ode_solver_type == 14)
359 {
360 arkode->SetERKTableNum(ARKODE_FEHLBERG_13_7_8);
361 }
362 if (use_mass_solver)
363 {
364 arkode->UseMFEMMassLinearSolver(SUNFALSE);
365 }
366 ode_solver = std::move(arkode);
367 break;
368 }
369 default:
370 cout << "Unknown ODE solver type: " << ode_solver_type << '\n';
371 return 3;
372 }
373
374 // Initialize MFEM integrators, SUNDIALS integrators are initialized above
375 if (ode_solver_type < 8) { ode_solver->Init(oper); }
376
377 // Since we want to update the diffusion coefficient after every time step,
378 // we need to use the "one-step" mode of the SUNDIALS solvers.
379 if (CVODESolver* cvode = dynamic_cast<CVODESolver*>(ode_solver.get()))
380 {
381 cvode->SetStepMode(CV_ONE_STEP);
382 }
383 else if (ARKStepSolver* arkode = dynamic_cast<ARKStepSolver*>(ode_solver.get()))
384 {
385 arkode->SetStepMode(ARK_ONE_STEP);
386 }
387
388 // 8. Perform time-integration (looping over the time iterations, ti, with a
389 // time-step dt).
390 cout << "Integrating the ODE ..." << endl;
391 tic_toc.Clear();
392 tic_toc.Start();
393
394 bool last_step = false;
395 for (int ti = 1; !last_step; ti++)
396 {
397 real_t dt_real = min(dt, t_final - t);
398
399 // Note that since we are using the "one-step" mode of the SUNDIALS
400 // solvers, they will, generally, step over the final time and will not
401 // explicitly perform the interpolation to t_final as they do in the
402 // "normal" step mode.
403
404 ode_solver->Step(u, t, dt_real);
405
406 last_step = (t >= t_final - 1e-8*dt);
407
408 if (last_step || (ti % vis_steps) == 0)
409 {
410 cout << "step " << ti << ", t = " << t << endl;
411 if (CVODESolver* cvode = dynamic_cast<CVODESolver*>(ode_solver.get()))
412 {
413 cvode->PrintInfo();
414 }
415 else if (ARKStepSolver* arkode = dynamic_cast<ARKStepSolver*>(ode_solver.get()))
416 {
417 arkode->PrintInfo();
418 }
419
420 u_gf.SetFromTrueDofs(u);
421 if (visualization)
422 {
423 sout << "solution\n" << *mesh << u_gf << flush;
424 }
425
426 if (visit)
427 {
428 visit_dc.SetCycle(ti);
429 visit_dc.SetTime(t);
430 visit_dc.Save();
431 }
432 }
433 oper.SetConductionTensor(u);
434 }
435 tic_toc.Stop();
436 cout << "Done, " << tic_toc.RealTime() << "s." << endl;
437
438 // 9. Save the final solution. This output can be viewed later using GLVis:
439 // "glvis -m ex16.mesh -g ex16-final.gf".
440 u_gf.Save("ex16-final.gf", precision);
441
442 return 0;
443}
444
445ConductionOperator::ConductionOperator(FiniteElementSpace &fes,
446 const real_t alpha, const real_t kappa,
447 const Vector &u,
448 const Type &ode_expression_type)
449 : TimeDependentOperator(fes.GetTrueVSize(), 0.0, ode_expression_type),
450 fespace(fes), M(&fespace), alpha(alpha), kappa(kappa), z(height)
451{
452 // specify a relative tolerance for all solves with MFEM integrators
453 const real_t rel_tol = 1e-8;
454
455 M.AddDomainIntegrator(new MassIntegrator());
456 M.Assemble();
457 M.FormSystemMatrix(ess_tdof_list, Mmat);
458
459 M_solver.iterative_mode = false;
460 M_solver.SetRelTol(rel_tol); // will be overwritten with SUNDIALS integrators
461 M_solver.SetAbsTol(0.0);
462 M_solver.SetMaxIter(50);
463 M_solver.SetPrintLevel(0);
464 M_solver.SetPreconditioner(M_prec);
465 M_solver.SetOperator(Mmat);
466
467 T_solver.iterative_mode = false;
468 T_solver.SetRelTol(rel_tol); // will be overwritten with SUNDIALS integrators
469 T_solver.SetAbsTol(0.0);
470 T_solver.SetMaxIter(100);
471 T_solver.SetPrintLevel(0);
472 T_solver.SetPreconditioner(T_prec);
473
474 SetConductionTensor(u);
475}
476
477void ConductionOperator::SetConductionTensor(const Vector &u)
478{
479 // Compute K(u_n).
480 GridFunction u_alpha_gf(&fespace);
481 u_alpha_gf.SetFromTrueDofs(u);
482 for (int i = 0; i < u_alpha_gf.Size(); i++)
483 {
484 u_alpha_gf(i) = kappa + alpha*u_alpha_gf(i);
485 }
486 GridFunctionCoefficient u_coeff(&u_alpha_gf);
487
488 K = std::make_unique<BilinearForm>(&fespace);
490 K->Assemble();
491 K->FormSystemMatrix(ess_tdof_list, Kmat);
492}
493
494void ConductionOperator::ExplicitMult(const Vector &u, Vector &v) const
495{
496 // Compute - K(u_n) u.
497 Kmat.Mult(u, v);
498 v.Neg();
499}
500
501void ConductionOperator::Mult(const Vector &u, Vector &k) const
502{
503 // Compute - inv(M) K(u_n) u.
504 ExplicitMult(u, z);
505 M_solver.Mult(z, k);
506}
507
508void ConductionOperator::ImplicitSolve(const real_t gam, const Vector &u,
509 Vector &k)
510{
511 // Solve for k in M k = - K(u_n) [u + gam*k].
512 ExplicitMult(u, z);
513 T = std::unique_ptr<SparseMatrix>(Add(1.0, Mmat, gam, Kmat));
514 T_solver.SetOperator(*T);
515 T_solver.Mult(z, k);
516}
517
518int ConductionOperator::SUNImplicitSetup(const Vector &u, const Vector &fu,
519 int jok, int *jcur, real_t gam)
520{
521 // Compute T = M + gamma K(u_n).
522 T = std::unique_ptr<SparseMatrix>(Add(1.0, Mmat, gam, Kmat));
523 T_solver.SetOperator(*T);
524 *jcur = SUNTRUE; // this should eventually only be set true if K(u) is used
525 return SUN_SUCCESS;
526}
527
528int ConductionOperator::SUNImplicitSolve(const Vector &r, Vector &dk,
529 real_t tol)
530{
531 // Solve the system [M + gamma K(u_n)] dk = - K(u_n) u - M k.
532 // What value r is providing depends on the ODE expression form:
533 // EXPLICIT form: r = -inv(M) K(u_n) u - k
534 // IMPLICIT form: r = -K(u_n) u - M k
535 T_solver.SetRelTol(tol);
536 if (isExplicit())
537 {
538 Mmat.Mult(r, z);
539 T_solver.Mult(z, dk);
540 }
541 else
542 {
543 T_solver.Mult(r, dk);
544 }
545 if (T_solver.GetConverged())
546 {
547 return SUN_SUCCESS;
548 }
549 else
550 {
551 return SUNLS_CONV_FAIL;
552 }
553}
554
555int ConductionOperator::SUNMassSetup()
556{
557 // Do nothing b/c mass solver was setup in constructor.
558 return SUN_SUCCESS;
559}
560
561int ConductionOperator::SUNMassSolve(const Vector &b, Vector &x, real_t tol)
562{
563 // Solve the system M x = b.
564 M_solver.SetRelTol(tol);
565 M_solver.Mult(b, x);
566 if (M_solver.GetConverged())
567 {
568 return SUN_SUCCESS;
569 }
570 else
571 {
572 return SUNLS_CONV_FAIL;
573 }
574}
575
576int ConductionOperator::SUNMassMult(const Vector &x, Vector &v)
577{
578 // Compute M x.
579 Mmat.Mult(x, v);
580 return SUN_SUCCESS;
581}
582
Interface to ARKode's ARKStep module – additive Runge-Kutta methods.
Definition sundials.hpp:711
Type
Types of ARKODE solvers.
Definition sundials.hpp:715
@ IMPLICIT
Implicit RK method.
Definition sundials.hpp:717
@ EXPLICIT
Explicit RK method.
Definition sundials.hpp:716
A "square matrix" operator for the associated FE space and BLFIntegrators The sum of all the BLFInteg...
void AddDomainIntegrator(BilinearFormIntegrator *bfi)
Adds new Domain Integrator. Assumes ownership of bfi.
void Assemble(int skip_zeros=1)
Assembles the form i.e. sums over all domain/bdr integrators.
virtual void FormSystemMatrix(const Array< int > &ess_tdof_list, OperatorHandle &A)
Form the linear system matrix A, see FormLinearSystem() for details.
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
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
Definition solvers.hpp:551
Interface to the CVODE library – linear multi-step methods.
Definition sundials.hpp:420
Data type for scaled Jacobi-type smoother of sparse matrix.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
void SetTime(real_t t)
Set physical time (for time-dependent simulations)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Definition fespace.hpp:851
A general function coefficient.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
Definition gridfunc.cpp:378
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
void GetTrueDofs(Vector &tv) const
Extract the true-dofs from the GridFunction.
Definition gridfunc.cpp:363
Arbitrary order H1-conforming (continuous) finite elements.
Definition fe_coll.hpp:275
void SetRelTol(real_t rtol)
Definition solvers.hpp:229
bool GetConverged() const
Returns true if the last call to Mult() converged successfully.
Definition solvers.hpp:282
Mesh data type.
Definition mesh.hpp:64
Type
Enumeration defining IDs for some classes derived from Operator.
Definition operator.hpp:284
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.
Data type sparse matrix.
Definition sparsemat.hpp:51
void Mult(const Vector &x, Vector &y) const override
Matrix vector multiplication.
double RealTime()
Return the number of real seconds elapsed since the stopwatch was started.
Definition tic_toc.cpp:432
void Start()
Start the stopwatch. The elapsed time is not cleared.
Definition tic_toc.cpp:411
void Stop()
Stop the stopwatch.
Definition tic_toc.cpp:422
void Clear()
Clear the elapsed time on the stopwatch and restart it if it's running.
Definition tic_toc.cpp:406
static void Init()
Definition sundials.cpp:174
Base abstract class for first order time dependent operators.
Definition operator.hpp:332
bool isExplicit() const
True if type is EXPLICIT.
Definition operator.hpp:397
Type
Enum used to describe the form of the time-dependent operator.
Definition operator.hpp:353
@ EXPLICIT
This type assumes F(u,k,t) = k.
Definition operator.hpp:354
@ IMPLICIT
This is the most general type, no assumptions on F and G.
Definition operator.hpp:355
Vector data type.
Definition vector.hpp:82
void Neg()
(*this) = -(*this)
Definition vector.cpp:375
real_t Norml2() const
Returns the l2 norm of the vector.
Definition vector.cpp:931
Data collection with VisIt I/O routines.
void Save() override
Save the collection and a VisIt root file.
void RegisterField(const std::string &field_name, GridFunction *gf) override
Add a grid function to the collection and update the root file.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
const real_t alpha
Definition ex15.cpp:369
real_t kappa
Definition ex24.cpp:54
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
StopWatch tic_toc
Definition tic_toc.cpp:450
float real_t
Definition config.hpp:43
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30
void Add(const DenseMatrix &A, const DenseMatrix &B, real_t alpha, DenseMatrix &C)
C = A + alpha*B.
const char vishost[]
real_t InitialTemperature(const Vector &x)
Definition ex16.cpp:130
constexpr ARKODE_ERKTableID ARKODE_FEHLBERG_13_7_8
Definition sundials.hpp:69
@ SUN_SUCCESS
Definition sundials.hpp:95