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