MFEM  v3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
ncmesh.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_NCMESH
13 #define MFEM_NCMESH
14 
15 #include <vector>
16 #include <map>
17 #include <iostream>
18 
19 #include "../config/config.hpp"
20 #include "../general/hash.hpp"
21 #include "../linalg/densemat.hpp"
22 #include "element.hpp"
23 #include "vertex.hpp"
24 #include "../fem/geom.hpp"
25 
26 namespace mfem
27 {
28 
33 struct Refinement
34 {
35  int index;
36  char ref_type;
37 
38  Refinement(int index, int type = 7) : index(index), ref_type(type) {}
39 };
40 
42 struct Embedding
43 {
44  int parent;
45  int matrix;
46 
47  Embedding(int elem, int matrix = 0) : parent(elem), matrix(matrix) {}
48 };
49 
52 {
55 };
56 
57 
79 class NCMesh
80 {
81 protected:
82  struct Element; // forward
83 
84 public:
85 
89  NCMesh(const Mesh *mesh, std::istream *vertex_parents = NULL);
90 
92  NCMesh(const NCMesh &other);
93 
94  virtual ~NCMesh();
95 
96  int Dimension() const { return Dim; }
97  int SpaceDimension() const { return spaceDim; }
98 
103  virtual void Refine(const Array<Refinement> &refinements);
104 
108  virtual void LimitNCLevel(int max_nc_level);
109 
114  const Table &GetDerefinementTable();
115 
119  virtual void CheckDerefinementNCLevel(const Table &deref_table,
120  Array<int> &level_ok, int max_nc_level);
121 
125  virtual void Derefine(const Array<int> &derefs);
126 
127 
128  // master/slave lists
129 
131  struct MeshId
132  {
133  int index;
134  int local;
136 
137  MeshId(int index = -1, Element* element = NULL, int local = -1)
139  };
140 
143  struct Master : public MeshId
144  {
146 
147  Master(int index, Element* element, int local, int sb, int se)
148  : MeshId(index, element, local), slaves_begin(sb), slaves_end(se) {}
149  };
150 
153  struct Slave : public MeshId
154  {
155  int master;
158 
160  : MeshId(index, element, local), master(-1), edge_flags(0) {}
161 
163  void OrientedPointMatrix(DenseMatrix &oriented_matrix) const;
164  };
165 
167  struct NCList
168  {
169  std::vector<MeshId> conforming;
170  std::vector<Master> masters;
171  std::vector<Slave> slaves;
172  // TODO: switch to Arrays when fixed for non-POD types
173  // TODO: make a list of unique slave matrices to save memory (+ time later)
174 
175  void Clear() { conforming.clear(); masters.clear(); slaves.clear(); }
176  bool Empty() const { return !conforming.size() && !masters.size(); }
177  long MemoryUsage() const;
178  };
179 
182  {
183  if (face_list.Empty()) { BuildFaceList(); }
184  return face_list;
185  }
186 
189  {
190  if (edge_list.Empty()) { BuildEdgeList(); }
191  return edge_list;
192  }
193 
194 
195  // coarse/fine transforms
196 
199  void MarkCoarseLevel();
200 
205 
211 
213  void ClearTransforms();
214 
215 
216  // utility
217 
221  int GetEdgeMaster(int v1, int v2) const;
222 
228  virtual void GetBoundaryClosure(const Array<int> &bdr_attr_is_ess,
229  Array<int> &bdr_vertices,
230  Array<int> &bdr_edges);
231 
233  int GetElementGeometry() const { return root_elements[0]->geom; }
234 
236  int GetElementDepth(int i) const;
237 
239  void PrintVertexParents(std::ostream &out) const;
240 
242  void PrintCoarseElements(std::ostream &out) const;
243 
246  void LoadVertexParents(std::istream &input);
247 
249  void LoadCoarseElements(std::istream &input);
250 
252  void SetVertexPositions(const Array<mfem::Vertex> &vertices);
253 
255  long MemoryUsage() const;
256 
257  void PrintMemoryDetail() const;
258 
259 
260 protected: // interface for Mesh to be able to construct itself from NCMesh
261 
262  friend class Mesh;
263 
265  void GetMeshComponents(Array<mfem::Vertex>& vertices,
266  Array<mfem::Element*>& elements,
267  Array<mfem::Element*>& boundary) const;
268 
271  virtual void OnMeshUpdated(Mesh *mesh);
272 
273 
274 protected: // implementation
275 
276  int Dim, spaceDim;
277  bool Iso;
278 
279  Element* CopyHierarchy(Element* elem);
280  void DeleteHierarchy(Element* elem);
281 
282 
283  // primary data
284 
287  struct RefCount
288  {
290 
291  RefCount() : ref_count(0) {}
292 
293  int Ref()
294  {
295  return ++ref_count;
296  }
297  int Unref()
298  {
299  int ret = --ref_count;
300  if (!ret) { delete this; }
301  return ret;
302  }
303  };
304 
307  struct Vertex : public RefCount
308  {
309  int index;
310  double pos[3];
311 
312  Vertex() {}
313  Vertex(double x, double y, double z) : index(-1)
314  { pos[0] = x, pos[1] = y, pos[2] = z; }
315  Vertex(const Vertex& other) { std::memcpy(this, &other, sizeof(*this)); }
316  };
317 
319  struct Edge : public RefCount
320  {
321  int attribute;
322  int index;
323 
324  Edge() : attribute(-1), index(-1) {}
325  Edge(const Edge &other) { std::memcpy(this, &other, sizeof(*this)); }
326 
327  bool Boundary() const { return attribute >= 0; }
328  };
329 
340  struct Node : public Hashed2<Node>
341  {
344 
345  Node(int id) : Hashed2<Node>(id), vertex(NULL), edge(NULL) {}
346  Node(const Node &other);
347  ~Node();
348 
349  // Bump ref count on a vertex or an edge, or create them. Used when an
350  // element starts using a vertex or an edge.
351  void RefVertex();
352  void RefEdge();
353 
354  // Decrement ref on vertex or edge when an element is not using them
355  // anymore. The vertex, edge or the whole Node can autodestruct.
356  // (The hash-table pointer needs to be known then to remove the node.)
358  // Implement as a static method since we check if node == NULL.
359  static void UnrefEdge(Node *node, HashTable<Node>& nodes);
360  };
361 
366  struct Face : public RefCount, public Hashed4<Face>
367  {
368  int attribute;
369  int index;
370  Element* elem[2];
371 
372  Face(int id);
373  Face(const Face& other);
374 
375  bool Boundary() const { return attribute >= 0; }
376 
377  // add or remove an element from the 'elem[2]' array
378  void RegisterElement(Element* e);
379  void ForgetElement(Element* e);
380 
382  Element* GetSingleElement() const;
383 
384  // overloaded Unref without auto-destruction
385  int Unref() { return --ref_count; }
386  };
387 
391  struct Element
392  {
393  char geom;
394  char ref_type;
395  char flag;
396  int index;
397  int rank;
399  union
400  {
401  Node* node[8];
403  };
405 
406  Element(int geom, int attr);
407  Element(const Element& other) { std::memcpy(this, &other, sizeof(*this)); }
408  };
409 
410  // TODO: use MemAlloc or similar to store Element, Face, Node, etc., replace
411  // most pointers with indices (ints) into the allocators to save memory;
412  // ref_count and attributes could be chars
413 
414  Array<Element*> root_elements; // coarsest mesh, initialized by constructor
415 
416  HashTable<Node> nodes; // associative container holding all Nodes
417  HashTable<Face> faces; // associative container holding all Faces
418 
419 
420  // secondary data
421 
428  virtual void Update();
429 
430  Array<Element*> leaf_elements; // finest level, updated by UpdateLeafElements
431 
432  Array<int> vertex_nodeId; // vertex-index to node-id map, see UpdateVertices
433 
436 
439 
442 
443  virtual void UpdateVertices();
444 
445  void CollectLeafElements(Element* elem, int state);
446  void UpdateLeafElements();
447 
448  virtual void AssignLeafIndices();
449 
450  virtual bool IsGhost(const Element* elem) const { return false; }
451  virtual int GetNumGhosts() const { return 0; }
452 
453 
454  // refinement/derefinement
455 
456  struct ElemRefType
457  {
459  int ref_type;
460 
462  : elem(elem), ref_type(type) {}
463  };
464 
466 
468 
469  void RefineElement(Element* elem, char ref_type);
470  void DerefineElement(Element* elem);
471 
472  Element* NewHexahedron(Node* n0, Node* n1, Node* n2, Node* n3,
473  Node* n4, Node* n5, Node* n6, Node* n7,
474  int attr,
475  int fattr0, int fattr1, int fattr2,
476  int fattr3, int fattr4, int fattr5);
477 
478  Element* NewQuadrilateral(Node* n0, Node* n1, Node* n2, Node* n3,
479  int attr,
480  int eattr0, int eattr1, int eattr2, int eattr3);
481 
482  Element* NewTriangle(Node* n0, Node* n1, Node* n2,
483  int attr, int eattr0, int eattr1, int eattr2);
484 
485  Vertex* NewVertex(Node* v1, Node* v2);
486 
487  mfem::Element* NewMeshElement(int geom) const;
488 
489  Node* GetMidEdgeVertex(Node* v1, Node* v2);
491  Node* GetMidFaceVertex(Node* e1, Node* e2, Node* e3, Node* e4);
492 
493  int FaceSplitType(Node* v1, Node* v2, Node* v3, Node* v4,
494  Node* mid[4] = NULL /* optional output of mid-edge nodes*/)
495  const;
496 
497  void ForceRefinement(Node* v1, Node* v2, Node* v3, Node* v4);
498 
499  void CheckAnisoFace(Node* v1, Node* v2, Node* v3, Node* v4,
500  Node* mid12, Node* mid34, int level = 0);
501 
502  void CheckIsoFace(Node* v1, Node* v2, Node* v3, Node* v4,
503  Node* e1, Node* e2, Node* e3, Node* e4, Node* midf);
504 
505  void RefElementNodes(Element *elem);
506  void UnrefElementNodes(Element *elem);
507  Face* GetFace(Element* elem, int face_no);
508  void RegisterFaces(Element* elem, int *fattr = NULL);
509 
510  Node* PeekAltParents(Node* v1, Node* v2);
511 
512  bool NodeSetX1(Node* node, Node** n);
513  bool NodeSetX2(Node* node, Node** n);
514  bool NodeSetY1(Node* node, Node** n);
515  bool NodeSetY2(Node* node, Node** n);
516  bool NodeSetZ1(Node* node, Node** n);
517  bool NodeSetZ2(Node* node, Node** n);
518 
520 
521  // face/edge lists
522 
523  static int find_node(Element* elem, Node* node);
524  static int find_node(Element* elem, int node_id);
525  static int find_element_edge(Element* elem, int v0, int v1);
526  static int find_hex_face(int a, int b, int c);
527 
528  int ReorderFacePointMat(Node* v0, Node* v1, Node* v2, Node* v3,
529  Element* elem, DenseMatrix& mat) const;
530  struct PointMatrix;
531 
532  void TraverseFace(Node* v0, Node* v1, Node* v2, Node* v3,
533  const PointMatrix& pm, int level);
534 
535  void TraverseEdge(Node* v0, Node* v1, double t0, double t1, int flags,
536  int level);
537 
538  virtual void BuildFaceList();
539  virtual void BuildEdgeList();
540 
541  virtual void ElementSharesEdge(Element* elem, Edge* edge) {} // ParNCMesh
542  virtual void ElementSharesFace(Element* elem, Face* face) {} // ParNCMesh
543 
544 
545  // neighbors / element_vertex table
546 
553  void FindSetNeighbors(const Array<char> &elem_set,
554  Array<Element*> *neighbors, /* append */
555  Array<char> *neighbor_set = NULL);
556 
560  void FindNeighbors(const Element* elem,
561  Array<Element*> &neighbors, /* append */
562  const Array<Element*> *search_set = NULL);
563 
569  void NeighborExpand(const Array<Element*> &elements,
570  Array<Element*> &expanded,
571  const Array<Element*> *search_set = NULL);
572 
573 
574  void CollectEdgeVertices(Node *v0, Node *v1, Array<int> &indices);
575  void CollectFaceVertices(Node* v0, Node* v1, Node* v2, Node* v3,
576  Array<int> &indices);
578 
580  {
582  }
583 
584 
585  // coarse/fine transformations
586 
587  struct Point
588  {
589  int dim;
590  double coord[3];
591 
592  Point() { dim = 0; }
593 
594  Point(double x, double y)
595  { dim = 2; coord[0] = x; coord[1] = y; }
596 
597  Point(double x, double y, double z)
598  { dim = 3; coord[0] = x; coord[1] = y; coord[2] = z; }
599 
600  Point(const Point& p0, const Point& p1)
601  {
602  dim = p0.dim;
603  for (int i = 0; i < dim; i++)
604  {
605  coord[i] = (p0.coord[i] + p1.coord[i]) * 0.5;
606  }
607  }
608 
609  Point(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
610  {
611  dim = p0.dim;
612  MFEM_ASSERT(p1.dim == dim && p2.dim == dim && p3.dim == dim, "");
613  for (int i = 0; i < dim; i++)
614  {
615  coord[i] = (p0.coord[i] + p1.coord[i] + p2.coord[i] + p3.coord[i])
616  * 0.25;
617  }
618  }
619 
620  Point& operator=(const Point& src)
621  {
622  dim = src.dim;
623  for (int i = 0; i < dim; i++) { coord[i] = src.coord[i]; }
624  return *this;
625  }
626  };
627 
628  struct PointMatrix
629  {
630  int np;
632 
633  PointMatrix(const Point& p0, const Point& p1, const Point& p2)
634  { np = 3; points[0] = p0; points[1] = p1; points[2] = p2; }
635 
636  PointMatrix(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
637  { np = 4; points[0] = p0; points[1] = p1; points[2] = p2; points[3] = p3; }
638 
639  PointMatrix(const Point& p0, const Point& p1, const Point& p2,
640  const Point& p3, const Point& p4, const Point& p5,
641  const Point& p6, const Point& p7)
642  {
643  np = 8;
644  points[0] = p0; points[1] = p1; points[2] = p2; points[3] = p3;
645  points[4] = p4; points[5] = p5; points[6] = p6; points[7] = p7;
646  }
647 
648  Point& operator()(int i) { return points[i]; }
649  const Point& operator()(int i) const { return points[i]; }
650 
651  void GetMatrix(DenseMatrix& point_matrix) const;
652  };
653 
657 
658  static const PointMatrix& GetGeomIdentity(int geom);
659 
660  void GetPointMatrix(int geom, const char* ref_path, DenseMatrix& matrix);
661 
662  typedef std::map<std::string, int> RefPathMap;
663 
664  void TraverseRefinements(Element* elem, int coarse_index,
665  std::string &ref_path, RefPathMap &map);
666 
669 
672 
673  void InitDerefTransforms();
674  void SetDerefMatrixCodes(Element* parent, Array<Element*> &coarse);
675 
676 
677  // utility
678 
679  Node* GetEdgeMaster(Node* node) const;
680 
681  static void find_face_nodes(const Face *face, Node* node[4]);
682 
683  int EdgeSplitLevel(Node* v1, Node* v2) const;
684  void FaceSplitLevel(Node* v1, Node* v2, Node* v3, Node* v4,
685  int& h_level, int& v_level) const;
686 
687  void CountSplits(Element* elem, int splits[3]) const;
688  void GetLimitRefinements(Array<Refinement> &refinements, int max_level);
689 
690  int CountElements(Element* elem) const;
691 
692  int PrintElements(std::ostream &out, Element* elem, int &coarse_id) const;
693 
694  void CountObjects(int &nelem, int &nvert, int &nedges) const;
695 
696 
697 public: // TODO: maybe make this part of mfem::Geometry?
698 
701  struct GeomInfo
702  {
703  int nv, ne, nf, nfv; // number of: vertices, edges, faces, face vertices
704  int edges[12][2]; // edge vertices (up to 12 edges)
705  int faces[6][4]; // face vertices (up to 6 faces)
706 
708  GeomInfo() : initialized(false) {}
709  void Initialize(const mfem::Element* elem);
710  };
711 
713 
714 #ifdef MFEM_DEBUG
715 public:
716  void DebugNeighbors(Array<char> &elem_set);
717 
719  void DebugLeafOrder() const;
720 #endif
721 
722  friend class ParNCMesh/*::ElementSet*/;
723 };
724 
725 }
726 
727 #endif
NCList face_list
lazy-initialized list of faces, see GetFaceList
Definition: ncmesh.hpp:434
NCList edge_list
lazy-initialized list of edges, see GetEdgeList
Definition: ncmesh.hpp:435
NCMesh(const Mesh *mesh, std::istream *vertex_parents=NULL)
Definition: ncmesh.cpp:68
Element * NewHexahedron(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5, Node *n6, Node *n7, int attr, int fattr0, int fattr1, int fattr2, int fattr3, int fattr4, int fattr5)
Definition: ncmesh.cpp:491
CoarseFineTransformations transforms
storage for data returned by Get[De]RefinementTransforms()
Definition: ncmesh.hpp:668
void FindNeighbors(const Element *elem, Array< Element * > &neighbors, const Array< Element * > *search_set=NULL)
Definition: ncmesh.cpp:2280
char ref_type
refinement XYZ bit mask (7 = full isotropic)
Definition: ncmesh.hpp:36
const CoarseFineTransformations & GetDerefinementTransforms()
Definition: ncmesh.cpp:2812
int index
edge number in the Mesh
Definition: ncmesh.hpp:322
char flag
generic flag/marker, can be used by algorithms
Definition: ncmesh.hpp:395
Array< Element * > coarse_elements
state of leaf_elements before Refine(), set by MarkCoarseLevel()
Definition: ncmesh.hpp:671
int PrintElements(std::ostream &out, Element *elem, int &coarse_id) const
Definition: ncmesh.cpp:3182
PointMatrix(const Point &p0, const Point &p1, const Point &p2)
Definition: ncmesh.hpp:633
Point(const Point &p0, const Point &p1)
Definition: ncmesh.hpp:600
static const int NumGeom
Definition: geom.hpp:34
Slave(int index, Element *element, int local)
Definition: ncmesh.hpp:159
void PrintVertexParents(std::ostream &out) const
I/O: Print the &quot;vertex_parents&quot; section of the mesh file (ver. &gt;= 1.1).
Definition: ncmesh.cpp:3120
void GetPointMatrix(int geom, const char *ref_path, DenseMatrix &matrix)
Definition: ncmesh.cpp:2435
Node * PeekAltParents(Node *v1, Node *v2)
Definition: ncmesh.cpp:424
virtual void LimitNCLevel(int max_nc_level)
Definition: ncmesh.cpp:3105
void PrintMemoryDetail() const
Definition: ncmesh.cpp:3359
int index
element number in the Mesh, -1 if refined
Definition: ncmesh.hpp:396
PointMatrix(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
Definition: ncmesh.hpp:636
const Geometry::Type geom
virtual int GetNumGhosts() const
Definition: ncmesh.hpp:451
int GetElementGeometry() const
Return the type of elements in the mesh.
Definition: ncmesh.hpp:233
PointMatrix(const Point &p0, const Point &p1, const Point &p2, const Point &p3, const Point &p4, const Point &p5, const Point &p6, const Point &p7)
Definition: ncmesh.hpp:639
Lists all edges/faces in the nonconforming mesh.
Definition: ncmesh.hpp:167
void DebugLeafOrder() const
Print the space-filling curve formed by the sequence of leaf elements.
Definition: ncmesh.cpp:3385
int attribute
boundary element attribute, -1 if internal edge (2D)
Definition: ncmesh.hpp:321
void ClearTransforms()
Free all internal data created by the above three functions.
Definition: ncmesh.cpp:2855
bool Boundary() const
Definition: ncmesh.hpp:327
Table derefinements
possible derefinements, see GetDerefinementTable
Definition: ncmesh.hpp:467
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
void InitDerefTransforms()
Definition: ncmesh.cpp:1436
void RefElementNodes(Element *elem)
Definition: ncmesh.cpp:306
char geom
Geometry::Type of the element.
Definition: ncmesh.hpp:393
static int find_node(Element *elem, Node *node)
Definition: ncmesh.cpp:1745
void SetDerefMatrixCodes(Element *parent, Array< Element * > &coarse)
Definition: ncmesh.cpp:1451
int FaceSplitType(Node *v1, Node *v2, Node *v3, Node *v4, Node *mid[4]=NULL) const
Definition: ncmesh.cpp:1717
virtual void ElementSharesFace(Element *elem, Face *face)
Definition: ncmesh.hpp:542
void OrientedPointMatrix(DenseMatrix &oriented_matrix) const
Return the point matrix oriented according to the master and slave edges.
Definition: ncmesh.cpp:2059
static PointMatrix pm_tri_identity
Definition: ncmesh.hpp:654
int index
vertex number in the Mesh
Definition: ncmesh.hpp:309
void NeighborExpand(const Array< Element * > &elements, Array< Element * > &expanded, const Array< Element * > *search_set=NULL)
Definition: ncmesh.cpp:2342
MeshId(int index=-1, Element *element=NULL, int local=-1)
Definition: ncmesh.hpp:137
void CountObjects(int &nelem, int &nvert, int &nedges) const
Definition: ncmesh.cpp:3322
const Point & operator()(int i) const
Definition: ncmesh.hpp:649
std::vector< MeshId > conforming
Definition: ncmesh.hpp:169
Point & operator()(int i)
Definition: ncmesh.hpp:648
void GetLimitRefinements(Array< Refinement > &refinements, int max_level)
Definition: ncmesh.cpp:3075
Element * parent
parent element, NULL if this is a root element
Definition: ncmesh.hpp:404
double coord[3]
Definition: ncmesh.hpp:590
Vertex * NewVertex(Node *v1, Node *v2)
Definition: ncmesh.cpp:570
bool NodeSetY1(Node *node, Node **n)
Definition: ncmesh.cpp:626
int spaceDim
dimensions of the elements and the vertex coordinates
Definition: ncmesh.hpp:276
Array< int > vertex_nodeId
Definition: ncmesh.hpp:432
int attribute
boundary element attribute, -1 if internal face
Definition: ncmesh.hpp:368
int index
Mesh element number.
Definition: ncmesh.hpp:35
int master
master number (in Mesh numbering)
Definition: ncmesh.hpp:155
Element * element
NCMesh::Element containing this vertex/edge/face.
Definition: ncmesh.hpp:135
const NCList & GetFaceList()
Return the current list of conforming and nonconforming faces.
Definition: ncmesh.hpp:181
virtual void OnMeshUpdated(Mesh *mesh)
Definition: ncmesh.cpp:1671
A parallel extension of the NCMesh class.
Definition: pncmesh.hpp:65
Element * NewQuadrilateral(Node *n0, Node *n1, Node *n2, Node *n3, int attr, int eattr0, int eattr1, int eattr2, int eattr3)
Definition: ncmesh.cpp:519
void DebugNeighbors(Array< char > &elem_set)
Definition: ncmesh.cpp:2385
void CollectEdgeVertices(Node *v0, Node *v1, Array< int > &indices)
Definition: ncmesh.cpp:2083
virtual bool IsGhost(const Element *elem) const
Definition: ncmesh.hpp:450
bool Empty() const
Definition: ncmesh.hpp:176
Point(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
Definition: ncmesh.hpp:609
Vertex(double x, double y, double z)
Definition: ncmesh.hpp:313
int num_vertices
width of the table
Definition: ncmesh.hpp:441
Refinement(int index, int type=7)
Definition: ncmesh.hpp:38
int index
face number in the Mesh
Definition: ncmesh.hpp:369
const Table & GetDerefinementTable()
Definition: ncmesh.cpp:1356
Table element_vertex
leaf-element to vertex table, see FindSetNeighbors
Definition: ncmesh.hpp:440
DenseTensor point_matrices
matrices for IsoparametricTransformation
Definition: ncmesh.hpp:53
int local
local number within &#39;element&#39;
Definition: ncmesh.hpp:134
Element * elem[2]
up to 2 elements sharing the face
Definition: ncmesh.hpp:370
static void UnrefEdge(Node *node, HashTable< Node > &nodes)
Definition: ncmesh.cpp:284
void GetMatrix(DenseMatrix &point_matrix) const
Definition: ncmesh.cpp:2400
void CheckAnisoFace(Node *v1, Node *v2, Node *v3, Node *v4, Node *mid12, Node *mid34, int level=0)
Definition: ncmesh.cpp:673
virtual void Derefine(const Array< int > &derefs)
Definition: ncmesh.cpp:1400
void RegisterFaces(Element *elem, int *fattr=NULL)
Definition: ncmesh.cpp:399
std::vector< Master > masters
Definition: ncmesh.hpp:170
virtual void UpdateVertices()
update Vertex::index and vertex_nodeId
Definition: ncmesh.cpp:1469
void RegisterElement(Element *e)
Definition: ncmesh.cpp:377
int ReorderFacePointMat(Node *v0, Node *v1, Node *v2, Node *v3, Element *elem, DenseMatrix &mat) const
Definition: ncmesh.cpp:1795
Element * CopyHierarchy(Element *elem)
Definition: ncmesh.cpp:198
void RefineElement(Element *elem, char ref_type)
Definition: ncmesh.cpp:756
void FaceSplitLevel(Node *v1, Node *v2, Node *v3, Node *v4, int &h_level, int &v_level) const
Definition: ncmesh.cpp:2995
Element(int geom, int attr)
Definition: ncmesh.cpp:478
Array< Embedding > embeddings
fine element positions in their parents
Definition: ncmesh.hpp:54
virtual void BuildEdgeList()
Definition: ncmesh.cpp:1987
const CoarseFineTransformations & GetRefinementTransforms()
Definition: ncmesh.cpp:2775
void LoadCoarseElements(std::istream &input)
I/O: Load the element refinement hierarchy from a mesh file.
Definition: ncmesh.cpp:3229
Identifies a vertex/edge/face in both Mesh and NCMesh.
Definition: ncmesh.hpp:131
void MarkCoarseLevel()
Definition: ncmesh.cpp:2732
virtual void ElementSharesEdge(Element *elem, Edge *edge)
Definition: ncmesh.hpp:541
int Size() const
Returns the number of TYPE I elements.
Definition: table.hpp:86
A class for non-conforming AMR on higher-order hexahedral, quadrilateral or triangular meshes...
Definition: ncmesh.hpp:79
bool NodeSetX1(Node *node, Node **n)
Definition: ncmesh.cpp:620
virtual ~NCMesh()
Definition: ncmesh.cpp:254
virtual void GetBoundaryClosure(const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges)
Definition: ncmesh.cpp:2932
Embedding(int elem, int matrix=0)
Definition: ncmesh.hpp:47
static GeomInfo GI[Geometry::NumGeom]
Definition: ncmesh.hpp:712
void DeleteHierarchy(Element *elem)
Definition: ncmesh.cpp:224
int slaves_end
slave faces
Definition: ncmesh.hpp:145
Vertex * vertex
Definition: ncmesh.hpp:342
bool Iso
true if the mesh only contains isotropic refinements
Definition: ncmesh.hpp:277
void TraverseEdge(Node *v0, Node *v1, double t0, double t1, int flags, int level)
Definition: ncmesh.cpp:1951
Point(double x, double y, double z)
Definition: ncmesh.hpp:597
void DerefineElement(Element *elem)
Definition: ncmesh.cpp:1211
std::map< std::string, int > RefPathMap
Definition: ncmesh.hpp:662
Array< Node * > boundary_edges
subset of all edges, set by BuildEdgeList
Definition: ncmesh.hpp:438
void FindSetNeighbors(const Array< char > &elem_set, Array< Element * > *neighbors, Array< char > *neighbor_set=NULL)
Definition: ncmesh.cpp:2196
int SpaceDimension() const
Definition: ncmesh.hpp:97
std::vector< Slave > slaves
Definition: ncmesh.hpp:171
virtual void BuildFaceList()
Definition: ncmesh.cpp:1876
void ForceRefinement(Node *v1, Node *v2, Node *v3, Node *v4)
Definition: ncmesh.cpp:639
void SetVertexPositions(const Array< mfem::Vertex > &vertices)
I/O: Set positions of all vertices (used by mesh loader).
Definition: ncmesh.cpp:3168
int edge_flags
edge orientation flags
Definition: ncmesh.hpp:156
bool Boundary() const
Definition: ncmesh.hpp:375
double pos[3]
3D position
Definition: ncmesh.hpp:310
static const PointMatrix & GetGeomIdentity(int geom)
Definition: ncmesh.cpp:2423
Element * child[8]
2-8 children (if ref_type != 0)
Definition: ncmesh.hpp:402
Face * GetFace(Element *elem, int face_no)
Definition: ncmesh.cpp:391
Array< Element * > leaf_elements
Definition: ncmesh.hpp:430
mfem::Element * NewMeshElement(int geom) const
Definition: ncmesh.cpp:1583
void UpdateLeafElements()
Definition: ncmesh.cpp:1560
Vertex(const Vertex &other)
Definition: ncmesh.hpp:315
bool NodeSetZ1(Node *node, Node **n)
Definition: ncmesh.cpp:632
Node * GetMidEdgeVertexSimple(Node *v1, Node *v2)
Definition: ncmesh.cpp:593
long MemoryUsage() const
Definition: ncmesh.cpp:3307
void BuildElementToVertexTable()
Definition: ncmesh.cpp:2119
HashTable< Node > nodes
Definition: ncmesh.hpp:416
Edge(const Edge &other)
Definition: ncmesh.hpp:325
void UnrefElementNodes(Element *elem)
Definition: ncmesh.cpp:335
Master(int index, Element *element, int local, int sb, int se)
Definition: ncmesh.hpp:147
static PointMatrix pm_quad_identity
Definition: ncmesh.hpp:655
void CheckIsoFace(Node *v1, Node *v2, Node *v3, Node *v4, Node *e1, Node *e2, Node *e3, Node *e4, Node *midf)
Definition: ncmesh.cpp:739
Node * GetMidFaceVertex(Node *e1, Node *e2, Node *e3, Node *e4)
Definition: ncmesh.cpp:602
Element(const Element &other)
Definition: ncmesh.hpp:407
void CollectFaceVertices(Node *v0, Node *v1, Node *v2, Node *v3, Array< int > &indices)
Definition: ncmesh.cpp:2095
bool NodeSetZ2(Node *node, Node **n)
Definition: ncmesh.cpp:635
void Initialize(const mfem::Element *elem)
Definition: ncmesh.cpp:29
bool NodeSetX2(Node *node, Node **n)
Definition: ncmesh.cpp:623
void GetMeshComponents(Array< mfem::Vertex > &vertices, Array< mfem::Element * > &elements, Array< mfem::Element * > &boundary) const
Return the basic Mesh arrays for the current finest level.
Definition: ncmesh.cpp:1595
Node * node[8]
element corners (if ref_type == 0)
Definition: ncmesh.hpp:401
void CollectLeafElements(Element *elem, int state)
Definition: ncmesh.cpp:1520
Element * NewTriangle(Node *n0, Node *n1, Node *n2, int attr, int eattr0, int eattr1, int eattr2)
Definition: ncmesh.cpp:546
int parent
element index in the coarse mesh
Definition: ncmesh.hpp:44
Point(double x, double y)
Definition: ncmesh.hpp:594
virtual void AssignLeafIndices()
Definition: ncmesh.cpp:1574
static PointMatrix pm_hex_identity
Definition: ncmesh.hpp:656
static int find_hex_face(int a, int b, int c)
Definition: ncmesh.cpp:1779
int Dimension() const
Definition: ncmesh.hpp:96
virtual void CheckDerefinementNCLevel(const Table &deref_table, Array< int > &level_ok, int max_nc_level)
Definition: ncmesh.cpp:1371
Array< ElemRefType > ref_stack
stack of scheduled refinements (temporary)
Definition: ncmesh.hpp:465
static void find_face_nodes(const Face *face, Node *node[4])
Definition: ncmesh.cpp:2912
Array< Element * > root_elements
Definition: ncmesh.hpp:414
virtual void Update()
Definition: ncmesh.cpp:187
long MemoryUsage() const
Return total number of bytes allocated.
Definition: ncmesh.cpp:3336
Node * GetMidEdgeVertex(Node *v1, Node *v2)
Definition: ncmesh.cpp:584
int EdgeSplitLevel(Node *v1, Node *v2) const
Definition: ncmesh.cpp:2988
Element * GetSingleElement() const
Return one of elem[0] or elem[1] and make sure the other is NULL.
Definition: ncmesh.cpp:410
void PrintCoarseElements(std::ostream &out) const
I/O: Print the &quot;coarse_elements&quot; section of the mesh file (ver. &gt;= 1.1).
Definition: ncmesh.cpp:3211
static int find_element_edge(Element *elem, int v0, int v1)
Definition: ncmesh.cpp:1763
Defines the coarse-fine transformations of all fine elements.
Definition: ncmesh.hpp:51
const NCList & GetEdgeList()
Return the current list of conforming and nonconforming edges.
Definition: ncmesh.hpp:188
void TraverseFace(Node *v0, Node *v1, Node *v2, Node *v3, const PointMatrix &pm, int level)
Definition: ncmesh.cpp:1827
void UpdateElementToVertexTable()
Definition: ncmesh.hpp:579
int GetElementDepth(int i) const
Return the distance of leaf &#39;i&#39; from the root.
Definition: ncmesh.cpp:2900
void CountSplits(Element *elem, int splits[3]) const
Definition: ncmesh.cpp:3028
void ForgetElement(Element *e)
Definition: ncmesh.cpp:384
char ref_type
bit mask of X,Y,Z refinements (bits 0,1,2 respectively)
Definition: ncmesh.hpp:394
ElemRefType(Element *elem, int type)
Definition: ncmesh.hpp:461
bool NodeSetY2(Node *node, Node **n)
Definition: ncmesh.cpp:629
int index
Mesh number.
Definition: ncmesh.hpp:133
void LoadVertexParents(std::istream &input)
Definition: ncmesh.cpp:3148
Rank 3 tensor (array of matrices)
Definition: densemat.hpp:569
int CountElements(Element *elem) const
Definition: ncmesh.cpp:3294
Abstract data type element.
Definition: element.hpp:27
Point & operator=(const Point &src)
Definition: ncmesh.hpp:620
Array< Face * > boundary_faces
subset of all faces, set by BuildFaceList
Definition: ncmesh.hpp:437
void TraverseRefinements(Element *elem, int coarse_index, std::string &ref_path, RefPathMap &map)
Definition: ncmesh.cpp:2746
int rank
processor number (ParNCMesh)
Definition: ncmesh.hpp:397
void CollectDerefinements(Element *elem, Array< Connection > &list)
Definition: ncmesh.cpp:1320
DenseMatrix point_matrix
position within the master edge/face
Definition: ncmesh.hpp:157
HashTable< Face > faces
Definition: ncmesh.hpp:417
Defines the position of a fine element within a coarse element.
Definition: ncmesh.hpp:42
virtual void Refine(const Array< Refinement > &refinements)
Definition: ncmesh.cpp:1169
int matrix
index into CoarseFineTransformations::point_matrices
Definition: ncmesh.hpp:45
int GetEdgeMaster(int v1, int v2) const
Definition: ncmesh.cpp:2891
void UnrefVertex(HashTable< Node > &nodes)
Definition: ncmesh.cpp:277