70int main(
int argc,
char *argv[])
73 const char *mesh_file =
"../../data/star.mesh";
80 bool use_pointwise_transfer =
false;
81 bool use_weighted_transfer =
false;
82 const char *device_config =
"cpu";
86 args.
AddOption(&mesh_file,
"-m",
"--mesh",
89 "Problem type (see the RHO_exact function).");
91 "Finite element order (polynomial degree) or -1 for"
92 " isoparametric space.");
93 args.
AddOption(&lref,
"-lref",
"--lor-ref-level",
"LOR refinement level.");
94 args.
AddOption(&lorder,
"-lo",
"--lor-order",
95 "LOR space order (polynomial degree, zero by default).");
96 args.
AddOption(&vis,
"-vis",
"--visualization",
"-no-vis",
98 "Enable or disable GLVis visualization.");
99 args.
AddOption(&useH1,
"-h1",
"--use-h1",
"-l2",
"--use-l2",
100 "Use H1 spaces instead of L2.");
101 args.
AddOption(&use_pointwise_transfer,
"-t",
"--use-pointwise-transfer",
102 "-no-t",
"--dont-use-pointwise-transfer",
103 "Use pointwise transfer operators instead of L2 projection.");
104 args.
AddOption(&use_weighted_transfer,
"-w",
"--use-weighted-transfer",
105 "-no-w",
"--dont-use-weighted-transfer",
106 "Use coefficient-weighted L2 projection.");
107 args.
AddOption(&device_config,
"-d",
"--device",
108 "Device configuration string, see Device::Configure().");
109 args.
AddOption(&use_ea,
"-ea",
"--ea-version",
"-no-ea",
110 "--no-ea-version",
"Use element assembly version.");
114 Device device(device_config);
116 if (use_weighted_transfer && !use_pointwise_transfer)
120 cout <<
"Switching to positive problem = 5 for weighted transfer.\n";
126 Mesh mesh(mesh_file, 1, 1);
141 cerr <<
"Switching the H1 LOR space order from 0 to 1\n";
158 if (use_weighted_transfer)
160 weight_coeff.
coeff = &weight_fn_coeff;
161 weight_coeff.
order = 2;
195 if (use_pointwise_transfer)
212 R.
Mult(rho, rho_lor);
216 if (use_weighted_transfer && !use_pointwise_transfer)
228 w.ProjectCoefficient(W);
235 vel_gt.
UseEA(use_ea);
237 compute_mass(w_lor, ho_momentum,
"rho w LOR", prod_lor_weight);
247 cout <<
"|w - P(R(w))|_∞ = " << w_prev.
Normlinf() <<
"\n\n";
257 P.
Mult(rho_lor, rho);
263 cout <<
"|HO - P(R(HO))|_∞ = " << rho_prev.
Normlinf() << endl;
267 LinearForm M_rho(&fespace), M_rho_lor(&fespace_lor);
271 M_ho.
Mult(rho, M_rho);
273 cout <<
"HO -> LOR dual field: " <<
abs(M_rho.Sum()-M_rho_lor.
Sum()) <<
"\n\n";
288 P.
Mult(rho_lor, rho);
295 R.
Mult(rho, rho_lor);
296 compute_mass(rho_lor, lor_mass,
"R(P(LOR))", weight_coeff);
297 if (vis) {
visualize(LOR_dc,
"R(P(LOR))",
Wx,
Wy, visport); }
299 rho_lor_prev -= rho_lor;
301 cout <<
"|LOR - R(P(LOR))|_∞ = " << rho_lor_prev.
Normlinf() << endl;
305 if (!use_pointwise_transfer)
307 M_lor.
Mult(rho_lor, M_rho_lor);
309 cout <<
"LOR -> HO dual field: " <<
abs(M_rho.Sum() - M_rho_lor.
Sum()) <<
'\n';
325 return x(1)+0.25*cos(2*M_PI*x.
Norml2());
327 return x(1)*x(1)*x(1) + 2*x(0)*x(1) + x(0);
329 return M_PI/2-atan(5*(2*x.
Norml2()-1));
331 return (x.
Norml2() < 0.1) ? 1 : 0;
333 return 2.0 + 2*x(0)*x(0) + 3*x(1)*x(1) - x(0)*x(1) + 0.1*sin(x.
Norml2());
342 return x(1) + 0.25*cos(2*M_PI*x.
Norml2());
348 return x(0)*x(0) + x(1)*x(1) + 1.0;
360 sol_sockL2.precision(8);
362 <<
"window_geometry " << x <<
" " << y <<
" " << w <<
" " << h
363 <<
"plot_caption '" <<
space <<
" " << prefix <<
" Density'"
364 <<
"window_title '" <<
direction <<
"'" << flush;
387 const real_t newmass = lf(gf);
389 cout <<
space <<
" " << prefix <<
" mass = " << newmass;
393 cout <<
" (" << fabs(newmass-oldmass)*100/oldmass <<
"%)";
@ GaussLobatto
Closed type.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
A coefficient that is constant across space and time.
GridFunction * GetField(const std::string &field_name)
Get a pointer to a grid function in the collection.
Mesh * GetMesh()
Get a pointer to the mesh in the collection.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
Class for domain integration .
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Mesh * GetMesh() const
Returns the mesh.
A general function coefficient.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Class for grid function - Vector with associated FE space.
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
void SetFromTrueVector()
Shortcut for calling SetFromTrueDofs() with GetTrueVector() as argument.
FiniteElementSpace * FESpace()
virtual void ProjectCoefficient(Coefficient &coeff, ProjectType type=ProjectType::DEFAULT)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Base class for transfer algorithms that construct transfer Operators between two finite element (FE) ...
virtual bool SupportsBackwardsOperator() const
virtual const Operator & ForwardOperator()=0
Return an Operator that transfers GridFunctions from the domain FE space to GridFunctions in the rang...
virtual const Operator & BackwardOperator()=0
Return an Operator that transfers GridFunctions from the range FE space back to GridFunctions in the ...
Arbitrary order H1-conforming (continuous) finite elements.
Transfer data between a coarse mesh and an embedded refined mesh using interpolation.
Transfer data in L2 and H1 finite element spaces between a coarse mesh and an embedded refined mesh u...
const Operator & BackwardOperator() override
Return an Operator that transfers GridFunctions from the range FE space back to GridFunctions in the ...
bool SupportsBackwardsOperator() const override
const Operator & ForwardOperator() override
Return an Operator that transfers GridFunctions from the domain FE space to GridFunctions in the rang...
Arbitrary order "L2-conforming" discontinuous finite elements.
int Dimension() const
Dimension of the reference space used within the elements.
ElementTransformation * GetTypicalElementTransformation()
If the local mesh is not empty return GetElementTransformation(0); otherwise, return the identity tra...
static Mesh MakeRefined(Mesh &orig_mesh, int ref_factor, int ref_type)
Create a refined (by any factor) version of orig_mesh.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
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...
Scalar coefficient defined as the product of two scalar coefficients or a scalar and a scalar coeffic...
real_t Normlinf() const
Returns the l_infinity norm of the vector.
real_t Norml2() const
Returns the l2 norm of the vector.
real_t Sum() const
Return the sum of the vector entries.
Data collection with VisIt I/O routines.
void RegisterField(const std::string &field_name, GridFunction *gf) override
Add a grid function to the collection and update the root file.
real_t weight(const Vector &x)
real_t compute_mass(GridFunction &, real_t, string, CoefficientWithOrder)
void visualize(VisItDataCollection &, string, int, int, int visport=19916)
real_t W_exact(const Vector &x)
real_t RHO_exact(const Vector &x)
MFEM_HOST_DEVICE real_t abs(const Complex &z)