60int main(
int argc,
char *argv[])
64 const real_t specific_heat_ratio = 1.4;
65 const real_t gas_constant = 1.0;
67 string mesh_file =
"";
68 int IntOrderOffset = 1;
71 int ode_solver_type = 4;
75 bool visualization =
true;
76 bool preassembleWeakDiv =
true;
80 cout.precision(precision);
83 args.
AddOption(&mesh_file,
"-m",
"--mesh",
84 "Mesh file to use. If not provided, then a periodic square"
85 " mesh will be used.");
87 "Problem setup to use. See EulerInitialCondition().");
88 args.
AddOption(&ref_levels,
"-r",
"--refine",
89 "Number of times to refine the mesh uniformly.");
91 "Order (degree) of the finite elements.");
92 args.
AddOption(&ode_solver_type,
"-s",
"--ode-solver",
94 args.
AddOption(&t_final,
"-tf",
"--t-final",
"Final time; start time is 0.");
96 "Time step. Positive number skips CFL timestep calculation.");
97 args.
AddOption(&cfl,
"-c",
"--cfl-number",
98 "CFL number for timestep calculation.");
99 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
100 "--no-visualization",
101 "Enable or disable GLVis visualization.");
102 args.
AddOption(&preassembleWeakDiv,
"-ea",
"--element-assembly-divergence",
103 "-mf",
"--matrix-free-divergence",
104 "Weak divergence assembly level\n"
105 " ea - Element assembly with interpolated F\n"
106 " mf - Nonlinear assembly in matrix-free manner");
107 args.
AddOption(&vis_steps,
"-vs",
"--visualization-steps",
108 "Visualize every n-th timestep.");
115 const int num_equations =
dim + 2;
120 for (
int lev = 0; lev < ref_levels; lev++)
142 cout <<
"Number of unknowns: " << vfes.
GetVSize() << endl;
157 ostringstream mesh_name;
158 mesh_name <<
"euler-mesh.mesh";
159 ofstream mesh_ofs(mesh_name.str().c_str());
160 mesh_ofs.precision(precision);
163 for (
int k = 0; k < num_equations; k++)
166 ostringstream sol_name;
167 sol_name <<
"euler-" << k <<
"-init.gf";
168 ofstream sol_ofs(sol_name.str().c_str());
169 sol_ofs.precision(precision);
178 vfes, std::unique_ptr<HyperbolicFormIntegrator>(
192 visualization =
false;
193 cout <<
"Unable to connect to GLVis server at " <<
vishost <<
':'
195 cout <<
"GLVis visualization disabled.\n";
199 sout.precision(precision);
201 sout <<
"solution\n" << mesh << mom;
202 sout <<
"window_title 'momentum, t = 0'\n";
203 sout <<
"view 0 0\n";
204 sout <<
"keys jlm\n";
207 cout <<
"GLVis visualization paused."
208 <<
" Press space (in the GLVis window) to resume it.\n";
219 for (
int i = 0; i < mesh.
GetNE(); i++)
230 dt = cfl * hmin / max_char_speed / (2 * order + 1);
240 ode_solver->Init(euler);
244 for (
int ti = 0; !done;)
246 real_t dt_real = min(dt, t_final - t);
248 ode_solver->Step(sol, t, dt_real);
252 dt = cfl * hmin / max_char_speed / (2 * order + 1);
256 done = (t >= t_final - 1e-8 * dt);
257 if (done || ti % vis_steps == 0)
259 cout <<
"time step: " << ti <<
", time: " << t << endl;
262 sout <<
"window_title 'momentum, t = " << t <<
"'\n";
263 sout <<
"solution\n" << mesh << mom << flush;
274 ostringstream mesh_name;
275 mesh_name <<
"euler-mesh-final.mesh";
276 ofstream mesh_ofs(mesh_name.str().c_str());
277 mesh_ofs.precision(precision);
280 for (
int k = 0; k < num_equations; k++)
283 ostringstream sol_name;
284 sol_name <<
"euler-" << k <<
"-final.gf";
285 ofstream sol_ofs(sol_name.str().c_str());
286 sol_ofs.precision(precision);
293 cout <<
"Solution error: " << error << endl;
Time dependent DG operator for hyperbolic conservation laws.
void Mult(const Vector &x, Vector &y) const override
Apply nonlinear form to obtain M⁻¹(DIVF + JUMP HAT(F))
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
Ordering::Type GetOrdering() const
Return the ordering method.
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Class for grid function - Vector with associated FE space.
virtual real_t ComputeLpError(const real_t p, Coefficient &exsol, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
Returns ||u_ex - u_h||_Lp for H1 or L2 elements.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Arbitrary order "L2-conforming" discontinuous finite elements.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
real_t GetElementSize(int i, int type=0)
Get the size of the i-th element relative to the perfect reference element.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static MFEM_EXPORT std::string ExplicitTypes
static MFEM_EXPORT std::unique_ptr< ODESolver > SelectExplicit(const int ode_solver_type)
void ParseCheck(std::ostream &out=mfem::out)
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...
Rusanov flux, also known as local Lax-Friedrichs, F̂ n = ½(F(u⁺,x)n + F(u⁻,x)n) - ½λ(u⁺ - u⁻) where λ...
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.
virtual void SetTime(const real_t t_)
Set the current time.
A general vector function coefficient.
int Size() const
Returns the size of the vector.
real_t * GetData() const
Return a pointer to the beginning of the Vector data.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
real_t infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
Mesh EulerMesh(const int problem)
VectorFunctionCoefficient EulerInitialCondition(const int problem, const real_t specific_heat_ratio, const real_t gas_constant)