MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
mesh.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_MESH
13 #define MFEM_MESH
14 
15 #include "../config/config.hpp"
16 #include "../general/stable3d.hpp"
17 #include "triangle.hpp"
18 #include "tetrahedron.hpp"
19 #include "vertex.hpp"
20 #include "ncmesh.hpp"
21 #include "../fem/eltrans.hpp"
22 #include "../fem/coefficient.hpp"
23 #include <iostream>
24 
25 namespace mfem
26 {
27 
28 // Data type mesh
29 
30 class KnotVector;
31 class NURBSExtension;
32 class FiniteElementSpace;
33 class GridFunction;
34 struct Refinement;
35 
36 #ifdef MFEM_USE_MPI
37 class ParMesh;
38 class ParNCMesh;
39 #endif
40 
41 class Mesh
42 {
43 #ifdef MFEM_USE_MPI
44  friend class ParMesh;
45  friend class ParNCMesh;
46 #endif
47  friend class NURBSExtension;
48 
49 protected:
50  int Dim;
51  int spaceDim;
52 
55 
57 
58  // 0 = Empty, 1 = Standard (NetGen), 2 = TrueGrid
59  int meshgen;
60 
65 
67  // Vertices are only at the corners of elements, where you would expect them
68  // in the lowest-order mesh.
72 
73  struct FaceInfo
74  {
76  int NCFace; /* -1 if this is a regular conforming/boundary face;
77  index into 'nc_faces_info' if >= 0. */
78  };
79  // NOTE: in NC meshes, master faces have Elem2No == -1. Slave faces on the
80  // other hand have Elem2No and Elem2Inf set to the master face's element and
81  // its local face number.
82 
83  struct NCFaceInfo
84  {
85  bool Slave; // true if this is a slave face, false if master face
86  int MasterFace; // if Slave, this is the index of the master face
87  const DenseMatrix* PointMatrix; // if Slave, position within master face
88  // (NOTE: PointMatrix points to a matrix owned by NCMesh.)
89 
90  NCFaceInfo(bool slave, int master, const DenseMatrix* pm)
91  : Slave(slave), MasterFace(master), PointMatrix(pm) {}
92  };
93 
96 
101  Table *bel_to_edge; // for 3D
103  mutable Table *face_edge;
104  mutable Table *edge_vertex;
105 
107  Array<int> fc_be_to_edge; // swapped with be_to_edge when switching state
108  Table *c_el_to_face, *f_el_to_face; // for 3D two-level state
109  Array<FaceInfo> fc_faces_info; // for 3D two-level state
110 
114 
115  // Nodes are only active for higher order meshes, and share locations with
116  // the vertices, plus all the higher- order control points within the
117  // element and along the edges and on the faces.
120 
121  // Backup of the coarse mesh. Only used if WantTwoLevelState == 1 and
122  // nonconforming refinements are used.
124 
125  static const int tet_faces[4][3];
126  static const int hex_faces[6][4]; // same as Hexahedron::faces
127 
128  static const int tri_orientations[6][3];
129  static const int quad_orientations[8][4];
130 
131 #ifdef MFEM_USE_MEMALLOC
132  friend class Tetrahedron;
133 
136 #endif
137 
138 public:
141 
144 
145 protected:
146  void Init();
147 
148  void InitTables();
149 
150  void DeleteTables();
151 
155  void DeleteCoarseTables();
156 
157  Element *ReadElementWithoutAttr(std::istream &);
158  static void PrintElementWithoutAttr(const Element *, std::ostream &);
159 
160  Element *ReadElement(std::istream &);
161  static void PrintElement(const Element *, std::ostream &);
162 
163  void SetMeshGen(); // set 'meshgen'
164 
166  double GetLength(int i, int j) const;
167 
170  void GetElementJacobian(int i, DenseMatrix &J);
171 
172  void MarkForRefinement();
174  void GetEdgeOrdering(DSTable &v_to_v, Array<int> &order);
176 
177  void PrepareNodeReorder(DSTable **old_v_to_v, Table **old_elem_vert);
178  void DoNodeReorder(DSTable *old_v_to_v, Table *old_elem_vert);
179 
181  STable3D *GetElementToFaceTable(int ret_ftbl = 0);
182 
185  void RedRefinement(int i, const DSTable &v_to_v,
186  int *edge1, int *edge2, int *middle)
187  { UniformRefinement(i, v_to_v, edge1, edge2, middle); }
188 
191  void GreenRefinement(int i, const DSTable &v_to_v,
192  int *edge1, int *edge2, int *middle)
193  { Bisection(i, v_to_v, edge1, edge2, middle); }
194 
196  void Bisection(int i, const DSTable &, int *, int *, int *);
197 
199  void Bisection(int i, const DSTable &, int *);
200 
202  void UniformRefinement(int i, const DSTable &, int *, int *, int *);
203 
206  void AverageVertices (int * indexes, int n, int result);
207 
209  void UpdateNodes();
210 
212  virtual void QuadUniformRefinement();
213 
215  virtual void HexUniformRefinement();
216 
218  virtual void NURBSUniformRefinement();
219 
221  virtual void LocalRefinement(const Array<int> &marked_el, int type = 3);
222 
224  virtual void NonconformingRefinement(const Array<Refinement> &refinements,
225  int nc_limit = 0);
226 
228  void LoadPatchTopo(std::istream &input, Array<int> &edge_to_knot);
229 
230  void UpdateNURBS();
231 
232  void PrintTopo(std::ostream &out, const Array<int> &e_to_k) const;
233 
234  void BisectTriTrans (DenseMatrix &pointmat, Triangle *tri,
235  int child);
236 
237  void BisectTetTrans (DenseMatrix &pointmat, Tetrahedron *tet,
238  int child);
239 
240  int GetFineElemPath (int i, int j);
241 
243 
247  int i);
249  int i);
252  int i);
255  int i);
259  const FaceInfo &fi);
260  bool IsSlaveFace(const FaceInfo &fi);
261 
263  static int GetTriOrientation (const int * base, const int * test);
265  static int GetQuadOrientation (const int * base, const int * test);
266 
267  static void GetElementArrayEdgeTable(const Array<Element*> &elem_array,
268  const DSTable &v_to_v,
269  Table &el_to_edge);
270 
274  void GetVertexToVertexTable(DSTable &) const;
275 
282 
284  void AddPointFaceElement(int lf, int gf, int el);
285 
286  void AddSegmentFaceElement (int lf, int gf, int el, int v0, int v1);
287 
288  void AddTriangleFaceElement (int lf, int gf, int el,
289  int v0, int v1, int v2);
290 
291  void AddQuadFaceElement (int lf, int gf, int el,
292  int v0, int v1, int v2, int v3);
296  bool FaceIsTrueInterior(int FaceNo) const
297  {
298  return FaceIsInterior(FaceNo) || (faces_info[FaceNo].Elem2Inf >= 0);
299  }
300 
301  // shift cyclically 3 integers left-to-right
302  inline static void ShiftL2R(int &, int &, int &);
303  // shift cyclically 3 integers so that the smallest is first
304  inline static void Rotate3(int &, int &, int &);
305 
306  void FreeElement (Element *E);
307 
308  void GenerateFaces();
309  void GenerateNCFaceInfo();
310 
312  void InitMesh(int _Dim, int _spaceDim, int NVert, int NElem, int NBdrElem);
313 
318  void Make3D(int nx, int ny, int nz, Element::Type type, int generate_edges,
319  double sx, double sy, double sz);
320 
325  void Make2D(int nx, int ny, Element::Type type, int generate_edges,
326  double sx, double sy);
327 
329  void Make1D(int n, double sx = 1.0);
330 
332  void InitFromNCMesh(const NCMesh &ncmesh);
333 
335  Mesh(const NCMesh &ncmesh);
336 
339  void Swap(Mesh& other, bool non_geometry = false);
340 
341 public:
342 
344 
345  Mesh() { Init(); InitTables(); meshgen = 0; Dim = 0; }
346 
352  explicit Mesh(const Mesh &mesh, bool copy_nodes = true);
353 
354  Mesh(int _Dim, int NVert, int NElem, int NBdrElem = 0, int _spaceDim= -1)
355  {
356  if (_spaceDim == -1)
357  {
358  _spaceDim = _Dim;
359  }
360  InitMesh(_Dim, _spaceDim, NVert, NElem, NBdrElem);
361  }
362 
363  Element *NewElement(int geom);
364 
365  void AddVertex(const double *);
366  void AddTri(const int *vi, int attr = 1);
367  void AddTriangle(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);
371  void AddHexAsTets(const int *vi, int attr = 1);
372  // 'elem' should be allocated using the NewElement method
373  void AddElement(Element *elem) { elements[NumOfElements++] = elem; }
374  void AddBdrElement(Element *elem) { boundary[NumOfBdrElements++] = elem; }
375  void AddBdrSegment(const int *vi, int attr = 1);
376  void AddBdrTriangle(const int *vi, int attr = 1);
377  void AddBdrQuad(const int *vi, int attr = 1);
378  void AddBdrQuadAsTriangles(const int *vi, int attr = 1);
380  void FinalizeTriMesh(int generate_edges = 0, int refine = 0,
381  bool fix_orientation = true);
382  void FinalizeQuadMesh(int generate_edges = 0, int refine = 0,
383  bool fix_orientation = true);
384  void FinalizeTetMesh(int generate_edges = 0, int refine = 0,
385  bool fix_orientation = true);
386  void FinalizeHexMesh(int generate_edges = 0, int refine = 0,
387  bool fix_orientation = true);
388 
389  void SetAttributes();
390 
391 #ifdef MFEM_USE_GECKO
392 
396  void GetGeckoElementReordering(Array<int> &ordering);
397 #endif
398 
402  void ReorderElements(const Array<int> &ordering, bool reorder_vertices = true);
403 
408  Mesh(int nx, int ny, int nz, Element::Type type, int generate_edges = 0,
409  double sx = 1.0, double sy = 1.0, double sz = 1.0)
410  {
411  Make3D(nx, ny, nz, type, generate_edges, sx, sy, sz);
412  }
413 
418  Mesh(int nx, int ny, Element::Type type, int generate_edges = 0,
419  double sx = 1.0, double sy = 1.0)
420  {
421  Make2D(nx, ny, type, generate_edges, sx, sy);
422  }
423 
425  explicit Mesh(int n, double sx = 1.0)
426  {
427  Make1D(n, sx);
428  }
429 
433  Mesh(std::istream &input, int generate_edges = 0, int refine = 1,
434  bool fix_orientation = true);
435 
437  Mesh(Mesh *mesh_array[], int num_pieces);
438 
439  /* This is similar to the above mesh constructor, but here the current
440  mesh is destroyed and another one created based on the data stream
441  again given in MFEM, netgen, or VTK format. If generate_edges = 0
442  (default) edges are not generated, if 1 edges are generated. */
443  void Load(std::istream &input, int generate_edges = 0, int refine = 1,
444  bool fix_orientation = true);
445 
447  inline int MeshGenerator() { return meshgen; }
448 
451  inline int GetNV() const { return NumOfVertices; }
452 
454  inline int GetNE() const { return NumOfElements; }
455 
457  inline int GetNBE() const { return NumOfBdrElements; }
458 
460  inline int GetNEdges() const { return NumOfEdges; }
461 
463  inline int GetNFaces() const { return NumOfFaces; }
464 
466  int GetNumFaces() const;
467 
469  inline int EulerNumber() const
472  inline int EulerNumber2D() const
473  { return NumOfVertices - NumOfEdges + NumOfElements; }
474 
475  int Dimension() const { return Dim; }
476  int SpaceDimension() const { return spaceDim; }
477 
479  const double *GetVertex(int i) const { return vertices[i](); }
480  double *GetVertex(int i) { return vertices[i](); }
481 
482  const Element *GetElement(int i) const { return elements[i]; }
483 
484  Element *GetElement(int i) { return elements[i]; }
485 
486  const Element *GetBdrElement(int i) const { return boundary[i]; }
487 
488  Element *GetBdrElement(int i) { return boundary[i]; }
489 
490  const Element *GetFace(int i) const { return faces[i]; }
491 
492  int GetFaceBaseGeometry(int i) const;
493 
494  int GetElementBaseGeometry(int i) const
495  { return elements[i]->GetGeometryType(); }
496 
497  int GetBdrElementBaseGeometry(int i) const
498  { return boundary[i]->GetGeometryType(); }
499 
501  void GetElementVertices(int i, Array<int> &dofs) const
502  { elements[i]->GetVertices(dofs); }
503 
505  void GetBdrElementVertices(int i, Array<int> &dofs) const
506  { boundary[i]->GetVertices(dofs); }
507 
509  void GetElementEdges(int i, Array<int> &edges, Array<int> &cor) const;
510 
512  void GetBdrElementEdges(int i, Array<int> &edges, Array<int> &cor) const;
513 
516  void GetFaceEdges(int i, Array<int> &, Array<int> &) const;
517 
519  void GetFaceVertices(int i, Array<int> &vert) const
520  {
521  if (Dim == 1)
522  {
523  vert.SetSize(1); vert[0] = i;
524  }
525  else
526  {
527  faces[i]->GetVertices(vert);
528  }
529  }
530 
532  void GetEdgeVertices(int i, Array<int> &vert) const;
533 
535  Table *GetFaceEdgeTable() const;
536 
538  Table *GetEdgeVertexTable() const;
539 
541  void GetElementFaces(int i, Array<int> &, Array<int> &) const;
542 
544  void GetBdrElementFace(int i, int *, int *) const;
545 
549  int GetBdrElementEdgeIndex(int i) const;
550 
552  int GetElementType(int i) const;
553 
555  int GetBdrElementType(int i) const;
556 
557  /* Return point matrix of element i of dimension Dim X #dofs, where for
558  every degree of freedom we give its coordinates in space of dimension
559  Dim. */
560  void GetPointMatrix(int i, DenseMatrix &pointmat) const;
561 
562  /* Return point matrix of boundary element i of dimension Dim X #dofs,
563  where for every degree of freedom we give its coordinates in space
564  of dimension Dim. */
565  void GetBdrPointMatrix(int i, DenseMatrix &pointmat) const;
566 
568 
572 
575 
578  void GetElementTransformation(int i, const Vector &nodes,
580 
584 
588 
591 
595 
598 
622  int mask = 31);
623 
625  {
626  if (faces_info[FaceNo].Elem2No < 0) { return NULL; }
627  return GetFaceElementTransformations (FaceNo);
628  }
629 
631 
633  bool FaceIsInterior(int FaceNo) const
634  {
635  return (faces_info[FaceNo].Elem2No >= 0);
636  }
637  void GetFaceElements (int Face, int *Elem1, int *Elem2);
638  void GetFaceInfos (int Face, int *Inf1, int *Inf2);
639 
641  void CheckElementOrientation(bool fix_it = true);
643  void CheckBdrElementOrientation(bool fix_it = true);
644 
646  int GetAttribute(int i) const { return elements[i]->GetAttribute();}
647 
649  int GetBdrAttribute(int i) const { return boundary[i]->GetAttribute(); }
650 
651  const Table &ElementToElementTable();
652 
653  const Table &ElementToFaceTable() const;
654 
655  const Table &ElementToEdgeTable() const;
656 
659 
663  Table *GetFaceToElementTable() const;
664 
673  virtual void ReorientTetMesh();
674 
675  int *CartesianPartitioning(int nxyz[]);
676  int *GeneratePartitioning(int nparts, int part_method = 1);
677  void CheckPartitioning(int *partitioning);
678 
679  void CheckDisplacements(const Vector &displacements, double &tmax);
680 
681  // Vertices are only at the corners of elements, where you would expect them
682  // in the lowest-order mesh.
683  void MoveVertices(const Vector &displacements);
684  void GetVertices(Vector &vert_coord) const;
685  void SetVertices(const Vector &vert_coord);
686 
687  // Nodes are only active for higher order meshes, and share locations with
688  // the vertices, plus all the higher- order control points within the element
689  // and along the edges and on the faces.
690  void GetNode(int i, double *coord);
691  void SetNode(int i, const double *coord);
692 
693  // Node operations for curved mesh.
694  // They call the corresponding '...Vertices' method if the
695  // mesh is not curved (i.e. Nodes == NULL).
696  void MoveNodes(const Vector &displacements);
697  void GetNodes(Vector &node_coord) const;
698  void SetNodes(const Vector &node_coord);
699 
701  GridFunction *GetNodes() { return Nodes; }
703  void NewNodes(GridFunction &nodes, bool make_owner = false);
706  void SwapNodes(GridFunction *&nodes, int &own_nodes_);
707 
709  void GetNodes(GridFunction &nodes) const;
717  void SetNodalGridFunction(GridFunction *nodes, bool make_owner = false);
721 
725  void SetCurvature(int order, bool discont = false, int space_dim = -1,
726  int ordering = 1);
727 
729  void UniformRefinement();
730 
739  void GeneralRefinement(const Array<Refinement> &refinements,
740  int nonconforming = -1, int nc_limit = 0);
741 
744  void GeneralRefinement(const Array<int> &el_to_refine,
745  int nonconforming = -1, int nc_limit = 0);
746 
749  void EnsureNCMesh();
750 
752  void RandomRefinement(int levels, int frac = 2, bool aniso = false,
753  int nonconforming = -1, int nc_limit = -1,
754  int seed = 0 /* should be the same on all CPUs */);
755 
757  void RefineAtVertex(const Vertex& vert, int levels,
758  double eps = 0.0, int nonconforming = -1);
759 
760  // NURBS mesh refinement methods
762  void DegreeElevate(int t);
763 
766  void UseTwoLevelState (int use)
767  {
768  if (!use && State != Mesh::NORMAL)
769  {
771  }
772  WantTwoLevelState = use;
773  }
774 
776  void SetState (int s);
777 
778  int GetState() const { return State; }
779 
782  int GetNumFineElems (int i);
783 
785  int GetRefinementType (int i);
786 
789  int GetFineElem (int i, int j);
790 
794  ElementTransformation * GetFineElemTrans (int i, int j);
795 
797  virtual void PrintXG(std::ostream &out = std::cout) const;
798 
800  virtual void Print(std::ostream &out = std::cout) const;
801 
803  void PrintVTK(std::ostream &out);
804 
809  void PrintVTK(std::ostream &out, int ref, int field_data=0);
810 
811  void GetElementColoring(Array<int> &colors, int el0 = 0);
812 
816  void PrintWithPartitioning (int *partitioning,
817  std::ostream &out, int elem_attr = 0) const;
818 
819  void PrintElementsWithPartitioning (int *partitioning,
820  std::ostream &out,
821  int interior_faces = 0);
822 
824 
828  void PrintSurfaces(const Table &Aface_face, std::ostream &out) const;
829 
830  void ScaleSubdomains (double sf);
831  void ScaleElements (double sf);
832 
833  void Transform(void (*f)(const Vector&, Vector&));
834  void Transform(VectorCoefficient &deformation);
835 
837  void RemoveUnusedVertices();
838 
842 
845  double GetElementSize(int i, int type = 0);
846 
847  double GetElementSize(int i, const Vector &dir);
848 
849  double GetElementVolume(int i);
850 
851  void PrintCharacteristics(Vector *Vh = NULL, Vector *Vk = NULL,
852  std::ostream &out = std::cout);
853 
854  virtual void PrintInfo(std::ostream &out = std::cout)
855  {
856  PrintCharacteristics(NULL, NULL, out);
857  }
858 
859  void MesquiteSmooth(const int mesquite_option = 0);
860 
862  virtual ~Mesh();
863 };
864 
867 std::ostream &operator<<(std::ostream &out, const Mesh &mesh);
868 
869 
872 {
873 private:
874  int n, layer;
875  double p[2], s;
876  Vector tip;
877 public:
878  NodeExtrudeCoefficient(const int dim, const int _n, const double _s);
879  void SetLayer(const int l) { layer = l; }
881  virtual void Eval(Vector &V, ElementTransformation &T,
882  const IntegrationPoint &ip);
884 };
885 
886 
888 Mesh *Extrude1D(Mesh *mesh, const int ny, const double sy,
889  const bool closed = false);
890 
891 
892 // inline functions
893 inline void Mesh::ShiftL2R(int &a, int &b, int &c)
894 {
895  int t = a;
896  a = c; c = b; b = t;
897 }
898 
899 inline void Mesh::Rotate3(int &a, int &b, int &c)
900 {
901  if (a < b)
902  {
903  if (a > c)
904  {
905  ShiftL2R(a, b, c);
906  }
907  }
908  else
909  {
910  if (b < c)
911  {
912  ShiftL2R(c, b, a);
913  }
914  else
915  {
916  ShiftL2R(a, b, c);
917  }
918  }
919 }
920 
921 }
922 
923 #endif
Abstract class for Finite Elements.
Definition: fe.hpp:44
void AddHex(const int *vi, int attr=1)
Definition: mesh.cpp:884
void SetState(int s)
Change the mesh state to NORMAL, TWO_LEVEL_COARSE, TWO_LEVEL_FINE.
Definition: mesh.cpp:7397
std::ostream & operator<<(std::ostream &out, const Mesh &mesh)
Definition: mesh.cpp:9824
void GetFaceEdges(int i, Array< int > &, Array< int > &) const
Definition: mesh.cpp:4116
void PrintSurfaces(const Table &Aface_face, std::ostream &out) const
Print set of disjoint surfaces:
Definition: mesh.cpp:9327
Table * f_el_to_face
Definition: mesh.hpp:108
void GetPointMatrix(int i, DenseMatrix &pointmat) const
Definition: mesh.cpp:4418
int * CartesianPartitioning(int nxyz[])
Definition: mesh.cpp:5023
virtual void PrintInfo(std::ostream &out=std::cout)
Definition: mesh.hpp:854
const DenseMatrix * PointMatrix
Definition: mesh.hpp:87
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
Definition: mesh.hpp:649
const double * GetVertex(int i) const
Return pointer to vertex i&#39;s coordinates.
Definition: mesh.hpp:479
void ScaleElements(double sf)
Definition: mesh.cpp:9461
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:27
Table * GetEdgeVertexTable() const
Returns the edge-to-vertex Table (3D)
Definition: mesh.cpp:4186
void GetBdrElementEdges(int i, Array< int > &edges, Array< int > &cor) const
Return the indices and the orientations of all edges of bdr element i.
Definition: mesh.cpp:4084
void FreeElement(Element *E)
Definition: mesh.cpp:9779
void GetFaceInfos(int Face, int *Inf1, int *Inf2)
Definition: mesh.cpp:740
void SetVertices(const Vector &vert_coord)
Definition: mesh.cpp:5784
void GetEdgeVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of edge i.
Definition: mesh.cpp:4148
int f_NumOfEdges
Definition: mesh.hpp:64
bool FaceIsTrueInterior(int FaceNo) const
Definition: mesh.hpp:296
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Definition: mesh.cpp:9837
int GetBdrElementBaseGeometry(int i) const
Definition: mesh.hpp:497
int f_NumOfElements
Definition: mesh.hpp:62
Table * c_bel_to_edge
Definition: mesh.hpp:106
void AddHexAsTets(const int *vi, int attr=1)
Definition: mesh.cpp:889
void GetFaceElements(int Face, int *Elem1, int *Elem2)
Definition: mesh.cpp:734
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Array< Element * > boundary
Definition: mesh.hpp:70
int * GeneratePartitioning(int nparts, int part_method=1)
Definition: mesh.cpp:5068
void BisectTetTrans(DenseMatrix &pointmat, Tetrahedron *tet, int child)
Definition: mesh.cpp:7886
int own_nodes
Definition: mesh.hpp:119
void MoveVertices(const Vector &displacements)
Definition: mesh.cpp:5764
int GetNBE() const
Returns number of boundary elements.
Definition: mesh.hpp:457
IsoparametricTransformation Transformation
Definition: mesh.hpp:111
void GetLocalPtToSegTransformation(IsoparametricTransformation &, int)
Used in GetFaceElementTransformations (...)
Definition: mesh.cpp:424
void PrintWithPartitioning(int *partitioning, std::ostream &out, int elem_attr=0) const
Definition: mesh.cpp:8843
void NewNodes(GridFunction &nodes, bool make_owner=false)
Replace the internal node GridFunction with the given GridFunction.
Definition: mesh.cpp:5868
int NumOfEdges
Definition: mesh.hpp:54
void SwapNodes(GridFunction *&nodes, int &own_nodes_)
Definition: mesh.cpp:5882
void GetElementFaces(int i, Array< int > &, Array< int > &) const
Return the indices and the orientations of all faces of element i.
Definition: mesh.cpp:4281
void AddBdrElement(Element *elem)
Definition: mesh.hpp:374
int GetElementBaseGeometry(int i) const
Definition: mesh.hpp:494
void DegreeElevate(int t)
Definition: mesh.cpp:3497
int EulerNumber2D() const
Equals 1 - num_holes.
Definition: mesh.hpp:472
void AddTri(const int *vi, int attr=1)
Definition: mesh.cpp:856
int WantTwoLevelState
Definition: mesh.hpp:56
void DeleteTables()
Definition: mesh.cpp:764
void GetFaceVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of face i.
Definition: mesh.hpp:519
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
GridFunction * Nodes
Definition: mesh.hpp:118
int NumOfElements
Definition: mesh.hpp:53
Mesh * Extrude1D(Mesh *mesh, const int ny, const double sy, const bool closed)
Extrude a 1D mesh.
Definition: mesh.cpp:9855
void Transform(void(*f)(const Vector &, Vector &))
Definition: mesh.cpp:9531
int GetBdrElementEdgeIndex(int i) const
Definition: mesh.cpp:4370
int GetNE() const
Returns number of elements.
Definition: mesh.hpp:454
const Element * GetFace(int i) const
Definition: mesh.hpp:490
Element * GetElement(int i)
Definition: mesh.hpp:484
void BisectTriTrans(DenseMatrix &pointmat, Triangle *tri, int child)
Definition: mesh.cpp:7862
void GenerateBoundaryElements()
Definition: mesh.cpp:938
void GetElementVertices(int i, Array< int > &dofs) const
Returns the indices of the dofs of element i.
Definition: mesh.hpp:501
void DeleteCoarseTables()
Definition: mesh.cpp:784
Data type for vertex.
Definition: vertex.hpp:21
void SetMeshGen()
Definition: mesh.cpp:2219
ElementTransformation * GetFineElemTrans(int i, int j)
Definition: mesh.cpp:7978
static int GetQuadOrientation(const int *base, const int *test)
Returns the orientation of &quot;test&quot; relative to &quot;base&quot;.
Definition: mesh.cpp:3924
void GetVertices(Vector &vert_coord) const
Definition: mesh.cpp:5773
virtual ~Mesh()
Destroys mesh.
Definition: mesh.cpp:9794
void AddBdrSegment(const int *vi, int attr=1)
Definition: mesh.cpp:908
Table * c_el_to_face
Definition: mesh.hpp:108
FaceElementTransformations * GetInteriorFaceTransformations(int FaceNo)
Definition: mesh.hpp:624
void CheckBdrElementOrientation(bool fix_it=true)
Check the orientation of the boundary elements.
Definition: mesh.cpp:3972
void RemoveInternalBoundaries()
Definition: mesh.cpp:9689
FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
Definition: mesh.cpp:557
Array< Element * > faces
Definition: mesh.hpp:71
void FinalizeHexMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Definition: mesh.cpp:1620
void GetVertexToVertexTable(DSTable &) const
Definition: mesh.cpp:4487
void RedRefinement(int i, const DSTable &v_to_v, int *edge1, int *edge2, int *middle)
Definition: mesh.hpp:185
void MarkTriMeshForRefinement()
Definition: mesh.cpp:1255
IsoparametricTransformation FaceTransformation
Definition: mesh.hpp:112
Array< NCFaceInfo > nc_faces_info
Definition: mesh.hpp:95
Element * ReadElement(std::istream &)
Definition: mesh.cpp:2201
void KnotInsert(Array< KnotVector * > &kv)
Definition: mesh.cpp:3468
Array< FaceInfo > fc_faces_info
Definition: mesh.hpp:109
int GetFineElemPath(int i, int j)
Definition: mesh.cpp:7937
A parallel extension of the NCMesh class.
Definition: pncmesh.hpp:66
Element * NewElement(int geom)
Definition: mesh.cpp:2152
FaceElementTransformations FaceElemTr
Definition: mesh.hpp:113
Table * el_to_face
Definition: mesh.hpp:98
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr)
Definition: mesh.cpp:369
void MarkForRefinement()
Definition: mesh.cpp:1240
void RefineAtVertex(const Vertex &vert, int levels, double eps=0.0, int nonconforming=-1)
Refine elements sharing the specified vertex, &#39;levels&#39; times.
Definition: mesh.cpp:6961
static const int tet_faces[4][3]
Definition: mesh.hpp:125
ElementTransformation * GetBdrElementTransformation(int i)
Returns the transformation defining the i-th boundary element.
Definition: mesh.cpp:246
int GetState() const
Definition: mesh.hpp:778
void AddVertex(const double *)
Definition: mesh.cpp:845
Mesh(int _Dim, int NVert, int NElem, int NBdrElem=0, int _spaceDim=-1)
Definition: mesh.hpp:354
void PrintTopo(std::ostream &out, const Array< int > &e_to_k) const
Definition: mesh.cpp:8406
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
Definition: mesh.cpp:3755
void AddElement(Element *elem)
Definition: mesh.hpp:373
void Load(std::istream &input, int generate_edges=0, int refine=1, bool fix_orientation=true)
Definition: mesh.cpp:2262
void GetElementJacobian(int i, DenseMatrix &J)
Definition: mesh.cpp:35
void MesquiteSmooth(const int mesquite_option=0)
Definition: mesquite.cpp:1144
Mesh(int nx, int ny, Element::Type type, int generate_edges=0, double sx=1.0, double sy=1.0)
Definition: mesh.hpp:418
void MoveNodes(const Vector &displacements)
Definition: mesh.cpp:5832
void GetEdgeOrdering(DSTable &v_to_v, Array< int > &order)
Definition: mesh.cpp:1270
int dim
Definition: ex3.cpp:48
NCFaceInfo(bool slave, int master, const DenseMatrix *pm)
Definition: mesh.hpp:90
void FinalizeTriMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Definition: mesh.cpp:992
void UpdateNURBS()
Definition: mesh.cpp:3519
Symmetric 3D Table.
Definition: stable3d.hpp:28
static const int quad_orientations[8][4]
Definition: mesh.hpp:129
void FinalizeTetMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Definition: mesh.cpp:1582
void AddBdrQuadAsTriangles(const int *vi, int attr=1)
Definition: mesh.cpp:923
void AddSegmentFaceElement(int lf, int gf, int el, int v0, int v1)
Definition: mesh.cpp:4616
void SetAttributes()
Definition: mesh.cpp:796
void MarkTetMeshForRefinement()
Definition: mesh.cpp:1296
int State
Definition: mesh.hpp:56
Table * f_el_to_edge
Definition: mesh.hpp:106
void GetFaceTransformation(int i, IsoparametricTransformation *FTr)
Definition: mesh.cpp:280
void GetLocalSegToTriTransformation(IsoparametricTransformation &loc, int i)
Definition: mesh.cpp:438
void AddQuadFaceElement(int lf, int gf, int el, int v0, int v1, int v2, int v3)
Definition: mesh.cpp:4667
int GetRefinementType(int i)
For a given coarse element i returns its refinement type.
Definition: mesh.cpp:7675
static FiniteElement * GetTransformationFEforElementType(int)
Definition: mesh.cpp:157
void LoadPatchTopo(std::istream &input, Array< int > &edge_to_knot)
Read NURBS patch/macro-element mesh.
Definition: mesh.cpp:3582
STable3D * GetElementToFaceTable(int ret_ftbl=0)
Definition: mesh.cpp:4841
void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Definition: mesh.cpp:3736
static void Rotate3(int &, int &, int &)
Definition: mesh.hpp:899
void Make2D(int nx, int ny, Element::Type type, int generate_edges, double sx, double sy)
Definition: mesh.cpp:1837
int MeshGenerator()
Truegrid or NetGen?
Definition: mesh.hpp:447
Type
Constants for the classes derived from Element.
Definition: element.hpp:37
void GetBdrPointMatrix(int i, DenseMatrix &pointmat) const
Definition: mesh.cpp:4434
void InitTables()
Definition: mesh.cpp:758
void CheckDisplacements(const Vector &displacements, double &tmax)
Definition: mesh.cpp:5687
void CheckElementOrientation(bool fix_it=true)
Check the orientation of the elements.
Definition: mesh.cpp:3770
Table * f_bel_to_edge
Definition: mesh.hpp:106
void SetLayer(const int l)
Definition: mesh.hpp:879
int GetElementToEdgeTable(Table &, Array< int > &)
Definition: mesh.cpp:4512
int c_NumOfEdges
Definition: mesh.hpp:63
int GetElementType(int i) const
Returns the type of element i.
Definition: mesh.cpp:4382
Data type triangle element.
Definition: triangle.hpp:23
const Element * GetElement(int i) const
Definition: mesh.hpp:482
Mesh(int n, double sx=1.0)
Definition: mesh.hpp:425
void GetLocalQuadToHexTransformation(IsoparametricTransformation &loc, int i)
Used in GetFaceElementTransformations (...)
Definition: mesh.cpp:536
IsoparametricTransformation Transformation2
Definition: mesh.hpp:111
void Init()
Definition: mesh.cpp:746
void SetNodalFESpace(FiniteElementSpace *nfes)
Definition: mesh.cpp:3719
Element * GetBdrElement(int i)
Definition: mesh.hpp:488
int f_NumOfVertices
Definition: mesh.hpp:62
A class for non-conforming AMR on higher-order hexahedral, quadrilateral or triangular meshes...
Definition: ncmesh.hpp:63
FaceElementTransformations * GetBdrFaceTransformations(int BdrElemNo)
Definition: mesh.cpp:708
int Dimension() const
Definition: mesh.hpp:475
virtual void ReorientTetMesh()
Definition: mesh.cpp:4914
int NumOfBdrElements
Definition: mesh.hpp:53
Table * el_to_edge
Definition: mesh.hpp:97
static void ShiftL2R(int &, int &, int &)
Definition: mesh.hpp:893
virtual void LocalRefinement(const Array< int > &marked_el, int type=3)
This function is not public anymore. Use GeneralRefinement instead.
Definition: mesh.cpp:6293
int c_NumOfBdrElements
Definition: mesh.hpp:61
int GetBdrElementType(int i) const
Returns the type of boundary element i.
Definition: mesh.cpp:4401
void GetGeckoElementReordering(Array< int > &ordering)
Definition: mesh.cpp:1049
Data type tetrahedron element.
Definition: tetrahedron.hpp:22
double GetElementSize(int i, int type=0)
Definition: mesh.cpp:43
int SpaceDimension() const
Definition: mesh.hpp:476
void GetBdrElementFace(int i, int *, int *) const
Return the index and the orientation of the face of bdr element i. (3D)
Definition: mesh.cpp:4319
int c_NumOfVertices
Definition: mesh.hpp:61
void CheckPartitioning(int *partitioning)
Definition: mesh.cpp:5369
virtual void Print(std::ostream &out=std::cout) const
Print the mesh to the given stream using the default MFEM mesh format.
Definition: mesh.cpp:8332
void PrintElementsWithPartitioning(int *partitioning, std::ostream &out, int interior_faces=0)
Definition: mesh.cpp:8953
bool FaceIsInterior(int FaceNo) const
Return true if the given face is interior.
Definition: mesh.hpp:633
void AddPointFaceElement(int lf, int gf, int el)
Used in GenerateFaces()
Definition: mesh.cpp:4599
void Make1D(int n, double sx=1.0)
Creates a 1D mesh for the interval [0,sx] divided into n equal intervals.
Definition: mesh.cpp:1987
int GetNumFineElems(int i)
Definition: mesh.cpp:7569
bool IsSlaveFace(const FaceInfo &fi)
Definition: mesh.cpp:690
Array< int > bdr_attributes
Definition: mesh.hpp:140
virtual void NonconformingRefinement(const Array< Refinement > &refinements, int nc_limit=0)
This function is not public anymore. Use GeneralRefinement instead.
Definition: mesh.cpp:6674
void PrintVTK(std::ostream &out)
Print the mesh in VTK format (linear and quadratic meshes only).
Definition: mesh.cpp:8448
void UseTwoLevelState(int use)
Definition: mesh.hpp:766
Table * el_to_el
Definition: mesh.hpp:99
int GetBisectionHierarchy(Element *E)
Definition: mesh.cpp:7636
Abstract finite element space.
Definition: fespace.hpp:62
void RemoveUnusedVertices()
Remove unused vertices and rebuild mesh connectivity.
Definition: mesh.cpp:9580
static void PrintElement(const Element *, std::ostream &)
Definition: mesh.cpp:2213
virtual void NURBSUniformRefinement()
Refine NURBS mesh.
Definition: mesh.cpp:3487
static void GetElementArrayEdgeTable(const Array< Element * > &elem_array, const DSTable &v_to_v, Table &el_to_edge)
Definition: mesh.cpp:4465
void PrintCharacteristics(Vector *Vh=NULL, Vector *Vk=NULL, std::ostream &out=std::cout)
Definition: mesh.cpp:86
GridFunction * GetNodes()
Return a pointer to the internal node GridFunction (may be NULL).
Definition: mesh.hpp:701
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
Definition: array.hpp:323
void PrepareNodeReorder(DSTable **old_v_to_v, Table **old_elem_vert)
Definition: mesh.cpp:1322
void AddQuad(const int *vi, int attr=1)
Definition: mesh.cpp:866
Array< Vertex > vertices
Definition: mesh.hpp:69
MemAlloc< BisectedElement, 1024 > BEMemory
Definition: mesh.hpp:135
virtual void QuadUniformRefinement()
Refine quadrilateral mesh.
Definition: mesh.cpp:5919
virtual void HexUniformRefinement()
Refine hexahedral mesh.
Definition: mesh.cpp:6068
void Swap(Mesh &other, bool non_geometry=false)
Definition: mesh.cpp:6783
Array< Element * > elements
Definition: mesh.hpp:66
const Table & ElementToElementTable()
Definition: mesh.cpp:4551
double GetLength(int i, int j) const
Return the length of the segment from node i to node j.
Definition: mesh.cpp:4450
int meshgen
Definition: mesh.hpp:59
Table * bel_to_edge
Definition: mesh.hpp:101
void AddBdrTriangle(const int *vi, int attr=1)
Definition: mesh.cpp:913
Array< int > fc_be_to_edge
Definition: mesh.hpp:107
Table * GetFaceToElementTable() const
Definition: mesh.cpp:4247
void GetLocalTriToTetTransformation(IsoparametricTransformation &loc, int i)
Used in GetFaceElementTransformations (...)
Definition: mesh.cpp:513
int EulerNumber() const
Equals 1 + num_holes - num_loops.
Definition: mesh.hpp:469
NURBSExtension * NURBSext
Definition: mesh.hpp:142
int GetNV() const
Definition: mesh.hpp:451
void AddBdrQuad(const int *vi, int attr=1)
Definition: mesh.cpp:918
Array< int > be_to_edge
Definition: mesh.hpp:100
const Table & ElementToFaceTable() const
Definition: mesh.cpp:4581
Table * c_el_to_edge
Definition: mesh.hpp:106
Class for integration point with weight.
Definition: intrules.hpp:25
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 &#39;levels&#39; times.
Definition: mesh.cpp:6938
void UniformRefinement()
Definition: mesh.cpp:6827
Element * ReadElementWithoutAttr(std::istream &)
Definition: mesh.cpp:2172
void GetElementEdges(int i, Array< int > &edges, Array< int > &cor) const
Return the indices and the orientations of all edges of element i.
Definition: mesh.cpp:4062
void AddTriangle(const int *vi, int attr=1)
Definition: mesh.cpp:861
int f_NumOfFaces
Definition: mesh.hpp:64
static const int hex_faces[6][4]
Definition: mesh.hpp:126
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
Definition: mesh.cpp:173
void GetLocalSegToQuadTransformation(IsoparametricTransformation &loc, int i)
Definition: mesh.cpp:461
const FiniteElementSpace * GetNodalFESpace()
Definition: mesh.cpp:3731
int c_NumOfElements
Definition: mesh.hpp:61
Table * face_edge
Definition: mesh.hpp:103
void FinalizeQuadMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Definition: mesh.cpp:1020
int c_NumOfFaces
Definition: mesh.hpp:63
NodeExtrudeCoefficient(const int dim, const int _n, const double _s)
Definition: mesh.cpp:9831
void ReorderElements(const Array< int > &ordering, bool reorder_vertices=true)
Definition: mesh.cpp:1094
Table * edge_vertex
Definition: mesh.hpp:104
void GetBdrElementVertices(int i, Array< int > &dofs) const
Returns the indices of the dofs of boundary element i.
Definition: mesh.hpp:505
void ApplySlaveTransformation(IsoparametricTransformation &transf, const FaceInfo &fi)
Definition: mesh.cpp:695
virtual ~NodeExtrudeCoefficient()
Definition: mesh.hpp:883
Array< FaceInfo > faces_info
Definition: mesh.hpp:94
STable3D * GetFacesTable()
Definition: mesh.cpp:4806
void Make3D(int nx, int ny, int nz, Element::Type type, int generate_edges, double sx, double sy, double sz)
Definition: mesh.cpp:1649
NCMesh * ncmesh
Definition: mesh.hpp:143
static void PrintElementWithoutAttr(const Element *, std::ostream &)
Definition: mesh.cpp:2189
int GetFineElem(int i, int j)
Definition: mesh.cpp:7751
int Dim
Definition: mesh.hpp:50
void EnsureNCMesh()
Definition: mesh.cpp:6929
int GetNEdges() const
Return the number of edges.
Definition: mesh.hpp:460
double * GetVertex(int i)
Definition: mesh.hpp:480
int GetNFaces() const
Return the number of faces in a 3D mesh.
Definition: mesh.hpp:463
Vector data type.
Definition: vector.hpp:33
int GetFaceBaseGeometry(int i) const
Definition: mesh.cpp:4348
void AverageVertices(int *indexes, int n, int result)
Definition: mesh.cpp:5892
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)
Definition: mesh.hpp:408
int f_NumOfBdrElements
Definition: mesh.hpp:62
static int GetTriOrientation(const int *base, const int *test)
Returns the orientation of &quot;test&quot; relative to &quot;base&quot;.
Definition: mesh.cpp:3880
void SetNode(int i, const double *coord)
Definition: mesh.cpp:5812
void GetNode(int i, double *coord)
Definition: mesh.cpp:5793
void GenerateFaces()
Definition: mesh.cpp:4688
void GetElementColoring(Array< int > &colors, int el0=0)
Definition: mesh.cpp:8768
int spaceDim
Definition: mesh.hpp:51
IsoparametricTransformation EdgeTransformation
Definition: mesh.hpp:112
void AddTet(const int *vi, int attr=1)
Definition: mesh.cpp:871
MemAlloc< Tetrahedron, 1024 > TetMemory
Definition: mesh.hpp:134
Table * GetFaceEdgeTable() const
Returns the face-to-edge Table (3D)
Definition: mesh.cpp:4158
void DoNodeReorder(DSTable *old_v_to_v, Table *old_elem_vert)
Definition: mesh.cpp:1364
void SetNodes(const Vector &node_coord)
Definition: mesh.cpp:5856
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
Definition: mesh.cpp:3725
int NumOfVertices
Definition: mesh.hpp:53
void ScaleSubdomains(double sf)
Definition: mesh.cpp:9391
Array< int > be_to_face
Definition: mesh.hpp:102
Mesh * nc_coarse_level
Definition: mesh.hpp:123
virtual void PrintXG(std::ostream &out=std::cout) const
Print the mesh to the given stream using Netgen/Truegrid format.
Definition: mesh.cpp:8168
void InitFromNCMesh(const NCMesh &ncmesh)
Initialize vertices/elements/boundary/tables from a nonconforming mesh.
Definition: mesh.cpp:6741
void Bisection(int i, const DSTable &, int *, int *, int *)
Definition: mesh.cpp:6991
void GeneralRefinement(const Array< Refinement > &refinements, int nonconforming=-1, int nc_limit=0)
Definition: mesh.cpp:6864
Class for parallel meshes.
Definition: pmesh.hpp:28
Abstract data type element.
Definition: element.hpp:27
int GetAttribute(int i) const
Return the attribute of element i.
Definition: mesh.hpp:646
void AddTriangleFaceElement(int lf, int gf, int el, int v0, int v1, int v2)
Definition: mesh.cpp:4646
const Table & ElementToEdgeTable() const
Definition: mesh.cpp:4590
void GenerateNCFaceInfo()
Definition: mesh.cpp:4757
double GetElementVolume(int i)
Definition: mesh.cpp:70
Array< int > attributes
Definition: mesh.hpp:139
void InitMesh(int _Dim, int _spaceDim, int NVert, int NElem, int NBdrElem)
Begin construction of a mesh.
Definition: mesh.cpp:827
Table * GetVertexToElementTable()
The returned Table must be destroyed by the caller.
Definition: mesh.cpp:4212
const Element * GetBdrElement(int i) const
Definition: mesh.hpp:486
void UpdateNodes()
Update the nodes of a curved mesh after refinement.
Definition: mesh.cpp:5913
void GreenRefinement(int i, const DSTable &v_to_v, int *edge1, int *edge2, int *middle)
Definition: mesh.hpp:191
static const int tri_orientations[6][3]
Definition: mesh.hpp:128
Class used to extrude the nodes of a mesh.
Definition: mesh.hpp:871
int NumOfFaces
Definition: mesh.hpp:54