48 double a1 = 20., a2 = 2., a3 = 3.;
49 return tanh(a1*(x(1)-0.5) + a2*sin(a3*(x(0)-0.5)*M_PI));
52 int 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 double 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 192 for (
int i=0; i<fespace.
GetNE(); i++)
211 trans->SetIntPoint(&ip);
225 trans->SetIntPoint(&ip);
228 Mult(bmat,
trans->AdjugateJacobian(), pmat);
237 if (exact_volume > 0)
239 std::cout<<
"Algoim Volume="<<vol<<
" Error="<<vol-exact_volume<<std::endl;
240 std::cout<<
"Algoim Area="<<area<<
" Error="<<area-exact_area<<std::endl;
244 std::cout<<
"Algoim Volume="<<vol<<std::endl;
245 std::cout<<
"Algoim Area="<<area<<std::endl;
251 for (
int i=0; i<fespace.
GetNE(); i++)
262 trans->SetIntPoint(&ip);
271 if (exact_volume > 0.0)
273 std::cout<<
"MFEM Volume="<<vol<<
" Error="<<vol-exact_volume<<std::endl;
277 std::cout<<
"MFEM Volume="<<vol<<std::endl;
Abstract class for all finite elements.
void trans(const Vector &u, Vector &x)
int GetNPoints() const
Returns the number of the points in the integration rule.
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
const IntegrationRule * GetSurfaceIntegrationRule()
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
void PrintOptions(std::ostream &out) const
Print the options.
int Dimension() const
Dimension of the reference space used within the elements.
void SetSize(int s)
Resize the vector to size s.
Helper class for ParaView visualization data.
void PrintUsage(std::ostream &out) const
Print the usage message.
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
const IntegrationRule * GetVolumeIntegrationRule()
Data type dense matrix using column-major storage.
bool Good() const
Return true if the command line options were parsed successfully.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
virtual double GetValue(int i, const IntegrationPoint &ip, int vdim=1) const
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
double sphere_ls(const Vector &x)
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
int main(int argc, char *argv[])
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetTime(double t)
Set physical time (for time-dependent simulations)
int GetNE() const
Returns number of elements in the mesh.
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 int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
int GetDim() const
Returns the reference space dimension for the finite element.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
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...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Class for integration point with weight.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
double Norml2() const
Returns the l2 norm of the vector.
void SetLevelsOfDetail(int levels_of_detail_)
A general function coefficient.
virtual void Print(std::ostream &os=mfem::out) const
Arbitrary order H1-conforming (continuous) finite elements.
virtual void Save() override
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
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...
double sinusoidal_ls(const Vector &x)
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.