52 const real_t x = coord(0)*2.0 - 1.0,
53 y = (
dim > 1) ? coord(1)*2.0 - 1.0 : 0.0,
54 z = (
dim > 2) ? coord(2)*2.0 - 1.0 : 0.0;
61 return 0.75 - sqrt(x*x + y*y + z*z + 1e-12);
66 MFEM_VERIFY(
dim > 1,
"Problem 1 is not applicable to 1D.");
68 return 0.60 - sqrt(x*x + y*y + z*z + 1e-12) +
69 0.25 * (y*y*y*y*y + 5.0*x*x*x*x*y - 10.0*x*x*y*y*y) /
70 pow(x*x + y*y + z*z + 1e-12, 2.5) *
71 std::cos(0.5*M_PI * z / 0.6);
73 default: MFEM_ABORT(
"Bad option for --problem!");
return 0.0;
81 const real_t x = coord(0)*2.0 - 1.0 + 0.25,
82 y = (
dim > 1) ? coord(1)*2.0 - 1.0 : 0.0,
83 z = (
dim > 2) ? coord(2)*2.0 - 1.0 : 0.0;
85 return std::cos(M_PI * x) * std::cos(M_PI * y) * std::cos(M_PI * z);
95 std::cout << std::setprecision(12) << std::fixed
96 << text << norm << std::endl;
106 std::cout << std::setprecision(12) << std::fixed
107 << text << norm << std::endl;
111int main(
int argc,
char *argv[])
119 const char *mesh_file =
"../../data/inline-quad.mesh";
127 int vis_steps_cnt = 50;
130 args.
AddOption(&mesh_file,
"-m",
"--mesh",
131 "Mesh file to use.");
132 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
133 "Number of times to refine the mesh uniformly in serial.");
134 args.
AddOption((
int*)&ex_type,
"-et",
"--extrap-type",
135 "Extrapolation type: Aslam (0) or Bochkov (1).");
136 args.
AddOption((
int*)&dg_mode,
"-dg",
"--dg-mode",
137 "DG advection mode: 0 - Standard High-Order,\n\t"
138 " 1 - Low-Order Upwind Diffusion.");
139 args.
AddOption(&ex_degree,
"-ed",
"--extrap-degree",
140 "Extrapolation degree: 0/1/2 for constant/linear/quadratic.");
142 "Finite element order (polynomial degree) or -1 for"
143 " isoparametric space.");
144 args.
AddOption(&distance,
"-d",
"--distance",
145 "Extrapolation distance.");
149 args.
AddOption(&vis_on,
"-vis",
"--visualization",
"-no-vis",
150 "--no-visualization",
151 "Enable or disable GLVis visualization.");
152 args.
AddOption(&vis_steps_cnt,
"-vs",
"--visualization-steps",
153 "Visualize every n-th timestep.");
163 Mesh mesh(mesh_file, 1, 1);
165 ParMesh pmesh(MPI_COMM_WORLD, mesh);
174 u.ProjectCoefficient(u0_coeff);
187 PrintNorm(myid, ux,
"Solution l1 norm: ");
195 std::cout <<
"Global L1 error: " << err_L1 << std::endl
196 <<
"Global L2 error: " << err_L2 << std::endl;
198 real_t loc_error_L1, loc_error_L2, loc_error_LI;
200 loc_error_L1, loc_error_L2, loc_error_LI);
203 std::cout <<
"Local L1 error: " << loc_error_L1 << std::endl
204 <<
"Local L2 error: " << loc_error_L2 << std::endl
205 <<
"Local Li error: " << loc_error_LI << std::endl;
A coefficient that is constant across space and time.
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)
A general function coefficient.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Arbitrary order "L2-conforming" discontinuous finite elements.
void Clear()
Clear the contents of the Mesh.
int Dimension() const
Dimension of the reference space used within the elements.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
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.
Abstract parallel finite element space.
Class for parallel grid function.
real_t ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const override
real_t ComputeL1Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL) const override
void ProjectCoefficient(Coefficient &coeff) override
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Class for parallel meshes.
Helper class for ParaView visualization data.
void SetLevelsOfDetail(int levels_of_detail_)
virtual void Save() override
real_t Norml1() const
Returns the l_1 norm of the vector.
int Size() const
Returns the size of the vector.
real_t u(const Vector &xvec)
Helper struct to convert a C++ type to an MPI type.