48 real_t a1 = 20., a2 = 2., a3 = 3.;
49 return tanh(a1*(x(1)-0.5) + a2*sin(a3*(x(0)-0.5)*M_PI));
52int main(
int argc,
char *argv[])
55 const char *mesh_file =
"../../data/star-q3.mesh";
56 int ser_ref_levels = 1;
60 bool visualization =
true;
65 args.
AddOption(&mesh_file,
"-m",
"--mesh",
"Mesh file to use.");
69 "Number of times to refine the mesh uniformly in serial.");
73 "Order (degree) of the finite elements.");
77 "MFEM Integration order.");
81 "Algoim Integration order.");
85 "Level set type: 1: circle, 2 sinusoidal wave");
91 "Enable or disable GLVis visualization.");
92 args.
AddOption((&print_level),
"-prt",
"--print-level",
"Print level.");
102 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
107 for (
int lev = 0; lev < ser_ref_levels; lev++)
116 std::cout <<
"Number of finite element unknowns: " << glob_size << std::endl;
127 else if (ls_type == 2)
133 MFEM_ABORT(
"Level set coefficient not defined");
142 sock <<
"solution\n";
146 sock <<
"window_title 'Level set'\n"
147 <<
"window_geometry "
148 << 1200 <<
" " << 0 <<
" " << 600 <<
" " << 600 <<
"\n"
149 <<
"keys jRmmclA" << endl;
153 real_t exact_volume = -10, exact_area = -10;
156 if (strncmp(mesh_file,
"../../data/star-q3.mesh",100) == 0)
161 else if (strncmp(mesh_file,
"../../data/inline-quad.mesh",100) == 0)
163 exact_volume = M_PI/4;
167 else if (ls_type == 2)
169 if (strncmp(mesh_file,
"../../data/inline-quad.mesh",100) == 0)
172 exact_area = 1.194452300992437;
183#ifdef MFEM_USE_ALGOIM
191 for (
int i=0; i<fespace.
GetNE(); i++)
200 trans->SetIntPoint(&ip);
210 trans->SetIntPoint(&ip);
217 if (exact_volume > 0)
219 std::cout<<
"Algoim Volume="<<vol<<
" Error="<<vol-exact_volume<<std::endl;
220 std::cout<<
"Algoim Area="<<area<<
" Error="<<area-exact_area<<std::endl;
224 std::cout<<
"Algoim Volume="<<vol<<std::endl;
225 std::cout<<
"Algoim Area="<<area<<std::endl;
231 for (
int i=0; i<fespace.
GetNE(); i++)
242 trans->SetIntPoint(&ip);
251 if (exact_volume > 0.0)
253 std::cout<<
"MFEM Volume="<<vol<<
" Error="<<vol-exact_volume<<std::endl;
257 std::cout<<
"MFEM Volume="<<vol<<std::endl;
virtual void GetVolumeIntegrationRule(ElementTransformation &Tr, IntegrationRule &result, const IntegrationRule *sir=nullptr) override
Construct a cut-volume IntegrationRule.
virtual void GetSurfaceIntegrationRule(ElementTransformation &Tr, IntegrationRule &result) override
Construct a cut-surface IntegrationRule.
virtual void GetSurfaceWeights(ElementTransformation &Tr, const IntegrationRule &sir, Vector &weights) override
Compute transformation quadrature weights for surface integration.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
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)
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.
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
int GetNE() const
Returns number of elements in the mesh.
Abstract class for all finite elements.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
A general function coefficient.
Class for grid function - Vector with associated FE space.
virtual real_t GetValue(int i, const IntegrationPoint &ip, int vdim=1) const
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Arbitrary order H1-conforming (continuous) finite elements.
Class for integration point with weight.
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
int Dimension() const
Dimension of the reference space used within the elements.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
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.
Helper class for ParaView visualization data.
void SetLevelsOfDetail(int levels_of_detail_)
void trans(const Vector &u, Vector &x)
real_t sinusoidal_ls(const Vector &x)
real_t sphere_ls(const Vector &x)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)