MFEM  v4.1.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
pncmesh.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_PNCMESH
13 #define MFEM_PNCMESH
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 
19 #include <map>
20 #include <set>
21 
22 #include "ncmesh.hpp"
23 #include "../general/communication.hpp"
24 #include "../general/sort_pairs.hpp"
25 
26 namespace mfem
27 {
28 
29 class FiniteElementSpace;
30 
31 
32 /** \brief A parallel extension of the NCMesh class.
33  *
34  * The basic idea (and assumption) is that all processors share the coarsest
35  * layer ("root elements"). This has the advantage that refinements can easily
36  * be exchanged between processors when rebalancing since individual elements
37  * can be uniquely identified by the index of the root element and a path in
38  * the refinement tree.
39  *
40  * Each leaf element is owned by one of the processors (NCMesh::Element::rank).
41  * The underlying NCMesh stores not only elements for the current ('MyRank')
42  * processor, but also a minimal layer of adjacent "ghost" elements owned by
43  * other processors. The ghost layer is synchronized after refinement.
44  *
45  * The ghost layer contains all vertex-, edge- and face-neighbors of the
46  * current processor's region. It is used to determine constraining relations
47  * and ownership of DOFs on the processor boundary. Ghost elements are never
48  * seen by the rest of MFEM as they are skipped when a Mesh is created from
49  * the NCMesh.
50  *
51  * The processor that owns a vertex, edge or a face (and in turn its DOFs) is
52  * currently defined to be the one with the lowest rank in the group of
53  * processors that share the entity.
54  *
55  * Vertices, edges and faces that are not owned by this ('MyRank') processor
56  * are ghosts, and are numbered after all real vertices/edges/faces, i.e.,
57  * they have indices greater than NVertices, NEdges, NFaces, respectively.
58  *
59  * A shared vertex/edge/face is identified in an interprocessor message by a
60  * pair of numbers. The first number specifies an element in an ElementSet
61  * (typically sent at the beginning of the message) that contains the v/e/f.
62  * The second number is the local index of the v/e/f in that element.
63  */
64 class ParNCMesh : public NCMesh
65 {
66 public:
67  ParNCMesh(MPI_Comm comm, const NCMesh& ncmesh, int* part = NULL);
68 
69  ParNCMesh(const ParNCMesh &other);
70 
71  virtual ~ParNCMesh();
72 
73  /** An override of NCMesh::Refine, which is called eventually, after making
74  sure that refinements that occur on the processor boundary are sent to
75  the neighbor processors so they can keep their ghost layers up to date.*/
76  virtual void Refine(const Array<Refinement> &refinements);
77 
78  /// Parallel version of NCMesh::LimitNCLevel.
79  virtual void LimitNCLevel(int max_nc_level);
80 
81  /** Parallel version of NCMesh::CheckDerefinementNCLevel. */
82  virtual void CheckDerefinementNCLevel(const Table &deref_table,
83  Array<int> &level_ok, int max_nc_level);
84 
85  /** Parallel reimplementation of NCMesh::Derefine, keeps ghost layers
86  in sync. The interface is identical. */
87  virtual void Derefine(const Array<int> &derefs);
88 
89  /** Migrate leaf elements of the global refinement hierarchy (including ghost
90  elements) so that each processor owns the same number of leaves (+-1).
91  The default partitioning strategy is based on equal splitting of the
92  space-filling sequence of leaf elements (custom_partition == NULL).
93  Alternatively, a used-defined element-rank assignment array can be
94  passed. */
95  void Rebalance(const Array<int> *custom_partition = NULL);
96 
97 
98  // interface for ParFiniteElementSpace
99 
100  int GetNElements() const { return NElements; }
101 
102  int GetNGhostVertices() const { return NGhostVertices; }
103  int GetNGhostEdges() const { return NGhostEdges; }
104  int GetNGhostFaces() const { return NGhostFaces; }
105  int GetNGhostElements() const { return NGhostElements; }
106 
107  // Return a list of vertices/edges/faces shared by this processor and at
108  // least one other processor. These are subsets of NCMesh::<entity>_list. */
112 
113  /// Helper to get shared vertices/edges/faces ('entity' == 0/1/2 resp.).
114  const NCList& GetSharedList(int entity)
115  {
116  switch (entity)
117  {
118  case 0: return GetSharedVertices();
119  case 1: return GetSharedEdges();
120  default: return GetSharedFaces();
121  }
122  }
123 
124  /// Return (shared) face orientation relative to its owner element.
125  int GetFaceOrientation(int index) const
126  {
127  return (index < NFaces) ? face_orient[index] : 0;
128  }
129 
130  typedef short GroupId;
131  typedef std::vector<int> CommGroup;
132 
133  /// Return vertex/edge/face ('entity' == 0/1/2, resp.) owner.
134  GroupId GetEntityOwnerId(int entity, int index)
135  {
136  MFEM_ASSERT(entity >= 0 && entity < 3, "");
137  MFEM_ASSERT(index >= 0, "");
138  if (!entity_owner[entity].Size())
139  {
140  GetSharedList(entity);
141  }
142  return entity_owner[entity][index];
143  }
144 
145  /** Return the P matrix communication group ID for a vertex/edge/face.
146  The groups are calculated specifically to match the P matrix
147  construction algorithm and its communication pattern. */
148  GroupId GetEntityGroupId(int entity, int index)
149  {
150  MFEM_ASSERT(entity >= 0 && entity < 3, "");
151  MFEM_ASSERT(index >= 0, "");
152  if (!entity_pmat_group[entity].Size())
153  {
155  }
156  return entity_pmat_group[entity][index];
157  }
158 
159  /// Return a list of ranks contained in the group of the given ID.
160  const CommGroup& GetGroup(GroupId id) const
161  {
162  MFEM_ASSERT(id >= 0, "");
163  return groups[id];
164  }
165 
166  /// Return true if group 'id' contains the given rank.
167  bool GroupContains(GroupId id, int rank) const;
168 
169  /// Return true if the specified vertex/edge/face is a ghost.
170  bool IsGhost(int entity, int index) const
171  {
172  if (index < 0) // special case prism edge-face constraint
173  {
174  MFEM_ASSERT(entity == 2, "");
175  entity = 1;
176  index = -1 - index;
177  }
178  switch (entity)
179  {
180  case 0: return index >= NVertices;
181  case 1: return index >= NEdges;
182  default: return index >= NFaces;
183  }
184  }
185 
186  /** Returns owner processor for element 'index'. This is normally MyRank but
187  for index >= NElements (i.e., for ghosts) it may be something else. */
188  int ElementRank(int index) const
189  {
190  return elements[leaf_elements[index]].rank;
191  }
192 
193 
194  // utility
195 
196  int GetMyRank() const { return MyRank; }
197 
198  /// Use the communication pattern from last Rebalance() to send element DOFs.
199  void SendRebalanceDofs(int old_ndofs, const Table &old_element_dofs,
200  long old_global_offset, FiniteElementSpace* space);
201 
202  /// Receive element DOFs sent by SendRebalanceDofs().
204 
205  /** Get previous indices (pre-Rebalance) of current elements. Index of -1
206  indicates that an element didn't exist in the mesh before. */
208 
209  /** Get previous (pre-Derefine) fine element ranks. This complements the
210  CoarseFineTransformations::embeddings array in parallel. */
212 
213  /** Exchange element data for derefinements that straddle processor
214  boundaries. 'elem_data' is enlarged and filled with ghost values. */
215  template<typename Type>
217  const Table &deref_table);
218 
219  /** Extension of NCMesh::GetBoundaryClosure. Filters out ghost vertices and
220  ghost edges from 'bdr_vertices' and 'bdr_edges'. */
221  virtual void GetBoundaryClosure(const Array<int> &bdr_attr_is_ess,
222  Array<int> &bdr_vertices,
223  Array<int> &bdr_edges);
224 
225  /// Save memory by releasing all non-essential and cached data.
226  virtual void Trim();
227 
228  /// Return total number of bytes allocated.
229  long MemoryUsage(bool with_base = true) const;
230 
231  int PrintMemoryDetail(bool with_base = true) const;
232 
233  /** Extract a debugging Mesh containing all leaf elements, including ghosts.
234  The debug mesh will have element attributes set to element rank + 1. */
235  void GetDebugMesh(Mesh &debug_mesh) const;
236 
237 
238 protected: // interface for ParMesh
239 
240  friend class ParMesh;
241 
242  /** For compatibility with conforming code in ParMesh and ParFESpace.
243  Initializes shared structures in ParMesh: gtopo, shared_*, group_s*, s*_l*.
244  The ParMesh then acts as a parallel mesh cut along the NC interfaces. */
245  void GetConformingSharedStructures(class ParMesh &pmesh);
246 
247  /** Populate face neighbor members of ParMesh from the ghost layer, without
248  communication. */
249  void GetFaceNeighbors(class ParMesh &pmesh);
250 
251 
252 protected: // implementation
253 
254  MPI_Comm MyComm;
256 
259 
260  typedef std::vector<CommGroup> GroupList;
261  typedef std::map<CommGroup, GroupId> GroupMap;
262 
263  GroupList groups; // comm group list; NOTE: groups[0] = { MyRank }
264  GroupMap group_id; // search index over groups
265 
266  // owner rank for each vertex, edge and face (encoded as singleton group)
268  // P matrix comm pattern groups for each vertex/edge/face (0/1/2)
270 
271  // ParMesh-compatible (conforming) groups for each vertex/edge/face (0/1/2)
273  // ParMesh compatibility helper arrays to order groups, also temporary
275 
276  // lists of vertices/edges/faces shared by us and at least one more processor
278 
279  Array<char> face_orient; // see CalcFaceOrientations
280 
281  /** Type of each leaf element:
282  1 - our element (rank == MyRank),
283  3 - our element, and neighbor to the ghost layer,
284  2 - ghost layer element (existing element, but rank != MyRank),
285  0 - element beyond the ghost layer, may not be a real element.
286  Note: indexed by Element::index. See also UpdateLayers(). */
288 
289  Array<int> ghost_layer; ///< list of elements whose 'element_type' == 2.
290  Array<int> boundary_layer; ///< list of type 3 elements
291 
292  virtual void Update();
293 
294  virtual bool IsGhost(const Element& el) const
295  { return el.rank != MyRank; }
296 
297  virtual int GetNumGhostElements() const { return NGhostElements; }
298  virtual int GetNumGhostVertices() const { return NGhostVertices; }
299 
300  /// Return the processor number for a global element number.
301  int Partition(long index, long total_elements) const
302  { return index * NRanks / total_elements; }
303 
304  /// Helper to get the partitioning when the serial mesh gets split initially
305  int InitialPartition(int index) const
306  { return Partition(index, leaf_elements.Size()); }
307 
308  /// Return the global index of the first element owned by processor 'rank'.
309  long PartitionFirstIndex(int rank, long total_elements) const
310  { return (rank * total_elements + NRanks-1) / NRanks; }
311 
312  virtual void UpdateVertices();
313  virtual void AssignLeafIndices();
314  virtual void OnMeshUpdated(Mesh *mesh);
315 
316  virtual void BuildFaceList();
317  virtual void BuildEdgeList();
318  virtual void BuildVertexList();
319 
320  virtual void ElementSharesFace(int elem, int local, int face);
321  virtual void ElementSharesEdge(int elem, int local, int enode);
322  virtual void ElementSharesVertex(int elem, int local, int vnode);
323 
324  GroupId GetGroupId(const CommGroup &group);
325  GroupId GetSingletonGroup(int rank);
326 
327  Array<int> tmp_owner; // temporary
330 
331  void InitOwners(int num, Array<GroupId> &entity_owner);
332  void MakeSharedList(const NCList &list, NCList &shared);
333 
334  void AddConnections(int entity, int index, const Array<int> &ranks);
335  void CalculatePMatrixGroups();
336  void CreateGroups(int nentities, Array<Connection> &index_rank,
337  Array<GroupId> &entity_group);
338 
339  static int get_face_orientation(Face &face, Element &e1, Element &e2,
340  int local[2] = NULL /* optional output */);
341  void CalcFaceOrientations();
342 
343  void UpdateLayers();
344 
345  void MakeSharedTable(int ngroups, int ent, Array<int> &shared_local,
346  Table &group_shared, Array<char> *entity_geom = NULL,
347  char geom = 0);
348 
349  /** Uniquely encodes a set of leaf elements in the refinement hierarchy of
350  an NCMesh. Can be dumped to a stream, sent to another processor, loaded,
351  and decoded to identify the same set of elements (refinements) in a
352  different but compatible NCMesh. The encoding can optionally include
353  the refinement types needed to reach the leaves, so the element set can
354  be decoded (recreated) even if the receiver has an incomplete tree. */
356  {
357  public:
358  ElementSet(NCMesh *ncmesh = NULL, bool include_ref_types = false)
359  : ncmesh(ncmesh), include_ref_types(include_ref_types) {}
360  ElementSet(const ElementSet &other);
361 
362  void Encode(const Array<int> &elements);
363  void Dump(std::ostream &os) const;
364 
365  void Load(std::istream &is);
366  void Decode(Array<int> &elements) const;
367 
368  void SetNCMesh(NCMesh *ncmesh) { this->ncmesh = ncmesh; }
369  const NCMesh* GetNCMesh() const { return ncmesh; }
370 
371  protected:
372  Array<unsigned char> data; ///< encoded refinement (sub-)trees
375 
376  void EncodeTree(int elem);
377  void DecodeTree(int elem, int &pos, Array<int> &elements) const;
378 
379  void WriteInt(int value);
380  int GetInt(int pos) const;
381  void FlagElements(const Array<int> &elements, char flag);
382 
383 #ifdef MFEM_DEBUG
385  std::string RefPath() const;
386 #endif
387  };
388 
389  /** Adjust some of the MeshIds before encoding for recipient 'rank', so that
390  they only reference elements that exist in the recipient's ref. tree. */
391  void AdjustMeshIds(Array<MeshId> ids[], int rank);
392 
393  void ChangeVertexMeshIdElement(NCMesh::MeshId &id, int elem);
394  void ChangeEdgeMeshIdElement(NCMesh::MeshId &id, int elem);
395  void ChangeRemainingMeshIds(Array<MeshId> &ids, int pos,
396  const Array<Pair<int, int> > &find);
397 
398  // Write/read a processor-independent encoding of vertex/edge/face IDs.
399  void EncodeMeshIds(std::ostream &os, Array<MeshId> ids[]);
400  void DecodeMeshIds(std::istream &is, Array<MeshId> ids[]);
401 
402  // Write/read comm groups and a list of their IDs.
403  void EncodeGroups(std::ostream &os, const Array<GroupId> &ids);
404  void DecodeGroups(std::istream &is, Array<GroupId> &ids);
405 
406  bool CheckElementType(int elem, int type);
407 
408  Array<int> tmp_neighbors; // temporary, used by ElementNeighborProcessors
409 
410  /** Return a list of processors that own elements in the immediate
411  neighborhood of 'elem' (i.e., vertex, edge and face neighbors),
412  and are not 'MyRank'. */
413  void ElementNeighborProcessors(int elem, Array<int> &ranks);
414 
415  /** Get a list of ranks that own elements in the neighborhood of our region.
416  NOTE: MyRank is not included. */
417  void NeighborProcessors(Array<int> &neighbors);
418 
419  /** Traverse the (local) refinement tree and determine which subtrees are
420  no longer needed, i.e., their leaves are not owned by us nor are they our
421  ghosts. These subtrees are then derefined. */
422  void Prune();
423 
424  /// Internal. Recursive part of Prune().
425  bool PruneTree(int elem);
426 
427 
428  /** A base for internal messages used by Refine(), Derefine() and Rebalance().
429  * Allows sending values associated with elements in a set.
430  * If RefType == true, the element set is recreated on the receiving end.
431  */
432  template<class ValueType, bool RefTypes, int Tag>
433  class ElementValueMessage : public VarMessage<Tag>
434  {
435  public:
436  using VarMessage<Tag>::data;
437  std::vector<int> elements;
438  std::vector<ValueType> values;
439 
440  int Size() const { return elements.size(); }
441  void Reserve(int size) { elements.reserve(size); values.reserve(size); }
442 
443  void Add(int elem, ValueType val)
444  { elements.push_back(elem); values.push_back(val); }
445 
446  /// Set pointer to ParNCMesh (needed to encode the message).
447  void SetNCMesh(ParNCMesh* pncmesh) { this->pncmesh = pncmesh; }
448 
450 
451  protected:
453 
454  virtual void Encode(int);
455  virtual void Decode(int);
456  };
457 
458  /** Used by ParNCMesh::Refine() to inform neighbors about refinements at
459  * the processor boundary. This keeps their ghost layers synchronized.
460  */
461  class NeighborRefinementMessage : public ElementValueMessage<char, false, 289>
462  {
463  public:
464  void AddRefinement(int elem, char ref_type) { Add(elem, ref_type); }
465  typedef std::map<int, NeighborRefinementMessage> Map;
466  };
467 
468  /** Used by ParNCMesh::Derefine() to keep the ghost layers synchronized.
469  */
470  class NeighborDerefinementMessage : public ElementValueMessage<int, false, 290>
471  {
472  public:
473  void AddDerefinement(int elem, int rank) { Add(elem, rank); }
474  typedef std::map<int, NeighborDerefinementMessage> Map;
475  };
476 
477  /** Used in Step 2 of Rebalance() to synchronize new rank assignments in
478  * the ghost layer.
479  */
480  class NeighborElementRankMessage : public ElementValueMessage<int, false, 156>
481  {
482  public:
483  void AddElementRank(int elem, int rank) { Add(elem, rank); }
484  typedef std::map<int, NeighborElementRankMessage> Map;
485  };
486 
487  /** Used by Rebalance() to send elements and their ranks. Note that
488  * RefTypes == true which means the refinement hierarchy will be recreated
489  * on the receiving side.
490  */
491  class RebalanceMessage : public ElementValueMessage<int, true, 157>
492  {
493  public:
494  void AddElementRank(int elem, int rank) { Add(elem, rank); }
495  typedef std::map<int, RebalanceMessage> Map;
496  };
497 
498  /** Allows migrating element data (DOFs) after Rebalance().
499  * Used by SendRebalanceDofs and RecvRebalanceDofs.
500  */
501  class RebalanceDofMessage : public VarMessage<158>
502  {
503  public:
504  std::vector<int> elem_ids, dofs;
506 
507  void SetElements(const Array<int> &elems, NCMesh *ncmesh);
508  void SetNCMesh(NCMesh* ncmesh) { eset.SetNCMesh(ncmesh); }
509  long MemoryUsage() const;
510 
511  typedef std::map<int, RebalanceDofMessage> Map;
512 
513  protected:
515 
516  virtual void Encode(int);
517  virtual void Decode(int);
518  };
519 
520  /** Assign new Element::rank to leaf elements and send them to their new
521  owners, keeping the ghost layer up to date. Used by Rebalance() and
522  Derefine(). 'target_elements' is the number of elements this rank
523  is supposed to own after the exchange. If this number is not known
524  a priori, the parameter can be set to -1, but more expensive communication
525  (synchronous sends and a barrier) will be used in that case. */
526  void RedistributeElements(Array<int> &new_ranks, int target_elements,
527  bool record_comm);
528 
529  /** Recorded communication pattern from last Rebalance. Used by
530  Send/RecvRebalanceDofs to ship element DOFs. */
533 
534  /** After Rebalance, this array holds the old element indices, or -1 if an
535  element didn't exist in the mesh previously. After Derefine, it holds
536  the ranks of the old (potentially non-existent) fine elements. */
538 
539  /// Stores modified point matrices created by GetFaceNeighbors
541  void ClearAuxPM();
542 
543  long GroupsMemoryUsage() const;
544 
545  friend class NeighborRowMessage;
546 };
547 
548 
549 
550 // comparison operator so that MeshId can be used as key in std::map
551 inline bool operator< (const NCMesh::MeshId &a, const NCMesh::MeshId &b)
552 {
553  return a.index < b.index;
554 }
555 
556 // equality of MeshId is based on 'index' (element/local are not unique)
557 inline bool operator== (const NCMesh::MeshId &a, const NCMesh::MeshId &b)
558 {
559  return a.index == b.index;
560 }
561 
562 } // namespace mfem
563 
564 #endif // MFEM_USE_MPI
565 
566 #endif // MFEM_PNCMESH
NCList shared_edges
Definition: pncmesh.hpp:277
void SetNCMesh(NCMesh *ncmesh)
Definition: pncmesh.hpp:508
int Partition(long index, long total_elements) const
Return the processor number for a global element number.
Definition: pncmesh.hpp:301
ElementSet(NCMesh *ncmesh=NULL, bool include_ref_types=false)
Definition: pncmesh.hpp:358
void SendRebalanceDofs(int old_ndofs, const Table &old_element_dofs, long old_global_offset, FiniteElementSpace *space)
Use the communication pattern from last Rebalance() to send element DOFs.
Definition: pncmesh.cpp:2123
void DecodeMeshIds(std::istream &is, Array< MeshId > ids[])
Definition: pncmesh.cpp:2559
Array< char > element_type
Definition: pncmesh.hpp:287
int Size() const
Logical size of the array.
Definition: array.hpp:124
std::vector< ValueType > values
Definition: pncmesh.hpp:438
long PartitionFirstIndex(int rank, long total_elements) const
Return the global index of the first element owned by processor &#39;rank&#39;.
Definition: pncmesh.hpp:309
void GetConformingSharedStructures(class ParMesh &pmesh)
Definition: pncmesh.cpp:930
virtual void Trim()
Save memory by releasing all non-essential and cached data.
Definition: pncmesh.cpp:2839
std::vector< int > CommGroup
Definition: pncmesh.hpp:131
void CalcFaceOrientations()
Definition: pncmesh.cpp:715
const CommGroup & GetGroup(GroupId id) const
Return a list of ranks contained in the group of the given ID.
Definition: pncmesh.hpp:160
void MakeSharedList(const NCList &list, NCList &shared)
Definition: pncmesh.cpp:454
Array< char > face_orient
Definition: pncmesh.hpp:279
void WriteInt(int value)
Definition: pncmesh.cpp:2201
MPI_Comm MyComm
Definition: pncmesh.hpp:254
void ChangeRemainingMeshIds(Array< MeshId > &ids, int pos, const Array< Pair< int, int > > &find)
Definition: pncmesh.cpp:2504
virtual void BuildFaceList()
Definition: pncmesh.cpp:295
void Dump(std::ostream &os) const
Definition: pncmesh.cpp:2362
virtual int GetNumGhostVertices() const
Definition: pncmesh.hpp:298
const NCList & GetSharedVertices()
Definition: pncmesh.hpp:109
GroupId GetSingletonGroup(int rank)
Definition: pncmesh.cpp:550
const Geometry::Type geom
Definition: ex1.cpp:40
void GetFaceNeighbors(class ParMesh &pmesh)
Definition: pncmesh.cpp:1031
Lists all edges/faces in the nonconforming mesh.
Definition: ncmesh.hpp:193
std::string RefPath() const
Definition: pncmesh.cpp:2292
void SetNCMesh(ParNCMesh *pncmesh)
Set pointer to ParNCMesh (needed to encode the message).
Definition: pncmesh.hpp:447
std::map< int, NeighborElementRankMessage > Map
Definition: pncmesh.hpp:484
const NCMesh * GetNCMesh() const
Definition: pncmesh.hpp:369
virtual void ElementSharesVertex(int elem, int local, int vnode)
Definition: pncmesh.cpp:389
std::vector< CommGroup > GroupList
Definition: pncmesh.hpp:260
int NVertices
Definition: ncmesh.hpp:489
void Load(std::istream &is)
Definition: pncmesh.cpp:2368
void Add(int elem, ValueType val)
Definition: pncmesh.hpp:443
void SynchronizeDerefinementData(Array< Type > &elem_data, const Table &deref_table)
Definition: pncmesh.cpp:1648
int GetInt(int pos) const
Definition: pncmesh.cpp:2210
virtual void OnMeshUpdated(Mesh *mesh)
Definition: pncmesh.cpp:186
virtual void Derefine(const Array< int > &derefs)
Definition: pncmesh.cpp:1476
void SetElements(const Array< int > &elems, NCMesh *ncmesh)
Definition: pncmesh.cpp:2758
bool operator<(const Pair< A, B > &p, const Pair< A, B > &q)
Comparison operator for class Pair, based on the first element only.
Definition: sort_pairs.hpp:36
void ChangeEdgeMeshIdElement(NCMesh::MeshId &id, int elem)
Definition: pncmesh.cpp:2478
bool GroupContains(GroupId id, int rank) const
Return true if group &#39;id&#39; contains the given rank.
Definition: pncmesh.cpp:559
int PrintMemoryDetail() const
Definition: ncmesh.cpp:5136
void EncodeTree(int elem)
Definition: pncmesh.cpp:2234
virtual void AssignLeafIndices()
Definition: pncmesh.cpp:92
const NCList & GetSharedEdges()
Definition: pncmesh.hpp:110
const NCList & GetFaceList()
Return the current list of conforming and nonconforming faces.
Definition: ncmesh.hpp:212
const NCList & GetSharedList(int entity)
Helper to get shared vertices/edges/faces (&#39;entity&#39; == 0/1/2 resp.).
Definition: pncmesh.hpp:114
A parallel extension of the NCMesh class.
Definition: pncmesh.hpp:64
virtual int GetNumGhostElements() const
Definition: pncmesh.hpp:297
RebalanceDofMessage::Map send_rebalance_dofs
Definition: pncmesh.hpp:531
void FlagElements(const Array< int > &elements, char flag)
Definition: pncmesh.cpp:2219
virtual void Update()
Definition: pncmesh.cpp:64
void Decode(Array< int > &elements) const
Definition: pncmesh.cpp:2352
void AddElementRank(int elem, int rank)
Definition: pncmesh.hpp:494
GroupMap group_id
Definition: pncmesh.hpp:264
virtual bool IsGhost(const Element &el) const
Definition: pncmesh.hpp:294
Array< DenseMatrix * > aux_pm_store
Stores modified point matrices created by GetFaceNeighbors.
Definition: pncmesh.hpp:540
GroupId GetEntityGroupId(int entity, int index)
Definition: pncmesh.hpp:148
void RedistributeElements(Array< int > &new_ranks, int target_elements, bool record_comm)
Definition: pncmesh.cpp:1848
double b
Definition: lissajous.cpp:42
void ElementNeighborProcessors(int elem, Array< int > &ranks)
Definition: pncmesh.cpp:821
int GetNGhostEdges() const
Definition: pncmesh.hpp:103
A pair of objects.
Definition: sort_pairs.hpp:23
void CreateGroups(int nentities, Array< Connection > &index_rank, Array< GroupId > &entity_group)
Definition: pncmesh.cpp:570
Array< int > old_index_or_rank
Definition: pncmesh.hpp:537
RebalanceDofMessage::Map recv_rebalance_dofs
Definition: pncmesh.hpp:532
int InitialPartition(int index) const
Helper to get the partitioning when the serial mesh gets split initially.
Definition: pncmesh.hpp:305
NCList shared_vertices
Definition: pncmesh.hpp:277
void AddRefinement(int elem, char ref_type)
Definition: pncmesh.hpp:464
Identifies a vertex/edge/face in both Mesh and NCMesh.
Definition: ncmesh.hpp:151
std::map< int, NeighborRefinementMessage > Map
Definition: pncmesh.hpp:465
GroupList groups
Definition: pncmesh.hpp:263
virtual void ElementSharesFace(int elem, int local, int face)
Definition: pncmesh.cpp:272
A class for non-conforming AMR on higher-order hexahedral, prismatic, quadrilateral or triangular mes...
Definition: ncmesh.hpp:100
void ClearAuxPM()
Definition: pncmesh.cpp:1297
NCList shared_faces
Definition: pncmesh.hpp:277
virtual void GetBoundaryClosure(const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges)
Definition: pncmesh.cpp:741
void Rebalance(const Array< int > *custom_partition=NULL)
Definition: pncmesh.cpp:1786
void DecodeGroups(std::istream &is, Array< GroupId > &ids)
Definition: pncmesh.cpp:2658
void AdjustMeshIds(Array< MeshId > ids[], int rank)
Definition: pncmesh.cpp:2377
virtual void ElementSharesEdge(int elem, int local, int enode)
Definition: pncmesh.cpp:332
int GetNGhostFaces() const
Definition: pncmesh.hpp:104
Array< int > tmp_neighbors
Definition: pncmesh.hpp:408
std::map< int, RebalanceDofMessage > Map
Definition: pncmesh.hpp:511
std::map< int, NeighborDerefinementMessage > Map
Definition: pncmesh.hpp:474
const Array< int > & GetRebalanceOldIndex() const
Definition: pncmesh.hpp:207
bool operator==(const Array< T > &LHS, const Array< T > &RHS)
Definition: array.hpp:298
Array< Connection > entity_index_rank[3]
Definition: pncmesh.hpp:329
virtual void BuildEdgeList()
Definition: pncmesh.cpp:357
Array< GroupId > entity_owner[3]
Definition: pncmesh.hpp:267
void Encode(const Array< int > &elements)
Definition: pncmesh.cpp:2271
Array< char > tmp_shared_flag
Definition: pncmesh.hpp:328
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:87
void GetDebugMesh(Mesh &debug_mesh) const
Definition: pncmesh.cpp:2822
const NCList & GetVertexList()
Definition: ncmesh.hpp:227
int ElementRank(int index) const
Definition: pncmesh.hpp:188
bool PruneTree(int elem)
Internal. Recursive part of Prune().
Definition: pncmesh.cpp:1309
string space
GroupId GetEntityOwnerId(int entity, int index)
Return vertex/edge/face (&#39;entity&#39; == 0/1/2, resp.) owner.
Definition: pncmesh.hpp:134
void SetNCMesh(NCMesh *ncmesh)
Definition: pncmesh.hpp:368
void UpdateLayers()
Definition: pncmesh.cpp:766
double a
Definition: lissajous.cpp:41
int GetMyRank() const
Definition: pncmesh.hpp:196
virtual void Refine(const Array< Refinement > &refinements)
Definition: pncmesh.cpp:1380
virtual ~ParNCMesh()
Definition: pncmesh.cpp:59
void RecvRebalanceDofs(Array< int > &elements, Array< long > &dofs)
Receive element DOFs sent by SendRebalanceDofs().
Definition: pncmesh.cpp:2156
Array< int > leaf_elements
Definition: ncmesh.hpp:492
int GetNGhostElements() const
Definition: pncmesh.hpp:105
Array< int > boundary_layer
list of type 3 elements
Definition: pncmesh.hpp:290
std::map< CommGroup, GroupId > GroupMap
Definition: pncmesh.hpp:261
friend class NeighborRowMessage
Definition: pncmesh.hpp:545
int index(int i, int j, int nx, int ny)
Definition: life.cpp:241
void AddElementRank(int elem, int rank)
Definition: pncmesh.hpp:483
bool IsGhost(int entity, int index) const
Return true if the specified vertex/edge/face is a ghost.
Definition: pncmesh.hpp:170
void InitOwners(int num, Array< GroupId > &entity_owner)
Definition: pncmesh.cpp:444
void ChangeVertexMeshIdElement(NCMesh::MeshId &id, int elem)
Definition: pncmesh.cpp:2460
void DecodeTree(int elem, int &pos, Array< int > &elements) const
Definition: pncmesh.cpp:2310
void EncodeGroups(std::ostream &os, const Array< GroupId > &ids)
Definition: pncmesh.cpp:2616
virtual void BuildVertexList()
Definition: pncmesh.cpp:412
void CalculatePMatrixGroups()
Definition: pncmesh.cpp:612
Array< int > entity_elem_local[3]
Definition: pncmesh.hpp:274
int GetFaceOrientation(int index) const
Return (shared) face orientation relative to its owner element.
Definition: pncmesh.hpp:125
Array< int > leaf_glob_order
Definition: pncmesh.hpp:274
BlockArray< Element > elements
Definition: ncmesh.hpp:462
virtual void CheckDerefinementNCLevel(const Table &deref_table, Array< int > &level_ok, int max_nc_level)
Definition: pncmesh.cpp:1728
Array< int > ghost_layer
list of elements whose &#39;element_type&#39; == 2.
Definition: pncmesh.hpp:289
void EncodeMeshIds(std::ostream &os, Array< MeshId > ids[])
Definition: pncmesh.cpp:2516
int GetNElements() const
Definition: pncmesh.hpp:100
void AddConnections(int entity, int index, const Array< int > &ranks)
Definition: pncmesh.cpp:604
long MemoryUsage() const
Return total number of bytes allocated.
Definition: ncmesh.cpp:5114
void MakeSharedTable(int ngroups, int ent, Array< int > &shared_local, Table &group_shared, Array< char > *entity_geom=NULL, char geom=0)
Definition: pncmesh.cpp:870
const NCList & GetSharedFaces()
Definition: pncmesh.hpp:111
void AddDerefinement(int elem, int rank)
Definition: pncmesh.hpp:473
std::map< int, RebalanceMessage > Map
Definition: pncmesh.hpp:495
static int get_face_orientation(Face &face, Element &e1, Element &e2, int local[2]=NULL)
Definition: pncmesh.cpp:686
const NCList & GetEdgeList()
Return the current list of conforming and nonconforming edges.
Definition: ncmesh.hpp:219
Array< GroupId > entity_pmat_group[3]
Definition: pncmesh.hpp:269
void NeighborProcessors(Array< int > &neighbors)
Definition: pncmesh.cpp:853
long GroupsMemoryUsage() const
Definition: pncmesh.cpp:2880
int GetNGhostVertices() const
Definition: pncmesh.hpp:102
bool CheckElementType(int elem, int type)
Definition: pncmesh.cpp:804
virtual void UpdateVertices()
update Vertex::index and vertex_nodeId
Definition: pncmesh.cpp:140
int index
Mesh number.
Definition: ncmesh.hpp:153
Class for parallel meshes.
Definition: pmesh.hpp:32
Array< int > tmp_owner
Definition: pncmesh.hpp:327
GroupId GetGroupId(const CommGroup &group)
Definition: pncmesh.cpp:534
Variable-length MPI message containing unspecific binary data.
int rank
processor number (ParNCMesh), -1 if undefined/unknown
Definition: ncmesh.hpp:443
virtual void LimitNCLevel(int max_nc_level)
Parallel version of NCMesh::LimitNCLevel.
Definition: pncmesh.cpp:1458
Array< unsigned char > data
encoded refinement (sub-)trees
Definition: pncmesh.hpp:372
const Array< int > & GetDerefineOldRanks() const
Definition: pncmesh.hpp:211
ParNCMesh(MPI_Comm comm, const NCMesh &ncmesh, int *part=NULL)
Definition: pncmesh.cpp:28
Array< GroupId > entity_conf_group[3]
Definition: pncmesh.hpp:272