49 real_t a1 = 20., a2 = 2., a3 = 3.;
50 return tanh(a1*(x(1)-0.5) + a2*sin(a3*(x(0)-0.5)*M_PI));
53int main(
int argc,
char *argv[])
56 const char *mesh_file =
"../../data/star-q3.mesh";
57 int ser_ref_levels = 1;
61 bool visualization =
true;
66 args.
AddOption(&mesh_file,
"-m",
"--mesh",
"Mesh file to use.");
70 "Number of times to refine the mesh uniformly in serial.");
74 "Order (degree) of the finite elements.");
78 "MFEM Integration order.");
82 "Algoim Integration order.");
86 "Level set type: 1: circle, 2 sinusoidal wave");
92 "Enable or disable GLVis visualization.");
93 args.
AddOption((&print_level),
"-prt",
"--print-level",
"Print level.");
103 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
108 for (
int lev = 0; lev < ser_ref_levels; lev++)
117 std::cout <<
"Number of finite element unknowns: " << glob_size << std::endl;
128 else if (ls_type == 2)
134 MFEM_ABORT(
"Level set coefficient not defined");
143 sock <<
"solution\n";
147 sock <<
"window_title 'Level set'\n"
148 <<
"window_geometry "
149 << 1200 <<
" " << 0 <<
" " << 600 <<
" " << 600 <<
"\n"
150 <<
"keys jRmmclA" << endl;
154 real_t exact_volume = -10, exact_area = -10;
157 if (strncmp(mesh_file,
"../../data/star-q3.mesh",100) == 0)
162 else if (strncmp(mesh_file,
"../../data/inline-quad.mesh",100) == 0)
164 exact_volume = M_PI/4;
168 else if (ls_type == 2)
170 if (strncmp(mesh_file,
"../../data/inline-quad.mesh",100) == 0)
173 exact_area = 1.194452300992437;
184#ifdef MFEM_USE_ALGOIM
193 for (
int i=0; i<fespace.
GetNE(); i++)
212 trans->SetIntPoint(&ip);
226 trans->SetIntPoint(&ip);
229 Mult(bmat,
trans->AdjugateJacobian(), pmat);
238 if (exact_volume > 0)
240 std::cout<<
"Algoim Volume="<<vol<<
" Error="<<vol-exact_volume<<std::endl;
241 std::cout<<
"Algoim Area="<<area<<
" Error="<<area-exact_area<<std::endl;
245 std::cout<<
"Algoim Volume="<<vol<<std::endl;
246 std::cout<<
"Algoim Area="<<area<<std::endl;
252 for (
int i=0; i<fespace.
GetNE(); i++)
263 trans->SetIntPoint(&ip);
272 if (exact_volume > 0.0)
274 std::cout<<
"MFEM Volume="<<vol<<
" Error="<<vol-exact_volume<<std::endl;
278 std::cout<<
"MFEM Volume="<<vol<<std::endl;
const IntegrationRule * GetVolumeIntegrationRule()
const IntegrationRule * GetSurfaceIntegrationRule()
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)
Data type dense matrix using column-major storage.
void MultTranspose(const real_t *x, real_t *y) const
Multiply a vector with the transpose matrix.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
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.
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for the i'th element. The returned indices are offsets into an ...
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.
int GetDim() const
Returns the reference space dimension for the finite element.
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const =0
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
int GetDof() const
Returns the number of degrees of freedom in the finite 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_)
virtual void Save() override
real_t Norml2() const
Returns the l2 norm of the vector.
void SetSize(int s)
Resize the vector to size s.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
void trans(const Vector &u, Vector &x)
real_t sinusoidal_ls(const Vector &x)
real_t sphere_ls(const Vector &x)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)