15 #include "../config/config.hpp"
16 #include "../general/stable3d.hpp"
21 #include "../fem/eltrans.hpp"
22 #include "../fem/coefficient.hpp"
34 class FiniteElementSpace;
126 #ifdef MFEM_USE_MEMALLOC
163 void ReadMFEMMesh(std::istream &input,
bool mfem_v11,
int &curved);
168 void ReadVTKMesh(std::istream &input,
int &curved,
int &read_gf);
169 void ReadNURBSMesh(std::istream &input,
int &curved,
int &read_gf);
173 #ifdef MFEM_USE_NETCDF
182 if (is.peek() != comment_char) {
break; }
183 is.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
189 if (!line.empty() && *line.rbegin() ==
'\r')
190 { line.resize(line.size()-1); }
216 int *edge1,
int *edge2,
int *middle)
222 int *edge1,
int *edge2,
int *middle)
223 {
Bisection(i, v_to_v, edge1, edge2, middle); }
262 double threshold,
int nc_limit = 0,
324 int v0,
int v1,
int v2);
327 int v0,
int v1,
int v2,
int v3);
337 inline static void ShiftL2R(
int &,
int &,
int &);
339 inline static void Rotate3(
int &,
int &,
int &);
347 void InitMesh(
int _Dim,
int _spaceDim,
int NVert,
int NElem,
int NBdrElem);
356 double sx,
double sy,
double sz);
363 double sx,
double sy);
366 void Make1D(
int n,
double sx = 1.0);
376 void Swap(
Mesh& other,
bool non_geometry =
false);
386 explicit Mesh(
const Mesh &mesh,
bool copy_nodes =
true);
388 Mesh(
int _Dim,
int NVert,
int NElem,
int NBdrElem = 0,
int _spaceDim= -1)
394 InitMesh(_Dim, _spaceDim, NVert, NElem, NBdrElem);
400 void AddTri(
const int *vi,
int attr = 1);
402 void AddQuad(
const int *vi,
int attr = 1);
403 void AddTet(
const int *vi,
int attr = 1);
404 void AddHex(
const int *vi,
int attr = 1);
415 bool fix_orientation =
true);
417 bool fix_orientation =
true);
419 bool fix_orientation =
true);
421 bool fix_orientation =
true);
425 #ifdef MFEM_USE_GECKO
443 double sx = 1.0,
double sy = 1.0,
double sz = 1.0)
445 Make3D(nx, ny, nz, type, generate_edges, sx, sy, sz);
453 double sx = 1.0,
double sy = 1.0)
455 Make2D(nx, ny, type, generate_edges, sx, sy);
459 explicit Mesh(
int n,
double sx = 1.0)
467 Mesh(
const char *filename,
int generate_edges = 0,
int refine = 1,
468 bool fix_orientation =
true);
473 Mesh(std::istream &input,
int generate_edges = 0,
int refine = 1,
474 bool fix_orientation =
true);
477 Mesh(
Mesh *mesh_array[],
int num_pieces);
483 void Load(std::istream &input,
int generate_edges = 0,
int refine = 1,
484 bool fix_orientation =
true);
511 virtual long ReduceInt(
int value)
const {
return value; }
584 faces[i]->GetVertices(vert);
693 if (
faces_info[FaceNo].Elem2No < 0) {
return NULL; }
760 void GetNode(
int i,
double *coord);
761 void SetNode(
int i,
const double *coord);
796 void SetCurvature(
int order,
bool discont =
false,
int space_dim = -1,
811 int nonconforming = -1,
int nc_limit = 0);
816 int nonconforming = -1,
int nc_limit = 0);
820 int nonconforming = -1,
int nc_limit = 0);
824 double eps = 0.0,
int nonconforming = -1);
829 int nonconforming = -1,
int nc_limit = 0);
834 int nonconforming = -1,
int nc_limit = 0);
842 int nc_limit = 0,
int op = 1);
846 int nc_limit = 0,
int op = 1);
855 void EnsureNCMesh(
bool triangles_nonconforming =
false);
874 virtual void PrintXG(std::ostream &out = std::cout)
const;
877 virtual void Print(std::ostream &out = std::cout)
const;
886 void PrintVTK(std::ostream &out,
int ref,
int field_data=0);
894 std::ostream &out,
int elem_attr = 0)
const;
898 int interior_faces = 0);
933 std::ostream &out = std::cout);
948 std::ostream &
operator<<(std::ostream &out,
const Mesh &mesh);
969 Mesh *
Extrude1D(Mesh *mesh,
const int ny,
const double sy,
970 const bool closed =
false);
980 std::ifstream(mesh_name),
filename(mesh_name) {}
Abstract class for Finite Elements.
void AddHex(const int *vi, int attr=1)
std::ostream & operator<<(std::ostream &out, const Mesh &mesh)
void GetFaceEdges(int i, Array< int > &, Array< int > &) const
void PrintSurfaces(const Table &Aface_face, std::ostream &out) const
Print set of disjoint surfaces:
void GetPointMatrix(int i, DenseMatrix &pointmat) const
static const int vtk_quadratic_hex[27]
int * CartesianPartitioning(int nxyz[])
virtual void PrintInfo(std::ostream &out=std::cout)
const DenseMatrix * PointMatrix
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
const double * GetVertex(int i) const
Return pointer to vertex i's coordinates.
void ScaleElements(double sf)
Class for grid function - Vector with associated FE space.
Table * GetEdgeVertexTable() const
Returns the edge-to-vertex Table (3D)
void GetBdrElementEdges(int i, Array< int > &edges, Array< int > &cor) const
Return the indices and the orientations of all edges of bdr element i.
void FreeElement(Element *E)
void DerefineMesh(const Array< int > &derefinements)
Derefine elements once a list of derefinements is known.
void GetFaceInfos(int Face, int *Inf1, int *Inf2)
void SetVertices(const Vector &vert_coord)
static const int vtk_quadratic_tet[10]
void GetEdgeVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of edge i.
bool FaceIsTrueInterior(int FaceNo) const
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
long GetGlobalNE() const
Return the total (global) number of elements.
void AddHexAsTets(const int *vi, int attr=1)
void GetFaceElements(int Face, int *Elem1, int *Elem2)
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Array< Element * > boundary
Geometry::Constants< Geometry::SQUARE > quad_t
int * GeneratePartitioning(int nparts, int part_method=1)
CoarseFineTransformations CoarseFineTr
void MoveVertices(const Vector &displacements)
int GetNBE() const
Returns number of boundary elements.
IsoparametricTransformation Transformation
void GetLocalPtToSegTransformation(IsoparametricTransformation &, int)
Used in GetFaceElementTransformations (...)
void PrintWithPartitioning(int *partitioning, std::ostream &out, int elem_attr=0) const
int GetFaceGeometryType(int Face) const
void NewNodes(GridFunction &nodes, bool make_owner=false)
Replace the internal node GridFunction with the given GridFunction.
void SwapNodes(GridFunction *&nodes, int &own_nodes_)
void GetElementFaces(int i, Array< int > &, Array< int > &) const
Return the indices and the orientations of all faces of element i.
void GetLocalFaceTransformation(int face_type, int elem_type, IsoparametricTransformation &Transf, int inf)
Used in GetFaceElementTransformations (...)
void AddBdrElement(Element *elem)
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
void ReadNetgen2DMesh(std::istream &input, int &curved)
void DegreeElevate(int t)
int EulerNumber2D() const
Equals 1 - num_holes.
void AddTri(const int *vi, int attr=1)
void GetFaceVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of face i.
Data type dense matrix using column-major storage.
Mesh * Extrude1D(Mesh *mesh, const int ny, const double sy, const bool closed)
Extrude a 1D mesh.
void Transform(void(*f)(const Vector &, Vector &))
int GetBdrElementEdgeIndex(int i) const
int GetNE() const
Returns number of elements.
const Element * GetFace(int i) const
Element * GetElement(int i)
void GenerateBoundaryElements()
void GetElementVertices(int i, Array< int > &dofs) const
Returns the indices of the dofs of element i.
static int GetQuadOrientation(const int *base, const int *test)
Returns the orientation of "test" relative to "base".
void GetVertices(Vector &vert_coord) const
void ReadNetgen3DMesh(std::istream &input)
virtual ~Mesh()
Destroys mesh.
void AddBdrSegment(const int *vi, int attr=1)
int GetFaceElementType(int Face) const
FaceElementTransformations * GetInteriorFaceTransformations(int FaceNo)
void CheckBdrElementOrientation(bool fix_it=true)
Check the orientation of the boundary elements.
void RemoveInternalBoundaries()
FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
virtual long ReduceInt(int value) const
Utility function: sum integers from all processors (Allreduce).
void FinalizeHexMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
void GetVertexToVertexTable(DSTable &) const
void RedRefinement(int i, const DSTable &v_to_v, int *edge1, int *edge2, int *middle)
void MarkTriMeshForRefinement()
void InitRefinementTransforms()
IsoparametricTransformation FaceTransformation
Array< NCFaceInfo > nc_faces_info
Element * ReadElement(std::istream &)
void KnotInsert(Array< KnotVector * > &kv)
A parallel extension of the NCMesh class.
Element * NewElement(int geom)
FaceElementTransformations FaceElemTr
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr)
const GridFunction * GetNodes() const
ElementTransformation * GetBdrElementTransformation(int i)
Returns the transformation defining the i-th boundary element.
void AddVertex(const double *)
Mesh(int _Dim, int NVert, int NElem, int NBdrElem=0, int _spaceDim=-1)
void PrintTopo(std::ostream &out, const Array< int > &e_to_k) const
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
Geometry::Constants< Geometry::SEGMENT > seg_t
void AddElement(Element *elem)
void Load(std::istream &input, int generate_edges=0, int refine=1, bool fix_orientation=true)
void GetElementJacobian(int i, DenseMatrix &J)
void MesquiteSmooth(const int mesquite_option=0)
bool Nonconforming() const
Mesh(int nx, int ny, Element::Type type, int generate_edges=0, double sx=1.0, double sy=1.0)
void MoveNodes(const Vector &displacements)
void GetEdgeOrdering(DSTable &v_to_v, Array< int > &order)
NCFaceInfo(bool slave, int master, const DenseMatrix *pm)
void FinalizeTriMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
void FinalizeTetMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
void AddBdrQuadAsTriangles(const int *vi, int attr=1)
void AddSegmentFaceElement(int lf, int gf, int el, int v0, int v1)
void MarkTetMeshForRefinement()
int FindCoarseElement(int i)
void GetFaceTransformation(int i, IsoparametricTransformation *FTr)
void GetLocalSegToTriTransformation(IsoparametricTransformation &loc, int i)
void AddQuadFaceElement(int lf, int gf, int el, int v0, int v1, int v2, int v3)
named_ifstream(const char *mesh_name)
static FiniteElement * GetTransformationFEforElementType(int)
void LoadPatchTopo(std::istream &input, Array< int > &edge_to_knot)
Read NURBS patch/macro-element mesh.
STable3D * GetElementToFaceTable(int ret_ftbl=0)
void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
static void Rotate3(int &, int &, int &)
void Make2D(int nx, int ny, Element::Type type, int generate_edges, double sx, double sy)
Type
Constants for the classes derived from Element.
void GetBdrPointMatrix(int i, DenseMatrix &pointmat) const
void CheckDisplacements(const Vector &displacements, double &tmax)
void CheckElementOrientation(bool fix_it=true)
Check the orientation of the elements.
void ReadInlineMesh(std::istream &input, int generate_edges=0)
Geometry::Constants< Geometry::TETRAHEDRON > tet_t
void ReadLineMesh(std::istream &input)
void SetLayer(const int l)
int GetElementToEdgeTable(Table &, Array< int > &)
void GetBdrElementAdjacentElement(int bdr_el, int &el, int &info) const
For the given boundary element, bdr_el, return its adjacent element and its info, i...
void RandomRefinement(double prob, bool aniso=false, int nonconforming=-1, int nc_limit=0)
Refine each element with given probability. Uses GeneralRefinement.
int GetElementType(int i) const
Returns the type of element i.
const Element * GetElement(int i) const
Mesh(int n, double sx=1.0)
void GetLocalQuadToHexTransformation(IsoparametricTransformation &loc, int i)
Used in GetFaceElementTransformations (...)
IsoparametricTransformation Transformation2
void SetNodalFESpace(FiniteElementSpace *nfes)
Element * GetBdrElement(int i)
A class for non-conforming AMR on higher-order hexahedral, quadrilateral or triangular meshes...
FaceElementTransformations * GetBdrFaceTransformations(int BdrElemNo)
virtual void ReorientTetMesh()
static void ShiftL2R(int &, int &, int &)
virtual void LocalRefinement(const Array< int > &marked_el, int type=3)
This function is not public anymore. Use GeneralRefinement instead.
int GetBdrElementType(int i) const
Returns the type of boundary element i.
void GetGeckoElementReordering(Array< int > &ordering)
Data type tetrahedron element.
double GetElementSize(int i, int type=0)
int SpaceDimension() const
void GetBdrElementFace(int i, int *, int *) const
Return the index and the orientation of the face of bdr element i. (3D)
void CheckPartitioning(int *partitioning)
virtual void Print(std::ostream &out=std::cout) const
Print the mesh to the given stream using the default MFEM mesh format.
void PrintElementsWithPartitioning(int *partitioning, std::ostream &out, int interior_faces=0)
bool FaceIsInterior(int FaceNo) const
Return true if the given face is interior.
void ReadMFEMMesh(std::istream &input, bool mfem_v11, int &curved)
void AddPointFaceElement(int lf, int gf, int el)
Used in GenerateFaces()
void Make1D(int n, double sx=1.0)
Creates a 1D mesh for the interval [0,sx] divided into n equal intervals.
const Element *const * GetElementsArray() const
Array< int > bdr_attributes
virtual void NonconformingRefinement(const Array< Refinement > &refinements, int nc_limit=0)
This function is not public anymore. Use GeneralRefinement instead.
void PrintVTK(std::ostream &out)
Print the mesh in VTK format (linear and quadratic meshes only).
Geometry::Constants< Geometry::CUBE > hex_t
void RemoveUnusedVertices()
Remove unused vertices and rebuild mesh connectivity.
void ApplyLocalSlaveTransformation(IsoparametricTransformation &transf, const FaceInfo &fi)
static void PrintElement(const Element *, std::ostream &)
virtual void NURBSUniformRefinement()
Refine NURBS mesh.
static void GetElementArrayEdgeTable(const Array< Element * > &elem_array, const DSTable &v_to_v, Table &el_to_edge)
void PrintCharacteristics(Vector *Vh=NULL, Vector *Vk=NULL, std::ostream &out=std::cout)
GridFunction * GetNodes()
Return a pointer to the internal node GridFunction (may be NULL).
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
void PrepareNodeReorder(DSTable **old_v_to_v, Table **old_elem_vert)
bool IsSlaveFace(const FaceInfo &fi) const
void AddQuad(const int *vi, int attr=1)
void ReadGmshMesh(std::istream &input)
virtual void QuadUniformRefinement()
Refine quadrilateral mesh.
virtual void HexUniformRefinement()
Refine hexahedral mesh.
void RefineAtVertex(const Vertex &vert, double eps=0.0, int nonconforming=-1)
Refine elements sharing the specified vertex. Uses GeneralRefinement.
void Swap(Mesh &other, bool non_geometry=false)
Array< Element * > elements
const Table & ElementToElementTable()
double GetLength(int i, int j) const
Return the length of the segment from node i to node j.
const CoarseFineTransformations & GetRefinementTransforms()
bool RefineByError(const Array< double > &elem_error, double threshold, int nonconforming=-1, int nc_limit=0)
Operation GetLastOperation() const
Return type of last modification of the mesh.
int GetElementBaseGeometry(int i=0) const
void AddBdrTriangle(const int *vi, int attr=1)
Table * GetFaceToElementTable() const
void GetLocalTriToTetTransformation(IsoparametricTransformation &loc, int i)
Used in GetFaceElementTransformations (...)
int EulerNumber() const
Equals 1 + num_holes - num_loops.
NURBSExtension * NURBSext
void AddBdrQuad(const int *vi, int attr=1)
const Table & ElementToFaceTable() const
Class for integration point with weight.
void ReadCubit(named_ifstream &input, int &curved, int &read_gf)
Element * ReadElementWithoutAttr(std::istream &)
void GetElementEdges(int i, Array< int > &edges, Array< int > &cor) const
Return the indices and the orientations of all edges of element i.
void AddTriangle(const int *vi, int attr=1)
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
void GetLocalSegToQuadTransformation(IsoparametricTransformation &loc, int i)
const FiniteElementSpace * GetNodalFESpace() const
void FinalizeQuadMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
bool DerefineByError(Array< double > &elem_error, double threshold, int nc_limit=0, int op=1)
NodeExtrudeCoefficient(const int dim, const int _n, const double _s)
void ReorderElements(const Array< int > &ordering, bool reorder_vertices=true)
void ReadVTKMesh(std::istream &input, int &curved, int &read_gf)
static void skip_comment_lines(std::istream &is, const char comment_char)
void GetBdrElementVertices(int i, Array< int > &dofs) const
Returns the indices of the dofs of boundary element i.
virtual ~NodeExtrudeCoefficient()
Array< FaceInfo > faces_info
STable3D * GetFacesTable()
void Make3D(int nx, int ny, int nz, Element::Type type, int generate_edges, double sx, double sy, double sz)
void EnsureNCMesh(bool triangles_nonconforming=false)
static void PrintElementWithoutAttr(const Element *, std::ostream &)
virtual bool NonconformingDerefinement(Array< double > &elem_error, double threshold, int nc_limit=0, int op=1)
NC version of GeneralDerefinement.
int GetNEdges() const
Return the number of edges.
Geometry::Constants< Geometry::TRIANGLE > tri_t
double * GetVertex(int i)
Return pointer to vertex i's coordinates.
int GetNFaces() const
Return the number of faces in a 3D mesh.
void ReadTrueGridMesh(std::istream &input)
int GetFaceBaseGeometry(int i) const
void AverageVertices(int *indexes, int n, int result)
Mesh(int nx, int ny, int nz, Element::Type type, int generate_edges=0, double sx=1.0, double sy=1.0, double sz=1.0)
static int GetTriOrientation(const int *base, const int *test)
Returns the orientation of "test" relative to "base".
void SetNode(int i, const double *coord)
void GetNode(int i, double *coord)
void GetElementColoring(Array< int > &colors, int el0=0)
IsoparametricTransformation EdgeTransformation
void AddTet(const int *vi, int attr=1)
MemAlloc< Tetrahedron, 1024 > TetMemory
Table * GetFaceEdgeTable() const
Returns the face-to-edge Table (3D)
void DoNodeReorder(DSTable *old_v_to_v, Table *old_elem_vert)
void SetNodes(const Vector &node_coord)
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
void ReadNURBSMesh(std::istream &input, int &curved, int &read_gf)
void ScaleSubdomains(double sf)
virtual void PrintXG(std::ostream &out=std::cout) const
Print the mesh to the given stream using Netgen/Truegrid format.
void InitFromNCMesh(const NCMesh &ncmesh)
Initialize vertices/elements/boundary/tables from a nonconforming mesh.
void Bisection(int i, const DSTable &, int *, int *, int *)
void GeneralRefinement(const Array< Refinement > &refinements, int nonconforming=-1, int nc_limit=0)
static void filter_dos(std::string &line)
Class for parallel meshes.
Abstract data type element.
int GetAttribute(int i) const
Return the attribute of element i.
void AddTriangleFaceElement(int lf, int gf, int el, int v0, int v1, int v2)
const Table & ElementToEdgeTable() const
void GenerateNCFaceInfo()
int GetBdrElementBaseGeometry(int i=0) const
double GetElementVolume(int i)
void InitMesh(int _Dim, int _spaceDim, int NVert, int NElem, int NBdrElem)
Begin construction of a mesh.
Table * GetVertexToElementTable()
The returned Table must be destroyed by the caller.
const Element * GetBdrElement(int i) const
void UpdateNodes()
Update the nodes of a curved mesh after refinement.
void GreenRefinement(int i, const DSTable &v_to_v, int *edge1, int *edge2, int *middle)
Class used to extrude the nodes of a mesh.