MFEM  v4.2.0
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-2020, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_NCMESH
13 #define MFEM_NCMESH
14 
15 #include "../config/config.hpp"
16 #include "../general/hash.hpp"
17 #include "../general/globals.hpp"
18 #include "../general/sort_pairs.hpp"
19 #include "../linalg/densemat.hpp"
20 #include "element.hpp"
21 #include "vertex.hpp"
22 #include "../fem/geom.hpp"
23 
24 #include <vector>
25 #include <map>
26 #include <iostream>
27 
28 namespace mfem
29 {
30 
31 /** Represents the index of an element to refine, plus a refinement type.
32  The refinement type is needed for anisotropic refinement of quads and hexes.
33  Bits 0,1 and 2 of 'ref_type' specify whether the element should be split
34  in the X, Y and Z directions, respectively (Z is ignored for quads). */
35 struct Refinement
36 {
37  int index; ///< Mesh element number
38  char ref_type; ///< refinement XYZ bit mask (7 = full isotropic)
39 
40  Refinement() = default;
41 
42  Refinement(int index, int type = 7) : index(index), ref_type(type) {}
43 };
44 
45 /// Defines the position of a fine element within a coarse element.
46 struct Embedding
47 {
48  /// %Element index in the coarse mesh.
49  int parent;
50  /** @brief Index into the DenseTensor corresponding to the parent
51  Geometry::Type stored in CoarseFineTransformations::point_matrices. */
52  int matrix;
53 
54  Embedding() = default;
55 
56  Embedding(int elem, int matrix = 0) : parent(elem), matrix(matrix) {}
57 };
58 
59 /// Defines the coarse-fine transformations of all fine elements.
61 {
62  /// Matrices for IsoparametricTransformation organized by Geometry::Type
64  /// Fine element positions in their parents.
66 
67  void GetCoarseToFineMap(const Mesh &fine_mesh,
68  Table &coarse_to_fine,
69  Array<int> &coarse_to_ref_type,
70  Table &ref_type_to_matrix,
71  Array<Geometry::Type> &ref_type_to_geom) const;
72 
73  void Clear();
74  bool IsInitialized() const;
75  long MemoryUsage() const;
76 };
77 
78 struct MatrixMap; // for internal use
79 
80 
81 /** \brief A class for non-conforming AMR on higher-order hexahedral, prismatic,
82  * quadrilateral or triangular meshes.
83  *
84  * The class is used as follows:
85  *
86  * 1. NCMesh is constructed from elements of an existing Mesh. The elements
87  * are copied and become roots of the refinement hierarchy.
88  *
89  * 2. Some elements are refined with the Refine() method. Both isotropic and
90  * anisotropic refinements of quads/hexes are supported.
91  *
92  * 3. A new Mesh is created from NCMesh containing the leaf elements.
93  * This new mesh may have non-conforming (hanging) edges and faces.
94  *
95  * 4. FiniteElementSpace asks NCMesh for a list of conforming, master and
96  * slave edges/faces and creates the conforming interpolation matrix P.
97  *
98  * 5. A continuous/conforming solution is obtained by solving P'*A*P x = P'*b.
99  *
100  * 6. Repeat from step 2.
101  */
102 class NCMesh
103 {
104 public:
105  /** Initialize with elements from 'mesh'. If an already nonconforming mesh
106  is being loaded, 'vertex_parents' must point to a stream at the appropriate
107  section of the mesh file which contains the vertex hierarchy. */
108  explicit NCMesh(const Mesh *mesh, std::istream *vertex_parents = NULL);
109 
110  NCMesh(const NCMesh &other); // deep copy
111 
112  virtual ~NCMesh();
113 
114  int Dimension() const { return Dim; }
115  int SpaceDimension() const { return spaceDim; }
116 
117  int GetNVertices() const { return NVertices; }
118  int GetNEdges() const { return NEdges; }
119  int GetNFaces() const { return NFaces; }
120 
121  /** Perform the given batch of refinements. Please note that in the presence
122  of anisotropic splits additional refinements may be necessary to keep
123  the mesh consistent. However, the function always performs at least the
124  requested refinements. */
125  virtual void Refine(const Array<Refinement> &refinements);
126 
127  /** Check the mesh and potentially refine some elements so that the maximum
128  difference of refinement levels between adjacent elements is not greater
129  than 'max_nc_level'. */
130  virtual void LimitNCLevel(int max_nc_level);
131 
132  /** Return a list of derefinement opportunities. Each row of the table
133  contains Mesh indices of existing elements that can be derefined to form
134  a single new coarse element. Row numbers are then passed to Derefine.
135  This function works both in serial and parallel. */
136  const Table &GetDerefinementTable();
137 
138  /** Check derefinements returned by GetDerefinementTable and mark those that
139  can be done safely so that the maximum NC level condition is not violated.
140  On return, level_ok.Size() == deref_table.Size() and contains 0/1s. */
141  virtual void CheckDerefinementNCLevel(const Table &deref_table,
142  Array<int> &level_ok, int max_nc_level);
143 
144  /** Perform a subset of the possible derefinements (see GetDerefinementTable).
145  Note that if anisotropic refinements are present in the mesh, some of the
146  derefinements may have to be skipped to preserve mesh consistency. */
147  virtual void Derefine(const Array<int> &derefs);
148 
149 
150  // master/slave lists
151 
152  /// Identifies a vertex/edge/face in both Mesh and NCMesh.
153  struct MeshId
154  {
155  int index; ///< Mesh number
156  int element; ///< NCMesh::Element containing this vertex/edge/face
157  signed char local; ///< local number within 'element'
158  signed char geom; ///< Geometry::Type (faces only) (char to save RAM)
159 
160  Geometry::Type Geom() const { return Geometry::Type(geom); }
161 
162  MeshId(int index = -1, int element = -1, int local = -1, int geom = -1)
164  };
165 
166  /** Nonconforming edge/face that has more than one neighbor. The neighbors
167  are stored in NCList::slaves[i], slaves_begin <= i < slaves_end. */
168  struct Master : public MeshId
169  {
170  int slaves_begin, slaves_end; ///< slave faces
171 
172  Master() = default;
173  Master(int index, int element, int local, int geom, int sb, int se)
174  : MeshId(index, element, local, geom)
175  , slaves_begin(sb), slaves_end(se) {}
176  };
177 
178  /// Nonconforming edge/face within a bigger edge/face.
179  struct Slave : public MeshId
180  {
181  int master; ///< master number (in Mesh numbering)
182  unsigned matrix : 24; ///< index into NCList::point_matrices[geom]
183  unsigned edge_flags : 8; ///< orientation flags, see OrientedPointMatrix
184 
185  Slave() = default;
186  Slave(int index, int element, int local, int geom)
187  : MeshId(index, element, local, geom)
188  , master(-1), matrix(0), edge_flags(0) {}
189  };
190 
191  /// Lists all edges/faces in the nonconforming mesh.
192  struct NCList
193  {
197 
198  /// List of unique point matrices for each slave geometry.
200 
201  /// Return the point matrix oriented according to the master and slave edges
202  void OrientedPointMatrix(const Slave &slave,
203  DenseMatrix &oriented_matrix) const;
204 
205  void Clear();
206  bool Empty() const { return !conforming.Size() && !masters.Size(); }
207  long TotalSize() const;
208  long MemoryUsage() const;
209 
210  const MeshId& LookUp(int index, int *type = NULL) const;
211 
212  ~NCList() { Clear(); }
213  private:
214  mutable Array<int> inv_index;
215  };
216 
217  /// Return the current list of conforming and nonconforming faces.
219  {
220  if (face_list.Empty()) { BuildFaceList(); }
221  return face_list;
222  }
223 
224  /// Return the current list of conforming and nonconforming edges.
226  {
227  if (edge_list.Empty()) { BuildEdgeList(); }
228  return edge_list;
229  }
230 
231  /** Return a list of vertices (in 'conforming'); this function is provided
232  for uniformity/completeness. Needed in ParNCMesh/ParFESpace. */
234  {
235  if (vertex_list.Empty()) { BuildVertexList(); }
236  return vertex_list;
237  }
238 
239  /// Return vertex/edge/face list (entity = 0/1/2, respectively).
240  const NCList& GetNCList(int entity)
241  {
242  switch (entity)
243  {
244  case 0: return GetVertexList();
245  case 1: return GetEdgeList();
246  default: return GetFaceList();
247  }
248  }
249 
250 
251  // coarse/fine transforms
252 
253  /** Remember the current layer of leaf elements before the mesh is refined.
254  Needed by GetRefinementTransforms(), must be called before Refine(). */
255  void MarkCoarseLevel();
256 
257  /** After refinement, calculate the relation of each fine element to its
258  parent coarse element. Note that Refine() or LimitNCLevel() can be called
259  multiple times between MarkCoarseLevel() and this function. */
261 
262  /** After derefinement, calculate the relations of previous fine elements
263  (some of which may no longer exist) to the current leaf elements.
264  Unlike for refinement, Derefine() may only be called once before this
265  function so there is no MarkFineLevel(). */
267 
268  /// Free all internal data created by the above three functions.
269  void ClearTransforms();
270 
271 
272  // grid ordering
273 
274  /** Return a space filling curve for a rectangular grid of elements.
275  Implemented is a generalized Hilbert curve for arbitrary grid dimensions.
276  If the width is odd, height should be odd too, otherwise one diagonal
277  (vertex-neighbor) step cannot be avoided in the curve. Even dimensions
278  are recommended. */
279  static void GridSfcOrdering2D(int width, int height,
280  Array<int> &coords);
281 
282  /** Return a space filling curve for a 3D rectangular grid of elements.
283  The Hilbert-curve-like algorithm works well for even dimensions. For odd
284  width/height/depth it tends to produce some diagonal (edge-neighbor)
285  steps. Even dimensions are recommended. */
286  static void GridSfcOrdering3D(int width, int height, int depth,
287  Array<int> &coords);
288 
289 
290  // utility
291 
292  /// Return Mesh vertex indices of an edge identified by 'edge_id'.
293  void GetEdgeVertices(const MeshId &edge_id, int vert_index[2],
294  bool oriented = true) const;
295 
296  /** Return "NC" orientation of an edge. As opposed to standard Mesh edge
297  orientation based on vertex IDs, "NC" edge orientation follows the local
298  edge orientation within the element 'edge_id.element' and is thus
299  processor independent. TODO: this seems only partially true? */
300  int GetEdgeNCOrientation(const MeshId &edge_id) const;
301 
302  /** Return Mesh vertex and edge indices of a face identified by 'face_id'.
303  The return value is the number of face vertices. */
304  int GetFaceVerticesEdges(const MeshId &face_id,
305  int vert_index[4], int edge_index[4],
306  int edge_orientation[4]) const;
307 
308  /** Given an edge (by its vertex indices v1 and v2) return the first
309  (geometric) parent edge that exists in the Mesh or -1 if there is no such
310  parent. */
311  int GetEdgeMaster(int v1, int v2) const;
312 
313  /** Get a list of vertices (2D/3D) and edges (3D) that coincide with boundary
314  elements with the specified attributes (marked in 'bdr_attr_is_ess').
315  In 3D this function also reveals "hidden" boundary edges. In parallel it
316  helps identifying boundary vertices/edges affected by non-local boundary
317  elements. */
318  virtual void GetBoundaryClosure(const Array<int> &bdr_attr_is_ess,
319  Array<int> &bdr_vertices,
320  Array<int> &bdr_edges);
321 
322  /// Return element geometry type. @a index is the Mesh element number.
324  { return elements[leaf_elements[index]].Geom(); }
325 
326  /// Return face geometry type. @a index is the Mesh face number.
328  { return Geometry::Type(face_geom[index]); }
329 
330  /// Return the number of root elements.
331  int GetNumRootElements() { return root_state.Size(); }
332 
333  /// Return the distance of leaf 'i' from the root.
334  int GetElementDepth(int i) const;
335 
336  /** Return the size reduction compared to the root element (ignoring local
337  stretching and curvature). */
338  int GetElementSizeReduction(int i) const;
339 
340  /// Return the faces and face attributes of leaf element 'i'.
342  Array<int> &fattr) const;
343 
344 
345  /// I/O: Print the "vertex_parents" section of the mesh file (ver. >= 1.1).
346  void PrintVertexParents(std::ostream &out) const;
347 
348  /// I/O: Print the "coarse_elements" section of the mesh file (ver. >= 1.1).
349  void PrintCoarseElements(std::ostream &out) const;
350 
351  /** I/O: Load the vertex parent hierarchy from a mesh file. NOTE: called
352  indirectly through the constructor. */
353  void LoadVertexParents(std::istream &input);
354 
355  /// I/O: Load the element refinement hierarchy from a mesh file.
356  void LoadCoarseElements(std::istream &input);
357 
358  /// I/O: Set positions of all vertices (used by mesh loader).
359  void SetVertexPositions(const Array<mfem::Vertex> &vertices);
360 
361  /// Save memory by releasing all non-essential and cached data.
362  virtual void Trim();
363 
364  /// Return total number of bytes allocated.
365  long MemoryUsage() const;
366 
367  int PrintMemoryDetail() const;
368 
369  void PrintStats(std::ostream &out = mfem::out) const;
370 
371  typedef int64_t RefCoord;
372 
373 
374 protected: // interface for Mesh to be able to construct itself from NCMesh
375 
376  friend class Mesh;
377 
378  /// Fill Mesh::{vertices,elements,boundary} for the current finest level.
379  void GetMeshComponents(Mesh &mesh) const;
380 
381  /** Get edge and face numbering from 'mesh' (i.e., set all Edge::index and
382  Face::index) after a new mesh was created from us. */
383  virtual void OnMeshUpdated(Mesh *mesh);
384 
385 
386 protected: // implementation
387 
388  int Dim, spaceDim; ///< dimensions of the elements and the vertex coordinates
389  bool Iso; ///< true if the mesh only contains isotropic refinements
390  int Geoms; ///< bit mask of element geometries present, see InitGeomFlags()
391 
392  /** A Node can hold a vertex, an edge, or both. Elements directly point to
393  their corner nodes, but edge nodes also exist and can be accessed using
394  a hash-table given their two end-point node IDs. All nodes can be
395  accessed in this way, with the exception of top-level vertex nodes.
396  When an element is being refined, the mid-edge nodes are readily
397  available with this mechanism. The new elements "sign in" to the nodes
398  by increasing the reference counts of their vertices and edges. The
399  parent element "signs off" its nodes by decrementing the ref counts. */
400  struct Node : public Hashed2
401  {
404 
405  Node() : vert_refc(0), edge_refc(0), vert_index(-1), edge_index(-1) {}
406  ~Node();
407 
408  bool HasVertex() const { return vert_refc > 0; }
409  bool HasEdge() const { return edge_refc > 0; }
410 
411  // decrease vertex/edge ref count, return false if Node should be deleted
412  bool UnrefVertex() { --vert_refc; return vert_refc || edge_refc; }
413  bool UnrefEdge() { --edge_refc; return vert_refc || edge_refc; }
414  };
415 
416  /** Similarly to nodes, faces can be accessed by hashing their four vertex
417  node IDs. A face knows about the one or two elements that are using it.
418  A face that is not on the boundary and only has one element referencing
419  it is either a master or a slave face. */
420  struct Face : public Hashed4
421  {
422  int attribute; ///< boundary element attribute, -1 if internal face
423  int index; ///< face number in the Mesh
424  int elem[2]; ///< up to 2 elements sharing the face
425 
426  Face() : attribute(-1), index(-1) { elem[0] = elem[1] = -1; }
427 
428  bool Boundary() const { return attribute >= 0; }
429  bool Unused() const { return elem[0] < 0 && elem[1] < 0; }
430 
431  // add or remove an element from the 'elem[2]' array
432  void RegisterElement(int e);
433  void ForgetElement(int e);
434 
435  /// Return one of elem[0] or elem[1] and make sure the other is -1.
436  int GetSingleElement() const;
437  };
438 
439  /** This is an element in the refinement hierarchy. Each element has
440  either been refined and points to its children, or is a leaf and points
441  to its vertex nodes. */
442  struct Element
443  {
444  char geom; ///< Geometry::Type of the element (char for storage only)
445  char ref_type; ///< bit mask of X,Y,Z refinements (bits 0,1,2 respectively)
446  char tet_type; ///< tetrahedron split type, currently always 0
447  char flag; ///< generic flag/marker, can be used by algorithms
448  int index; ///< element number in the Mesh, -1 if refined
449  int rank; ///< processor number (ParNCMesh), -1 if undefined/unknown
451  union
452  {
453  int node[8]; ///< element corners (if ref_type == 0)
454  int child[8]; ///< 2-8 children (if ref_type != 0)
455  };
456  int parent; ///< parent element, -1 if this is a root element, -2 if free
457 
458  Element(Geometry::Type geom, int attr);
459 
460  Geometry::Type Geom() const { return Geometry::Type(geom); }
461  };
462 
463  // primary data
464 
465  HashTable<Node> nodes; // associative container holding all Nodes
466  HashTable<Face> faces; // associative container holding all Faces
467 
468  BlockArray<Element> elements; // storage for all Elements
469  Array<int> free_element_ids; // unused element ids - indices into 'elements'
470 
471  /** Initial traversal state (~ element orientation) for each root element
472  NOTE: M = root_state.Size() is the number of root elements.
473  NOTE: the first M items of 'elements' is the coarse mesh. */
475 
476  /// coordinates of top-level vertices (organized as triples)
478 
484 
485 
486  // secondary data
487 
488  /** Apart from the primary data structure, which is the element/node/face
489  hierarchy, there is secondary data that is derived from the primary
490  data and needs to be updated when the primary data changes. Update()
491  takes care of that and needs to be called after refinement and
492  derefinement. */
493  virtual void Update();
494 
495  int NVertices; // set by UpdateVertices
496  int NEdges, NFaces; // set by OnMeshUpdated
497 
498  Array<int> leaf_elements; // finest level, calculated by UpdateLeafElements
499  Array<int> vertex_nodeId; // vertex-index to node-id map, see UpdateVertices
500 
501  NCList face_list; ///< lazy-initialized list of faces, see GetFaceList
502  NCList edge_list; ///< lazy-initialized list of edges, see GetEdgeList
503  NCList vertex_list; ///< lazy-initialized list of vertices, see GetVertexList
504 
505  Array<int> boundary_faces; ///< subset of all faces, set by BuildFaceList
506  Array<char> face_geom; ///< face geometry by face index, set by OnMeshUpdated
507 
508  Table element_vertex; ///< leaf-element to vertex table, see FindSetNeighbors
509 
510 
511  virtual void UpdateVertices(); ///< update Vertex::index and vertex_nodeId
512 
513  void CollectLeafElements(int elem, int state);
514  void UpdateLeafElements();
515 
516  virtual void AssignLeafIndices();
517 
518  /** Try to find a space-filling curve friendly orientation of the root
519  elements: set 'root_state' based on the ordering of coarse elements.
520  Note that the coarse mesh itself must be ordered as an SFC by e.g.
521  Mesh::GetGeckoElementOrdering. */
522  void InitRootState(int root_count);
523 
524  virtual bool IsGhost(const Element &el) const { return false; }
525  virtual int GetNumGhostElements() const { return 0; }
526  virtual int GetNumGhostVertices() const { return 0; }
527 
528  void InitGeomFlags();
529 
530  bool HavePrisms() const { return Geoms & (1 << Geometry::PRISM); }
531  bool HaveTets() const { return Geoms & (1 << Geometry::TETRAHEDRON); }
532 
533 
534  // refinement/derefinement
535 
536  Array<Refinement> ref_stack; ///< stack of scheduled refinements (temporary)
537  HashTable<Node> shadow; ///< temporary storage for reparented nodes
538  Array<Triple<int, int, int> > reparents; ///< scheduled node reparents (tmp)
539 
540  Table derefinements; ///< possible derefinements, see GetDerefinementTable
541 
542  void RefineElement(int elem, char ref_type);
543  void DerefineElement(int elem);
544 
545  int AddElement(const Element &el)
546  {
547  if (free_element_ids.Size())
548  {
549  int idx = free_element_ids.Last();
551  elements[idx] = el;
552  return idx;
553  }
554  return elements.Append(el);
555  }
556  void FreeElement(int id)
557  {
559  elements[id].parent = -2; // mark the element as free
560  }
561 
562  int NewHexahedron(int n0, int n1, int n2, int n3,
563  int n4, int n5, int n6, int n7, int attr,
564  int fattr0, int fattr1, int fattr2,
565  int fattr3, int fattr4, int fattr5);
566 
567  int NewWedge(int n0, int n1, int n2,
568  int n3, int n4, int n5, int attr,
569  int fattr0, int fattr1,
570  int fattr2, int fattr3, int fattr4);
571 
572  int NewTetrahedron(int n0, int n1, int n2, int n3, int attr,
573  int fattr0, int fattr1, int fattr2, int fattr3);
574 
575  int NewQuadrilateral(int n0, int n1, int n2, int n3, int attr,
576  int eattr0, int eattr1, int eattr2, int eattr3);
577 
578  int NewTriangle(int n0, int n1, int n2,
579  int attr, int eattr0, int eattr1, int eattr2);
580 
581  mfem::Element* NewMeshElement(int geom) const;
582 
583  int QuadFaceSplitType(int v1, int v2, int v3, int v4, int mid[5]
584  = NULL /*optional output of mid-edge nodes*/) const;
585 
586  bool TriFaceSplit(int v1, int v2, int v3, int mid[3] = NULL) const;
587 
588  void ForceRefinement(int vn1, int vn2, int vn3, int vn4);
589 
590  void FindEdgeElements(int vn1, int vn2, int vn3, int vn4,
591  Array<MeshId> &prisms) const;
592 
593  void CheckAnisoPrism(int vn1, int vn2, int vn3, int vn4,
594  const Refinement *refs, int nref);
595 
596  void CheckAnisoFace(int vn1, int vn2, int vn3, int vn4,
597  int mid12, int mid34, int level = 0);
598 
599  void CheckIsoFace(int vn1, int vn2, int vn3, int vn4,
600  int en1, int en2, int en3, int en4, int midf);
601 
602  void ReparentNode(int node, int new_p1, int new_p2);
603 
604  int FindMidEdgeNode(int node1, int node2) const;
605  int GetMidEdgeNode(int node1, int node2);
606 
607  int GetMidFaceNode(int en1, int en2, int en3, int en4);
608 
609  void ReferenceElement(int elem);
610  void UnreferenceElement(int elem, Array<int> &elemFaces);
611 
612  Face* GetFace(Element &elem, int face_no);
613  void RegisterFaces(int elem, int *fattr = NULL);
614  void DeleteUnusedFaces(const Array<int> &elemFaces);
615 
616  void CollectDerefinements(int elem, Array<Connection> &list);
617 
618  /// Return el.node[index] correctly, even if the element is refined.
619  int RetrieveNode(const Element &el, int index);
620 
621  /// Extended version of find_node: works if 'el' is refined.
622  int FindNodeExt(const Element &el, int node, bool abort = true);
623 
624 
625  // face/edge lists
626 
627  static int find_node(const Element &el, int node);
628  static int find_element_edge(const Element &el, int vn0, int vn1,
629  bool abort = true);
630  static int find_local_face(int geom, int a, int b, int c);
631 
632  struct Point;
633  struct PointMatrix;
634 
635  int ReorderFacePointMat(int v0, int v1, int v2, int v3,
636  int elem, const PointMatrix &pm,
637  PointMatrix &reordered) const;
638 
639  void TraverseQuadFace(int vn0, int vn1, int vn2, int vn3,
640  const PointMatrix& pm, int level, Face* eface[4],
641  MatrixMap &matrix_map);
642  bool TraverseTriFace(int vn0, int vn1, int vn2,
643  const PointMatrix& pm, int level,
644  MatrixMap &matrix_map);
645  void TraverseTetEdge(int vn0, int vn1, const Point &p0, const Point &p1,
646  MatrixMap &matrix_map);
647  void TraverseEdge(int vn0, int vn1, double t0, double t1, int flags,
648  int level, MatrixMap &matrix_map);
649 
650  virtual void BuildFaceList();
651  virtual void BuildEdgeList();
652  virtual void BuildVertexList();
653 
654  virtual void ElementSharesFace(int elem, int local, int face) {} // ParNCMesh
655  virtual void ElementSharesEdge(int elem, int local, int enode) {} // ParNCMesh
656  virtual void ElementSharesVertex(int elem, int local, int vnode) {} // ParNCMesh
657 
658 
659  // neighbors / element_vertex table
660 
661  /** Return all vertex-, edge- and face-neighbors of a set of elements.
662  The neighbors are returned as a list (neighbors != NULL), as a set
663  (neighbor_set != NULL), or both. The sizes of the set arrays must match
664  that of leaf_elements. The function is intended to be used for large
665  sets of elements and its complexity is linear in the number of leaf
666  elements in the mesh. */
667  void FindSetNeighbors(const Array<char> &elem_set,
668  Array<int> *neighbors, /* append */
669  Array<char> *neighbor_set = NULL);
670 
671  /** Return all vertex-, edge- and face-neighbors of a single element.
672  You can limit the number of elements being checked using 'search_set'.
673  The complexity of the function is linear in the size of the search set.*/
674  void FindNeighbors(int elem,
675  Array<int> &neighbors, /* append */
676  const Array<int> *search_set = NULL);
677 
678  /** Expand a set of elements by all vertex-, edge- and face-neighbors.
679  The output array 'expanded' will contain all items from 'elems'
680  (provided they are in 'search_set') plus their neighbors. The neighbor
681  search can be limited to the optional search set. The complexity is
682  linear in the sum of the sizes of 'elems' and 'search_set'. */
683  void NeighborExpand(const Array<int> &elems,
684  Array<int> &expanded,
685  const Array<int> *search_set = NULL);
686 
687 
688  void CollectEdgeVertices(int v0, int v1, Array<int> &indices);
689  void CollectTriFaceVertices(int v0, int v1, int v2, Array<int> &indices);
690  void CollectQuadFaceVertices(int v0, int v1, int v2, int v3,
691  Array<int> &indices);
693 
695  {
697  }
698 
699  int GetVertexRootCoord(int elem, RefCoord coord[3]) const;
700  void CollectIncidentElements(int elem, const RefCoord coord[3],
701  Array<int> &list) const;
702 
703  /** Return elements neighboring to a local vertex of element 'elem'. Only
704  elements from within the same refinement tree ('cousins') are returned.
705  Complexity is proportional to the depth of elem's refinement tree. */
706  void FindVertexCousins(int elem, int local, Array<int> &cousins) const;
707 
708 
709  // coarse/fine transformations
710 
711  struct Point
712  {
713  int dim;
714  double coord[3];
715 
716  Point() { dim = 0; }
717 
718  Point(double x)
719  { dim = 1; coord[0] = x; }
720 
721  Point(double x, double y)
722  { dim = 2; coord[0] = x; coord[1] = y; }
723 
724  Point(double x, double y, double z)
725  { dim = 3; coord[0] = x; coord[1] = y; coord[2] = z; }
726 
727  Point(const Point& p0, const Point& p1)
728  {
729  dim = p0.dim;
730  for (int i = 0; i < dim; i++)
731  {
732  coord[i] = (p0.coord[i] + p1.coord[i]) * 0.5;
733  }
734  }
735 
736  Point(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
737  {
738  dim = p0.dim;
739  MFEM_ASSERT(p1.dim == dim && p2.dim == dim && p3.dim == dim, "");
740  for (int i = 0; i < dim; i++)
741  {
742  coord[i] = (p0.coord[i] + p1.coord[i] + p2.coord[i] + p3.coord[i])
743  * 0.25;
744  }
745  }
746 
747  Point& operator=(const Point& src)
748  {
749  dim = src.dim;
750  for (int i = 0; i < dim; i++) { coord[i] = src.coord[i]; }
751  return *this;
752  }
753  };
754 
755  struct PointMatrix
756  {
757  int np;
759 
760  PointMatrix() : np(0) {}
761 
762  PointMatrix(const Point& p0, const Point& p1)
763  { np = 2; points[0] = p0; points[1] = p1; }
764 
765  PointMatrix(const Point& p0, const Point& p1, const Point& p2)
766  { np = 3; points[0] = p0; points[1] = p1; points[2] = p2; }
767 
768  PointMatrix(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
769  { np = 4; points[0] = p0; points[1] = p1; points[2] = p2; points[3] = p3; }
770 
771  PointMatrix(const Point& p0, const Point& p1, const Point& p2,
772  const Point& p3, const Point& p4, const Point& p5)
773  {
774  np = 6;
775  points[0] = p0; points[1] = p1; points[2] = p2;
776  points[3] = p3; points[4] = p4; points[5] = p5;
777  }
778  PointMatrix(const Point& p0, const Point& p1, const Point& p2,
779  const Point& p3, const Point& p4, const Point& p5,
780  const Point& p6, const Point& p7)
781  {
782  np = 8;
783  points[0] = p0; points[1] = p1; points[2] = p2; points[3] = p3;
784  points[4] = p4; points[5] = p5; points[6] = p6; points[7] = p7;
785  }
786 
787  Point& operator()(int i) { return points[i]; }
788  const Point& operator()(int i) const { return points[i]; }
789 
790  bool operator==(const PointMatrix &pm) const;
791 
792  void GetMatrix(DenseMatrix& point_matrix) const;
793  };
794 
800 
802 
803  void GetPointMatrix(Geometry::Type geom, const char* ref_path,
804  DenseMatrix& matrix);
805 
806  typedef std::map<std::string, int> RefPathMap;
807 
808  void TraverseRefinements(int elem, int coarse_index,
809  std::string &ref_path, RefPathMap &map);
810 
811  /// storage for data returned by Get[De]RefinementTransforms()
813 
814  /// state of leaf_elements before Refine(), set by MarkCoarseLevel()
816 
817  void InitDerefTransforms();
818  void SetDerefMatrixCodes(int parent, Array<int> &fine_coarse);
819 
820 
821  // vertex temporary data, used by GetMeshComponents
822 
823  struct TmpVertex
824  {
825  bool valid, visited;
826  double pos[3];
827  TmpVertex() : valid(false), visited(false) {}
828  };
829 
831 
832  const double *CalcVertexPos(int node) const;
833 
834 
835  // utility
836 
837  int GetEdgeMaster(int node) const;
838 
839  void FindFaceNodes(int face, int node[4]);
840 
841  int EdgeSplitLevel(int vn1, int vn2) const;
842  int TriFaceSplitLevel(int vn1, int vn2, int vn3) const;
843  void QuadFaceSplitLevel(int vn1, int vn2, int vn3, int vn4,
844  int& h_level, int& v_level) const;
845 
846  void CountSplits(int elem, int splits[3]) const;
847  void GetLimitRefinements(Array<Refinement> &refinements, int max_level);
848 
849  int PrintElements(std::ostream &out, int elem, int &coarse_id) const;
850  void CopyElements(int elem, const BlockArray<Element> &tmp_elements,
851  Array<int> &index_map);
852 
853  // geometry
854 
855  /** This holds in one place the constants about the geometries we support
856  (triangles, quads, cubes) */
857  struct GeomInfo
858  {
859  int nv, ne, nf; // number of: vertices, edges, faces
860  int edges[12][2]; // edge vertices (up to 12 edges)
861  int faces[6][4]; // face vertices (up to 6 faces)
862  int nfv[6]; // number of face vertices
863 
865  GeomInfo() : initialized(false) {}
866  void Initialize(const mfem::Element* elem);
867  };
868 
870 
871 #ifdef MFEM_DEBUG
872 public:
873  void DebugLeafOrder(std::ostream &out) const;
874  void DebugDump(std::ostream &out) const;
875 #endif
876 
877  friend class ParNCMesh; // for ParNCMesh::ElementSet
878  friend struct MatrixMap;
879  friend struct PointMatrixHash;
880 };
881 
882 }
883 
884 #endif
NCList face_list
lazy-initialized list of faces, see GetFaceList
Definition: ncmesh.hpp:501
void CollectLeafElements(int elem, int state)
Definition: ncmesh.cpp:1874
NCList edge_list
lazy-initialized list of edges, see GetEdgeList
Definition: ncmesh.hpp:502
NCMesh(const Mesh *mesh, std::istream *vertex_parents=NULL)
Definition: ncmesh.cpp:72
int Size() const
Return the logical size of the array.
Definition: array.hpp:124
static void GridSfcOrdering3D(int width, int height, int depth, Array< int > &coords)
Definition: ncmesh.cpp:4496
void CheckAnisoPrism(int vn1, int vn2, int vn3, int vn4, const Refinement *refs, int nref)
Definition: ncmesh.cpp:731
CoarseFineTransformations transforms
storage for data returned by Get[De]RefinementTransforms()
Definition: ncmesh.hpp:812
static void GridSfcOrdering2D(int width, int height, Array< int > &coords)
Definition: ncmesh.cpp:4481
int NewQuadrilateral(int n0, int n1, int n2, int n3, int attr, int eattr0, int eattr1, int eattr2, int eattr3)
Definition: ncmesh.cpp:550
int elem[2]
up to 2 elements sharing the face
Definition: ncmesh.hpp:424
char ref_type
refinement XYZ bit mask (7 = full isotropic)
Definition: ncmesh.hpp:38
int GetFaceVerticesEdges(const MeshId &face_id, int vert_index[4], int edge_index[4], int edge_orientation[4]) const
Definition: ncmesh.cpp:4559
TmpVertex * tmp_vertex
Definition: ncmesh.hpp:830
Array< double > top_vertex_pos
coordinates of top-level vertices (organized as triples)
Definition: ncmesh.hpp:477
bool TriFaceSplit(int v1, int v2, int v3, int mid[3]=NULL) const
Definition: ncmesh.cpp:2243
void SetDerefMatrixCodes(int parent, Array< int > &fine_coarse)
Definition: ncmesh.cpp:1837
const CoarseFineTransformations & GetDerefinementTransforms()
Definition: ncmesh.cpp:4060
char flag
generic flag/marker, can be used by algorithms
Definition: ncmesh.hpp:447
bool HasEdge() const
Definition: ncmesh.hpp:409
PointMatrix(const Point &p0, const Point &p1, const Point &p2)
Definition: ncmesh.hpp:765
Array< Triple< int, int, int > > reparents
scheduled node reparents (tmp)
Definition: ncmesh.hpp:538
Point(const Point &p0, const Point &p1)
Definition: ncmesh.hpp:727
static const int NumGeom
Definition: geom.hpp:41
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:4961
Array< Slave > slaves
Definition: ncmesh.hpp:196
void CollectTriFaceVertices(int v0, int v1, int v2, Array< int > &indices)
Definition: ncmesh.cpp:3005
char tet_type
tetrahedron split type, currently always 0
Definition: ncmesh.hpp:446
virtual void LimitNCLevel(int max_nc_level)
Definition: ncmesh.cpp:4946
virtual void Trim()
Save memory by releasing all non-essential and cached data.
Definition: ncmesh.cpp:5184
int index
element number in the Mesh, -1 if refined
Definition: ncmesh.hpp:448
PointMatrix(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
Definition: ncmesh.hpp:768
const Geometry::Type geom
Definition: ex1.cpp:40
Embedding()=default
void CopyElements(int elem, const BlockArray< Element > &tmp_elements, Array< int > &index_map)
Definition: ncmesh.cpp:5071
void ForceRefinement(int vn1, int vn2, int vn3, int vn4)
Definition: ncmesh.cpp:626
virtual int GetNumGhostElements() const
Definition: ncmesh.hpp:525
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:778
Lists all edges/faces in the nonconforming mesh.
Definition: ncmesh.hpp:192
unsigned matrix
index into NCList::point_matrices[geom]
Definition: ncmesh.hpp:182
int NVertices
Definition: ncmesh.hpp:495
int GetNVertices() const
Definition: ncmesh.hpp:117
void GetMeshComponents(Mesh &mesh) const
Fill Mesh::{vertices,elements,boundary} for the current finest level.
Definition: ncmesh.cpp:2042
void ClearTransforms()
Free all internal data created by the above three functions.
Definition: ncmesh.cpp:4233
Table derefinements
possible derefinements, see GetDerefinementTable
Definition: ncmesh.hpp:540
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
Geometry::Type Geom() const
Definition: ncmesh.hpp:160
NCList vertex_list
lazy-initialized list of vertices, see GetVertexList
Definition: ncmesh.hpp:503
void InitDerefTransforms()
Definition: ncmesh.cpp:1822
static PointMatrix pm_prism_identity
Definition: ncmesh.hpp:798
char geom
Geometry::Type of the element (char for storage only)
Definition: ncmesh.hpp:444
BlockArray< Element >::iterator elem_iterator
Definition: ncmesh.hpp:483
void InitRootState(int root_count)
Definition: ncmesh.cpp:1936
long TotalSize() const
Definition: ncmesh.cpp:2923
int GetEdgeNCOrientation(const MeshId &edge_id) const
Definition: ncmesh.cpp:4547
int NewTetrahedron(int n0, int n1, int n2, int n3, int attr, int fattr0, int fattr1, int fattr2, int fattr3)
Definition: ncmesh.cpp:524
void CheckAnisoFace(int vn1, int vn2, int vn3, int vn4, int mid12, int mid34, int level=0)
Definition: ncmesh.cpp:756
virtual int GetNumGhostVertices() const
Definition: ncmesh.hpp:526
static PointMatrix pm_tri_identity
Definition: ncmesh.hpp:795
void FreeElement(int id)
Definition: ncmesh.hpp:556
void CountSplits(int elem, int splits[3]) const
Definition: ncmesh.cpp:4833
Geometry::Type Geom() const
Definition: ncmesh.hpp:460
void CollectDerefinements(int elem, Array< Connection > &list)
Definition: ncmesh.cpp:1709
const Point & operator()(int i) const
Definition: ncmesh.hpp:788
Point & operator()(int i)
Definition: ncmesh.hpp:787
void GetLimitRefinements(Array< Refinement > &refinements, int max_level)
Definition: ncmesh.cpp:4916
int PrintMemoryDetail() const
Definition: ncmesh.cpp:5246
void TraverseEdge(int vn0, int vn1, double t0, double t1, int flags, int level, MatrixMap &matrix_map)
Definition: ncmesh.cpp:2714
double coord[3]
Definition: ncmesh.hpp:714
bool UnrefVertex()
Definition: ncmesh.hpp:412
int spaceDim
dimensions of the elements and the vertex coordinates
Definition: ncmesh.hpp:388
bool HavePrisms() const
Definition: ncmesh.hpp:530
Array< int > vertex_nodeId
Definition: ncmesh.hpp:499
int attribute
boundary element attribute, -1 if internal face
Definition: ncmesh.hpp:422
void DebugDump(std::ostream &out) const
Definition: ncmesh.cpp:5351
void FindFaceNodes(int face, int node[4])
Definition: ncmesh.cpp:4685
Array< int > root_state
Definition: ncmesh.hpp:474
static const PointMatrix & GetGeomIdentity(Geometry::Type geom)
Definition: ncmesh.cpp:3528
static int find_element_edge(const Element &el, int vn0, int vn1, bool abort=true)
Definition: ncmesh.cpp:2280
int index
Mesh element number.
Definition: ncmesh.hpp:37
int master
master number (in Mesh numbering)
Definition: ncmesh.hpp:181
const NCList & GetFaceList()
Return the current list of conforming and nonconforming faces.
Definition: ncmesh.hpp:218
const MeshId & LookUp(int index, int *type=NULL) const
Definition: ncmesh.cpp:2928
virtual void OnMeshUpdated(Mesh *mesh)
Definition: ncmesh.cpp:2130
void DebugLeafOrder(std::ostream &out) const
Definition: ncmesh.cpp:5326
A parallel extension of the NCMesh class.
Definition: pncmesh.hpp:64
int NewWedge(int n0, int n1, int n2, int n3, int n4, int n5, int attr, int fattr0, int fattr1, int fattr2, int fattr3, int fattr4)
Definition: ncmesh.cpp:492
void CollectEdgeVertices(int v0, int v1, Array< int > &indices)
Definition: ncmesh.cpp:2993
static int find_local_face(int geom, int a, int b, int c)
Definition: ncmesh.cpp:2298
Array< Refinement > ref_stack
stack of scheduled refinements (temporary)
Definition: ncmesh.hpp:536
bool Empty() const
Definition: ncmesh.hpp:206
Point(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
Definition: ncmesh.hpp:736
void CollectIncidentElements(int elem, const RefCoord coord[3], Array< int > &list) const
Definition: ncmesh.cpp:3444
void ReferenceElement(int elem)
Definition: ncmesh.cpp:312
virtual bool IsGhost(const Element &el) const
Definition: ncmesh.hpp:524
void GetPointMatrix(Geometry::Type geom, const char *ref_path, DenseMatrix &matrix)
Definition: ncmesh.cpp:3543
void CheckIsoFace(int vn1, int vn2, int vn3, int vn4, int en1, int en2, int en3, int en4, int midf)
Definition: ncmesh.cpp:851
void InitGeomFlags()
Definition: ncmesh.cpp:213
Face * GetFace(Element &elem, int face_no)
Definition: ncmesh.cpp:425
void TraverseRefinements(int elem, int coarse_index, std::string &ref_path, RefPathMap &map)
Definition: ncmesh.cpp:3977
int GetMidEdgeNode(int node1, int node2)
Definition: ncmesh.cpp:297
Element(Geometry::Type geom, int attr)
Definition: ncmesh.cpp:450
int PrintElements(std::ostream &out, int elem, int &coarse_id) const
Definition: ncmesh.cpp:5031
Refinement(int index, int type=7)
Definition: ncmesh.hpp:42
int index
face number in the Mesh
Definition: ncmesh.hpp:423
const Table & GetDerefinementTable()
Definition: ncmesh.cpp:1742
Table element_vertex
leaf-element to vertex table, see FindSetNeighbors
Definition: ncmesh.hpp:508
DenseTensor point_matrices[Geometry::NumGeom]
Matrices for IsoparametricTransformation organized by Geometry::Type.
Definition: ncmesh.hpp:63
int Append(const T &el)
Append element &#39;el&#39; to array, resize if necessary.
Definition: array.hpp:726
bool operator==(const PointMatrix &pm) const
Definition: ncmesh.cpp:3484
void GetMatrix(DenseMatrix &point_matrix) const
Definition: ncmesh.cpp:3498
int AddElement(const Element &el)
Definition: ncmesh.hpp:545
virtual void Derefine(const Array< int > &derefs)
Definition: ncmesh.cpp:1786
double b
Definition: lissajous.cpp:42
void QuadFaceSplitLevel(int vn1, int vn2, int vn3, int vn4, int &h_level, int &v_level) const
Definition: ncmesh.cpp:4806
void FindNeighbors(int elem, Array< int > &neighbors, const Array< int > *search_set=NULL)
Definition: ncmesh.cpp:3246
Geometry::Type GetElementGeometry(int index) const
Return element geometry type. index is the Mesh element number.
Definition: ncmesh.hpp:323
friend struct MatrixMap
Definition: ncmesh.hpp:878
Array< int > coarse_elements
state of leaf_elements before Refine(), set by MarkCoarseLevel()
Definition: ncmesh.hpp:815
virtual void UpdateVertices()
update Vertex::index and vertex_nodeId
Definition: ncmesh.cpp:1856
void GetCoarseToFineMap(const Mesh &fine_mesh, Table &coarse_to_fine, Array< int > &coarse_to_ref_type, Table &ref_type_to_matrix, Array< Geometry::Type > &ref_type_to_geom) const
Definition: ncmesh.cpp:4149
int ReorderFacePointMat(int v0, int v1, int v2, int v3, int elem, const PointMatrix &pm, PointMatrix &reordered) const
Definition: ncmesh.cpp:2376
Master(int index, int element, int local, int geom, int sb, int se)
Definition: ncmesh.hpp:173
Array< DenseMatrix * > point_matrices[Geometry::NumGeom]
List of unique point matrices for each slave geometry.
Definition: ncmesh.hpp:199
void RegisterFaces(int elem, int *fattr=NULL)
Definition: ncmesh.cpp:386
Array< Embedding > embeddings
Fine element positions in their parents.
Definition: ncmesh.hpp:65
virtual void BuildEdgeList()
Definition: ncmesh.cpp:2742
const CoarseFineTransformations & GetRefinementTransforms()
Definition: ncmesh.cpp:4009
void LoadCoarseElements(std::istream &input)
I/O: Load the element refinement hierarchy from a mesh file.
Definition: ncmesh.cpp:5091
Identifies a vertex/edge/face in both Mesh and NCMesh.
Definition: ncmesh.hpp:153
int FindMidEdgeNode(int node1, int node2) const
Definition: ncmesh.cpp:281
int parent
parent element, -1 if this is a root element, -2 if free
Definition: ncmesh.hpp:456
void MarkCoarseLevel()
Definition: ncmesh.cpp:3963
signed char local
local number within &#39;element&#39;
Definition: ncmesh.hpp:157
virtual void ElementSharesFace(int elem, int local, int face)
Definition: ncmesh.hpp:654
int GetNumRootElements()
Return the number of root elements.
Definition: ncmesh.hpp:331
virtual void ElementSharesVertex(int elem, int local, int vnode)
Definition: ncmesh.hpp:656
int Size() const
Returns the number of TYPE I elements.
Definition: table.hpp:92
A class for non-conforming AMR on higher-order hexahedral, prismatic, quadrilateral or triangular mes...
Definition: ncmesh.hpp:102
int GetElementSizeReduction(int i) const
Definition: ncmesh.cpp:4650
virtual ~NCMesh()
Definition: ncmesh.cpp:234
friend struct PointMatrixHash
Definition: ncmesh.hpp:879
int GetNFaces() const
Definition: ncmesh.hpp:119
virtual void GetBoundaryClosure(const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges)
Definition: ncmesh.cpp:4709
int element
NCMesh::Element containing this vertex/edge/face.
Definition: ncmesh.hpp:156
Embedding(int elem, int matrix=0)
Definition: ncmesh.hpp:56
Geometry::Type GetFaceGeometry(int index) const
Return face geometry type. index is the Mesh face number.
Definition: ncmesh.hpp:327
static GeomInfo GI[Geometry::NumGeom]
Definition: ncmesh.hpp:869
HashTable< Node >::iterator node_iterator
Definition: ncmesh.hpp:479
int slaves_end
slave faces
Definition: ncmesh.hpp:170
NCMesh::RefCoord RefCoord
void ReparentNode(int node, int new_p1, int new_p2)
Definition: ncmesh.cpp:265
int NewTriangle(int n0, int n1, int n2, int attr, int eattr0, int eattr1, int eattr2)
Definition: ncmesh.cpp:576
void DeleteUnusedFaces(const Array< int > &elemFaces)
Definition: ncmesh.cpp:400
bool Iso
true if the mesh only contains isotropic refinements
Definition: ncmesh.hpp:389
Point(double x, double y, double z)
Definition: ncmesh.hpp:724
bool HasVertex() const
Definition: ncmesh.hpp:408
std::map< std::string, int > RefPathMap
Definition: ncmesh.hpp:806
int SpaceDimension() const
Definition: ncmesh.hpp:115
virtual void BuildFaceList()
Definition: ncmesh.cpp:2622
Nonconforming edge/face within a bigger edge/face.
Definition: ncmesh.hpp:179
void DerefineElement(int elem)
Definition: ncmesh.cpp:1583
void GetElementFacesAttributes(int i, Array< int > &faces, Array< int > &fattr) const
Return the faces and face attributes of leaf element &#39;i&#39;.
Definition: ncmesh.cpp:4664
void SetVertexPositions(const Array< mfem::Vertex > &vertices)
I/O: Set positions of all vertices (used by mesh loader).
Definition: ncmesh.cpp:5010
HashTable< Node >::const_iterator node_const_iterator
Definition: ncmesh.hpp:481
const NCList & GetVertexList()
Definition: ncmesh.hpp:233
bool Boundary() const
Definition: ncmesh.hpp:428
Point(double x)
Definition: ncmesh.hpp:718
void RegisterElement(int e)
Definition: ncmesh.cpp:411
mfem::Element * NewMeshElement(int geom) const
Definition: ncmesh.cpp:1999
PointMatrix(const Point &p0, const Point &p1, const Point &p2, const Point &p3, const Point &p4, const Point &p5)
Definition: ncmesh.hpp:771
void DeleteLast()
Delete the last entry of the array.
Definition: array.hpp:179
void UpdateLeafElements()
Definition: ncmesh.cpp:1916
int TriFaceSplitLevel(int vn1, int vn2, int vn3) const
Definition: ncmesh.cpp:4789
int GetNEdges() const
Definition: ncmesh.hpp:118
int RetrieveNode(const Element &el, int index)
Return el.node[index] correctly, even if the element is refined.
Definition: ncmesh.cpp:1547
int Geoms
bit mask of element geometries present, see InitGeomFlags()
Definition: ncmesh.hpp:390
PointMatrix(const Point &p0, const Point &p1)
Definition: ncmesh.hpp:762
long MemoryUsage() const
Definition: ncmesh.cpp:5196
void BuildElementToVertexTable()
Definition: ncmesh.cpp:3063
HashTable< Node > nodes
Definition: ncmesh.hpp:465
double a
Definition: lissajous.cpp:41
void ForgetElement(int e)
Definition: ncmesh.cpp:418
static PointMatrix pm_tet_identity
Definition: ncmesh.hpp:797
int GetMidFaceNode(int en1, int en2, int en3, int en4)
Definition: ncmesh.cpp:304
void RefineElement(int elem, char ref_type)
Definition: ncmesh.cpp:868
int NewHexahedron(int n0, int n1, int n2, int n3, int n4, int n5, int n6, int n7, int attr, int fattr0, int fattr1, int fattr2, int fattr3, int fattr4, int fattr5)
Definition: ncmesh.cpp:462
void TraverseTetEdge(int vn0, int vn1, const Point &p0, const Point &p1, MatrixMap &matrix_map)
Definition: ncmesh.cpp:2526
Array< int > boundary_faces
subset of all faces, set by BuildFaceList
Definition: ncmesh.hpp:505
int child[8]
2-8 children (if ref_type != 0)
Definition: ncmesh.hpp:454
const NCList & GetNCList(int entity)
Return vertex/edge/face list (entity = 0/1/2, respectively).
Definition: ncmesh.hpp:240
Array< int > leaf_elements
Definition: ncmesh.hpp:498
static PointMatrix pm_quad_identity
Definition: ncmesh.hpp:796
Array< Master > masters
Definition: ncmesh.hpp:195
int EdgeSplitLevel(int vn1, int vn2) const
Definition: ncmesh.cpp:4782
Array< MeshId > conforming
Definition: ncmesh.hpp:194
unsigned edge_flags
orientation flags, see OrientedPointMatrix
Definition: ncmesh.hpp:183
void Initialize(const mfem::Element *elem)
Definition: ncmesh.cpp:30
void FindVertexCousins(int elem, int local, Array< int > &cousins) const
Definition: ncmesh.cpp:3467
signed char geom
Geometry::Type (faces only) (char to save RAM)
Definition: ncmesh.hpp:158
int QuadFaceSplitType(int v1, int v2, int v3, int v4, int mid[5]=NULL) const
Definition: ncmesh.cpp:2196
void OrientedPointMatrix(const Slave &slave, DenseMatrix &oriented_matrix) const
Return the point matrix oriented according to the master and slave edges.
Definition: ncmesh.cpp:2883
Array< int > free_element_ids
Definition: ncmesh.hpp:469
void TraverseQuadFace(int vn0, int vn1, int vn2, int vn3, const PointMatrix &pm, int level, Face *eface[4], MatrixMap &matrix_map)
Definition: ncmesh.cpp:2407
int index(int i, int j, int nx, int ny)
Definition: life.cpp:241
int parent
Element index in the coarse mesh.
Definition: ncmesh.hpp:49
Point(double x, double y)
Definition: ncmesh.hpp:721
virtual void AssignLeafIndices()
Definition: ncmesh.cpp:1927
static PointMatrix pm_hex_identity
Definition: ncmesh.hpp:799
int Dimension() const
Definition: ncmesh.hpp:114
void FindEdgeElements(int vn1, int vn2, int vn3, int vn4, Array< MeshId > &prisms) const
Definition: ncmesh.cpp:684
virtual void CheckDerefinementNCLevel(const Table &deref_table, Array< int > &level_ok, int max_nc_level)
Definition: ncmesh.cpp:1757
T & Last()
Return the last element in the array.
Definition: array.hpp:759
void NeighborExpand(const Array< int > &elems, Array< int > &expanded, const Array< int > *search_set=NULL)
Definition: ncmesh.cpp:3329
BlockArray< Element > elements
Definition: ncmesh.hpp:468
void FindSetNeighbors(const Array< char > &elem_set, Array< int > *neighbors, Array< char > *neighbor_set=NULL)
Definition: ncmesh.cpp:3143
void GetEdgeVertices(const MeshId &edge_id, int vert_index[2], bool oriented=true) const
Return Mesh vertex indices of an edge identified by &#39;edge_id&#39;.
Definition: ncmesh.cpp:4528
virtual void Update()
Definition: ncmesh.cpp:222
Slave(int index, int element, int local, int geom)
Definition: ncmesh.hpp:186
bool HaveTets() const
Definition: ncmesh.hpp:531
Data type point element.
Definition: point.hpp:22
long MemoryUsage() const
Return total number of bytes allocated.
Definition: ncmesh.cpp:5224
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:5057
HashTable< Node > shadow
temporary storage for reparented nodes
Definition: ncmesh.hpp:537
Defines the coarse-fine transformations of all fine elements.
Definition: ncmesh.hpp:60
virtual void BuildVertexList()
Definition: ncmesh.cpp:2848
const NCList & GetEdgeList()
Return the current list of conforming and nonconforming edges.
Definition: ncmesh.hpp:225
void UpdateElementToVertexTable()
Definition: ncmesh.hpp:694
virtual void ElementSharesEdge(int elem, int local, int enode)
Definition: ncmesh.hpp:655
MeshId(int index=-1, int element=-1, int local=-1, int geom=-1)
Definition: ncmesh.hpp:162
int GetElementDepth(int i) const
Return the distance of leaf &#39;i&#39; from the root.
Definition: ncmesh.cpp:4638
HashTable< Face >::iterator face_iterator
Definition: ncmesh.hpp:480
int FindNodeExt(const Element &el, int node, bool abort=true)
Extended version of find_node: works if &#39;el&#39; is refined.
Definition: ncmesh.cpp:2270
char ref_type
bit mask of X,Y,Z refinements (bits 0,1,2 respectively)
Definition: ncmesh.hpp:445
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition: globals.hpp:66
void CollectQuadFaceVertices(int v0, int v1, int v2, int v3, Array< int > &indices)
Definition: ncmesh.cpp:3029
bool Unused() const
Definition: ncmesh.hpp:429
static int find_node(const Element &el, int node)
Definition: ncmesh.cpp:2260
void UnreferenceElement(int elem, Array< int > &elemFaces)
Definition: ncmesh.cpp:343
int index
Mesh number.
Definition: ncmesh.hpp:155
void LoadVertexParents(std::istream &input)
Definition: ncmesh.cpp:4988
Rank 3 tensor (array of matrices)
Definition: densemat.hpp:728
Abstract data type element.
Definition: element.hpp:28
Point & operator=(const Point &src)
Definition: ncmesh.hpp:747
Refinement()=default
void PrintStats(std::ostream &out=mfem::out) const
Definition: ncmesh.cpp:5272
int GetSingleElement() const
Return one of elem[0] or elem[1] and make sure the other is -1.
Definition: ncmesh.cpp:433
const double * CalcVertexPos(int node) const
Definition: ncmesh.cpp:2013
int rank
processor number (ParNCMesh), -1 if undefined/unknown
Definition: ncmesh.hpp:449
int node[8]
element corners (if ref_type == 0)
Definition: ncmesh.hpp:453
int GetVertexRootCoord(int elem, RefCoord coord[3]) const
Definition: ncmesh.cpp:3396
bool TraverseTriFace(int vn0, int vn1, int vn2, const PointMatrix &pm, int level, MatrixMap &matrix_map)
Definition: ncmesh.cpp:2563
HashTable< Face > faces
Definition: ncmesh.hpp:466
Defines the position of a fine element within a coarse element.
Definition: ncmesh.hpp:46
HashTable< Face >::const_iterator face_const_iterator
Definition: ncmesh.hpp:482
virtual void Refine(const Array< Refinement > &refinements)
Definition: ncmesh.cpp:1501
int matrix
Index into the DenseTensor corresponding to the parent Geometry::Type stored in CoarseFineTransformat...
Definition: ncmesh.hpp:52
int64_t RefCoord
Definition: ncmesh.hpp:371
Array< char > face_geom
face geometry by face index, set by OnMeshUpdated
Definition: ncmesh.hpp:506
int GetEdgeMaster(int v1, int v2) const
Definition: ncmesh.cpp:4629