15 #include "../config/config.hpp"
16 #include "../general/stable3d.hpp"
21 #include "../fem/eltrans.hpp"
22 #include "../fem/coefficient.hpp"
32 class FiniteElementSpace;
131 #ifdef MFEM_USE_MEMALLOC
186 int *edge1,
int *edge2,
int *middle)
192 int *edge1,
int *edge2,
int *middle)
193 {
Bisection(i, v_to_v, edge1, edge2, middle); }
289 int v0,
int v1,
int v2);
292 int v0,
int v1,
int v2,
int v3);
302 inline static void ShiftL2R(
int &,
int &,
int &);
304 inline static void Rotate3(
int &,
int &,
int &);
312 void InitMesh(
int _Dim,
int _spaceDim,
int NVert,
int NElem,
int NBdrElem);
319 double sx,
double sy,
double sz);
326 double sx,
double sy);
329 void Make1D(
int n,
double sx = 1.0);
339 void Swap(
Mesh& other,
bool non_geometry =
false);
352 explicit Mesh(
const Mesh &mesh,
bool copy_nodes =
true);
354 Mesh(
int _Dim,
int NVert,
int NElem,
int NBdrElem = 0,
int _spaceDim= -1)
360 InitMesh(_Dim, _spaceDim, NVert, NElem, NBdrElem);
366 void AddTri(
const int *vi,
int attr = 1);
368 void AddQuad(
const int *vi,
int attr = 1);
369 void AddTet(
const int *vi,
int attr = 1);
370 void AddHex(
const int *vi,
int attr = 1);
381 bool fix_orientation =
true);
383 bool fix_orientation =
true);
385 bool fix_orientation =
true);
387 bool fix_orientation =
true);
391 #ifdef MFEM_USE_GECKO
409 double sx = 1.0,
double sy = 1.0,
double sz = 1.0)
411 Make3D(nx, ny, nz, type, generate_edges, sx, sy, sz);
419 double sx = 1.0,
double sy = 1.0)
421 Make2D(nx, ny, type, generate_edges, sx, sy);
425 explicit Mesh(
int n,
double sx = 1.0)
433 Mesh(std::istream &input,
int generate_edges = 0,
int refine = 1,
434 bool fix_orientation =
true);
437 Mesh(
Mesh *mesh_array[],
int num_pieces);
443 void Load(std::istream &input,
int generate_edges = 0,
int refine = 1,
444 bool fix_orientation =
true);
495 {
return elements[i]->GetGeometryType(); }
498 {
return boundary[i]->GetGeometryType(); }
527 faces[i]->GetVertices(vert);
626 if (
faces_info[FaceNo].Elem2No < 0) {
return NULL; }
690 void GetNode(
int i,
double *coord);
691 void SetNode(
int i,
const double *coord);
725 void SetCurvature(
int order,
bool discont =
false,
int space_dim = -1,
740 int nonconforming = -1,
int nc_limit = 0);
745 int nonconforming = -1,
int nc_limit = 0);
753 int nonconforming = -1,
int nc_limit = -1,
758 double eps = 0.0,
int nonconforming = -1);
797 virtual void PrintXG(std::ostream &out = std::cout)
const;
800 virtual void Print(std::ostream &out = std::cout)
const;
809 void PrintVTK(std::ostream &out,
int ref,
int field_data=0);
817 std::ostream &out,
int elem_attr = 0)
const;
821 int interior_faces = 0);
852 std::ostream &out = std::cout);
867 std::ostream &
operator<<(std::ostream &out,
const Mesh &mesh);
888 Mesh *
Extrude1D(Mesh *mesh,
const int ny,
const double sy,
889 const bool closed =
false);
Abstract class for Finite Elements.
void AddHex(const int *vi, int attr=1)
void SetState(int s)
Change the mesh state to NORMAL, TWO_LEVEL_COARSE, TWO_LEVEL_FINE.
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
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 GetFaceInfos(int Face, int *Inf1, int *Inf2)
void SetVertices(const Vector &vert_coord)
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)
int GetBdrElementBaseGeometry(int i) const
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
int * GeneratePartitioning(int nparts, int part_method=1)
void BisectTetTrans(DenseMatrix &pointmat, Tetrahedron *tet, int child)
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
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 AddBdrElement(Element *elem)
int GetElementBaseGeometry(int i) const
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 BisectTriTrans(DenseMatrix &pointmat, Triangle *tri, int child)
void GenerateBoundaryElements()
void GetElementVertices(int i, Array< int > &dofs) const
Returns the indices of the dofs of element i.
void DeleteCoarseTables()
ElementTransformation * GetFineElemTrans(int i, int j)
static int GetQuadOrientation(const int *base, const int *test)
Returns the orientation of "test" relative to "base".
void GetVertices(Vector &vert_coord) const
virtual ~Mesh()
Destroys mesh.
void AddBdrSegment(const int *vi, int attr=1)
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)
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()
IsoparametricTransformation FaceTransformation
Array< NCFaceInfo > nc_faces_info
Element * ReadElement(std::istream &)
void KnotInsert(Array< KnotVector * > &kv)
Array< FaceInfo > fc_faces_info
int GetFineElemPath(int i, int j)
A parallel extension of the NCMesh class.
Element * NewElement(int geom)
FaceElementTransformations FaceElemTr
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr)
void RefineAtVertex(const Vertex &vert, int levels, double eps=0.0, int nonconforming=-1)
Refine elements sharing the specified vertex, 'levels' times.
static const int tet_faces[4][3]
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).
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)
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)
static const int quad_orientations[8][4]
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()
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)
int GetRefinementType(int i)
For a given coarse element i returns its refinement type.
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)
int MeshGenerator()
Truegrid or NetGen?
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 SetLayer(const int l)
int GetElementToEdgeTable(Table &, Array< int > &)
int GetElementType(int i) const
Returns the type of element i.
Data type triangle element.
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 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.
int GetNumFineElems(int i)
bool IsSlaveFace(const FaceInfo &fi)
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).
void UseTwoLevelState(int use)
int GetBisectionHierarchy(Element *E)
Abstract finite element space.
void RemoveUnusedVertices()
Remove unused vertices and rebuild mesh connectivity.
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)
void AddQuad(const int *vi, int attr=1)
MemAlloc< BisectedElement, 1024 > BEMemory
virtual void QuadUniformRefinement()
Refine quadrilateral mesh.
virtual void HexUniformRefinement()
Refine hexahedral mesh.
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.
void AddBdrTriangle(const int *vi, int attr=1)
Array< int > fc_be_to_edge
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 RandomRefinement(int levels, int frac=2, bool aniso=false, int nonconforming=-1, int nc_limit=-1, int seed=0)
Refine each element with 1/frac probability, repeat 'levels' times.
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)
static const int hex_faces[6][4]
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
void GetLocalSegToQuadTransformation(IsoparametricTransformation &loc, int i)
const FiniteElementSpace * GetNodalFESpace()
void FinalizeQuadMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
NodeExtrudeCoefficient(const int dim, const int _n, const double _s)
void ReorderElements(const Array< int > &ordering, bool reorder_vertices=true)
void GetBdrElementVertices(int i, Array< int > &dofs) const
Returns the indices of the dofs of boundary element i.
void ApplySlaveTransformation(IsoparametricTransformation &transf, const FaceInfo &fi)
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)
static void PrintElementWithoutAttr(const Element *, std::ostream &)
int GetFineElem(int i, int j)
int GetNEdges() const
Return the number of edges.
double * GetVertex(int i)
int GetNFaces() const
Return the number of faces in a 3D mesh.
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 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)
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()
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)
static const int tri_orientations[6][3]
Class used to extrude the nodes of a mesh.