45 for (
int i = 0; i < mesh.
GetNE(); i++)
65 MFEM_ASSERT(children.
Size() == 2,
"");
67 const int elem1 = children[0];
78 for (
int i = 0; i < num_refs; i++)
80 const auto elem = gen() % mesh.
GetNE();
81 const auto t = gen() %
dim;
91int main(
int argc,
char *argv[])
94 const char *mesh_file =
"../../data/star.mesh";
96 bool visualization =
true;
97 bool makeMesh =
false;
102 args.
AddOption(&mesh_file,
"-m",
"--mesh",
103 "Mesh file to use.");
105 "Finite element order (polynomial degree) or -1 for"
106 " isoparametric space.");
107 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
108 "--no-visualization",
109 "Enable or disable GLVis visualization.");
110 args.
AddOption(&makeMesh,
"-mm",
"--make-mesh",
"-no-mm",
111 "--no-make-mesh",
"Create Cartesian mesh");
112 args.
AddOption(&tdim,
"-dim",
"--dimension",
"Dimension for Cartesian mesh");
113 args.
AddOption(&num_refs,
"-r",
"--refs",
"Number of 3:1 refinements");
143 cout <<
"Number of finite element unknowns: "
174 PCG(*A, M, B, X, 1, 2000, 1e-12, 0.0);
175 a.RecoverFEMSolution(X,
b, x);
180 cout <<
"Error of H1 continuity: " << h1err << endl;
181 MFEM_VERIFY(h1err < 1.0e-7,
"");
185 ofstream mesh_ofs(
"ref321.mesh");
186 mesh_ofs.precision(8);
187 mesh.
Print(mesh_ofs);
188 ofstream sol_ofs(
"sol.gf");
189 sol_ofs.precision(8);
198 sol_sock.precision(8);
199 sol_sock <<
"solution\n" << mesh << x << flush;
221 int Inf1, Inf2, NCFace;
228 auto &int_rule =
IntRules.
Get(FT->FaceGeom, 2 * faceOrder);
236 bool isNCSlave = FT->Elem2No >= 0 && NCFace >= 0;
237 bool isConforming = FT->Elem2No >= 0 && NCFace == -1;
238 if ((FT->Elem1No < FT->Elem2No && isConforming) || isNCSlave)
240 for (
int i = 0; i < nip; i++)
242 const auto &fip = int_rule.IntPoint(i);
245 FT->Loc1.Transform(fip, ip);
248 FT->Loc2.Transform(fip, ip);
251 const real_t err_i = std::abs(v1 - v2);
252 errorMax = std::max(errorMax, err_i);
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
A coefficient that is constant across space and time.
Class for domain integration .
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.
int GetEdgeOrder(int edge, int variant=0) const
int GetFaceOrder(int face, int variant=0) const
Returns the polynomial degree of the i'th face finite element.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
Mesh * GetMesh() const
Returns the mesh.
Gauss-Seidel smoother of a sparse matrix.
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.
FiniteElementSpace * FESpace()
Arbitrary order H1-conforming (continuous) finite elements.
Class for integration point with weight.
int GetNPoints() const
Returns the number of the points in the integration rule.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
virtual FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void GetFaceInfos(int Face, int *Inf1, int *Inf2) const
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
void GeneralRefinement(const Array< Refinement > &refinements, int nonconforming=-1, int nc_limit=0)
void EnsureNodes()
Make sure that the mesh has valid nodes, i.e. its geometry is described by a vector finite element gr...
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
Print the mesh to the given stream using the default MFEM mesh format.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
bool FaceIsInterior(int FaceNo) const
Return true if the given face is interior.
static Mesh MakeCartesian3D(int nx, int ny, int nz, Element::Type type, real_t sx=1.0, real_t sy=1.0, real_t sz=1.0, bool sfc_ordering=true)
Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into nx*ny*nz hexahedra if type =...
static Mesh LoadFromFile(const std::string &filename, int generate_edges=0, int refine=1, bool fix_orientation=true)
NCMesh * ncmesh
Optional nonconforming mesh extension.
static Mesh MakeCartesian2D(int nx, int ny, Element::Type type, bool generate_edges=false, real_t sx=1.0, real_t sy=1.0, bool sfc_ordering=true)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny quadrilaterals if type = QUADRILATER...
const CoarseFineTransformations & GetRefinementTransforms() const
Pointer to an Operator of a specified type.
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.
const int * ess_tdof_list
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
std::function< real_t(const Vector &)> f(real_t mass_coeff)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
real_t p(const Vector &x, real_t t)
void FindChildren(const Mesh &mesh, int elem, Array< int > &children)
real_t CheckH1Continuity(GridFunction &x)
void Refine31(Mesh &mesh, int elem, char type)
void TestAnisoRefRandom(int num_refs, int dim, Mesh &mesh)