MFEM  v4.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, 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 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  void Rebalance();
92 
93 
94  // interface for ParFiniteElementSpace
95 
96  int GetNElements() const { return NElements; }
97 
98  int GetNGhostVertices() const { return NGhostVertices; }
99  int GetNGhostEdges() const { return NGhostEdges; }
100  int GetNGhostFaces() const { return NGhostFaces; }
101  int GetNGhostElements() const { return NGhostElements; }
102 
103  Geometry::Type GetGhostFaceGeometry(int ghost_face_id) const
104  { return Geometry::SQUARE; }
105 
106  // Return a list of vertices/edges/faces shared by this processor and at
107  // least one other processor. These are subsets of NCMesh::<entity>_list. */
111 
112  /// Helper to get shared vertices/edges/faces ('entity' == 0/1/2 resp.).
113  const NCList& GetSharedList(int entity)
114  {
115  switch (entity)
116  {
117  case 0: return GetSharedVertices();
118  case 1: return GetSharedEdges();
119  default: return GetSharedFaces();
120  }
121  }
122 
123  /// Return (shared) face orientation relative to its owner element.
124  int GetFaceOrientation(int index) const
125  {
126  return (index < NFaces) ? face_orient[index] : 0;
127  }
128 
129  typedef short GroupId;
130  typedef std::vector<int> CommGroup;
131 
132  /// Return vertex/edge/face ('entity' == 0/1/2, resp.) owner.
133  GroupId GetEntityOwnerId(int entity, int index)
134  {
135  MFEM_ASSERT(entity >= 0 && entity < 3, "");
136  MFEM_ASSERT(index >= 0, "");
137  if (!entity_owner[entity].Size())
138  {
139  GetSharedList(entity);
140  }
141  return entity_owner[entity][index];
142  }
143 
144  /** Return the P matrix communication group ID for a vertex/edge/face.
145  The groups are calculated specifically to match the P matrix
146  construction algorithm and its communication pattern. */
147  GroupId GetEntityGroupId(int entity, int index)
148  {
149  MFEM_ASSERT(entity >= 0 && entity < 3, "");
150  MFEM_ASSERT(index >= 0, "");
151  if (!entity_pmat_group[entity].Size())
152  {
154  }
155  return entity_pmat_group[entity][index];
156  }
157 
158  /// Return a list of ranks contained in the group of the given ID.
159  const CommGroup& GetGroup(GroupId id) const
160  {
161  MFEM_ASSERT(id >= 0, "");
162  return groups[id];
163  }
164 
165  /// Return true if group 'id' contains the given rank.
166  bool GroupContains(GroupId id, int rank) const;
167 
168  /// Return true if the specified vertex/edge/face is a ghost.
169  bool IsGhost(int entity, int index) const
170  {
171  switch (entity)
172  {
173  case 0: return index >= NVertices;
174  case 1: return index >= NEdges;
175  default: return index >= NFaces;
176  }
177  }
178 
179  /** Returns owner processor for element 'index'. This is normally MyRank but
180  for index >= NElements (i.e., for ghosts) it may be something else. */
181  int ElementRank(int index) const
182  {
183  return elements[leaf_elements[index]].rank;
184  }
185 
186 
187  // utility
188 
189  int GetMyRank() const { return MyRank; }
190 
191  /// Use the communication pattern from last Rebalance() to send element DOFs.
192  void SendRebalanceDofs(int old_ndofs, const Table &old_element_dofs,
193  long old_global_offset, FiniteElementSpace* space);
194 
195  /// Receive element DOFs sent by SendRebalanceDofs().
197 
198  /** Get previous indices (pre-Rebalance) of current elements. Index of -1
199  indicates that an element didn't exist in the mesh before. */
201 
202  /** Get previous (pre-Derefine) fine element ranks. This complements the
203  CoarseFineTransformations::embeddings array in parallel. */
205 
206  /** Exchange element data for derefinements that straddle processor
207  boundaries. 'elem_data' is enlarged and filled with ghost values. */
208  template<typename Type>
210  const Table &deref_table);
211 
212  /** Extension of NCMesh::GetBoundaryClosure. Filters out ghost vertices and
213  ghost edges from 'bdr_vertices' and 'bdr_edges'. */
214  virtual void GetBoundaryClosure(const Array<int> &bdr_attr_is_ess,
215  Array<int> &bdr_vertices,
216  Array<int> &bdr_edges);
217 
218  /// Save memory by releasing all non-essential and cached data.
219  virtual void Trim();
220 
221  /// Return total number of bytes allocated.
222  long MemoryUsage(bool with_base = true) const;
223 
224  int PrintMemoryDetail(bool with_base = true) const;
225 
226  /** Extract a debugging Mesh containing all leaf elements, including ghosts.
227  The debug mesh will have element attributes set to element rank + 1. */
228  void GetDebugMesh(Mesh &debug_mesh) const;
229 
230 
231 protected: // interface for ParMesh
232 
233  friend class ParMesh;
234 
235  /** For compatibility with conforming code in ParMesh and ParFESpace.
236  Initializes shared structures in ParMesh: gtopo, shared_*, group_s*, s*_l*.
237  The ParMesh then acts as a parallel mesh cut along the NC interfaces. */
238  void GetConformingSharedStructures(class ParMesh &pmesh);
239 
240  /** Populate face neighbor members of ParMesh from the ghost layer, without
241  communication. */
242  void GetFaceNeighbors(class ParMesh &pmesh);
243 
244 
245 protected: // implementation
246 
247  MPI_Comm MyComm;
249 
252 
253  typedef std::vector<CommGroup> GroupList;
254  typedef std::map<CommGroup, GroupId> GroupMap;
255 
256  GroupList groups; // comm group list; NOTE: groups[0] = { MyRank }
257  GroupMap group_id; // search index over groups
258 
259  // owner rank for each vertex, edge and face (encoded as singleton groups)
261  // P matrix comm pattern groups for each vertex/edge/face (0/1/2)
263 
264  // ParMesh-compatible (conforming) groups for each vertex/edge/face (0/1/2)
266  // ParMesh compatibility helper arrays to order groups, also temporary
268 
269  // lists of vertices/edges/faces shared by us and at least one more processor
271 
272  Array<char> face_orient; // see CalcFaceOrientations
273 
274  /** Type of each leaf element:
275  1 - our element (rank == MyRank),
276  3 - our element, and neighbor to the ghost layer,
277  2 - ghost layer element (existing element, but rank != MyRank),
278  0 - element beyond the ghost layer, may not be a real element.
279  Note: indexed by Element::index. See also UpdateLayers(). */
281 
282  Array<int> ghost_layer; ///< list of elements whose 'element_type' == 2.
283  Array<int> boundary_layer; ///< list of type 3 elements
284 
285  virtual void Update();
286 
287  virtual bool IsGhost(const Element& el) const
288  { return el.rank != MyRank; }
289 
290  virtual int GetNumGhostElements() const { return NGhostElements; }
291  virtual int GetNumGhostVertices() const { return NGhostVertices; }
292 
293  /// Return the processor number for a global element number.
294  int Partition(long index, long total_elements) const
295  { return index * NRanks / total_elements; }
296 
297  /// Helper to get the partitioning when the serial mesh gets split initially
298  int InitialPartition(int index) const
299  { return Partition(index, leaf_elements.Size()); }
300 
301  /// Return the global index of the first element owned by processor 'rank'.
302  long PartitionFirstIndex(int rank, long total_elements) const
303  { return (rank * total_elements + NRanks-1) / NRanks; }
304 
305  virtual void UpdateVertices();
306  virtual void AssignLeafIndices();
307  virtual void OnMeshUpdated(Mesh *mesh);
308 
309  virtual void BuildFaceList();
310  virtual void BuildEdgeList();
311  virtual void BuildVertexList();
312 
313  virtual void ElementSharesFace(int elem, int local, int face);
314  virtual void ElementSharesEdge(int elem, int local, int enode);
315  virtual void ElementSharesVertex(int elem, int local, int vnode);
316 
317  GroupId GetGroupId(const CommGroup &group);
318  GroupId GetSingletonGroup(int rank);
319 
320  Array<int> tmp_owner; // temporary
323 
324  void InitOwners(int num, Array<GroupId> &entity_owner);
325  void MakeSharedList(const NCList &list, NCList &shared);
326 
327  void AddConnections(int entity, int index, const Array<int> &ranks);
328  void CalculatePMatrixGroups();
329  void CreateGroups(int nentities, Array<Connection> &index_rank,
330  Array<GroupId> &entity_group);
331 
332  static int get_face_orientation(Face &face, Element &e1, Element &e2,
333  int local[2] = NULL /* optional output */);
334  void CalcFaceOrientations();
335 
336  void UpdateLayers();
337 
338  void MakeSharedTable(int ngroups, int ent, Array<int> &shared_local,
339  Table &group_shared);
340 
341  /** Uniquely encodes a set of leaf elements in the refinement hierarchy of
342  an NCMesh. Can be dumped to a stream, sent to another processor, loaded,
343  and decoded to identify the same set of elements (refinements) in a
344  different but compatible NCMesh. The encoding can optionally include
345  the refinement types needed to reach the leaves, so the element set can
346  be decoded (recreated) even if the receiver has an incomplete tree. */
348  {
349  public:
350  ElementSet(NCMesh *ncmesh = NULL, bool include_ref_types = false)
351  : ncmesh(ncmesh), include_ref_types(include_ref_types) {}
352  ElementSet(const ElementSet &other);
353 
354  void Encode(const Array<int> &elements);
355  void Dump(std::ostream &os) const;
356 
357  void Load(std::istream &is);
358  void Decode(Array<int> &elements) const;
359 
360  void SetNCMesh(NCMesh *ncmesh) { this->ncmesh = ncmesh; }
361  const NCMesh* GetNCMesh() const { return ncmesh; }
362 
363  protected:
364  Array<unsigned char> data; ///< encoded refinement (sub-)trees
367 
368  void EncodeTree(int elem);
369  void DecodeTree(int elem, int &pos, Array<int> &elements) const;
370 
371  void WriteInt(int value);
372  int GetInt(int pos) const;
373  void FlagElements(const Array<int> &elements, char flag);
374  };
375 
376  /** Adjust some of the MeshIds before encoding for recipient 'rank', so that
377  they only reference elements that exist in the recipient's ref. tree. */
378  void AdjustMeshIds(Array<MeshId> ids[], int rank);
379 
380  void ChangeVertexMeshIdElement(NCMesh::MeshId &id, int elem);
381  void ChangeEdgeMeshIdElement(NCMesh::MeshId &id, int elem);
382  void ChangeRemainingMeshIds(Array<MeshId> &ids, int pos,
383  const Array<Pair<int, int> > &find);
384 
385  // Write/read a processor-independent encoding of vertex/edge/face IDs.
386  void EncodeMeshIds(std::ostream &os, Array<MeshId> ids[]);
387  void DecodeMeshIds(std::istream &is, Array<MeshId> ids[]);
388 
389  // Write/read comm groups and a list of their IDs.
390  void EncodeGroups(std::ostream &os, const Array<GroupId> &ids);
391  void DecodeGroups(std::istream &is, Array<GroupId> &ids);
392 
393  bool CheckElementType(int elem, int type);
394 
395  Array<int> tmp_neighbors; // temporary, used by ElementNeighborProcessors
396 
397  /** Return a list of processors that own elements in the immediate
398  neighborhood of 'elem' (i.e., vertex, edge and face neighbors),
399  and are not 'MyRank'. */
400  void ElementNeighborProcessors(int elem, Array<int> &ranks);
401 
402  /** Get a list of ranks that own elements in the neighborhood of our region.
403  NOTE: MyRank is not included. */
404  void NeighborProcessors(Array<int> &neighbors);
405 
406  /** Traverse the (local) refinement tree and determine which subtrees are
407  no longer needed, i.e., their leaves are not owned by us nor are they our
408  ghosts. These subtrees are then derefined. */
409  void Prune();
410 
411  /// Internal. Recursive part of Prune().
412  bool PruneTree(int elem);
413 
414 
415  /** A base for internal messages used by Refine(), Derefine() and Rebalance().
416  * Allows sending values associated with elements in a set.
417  * If RefType == true, the element set is recreated on the receiving end.
418  */
419  template<class ValueType, bool RefTypes, int Tag>
420  class ElementValueMessage : public VarMessage<Tag>
421  {
422  public:
423  using VarMessage<Tag>::data;
424  std::vector<int> elements;
425  std::vector<ValueType> values;
426 
427  int Size() const { return elements.size(); }
428  void Reserve(int size) { elements.reserve(size); values.reserve(size); }
429 
430  void Add(int elem, ValueType val)
431  { elements.push_back(elem); values.push_back(val); }
432 
433  /// Set pointer to ParNCMesh (needed to encode the message).
434  void SetNCMesh(ParNCMesh* pncmesh) { this->pncmesh = pncmesh; }
435 
437 
438  protected:
440 
441  virtual void Encode(int);
442  virtual void Decode(int);
443  };
444 
445  /** Used by ParNCMesh::Refine() to inform neighbors about refinements at
446  * the processor boundary. This keeps their ghost layers synchronized.
447  */
448  class NeighborRefinementMessage : public ElementValueMessage<char, false, 289>
449  {
450  public:
451  void AddRefinement(int elem, char ref_type) { Add(elem, ref_type); }
452  typedef std::map<int, NeighborRefinementMessage> Map;
453  };
454 
455  /** Used by ParNCMesh::Derefine() to keep the ghost layers synchronized.
456  */
457  class NeighborDerefinementMessage : public ElementValueMessage<int, false, 290>
458  {
459  public:
460  void AddDerefinement(int elem, int rank) { Add(elem, rank); }
461  typedef std::map<int, NeighborDerefinementMessage> Map;
462  };
463 
464  /** Used in Step 2 of Rebalance() to synchronize new rank assignments in
465  * the ghost layer.
466  */
467  class NeighborElementRankMessage : public ElementValueMessage<int, false, 156>
468  {
469  public:
470  void AddElementRank(int elem, int rank) { Add(elem, rank); }
471  typedef std::map<int, NeighborElementRankMessage> Map;
472  };
473 
474  /** Used by Rebalance() to send elements and their ranks. Note that
475  * RefTypes == true which means the refinement hierarchy will be recreated
476  * on the receiving side.
477  */
478  class RebalanceMessage : public ElementValueMessage<int, true, 157>
479  {
480  public:
481  void AddElementRank(int elem, int rank) { Add(elem, rank); }
482  typedef std::map<int, RebalanceMessage> Map;
483  };
484 
485  /** Allows migrating element data (DOFs) after Rebalance().
486  * Used by SendRebalanceDofs and RecvRebalanceDofs.
487  */
488  class RebalanceDofMessage : public VarMessage<158>
489  {
490  public:
491  std::vector<int> elem_ids, dofs;
493 
494  void SetElements(const Array<int> &elems, NCMesh *ncmesh);
495  void SetNCMesh(NCMesh* ncmesh) { eset.SetNCMesh(ncmesh); }
496  long MemoryUsage() const;
497 
498  typedef std::map<int, RebalanceDofMessage> Map;
499 
500  protected:
502 
503  virtual void Encode(int);
504  virtual void Decode(int);
505  };
506 
507  /** Assign new Element::rank to leaf elements and send them to their new
508  owners, keeping the ghost layer up to date. Used by Rebalance() and
509  Derefine(). */
510  void RedistributeElements(Array<int> &new_ranks, int target_elements,
511  bool record_comm);
512 
513  /** Recorded communication pattern from last Rebalance. Used by
514  Send/RecvRebalanceDofs to ship element DOFs. */
517 
518  /** After Rebalance, this array holds the old element indices, or -1 if an
519  element didn't exist in the mesh previously. After Derefine, it holds
520  the ranks of the old (potentially non-existent) fine elements. */
522 
523  /// Stores modified point matrices created by GetFaceNeighbors
525  void ClearAuxPM();
526 
527  long GroupsMemoryUsage() const;
528 
529  static bool compare_ranks_indices(const Element* a, const Element* b);
530 
531  friend class NeighborRowMessage;
532 };
533 
534 
535 
536 // comparison operator so that MeshId can be used as key in std::map
537 inline bool operator< (const NCMesh::MeshId &a, const NCMesh::MeshId &b)
538 {
539  return a.index < b.index;
540 }
541 
542 // equality of MeshId is based on 'index' (element/local are not unique)
543 inline bool operator== (const NCMesh::MeshId &a, const NCMesh::MeshId &b)
544 {
545  return a.index == b.index;
546 }
547 
548 } // namespace mfem
549 
550 #endif // MFEM_USE_MPI
551 
552 #endif // MFEM_PNCMESH
NCList shared_edges
Definition: pncmesh.hpp:270
void SetNCMesh(NCMesh *ncmesh)
Definition: pncmesh.hpp:495
int Partition(long index, long total_elements) const
Return the processor number for a global element number.
Definition: pncmesh.hpp:294
ElementSet(NCMesh *ncmesh=NULL, bool include_ref_types=false)
Definition: pncmesh.hpp:350
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:1957
void DecodeMeshIds(std::istream &is, Array< MeshId > ids[])
Definition: pncmesh.cpp:2364
Array< char > element_type
Definition: pncmesh.hpp:280
int Size() const
Logical size of the array.
Definition: array.hpp:118
std::vector< ValueType > values
Definition: pncmesh.hpp:425
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:302
void GetConformingSharedStructures(class ParMesh &pmesh)
Definition: pncmesh.cpp:874
virtual void Trim()
Save memory by releasing all non-essential and cached data.
Definition: pncmesh.cpp:2644
std::vector< int > CommGroup
Definition: pncmesh.hpp:130
void CalcFaceOrientations()
Definition: pncmesh.cpp:654
const CommGroup & GetGroup(GroupId id) const
Return a list of ranks contained in the group of the given ID.
Definition: pncmesh.hpp:159
void MakeSharedList(const NCList &list, NCList &shared)
Definition: pncmesh.cpp:411
Array< char > face_orient
Definition: pncmesh.hpp:272
void WriteInt(int value)
Definition: pncmesh.cpp:2035
MPI_Comm MyComm
Definition: pncmesh.hpp:247
void ChangeRemainingMeshIds(Array< MeshId > &ids, int pos, const Array< Pair< int, int > > &find)
Definition: pncmesh.cpp:2309
virtual void BuildFaceList()
Definition: pncmesh.cpp:255
void Dump(std::ostream &os) const
Definition: pncmesh.cpp:2167
virtual int GetNumGhostVertices() const
Definition: pncmesh.hpp:291
const NCList & GetSharedVertices()
Definition: pncmesh.hpp:108
GroupId GetSingletonGroup(int rank)
Definition: pncmesh.cpp:494
void GetFaceNeighbors(class ParMesh &pmesh)
Definition: pncmesh.cpp:968
Lists all edges/faces in the nonconforming mesh.
Definition: ncmesh.hpp:186
void SetNCMesh(ParNCMesh *pncmesh)
Set pointer to ParNCMesh (needed to encode the message).
Definition: pncmesh.hpp:434
std::map< int, NeighborElementRankMessage > Map
Definition: pncmesh.hpp:471
const NCMesh * GetNCMesh() const
Definition: pncmesh.hpp:361
virtual void ElementSharesVertex(int elem, int local, int vnode)
Definition: pncmesh.cpp:346
std::vector< CommGroup > GroupList
Definition: pncmesh.hpp:253
int NVertices
Definition: ncmesh.hpp:462
void Load(std::istream &is)
Definition: pncmesh.cpp:2173
void Add(int elem, ValueType val)
Definition: pncmesh.hpp:430
void SynchronizeDerefinementData(Array< Type > &elem_data, const Table &deref_table)
Definition: pncmesh.cpp:1573
int GetInt(int pos) const
Definition: pncmesh.cpp:2044
virtual void OnMeshUpdated(Mesh *mesh)
Definition: pncmesh.cpp:186
virtual void Derefine(const Array< int > &derefs)
Definition: pncmesh.cpp:1401
void SetElements(const Array< int > &elems, NCMesh *ncmesh)
Definition: pncmesh.cpp:2563
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:2283
bool GroupContains(GroupId id, int rank) const
Return true if group &#39;id&#39; contains the given rank.
Definition: pncmesh.cpp:503
int PrintMemoryDetail() const
Definition: ncmesh.cpp:4094
void EncodeTree(int elem)
Definition: pncmesh.cpp:2068
virtual void AssignLeafIndices()
Definition: pncmesh.cpp:92
const NCList & GetSharedEdges()
Definition: pncmesh.hpp:109
const NCList & GetFaceList()
Return the current list of conforming and nonconforming faces.
Definition: ncmesh.hpp:205
const NCList & GetSharedList(int entity)
Helper to get shared vertices/edges/faces (&#39;entity&#39; == 0/1/2 resp.).
Definition: pncmesh.hpp:113
A parallel extension of the NCMesh class.
Definition: pncmesh.hpp:64
virtual int GetNumGhostElements() const
Definition: pncmesh.hpp:290
RebalanceDofMessage::Map send_rebalance_dofs
Definition: pncmesh.hpp:515
void FlagElements(const Array< int > &elements, char flag)
Definition: pncmesh.cpp:2053
virtual void Update()
Definition: pncmesh.cpp:64
void Decode(Array< int > &elements) const
Definition: pncmesh.cpp:2157
void AddElementRank(int elem, int rank)
Definition: pncmesh.hpp:481
GroupMap group_id
Definition: pncmesh.hpp:257
virtual bool IsGhost(const Element &el) const
Definition: pncmesh.hpp:287
Geometry::Type GetGhostFaceGeometry(int ghost_face_id) const
Definition: pncmesh.hpp:103
Array< DenseMatrix * > aux_pm_store
Stores modified point matrices created by GetFaceNeighbors.
Definition: pncmesh.hpp:524
GroupId GetEntityGroupId(int entity, int index)
Definition: pncmesh.hpp:147
void RedistributeElements(Array< int > &new_ranks, int target_elements, bool record_comm)
Definition: pncmesh.cpp:1769
void ElementNeighborProcessors(int elem, Array< int > &ranks)
Definition: pncmesh.cpp:760
int GetNGhostEdges() const
Definition: pncmesh.hpp:99
A pair of objects.
Definition: sort_pairs.hpp:23
void CreateGroups(int nentities, Array< Connection > &index_rank, Array< GroupId > &entity_group)
Definition: pncmesh.cpp:514
Array< int > old_index_or_rank
Definition: pncmesh.hpp:521
RebalanceDofMessage::Map recv_rebalance_dofs
Definition: pncmesh.hpp:516
int InitialPartition(int index) const
Helper to get the partitioning when the serial mesh gets split initially.
Definition: pncmesh.hpp:298
NCList shared_vertices
Definition: pncmesh.hpp:270
void AddRefinement(int elem, char ref_type)
Definition: pncmesh.hpp:451
Identifies a vertex/edge/face in both Mesh and NCMesh.
Definition: ncmesh.hpp:151
std::map< int, NeighborRefinementMessage > Map
Definition: pncmesh.hpp:452
GroupList groups
Definition: pncmesh.hpp:256
virtual void ElementSharesFace(int elem, int local, int face)
Definition: pncmesh.cpp:232
A class for non-conforming AMR on higher-order hexahedral, quadrilateral or triangular meshes...
Definition: ncmesh.hpp:100
void ClearAuxPM()
Definition: pncmesh.cpp:1228
NCList shared_faces
Definition: pncmesh.hpp:270
virtual void GetBoundaryClosure(const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges)
Definition: pncmesh.cpp:680
void Rebalance()
Definition: pncmesh.cpp:1711
void DecodeGroups(std::istream &is, Array< GroupId > &ids)
Definition: pncmesh.cpp:2463
void AdjustMeshIds(Array< MeshId > ids[], int rank)
Definition: pncmesh.cpp:2182
virtual void ElementSharesEdge(int elem, int local, int enode)
Definition: pncmesh.cpp:289
int GetNGhostFaces() const
Definition: pncmesh.hpp:100
Array< int > tmp_neighbors
Definition: pncmesh.hpp:395
std::map< int, RebalanceDofMessage > Map
Definition: pncmesh.hpp:498
std::map< int, NeighborDerefinementMessage > Map
Definition: pncmesh.hpp:461
const Array< int > & GetRebalanceOldIndex() const
Definition: pncmesh.hpp:200
bool operator==(const Array< T > &LHS, const Array< T > &RHS)
Definition: array.hpp:286
Array< Connection > entity_index_rank[3]
Definition: pncmesh.hpp:322
virtual void BuildEdgeList()
Definition: pncmesh.cpp:314
Array< GroupId > entity_owner[3]
Definition: pncmesh.hpp:260
void Encode(const Array< int > &elements)
Definition: pncmesh.cpp:2105
Array< char > tmp_shared_flag
Definition: pncmesh.hpp:321
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:85
void GetDebugMesh(Mesh &debug_mesh) const
Definition: pncmesh.cpp:2627
const NCList & GetVertexList()
Definition: ncmesh.hpp:220
int ElementRank(int index) const
Definition: pncmesh.hpp:181
bool PruneTree(int elem)
Internal. Recursive part of Prune().
Definition: pncmesh.cpp:1240
string space
GroupId GetEntityOwnerId(int entity, int index)
Return vertex/edge/face (&#39;entity&#39; == 0/1/2, resp.) owner.
Definition: pncmesh.hpp:133
void SetNCMesh(NCMesh *ncmesh)
Definition: pncmesh.hpp:360
void UpdateLayers()
Definition: pncmesh.cpp:705
int GetMyRank() const
Definition: pncmesh.hpp:189
virtual void Refine(const Array< Refinement > &refinements)
Definition: pncmesh.cpp:1311
virtual ~ParNCMesh()
Definition: pncmesh.cpp:59
static bool compare_ranks_indices(const Element *a, const Element *b)
Definition: pncmesh.cpp:962
void RecvRebalanceDofs(Array< int > &elements, Array< long > &dofs)
Receive element DOFs sent by SendRebalanceDofs().
Definition: pncmesh.cpp:1990
Array< int > leaf_elements
Definition: ncmesh.hpp:465
int GetNGhostElements() const
Definition: pncmesh.hpp:101
Array< int > boundary_layer
list of type 3 elements
Definition: pncmesh.hpp:283
std::map< CommGroup, GroupId > GroupMap
Definition: pncmesh.hpp:254
friend class NeighborRowMessage
Definition: pncmesh.hpp:531
void AddElementRank(int elem, int rank)
Definition: pncmesh.hpp:470
bool IsGhost(int entity, int index) const
Return true if the specified vertex/edge/face is a ghost.
Definition: pncmesh.hpp:169
void InitOwners(int num, Array< GroupId > &entity_owner)
Definition: pncmesh.cpp:401
void ChangeVertexMeshIdElement(NCMesh::MeshId &id, int elem)
Definition: pncmesh.cpp:2265
void DecodeTree(int elem, int &pos, Array< int > &elements) const
Definition: pncmesh.cpp:2125
void EncodeGroups(std::ostream &os, const Array< GroupId > &ids)
Definition: pncmesh.cpp:2421
virtual void BuildVertexList()
Definition: pncmesh.cpp:369
void CalculatePMatrixGroups()
Definition: pncmesh.cpp:556
Array< int > entity_elem_local[3]
Definition: pncmesh.hpp:267
int GetFaceOrientation(int index) const
Return (shared) face orientation relative to its owner element.
Definition: pncmesh.hpp:124
Array< int > leaf_glob_order
Definition: pncmesh.hpp:267
BlockArray< Element > elements
Definition: ncmesh.hpp:435
virtual void CheckDerefinementNCLevel(const Table &deref_table, Array< int > &level_ok, int max_nc_level)
Definition: pncmesh.cpp:1653
Array< int > ghost_layer
list of elements whose &#39;element_type&#39; == 2.
Definition: pncmesh.hpp:282
void EncodeMeshIds(std::ostream &os, Array< MeshId > ids[])
Definition: pncmesh.cpp:2321
int GetNElements() const
Definition: pncmesh.hpp:96
void AddConnections(int entity, int index, const Array< int > &ranks)
Definition: pncmesh.cpp:548
long MemoryUsage() const
Return total number of bytes allocated.
Definition: ncmesh.cpp:4072
const NCList & GetSharedFaces()
Definition: pncmesh.hpp:110
void AddDerefinement(int elem, int rank)
Definition: pncmesh.hpp:460
std::map< int, RebalanceMessage > Map
Definition: pncmesh.hpp:482
static int get_face_orientation(Face &face, Element &e1, Element &e2, int local[2]=NULL)
Definition: pncmesh.cpp:628
const NCList & GetEdgeList()
Return the current list of conforming and nonconforming edges.
Definition: ncmesh.hpp:212
Array< GroupId > entity_pmat_group[3]
Definition: pncmesh.hpp:262
void NeighborProcessors(Array< int > &neighbors)
Definition: pncmesh.cpp:792
long GroupsMemoryUsage() const
Definition: pncmesh.cpp:2685
int GetNGhostVertices() const
Definition: pncmesh.hpp:98
bool CheckElementType(int elem, int type)
Definition: pncmesh.cpp:743
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:320
GroupId GetGroupId(const CommGroup &group)
Definition: pncmesh.cpp:478
Variable-length MPI message containing unspecific binary data.
int rank
processor number (ParNCMesh), -1 if undefined/unknown
Definition: ncmesh.hpp:418
virtual void LimitNCLevel(int max_nc_level)
Parallel version of NCMesh::LimitNCLevel.
Definition: pncmesh.cpp:1383
Array< unsigned char > data
encoded refinement (sub-)trees
Definition: pncmesh.hpp:364
const Array< int > & GetDerefineOldRanks() const
Definition: pncmesh.hpp:204
void MakeSharedTable(int ngroups, int ent, Array< int > &shared_local, Table &group_shared)
Definition: pncmesh.cpp:829
ParNCMesh(MPI_Comm comm, const NCMesh &ncmesh, int *part=NULL)
Definition: pncmesh.cpp:28
Array< GroupId > entity_conf_group[3]
Definition: pncmesh.hpp:265