71   std::unique_ptr<BilinearForm> K;
 
   74   std::unique_ptr<SparseMatrix> T; 
 
   88                      const Type &ode_expression_type);
 
   91   void SetConductionTensor(
const Vector &
u);
 
  113   int SUNImplicitSetup(
const Vector &
u, 
const Vector &fu, 
int jok, 
int *jcur,
 
  123   int SUNMassSetup() 
override;
 
  143int main(
int argc, 
char *argv[])
 
  149   const char *mesh_file = 
"../../data/star.mesh";
 
  152   int ode_solver_type = 9; 
 
  157   bool visualization = 
true;
 
  162   const real_t reltol = 1e-4, abstol = 1e-4;
 
  165   cout.precision(precision);
 
  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.");
 
  173                  "Order (degree) of the finite elements.");
 
  174   args.
AddOption(&ode_solver_type, 
"-s", 
"--ode-solver",
 
  176                  "1  - Forward Euler,\n\t" 
  180                  "5  - Backward Euler,\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",
 
  196                  "Alpha coefficient.");
 
  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.");
 
  215   bool use_mass_solver = ode_solver_type >= 13;
 
  219   std::unique_ptr<Mesh> mesh(
new Mesh(mesh_file, 1, 1));
 
  220   int dim = mesh->Dimension();
 
  225   for (
int lev = 0; lev < ref_levels; lev++)
 
  227      mesh->UniformRefinement();
 
  236   cout << 
"Number of temperature unknowns: " << fe_size << endl;
 
  257   ConductionOperator oper(fespace, 
alpha, 
kappa, 
u, ode_expression_type);
 
  261      ofstream omesh(
"ex16.mesh");
 
  262      omesh.precision(precision);
 
  264      ofstream osol(
"ex16-init.gf");
 
  265      osol.precision(precision);
 
  286         cout << 
"Unable to connect to GLVis server at " 
  287              << 
vishost << 
':' << visport << endl;
 
  288         visualization = 
false;
 
  289         cout << 
"GLVis visualization disabled.\n";
 
  293         sout.precision(precision);
 
  294         sout << 
"solution\n" << *mesh << u_gf;
 
  297         cout << 
"GLVis visualization paused." 
  298              << 
" Press space (in the GLVis window) to resume it.\n";
 
  304   std::unique_ptr<ODESolver> ode_solver;
 
  305   switch (ode_solver_type)
 
  308      case 1: ode_solver = std::make_unique<ForwardEulerSolver>(); 
break;
 
  309      case 2: ode_solver = std::make_unique<RK2Solver>(0.5); 
break; 
 
  310      case 3: ode_solver = std::make_unique<RK3SSPSolver>(); 
break;
 
  311      case 4: ode_solver = std::make_unique<RK4Solver>(); 
break;
 
  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;
 
  320         int cvode_solver_type;
 
  321         if (ode_solver_type == 8)
 
  323            cvode_solver_type = CV_ADAMS;
 
  327            cvode_solver_type = CV_BDF;
 
  329         std::unique_ptr<CVODESolver> cvode(
new CVODESolver(cvode_solver_type));
 
  331         cvode->SetSStolerances(reltol, abstol);
 
  332         cvode->SetMaxStep(dt);
 
  333         ode_solver = std::move(cvode);
 
  345         if (ode_solver_type == 12 || ode_solver_type == 15)
 
  353         std::unique_ptr<ARKStepSolver> arkode(
 
  356         arkode->SetSStolerances(reltol, abstol);
 
  357         arkode->SetMaxStep(dt);
 
  358         if (ode_solver_type == 11 || ode_solver_type == 14)
 
  364            arkode->UseMFEMMassLinearSolver(SUNFALSE);
 
  366         ode_solver = std::move(arkode);
 
  370         cout << 
"Unknown ODE solver type: " << ode_solver_type << 
'\n';
 
  375   if (ode_solver_type < 8) { ode_solver->Init(oper); }
 
  381      cvode->SetStepMode(CV_ONE_STEP);
 
  385      arkode->SetStepMode(ARK_ONE_STEP);
 
  390   cout << 
"Integrating the ODE ..." << endl;
 
  394   bool last_step = 
false;
 
  395   for (
int ti = 1; !last_step; ti++)
 
  397      real_t dt_real = min(dt, t_final - t);
 
  404      ode_solver->Step(
u, t, dt_real);
 
  406      last_step = (t >= t_final - 1e-8*dt);
 
  408      if (last_step || (ti % vis_steps) == 0)
 
  410         cout << 
"step " << ti << 
", t = " << t << endl;
 
  423            sout << 
"solution\n" << *mesh << u_gf << flush;
 
  433      oper.SetConductionTensor(
u);
 
  440   u_gf.
Save(
"ex16-final.gf", precision);
 
 
  448                                       const Type &ode_expression_type)
 
  453   const real_t rel_tol = 1e-8;
 
  457   M.FormSystemMatrix(ess_tdof_list, Mmat);
 
  459   M_solver.iterative_mode = 
false;
 
  460   M_solver.SetRelTol(rel_tol); 
 
  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);
 
  467   T_solver.iterative_mode = 
false;
 
  468   T_solver.SetRelTol(rel_tol); 
 
  469   T_solver.SetAbsTol(0.0);
 
  470   T_solver.SetMaxIter(100);
 
  471   T_solver.SetPrintLevel(0);
 
  472   T_solver.SetPreconditioner(T_prec);
 
  474   SetConductionTensor(
u);
 
  477void ConductionOperator::SetConductionTensor(
const Vector &
u)
 
  481   u_alpha_gf.SetFromTrueDofs(
u);
 
  482   for (
int i = 0; i < u_alpha_gf.Size(); i++)
 
  488   K = std::make_unique<BilinearForm>(&fespace);
 
  494void ConductionOperator::ExplicitMult(
const Vector &
u, 
Vector &v)
 const 
  501void ConductionOperator::Mult(
const Vector &
u, 
Vector &k)
 const 
  508void ConductionOperator::ImplicitSolve(
const real_t gam, 
const Vector &
u,
 
  513   T = std::unique_ptr<SparseMatrix>(
Add(1.0, Mmat, gam, Kmat));
 
  518int ConductionOperator::SUNImplicitSetup(
const Vector &
u, 
const Vector &fu,
 
  519                                         int jok, 
int *jcur, 
real_t gam)
 
  522   T = std::unique_ptr<SparseMatrix>(
Add(1.0, Mmat, gam, Kmat));
 
  528int ConductionOperator::SUNImplicitSolve(
const Vector &r, 
Vector &dk,
 
  539      T_solver.
Mult(z, dk);
 
  543      T_solver.
Mult(r, dk);
 
  551      return SUNLS_CONV_FAIL;
 
  555int ConductionOperator::SUNMassSetup()
 
  572      return SUNLS_CONV_FAIL;
 
  576int ConductionOperator::SUNMassMult(
const Vector &x, 
Vector &v)
 
Interface to ARKode's ARKStep module – additive Runge-Kutta methods.
 
Type
Types of ARKODE solvers.
 
@ IMPLICIT
Implicit RK method.
 
@ EXPLICIT
Explicit RK method.
 
Conjugate gradient method.
 
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the Conjugate Gradient method.
 
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
 
Interface to the CVODE library – linear multi-step methods.
 
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...
 
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
 
A general function coefficient.
 
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
 
Class for grid function - Vector with associated FE space.
 
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.
 
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.
 
Arbitrary order H1-conforming (continuous) finite elements.
 
void SetRelTol(real_t rtol)
 
bool GetConverged() const
Returns true if the last call to Mult() converged successfully.
 
Type
Enumeration defining IDs for some classes derived from Operator.
 
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...
 
bool Good() const
Return true if the command line options were parsed successfully.
 
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.
 
void Start()
Start the stopwatch. The elapsed time is not cleared.
 
void Stop()
Stop the stopwatch.
 
void Clear()
Clear the elapsed time on the stopwatch and restart it if it's running.
 
Base abstract class for first order time dependent operators.
 
bool isExplicit() const
True if type is EXPLICIT.
 
Type
Enum used to describe the form of the time-dependent operator.
 
@ EXPLICIT
This type assumes F(u,k,t) = k.
 
@ IMPLICIT
This is the most general type, no assumptions on F and G.
 
void Neg()
(*this) = -(*this)
 
real_t Norml2() const
Returns the l2 norm of the vector.
 
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'.
 
real_t u(const Vector &xvec)
 
std::function< real_t(const Vector &)> f(real_t mass_coeff)
 
void Add(const DenseMatrix &A, const DenseMatrix &B, real_t alpha, DenseMatrix &C)
C = A + alpha*B.
 
real_t InitialTemperature(const Vector &x)
 
constexpr ARKODE_ERKTableID ARKODE_FEHLBERG_13_7_8