52 const double 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 double 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);
91 MPI_Allreduce(MPI_IN_PLACE, &norm, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
94 std::cout << std::setprecision(12) << std::fixed
95 << text << norm << std::endl;
105 std::cout << std::setprecision(12) << std::fixed
106 << text << norm << std::endl;
110 int main(
int argc,
char *argv[])
114 int myid = Mpi::WorldRank();;
118 const char *mesh_file =
"../../data/inline-quad.mesh";
124 double distance = 0.35;
126 int vis_steps_cnt = 50;
129 args.
AddOption(&mesh_file,
"-m",
"--mesh",
130 "Mesh file to use.");
131 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
132 "Number of times to refine the mesh uniformly in serial.");
133 args.
AddOption((
int*)&ex_type,
"-et",
"--extrap-type",
134 "Extrapolation type: Aslam (0) or Bochkov (1).");
135 args.
AddOption((
int*)&dg_mode,
"-dg",
"--dg-mode",
136 "DG advection mode: 0 - Standard High-Order,\n\t"
137 " 1 - Low-Order Upwind Diffusion.");
138 args.
AddOption(&ex_degree,
"-ed",
"--extrap-degree",
139 "Extrapolation degree: 0/1/2 for constant/linear/quadratic.");
141 "Finite element order (polynomial degree) or -1 for"
142 " isoparametric space.");
143 args.
AddOption(&distance,
"-d",
"--distance",
144 "Extrapolation distance.");
148 args.
AddOption(&vis_on,
"-vis",
"--visualization",
"-no-vis",
149 "--no-visualization",
150 "Enable or disable GLVis visualization.");
151 args.
AddOption(&vis_steps_cnt,
"-vs",
"--visualization-steps",
152 "Visualize every n-th timestep.");
162 Mesh mesh(mesh_file, 1, 1);
164 ParMesh pmesh(MPI_COMM_WORLD, mesh);
186 PrintNorm(myid, ux,
"Solution l1 norm: ");
194 std::cout <<
"Global L1 error: " << err_L1 << std::endl
195 <<
"Global L2 error: " << err_L2 << std::endl;
197 double loc_error_L1, loc_error_L2, loc_error_LI;
199 loc_error_L1, loc_error_L2, loc_error_LI);
202 std::cout <<
"Local L1 error: " << loc_error_L1 << std::endl
203 <<
"Local L2 error: " << loc_error_L2 << std::endl
204 <<
"Local Li error: " << loc_error_LI << std::endl;
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
A coefficient that is constant across space and time.
Helper class for ParaView visualization data.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
int Size() const
Returns the size of the vector.
Abstract parallel finite element space.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
virtual double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
void PrintUsage(std::ostream &out) const
Print the usage message.
void SetTime(double t)
Set physical time (for time-dependent simulations)
virtual double ComputeL1Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL) const
double Norml1() const
Returns the l_1 norm of the vector.
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...
void PrintOptions(std::ostream &out) const
Print the options.
void SetLevelsOfDetail(int levels_of_detail_)
void Clear()
Clear the contents of the Mesh.
A general function coefficient.
virtual void Save() override
double u(const Vector &xvec)
Class for parallel grid function.
Class for parallel meshes.
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Good() const
Return true if the command line options were parsed successfully.