MFEM  v3.3
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 
25 namespace mfem
26 {
27 
28 class ParMesh;
29 class FiniteElementCollection; // for edge orientation handling
30 class FiniteElementSpace; // for Dof -> VDof conversion
31 
32 
33 /** \brief A parallel extension of the NCMesh class.
34  *
35  * The basic idea (and assumption) is that all processors share the coarsest
36  * layer ('root_elements'). This has the advantage that refinements can easily
37  * be exchanged between processors when rebalancing since individual elements
38  * can be uniquely identified by the index of the root element and a path in
39  * the refinement tree.
40  *
41  * Each leaf element is owned by one of the processors (NCMesh::Element::rank).
42  * The underlying NCMesh stores not only elements for the current ('MyRank')
43  * processor, but also a minimal layer of adjacent "ghost" elements owned by
44  * other processors. The ghost layer is synchronized after refinement.
45  *
46  * The ghost layer contains all vertex-, edge- and face-neighbors of the
47  * current processor's region. It is used to determine constraining relations
48  * and ownership of DOFs on the processor boundary. Ghost elements are never
49  * seen by the rest of MFEM as they are skipped when a Mesh is created from
50  * the NCMesh.
51  *
52  * The processor that owns a vertex, edge or a face (and in turn its DOFs) is
53  * currently defined to be the one with the lowest rank in the group of
54  * processors that share the entity.
55  *
56  * Vertices, edges and faces that are not shared by this ('MyRank') processor
57  * are ghosts, and are numbered after all real vertices/edges/faces, i.e.,
58  * they have indices greater than NVertices, NEdges, NFaces, respectively.
59  *
60  * A shared vertex/edge/face is identified in an interprocessor message by a
61  * pair of numbers. The first number specifies an element in an ElementSet
62  * (typically sent at the beginning of the message) that contains the v/e/f.
63  * The second number is the local index of the v/e/f in that element.
64  */
65 class ParNCMesh : public NCMesh
66 {
67 public:
68  ParNCMesh(MPI_Comm comm, const NCMesh& ncmesh);
69 
70  virtual ~ParNCMesh();
71 
72  /** An override of NCMesh::Refine, which is called eventually, after making
73  sure that refinements that occur on the processor boundary are sent to
74  the neighbor processors so they can keep their ghost layers up to date.*/
75  virtual void Refine(const Array<Refinement> &refinements);
76 
77  /// Parallel version of NCMesh::LimitNCLevel.
78  virtual void LimitNCLevel(int max_nc_level);
79 
80  /** Parallel version of NCMesh::CheckDerefinementNCLevel. */
81  virtual void CheckDerefinementNCLevel(const Table &deref_table,
82  Array<int> &level_ok, int max_nc_level);
83 
84  /** Parallel reimplementation of NCMesh::Derefine, keeps ghost layers
85  in sync. The interface is identical. */
86  virtual void Derefine(const Array<int> &derefs);
87 
88  /** Migrate leaf elements of the global refinement hierarchy (including ghost
89  elements) so that each processor owns the same number of leaves (+-1). */
90  void Rebalance();
91 
92 
93  // interface for ParFiniteElementSpace
94 
95  /** Return a list of vertices shared by this processor and at least one other
96  processor. (NOTE: only NCList::conforming will be set.) */
98  {
100  return shared_vertices;
101  }
102 
103  /** Return a list of edges shared by this processor and at least one other
104  processor. (NOTE: this is a subset of the NCMesh::edge_list; slaves are
105  empty.) */
107  {
108  if (edge_list.Empty()) { BuildEdgeList(); }
109  return shared_edges;
110  }
111 
112  /** Return a list of faces shared by this processor and another processor.
113  (NOTE: this is a subset of NCMesh::face_list; slaves are empty.) */
115  {
116  if (face_list.Empty()) { BuildFaceList(); }
117  return shared_faces;
118  }
119 
120  /// Helper to get shared vertices/edges/faces ('type' == 0/1/2 resp.).
121  const NCList& GetSharedList(int type)
122  {
123  switch (type)
124  {
125  case 0: return GetSharedVertices();
126  case 1: return GetSharedEdges();
127  default: return GetSharedFaces();
128  }
129  }
130 
131  /// Return (shared) face orientation relative to the owner element.
132  int GetFaceOrientation(int index) const
133  {
134  return face_orient[index];
135  }
136 
137  /// Return vertex/edge/face ('type' == 0/1/2, resp.) owner.
138  int GetOwner(int type, int index) const
139  {
140  switch (type)
141  {
142  case 0: return vertex_owner[index];
143  case 1: return edge_owner[index];
144  default: return face_owner[index];
145  }
146  }
147 
148  /** Return a list of processors sharing a vertex/edge/face
149  ('type' == 0/1/2, resp.) and the size of the list. */
150  const int* GetGroup(int type, int index, int &size) const
151  {
152  const Table* table;
153  switch (type)
154  {
155  case 0: table = &vertex_group; break;
156  case 1: table = &edge_group; break;
157  default: table = &face_group;
158  }
159  size = table->RowSize(index);
160  return table->GetRow(index);
161  }
162 
163  /** Returns true if 'rank' is in the processor group of a vertex/edge/face
164  ('type' == 0/1/2, resp.). */
165  bool RankInGroup(int type, int index, int rank) const
166  {
167  int size;
168  const int* group = GetGroup(type, index, size);
169  for (int i = 0; i < size; i++)
170  {
171  if (group[i] == rank) { return true; }
172  }
173  return false;
174  }
175 
176  /// Returns true if the specified vertex/edge/face is a ghost.
177  bool IsGhost(int type, int index) const
178  {
179  switch (type)
180  {
181  case 0: return index >= NVertices;
182  case 1: return index >= NEdges;
183  default: return index >= NFaces;
184  }
185  }
186 
187  /** Returns owner processor for element 'index'. This is normally MyRank but
188  for index >= NElements (i.e., for ghosts) it may be something else. */
189  int ElementRank(int index) const
190  { return leaf_elements[index]->rank; }
191 
192 
193  // interface for ParMesh
194 
195  /** Populate face neighbor members of ParMesh from the ghost layer, without
196  communication. */
197  void GetFaceNeighbors(ParMesh &pmesh);
198 
199 
200  // utility
201 
202  /// Use the communication pattern from last Rebalance() to send element DOFs.
203  void SendRebalanceDofs(int old_ndofs, const Table &old_element_dofs,
204  long old_global_offset, FiniteElementSpace* space);
205 
206  /// Receive element DOFs sent by SendRebalanceDofs().
207  void RecvRebalanceDofs(Array<int> &elements, Array<long> &dofs);
208 
209  /** Get previous indices (pre-Rebalance) of current elements. Index of -1
210  indicates that an element didn't exist in the mesh before. */
212 
213  /** Get previous (pre-Derefine) fine element ranks. This complements the
214  CoarseFineTransformations::embeddings array in parallel. */
216 
217  /** Exchange element data for derefinements that straddle processor
218  boundaries. 'elem_data' is enlarged and filled with ghost values. */
219  template<typename Type>
221  const Table &deref_table);
222 
223  /** Extension of NCMesh::GetBoundaryClosure. Filters out ghost vertices and
224  ghost edges from 'bdr_vertices' and 'bdr_edges'. */
225  virtual void GetBoundaryClosure(const Array<int> &bdr_attr_is_ess,
226  Array<int> &bdr_vertices,
227  Array<int> &bdr_edges);
228 
229  /** Extract a debugging Mesh containing all leaf elements, including ghosts.
230  The debug mesh will have element attributes set to element rank + 1. */
231  void GetDebugMesh(Mesh &debug_mesh) const;
232 
233 
234 protected:
235  MPI_Comm MyComm;
237 
242 
243  // lists of vertices/edges/faces shared by us and at least one more processor
247 
248  // owner processor for each vertex/edge/face
252 
253  // list of processors sharing each vertex/edge/face
257 
258  Array<char> face_orient; // see CalcFaceOrientations
259 
260  /** Type of each leaf element:
261  1 - our element (rank == MyRank),
262  3 - our element, and neighbor to the ghost layer,
263  2 - ghost layer element (existing element, but rank != MyRank),
264  0 - element beyond the ghost layer, may not be a real element.
265  See also UpdateLayers(). */
267 
268  Array<Element*> ghost_layer; ///< list of elements whose 'element_type' == 2.
269  Array<Element*> boundary_layer; ///< list of type 3 elements
270 
271  virtual void Update();
272 
273  /// Return the processor number for a global element number.
274  int Partition(long index, long total_elements) const
275  { return index * NRanks / total_elements; }
276 
277  /// Helper to get the partition when the serial mesh is being split initially
278  int InitialPartition(int index) const
279  { return Partition(index, leaf_elements.Size()); }
280 
281  /// Return the global index of the first element owned by processor 'rank'.
282  long PartitionFirstIndex(int rank, long total_elements) const
283  { return (rank * total_elements + NRanks-1) / NRanks; }
284 
285  virtual void UpdateVertices();
286  virtual void AssignLeafIndices();
287 
288  virtual bool IsGhost(const Element* elem) const
289  { return elem->rank != MyRank; }
290 
291  virtual int GetNumGhosts() const { return NGhostElements; }
292 
293  virtual void OnMeshUpdated(Mesh *mesh);
294 
295  virtual void BuildEdgeList();
296  virtual void BuildFaceList();
297 
298  virtual void ElementSharesEdge(Element* elem, Edge* edge);
299  virtual void ElementSharesFace(Element* elem, Face* face);
300 
301  void BuildSharedVertices();
302 
303  static int get_face_orientation(Face *face, Element* e1, Element* e2,
304  int local[2] = NULL);
305  void CalcFaceOrientations();
306 
307  void UpdateLayers();
308 
310 
311  void AddMasterSlaveRanks(int nitems, const NCList& list);
312  void MakeShared(const Table &groups, const NCList &list, NCList &shared);
313 
314  /** Uniquely encodes a set of leaf elements in the refinement hierarchy of
315  an NCMesh. Can be dumped to a stream, sent to another processor, loaded,
316  and decoded to identify the same set of elements (refinements) in a
317  different but compatible NCMesh. The encoding can optionally include
318  the refinement types needed to reach the leaves, so the element set can
319  be decoded (recreated) even if the receiver has an incomplete tree. */
321  {
322  public:
323  ElementSet(NCMesh *ncmesh = NULL, bool include_ref_types = false)
324  : ncmesh(ncmesh), include_ref_types(include_ref_types) {}
325  ElementSet(const ElementSet &other);
326 
327  void Encode(const Array<Element*> &elements);
328  void Dump(std::ostream &os) const;
329 
330  void Load(std::istream &is);
331  void Decode(Array<Element*> &elements) const;
332 
333  void SetNCMesh(NCMesh *ncmesh) { this->ncmesh = ncmesh; }
334 
335  protected:
336  Array<unsigned char> data; ///< encoded refinement (sub-)trees
339 
340  void EncodeTree(Element* elem);
341  void DecodeTree(Element* elem, int &pos, Array<Element*> &elements) const;
342 
343  void WriteInt(int value);
344  int GetInt(int pos) const;
345  void FlagElements(const Array<Element*> &elements, char flag);
346  };
347 
348  /// Write to 'os' a processor-independent encoding of vertex/edge/face IDs.
349  void EncodeMeshIds(std::ostream &os, Array<MeshId> ids[]);
350 
351  /// Read from 'is' a processor-independent encoding of vertex/edge/face IDs.
352  void DecodeMeshIds(std::istream &is, Array<MeshId> ids[]);
353 
354  bool CheckElementType(Element* elem, int type);
355 
356  Array<Element*> tmp_neighbors; // temporary used by ElementNeighborProcessors
357 
358  /** Return a list of processors that own elements in the immediate
359  neighborhood of 'elem' (i.e., vertex, edge and face neighbors),
360  and are not 'MyRank'. */
361  void ElementNeighborProcessors(Element* elem, Array<int> &ranks);
362 
363  /** Get a list of ranks that own elements in the neighborhood of our region.
364  NOTE: MyRank is not included. */
365  void NeighborProcessors(Array<int> &neighbors);
366 
367  /** Traverse the (local) refinement tree and determine which subtrees are
368  no longer needed, i.e., their leaves are not owned by us nor are they our
369  ghosts. These subtrees are then derefined. */
370  void Prune();
371 
372  /// Internal. Recursive part of Prune().
373  bool PruneTree(Element* elem);
374 
375 
376  /** A base for internal messages used by Refine(), Derefine() and Rebalance().
377  * Allows sending values associated with elements in a set.
378  * If RefType == true, the element set is recreated on the receiving end.
379  */
380  template<class ValueType, bool RefTypes, int Tag>
381  class ElementValueMessage : public VarMessage<Tag>
382  {
383  public:
384  using VarMessage<Tag>::data;
385  std::vector<Element*> elements;
386  std::vector<ValueType> values;
387 
388  int Size() const { return elements.size(); }
389  void Reserve(int size) { elements.reserve(size); values.reserve(size); }
390 
391  void Add(Element* elem, ValueType val)
392  { elements.push_back(elem); values.push_back(val); }
393 
394  /// Set pointer to ParNCMesh (needed to encode the message).
395  void SetNCMesh(ParNCMesh* pncmesh) { this->pncmesh = pncmesh; }
396 
398 
399  protected:
401 
402  virtual void Encode();
403  virtual void Decode();
404  };
405 
406  /** Used by ParNCMesh::Refine() to inform neighbors about refinements at
407  * the processor boundary. This keeps their ghost layers synchronized.
408  */
409  class NeighborRefinementMessage : public ElementValueMessage<char, false, 289>
410  {
411  public:
412  void AddRefinement(Element* elem, char ref_type) { Add(elem, ref_type); }
413  typedef std::map<int, NeighborRefinementMessage> Map;
414  };
415 
416  /** Used by ParNCMesh::Derefine() to keep the ghost layers synchronized.
417  */
418  class NeighborDerefinementMessage : public ElementValueMessage<int, false, 290>
419  {
420  public:
421  void AddDerefinement(Element* elem, int rank) { Add(elem, rank); }
422  typedef std::map<int, NeighborDerefinementMessage> Map;
423  };
424 
425  /** Used in Step 2 of Rebalance() to synchronize new rank assignments in
426  * the ghost layer.
427  */
428  class NeighborElementRankMessage : public ElementValueMessage<int, false, 156>
429  {
430  public:
431  void AddElementRank(Element* elem, int rank) { Add(elem, rank); }
432  typedef std::map<int, NeighborElementRankMessage> Map;
433  };
434 
435  /** Used by Rebalance() to send elements and their ranks. Note that
436  * RefTypes == true which means the refinement hierarchy will be recreated
437  * on the receiving side.
438  */
439  class RebalanceMessage : public ElementValueMessage<int, true, 157>
440  {
441  public:
442  void AddElementRank(Element* elem, int rank) { Add(elem, rank); }
443  typedef std::map<int, RebalanceMessage> Map;
444  };
445 
446  /** Allows migrating element data (DOFs) after Rebalance().
447  * Used by SendRebalanceDofs and RecvRebalanceDofs.
448  */
449  class RebalanceDofMessage : public VarMessage<158>
450  {
451  public:
452  std::vector<int> elem_ids, dofs;
454 
455  void SetElements(const Array<Element*> &elems, NCMesh *ncmesh);
456  void SetNCMesh(NCMesh* ncmesh) { eset.SetNCMesh(ncmesh); }
457 
458  typedef std::map<int, RebalanceDofMessage> Map;
459 
460  protected:
462 
463  virtual void Encode();
464  virtual void Decode();
465  };
466 
467  /** Assign new Element::rank to leaf elements and send them to their new
468  owners, keeping the ghost layer up to date. Used by Rebalance() and
469  Derefine(). */
470  void RedistributeElements(Array<int> &new_ranks, int target_elements,
471  bool record_comm);
472 
473  /** Recorded communication pattern from last Rebalance. Used by
474  Send/RecvRebalanceDofs to ship element DOFs. */
477 
478  /** After Rebalance, this array holds the old element indices, or -1 if an
479  element didn't exist in the mesh previously. After Derefine, it holds
480  the ranks of the old (potentially non-existent) fine elements. */
482 
483  /// Stores modified point matrices created by GetFaceNeighbors
485  void ClearAuxPM();
486 
487  static bool compare_ranks(const Element* a, const Element* b);
488  static bool compare_ranks_indices(const Element* a, const Element* b);
489 
490  friend class ParMesh;
491  friend class NeighborDofMessage;
492 };
493 
494 
495 /** Represents a message about DOF assignment of vertex, edge and face DOFs on
496  * the boundary with another processor. This and other messages below
497  * are only exchanged between immediate neighbors. Used by
498  * ParFiniteElementSpace::GetParallelConformingInterpolation().
499  */
500 class NeighborDofMessage : public VarMessage<135>
501 {
502 public:
503  /// Add vertex/edge/face DOFs to an outgoing message.
504  void AddDofs(int type, const NCMesh::MeshId &id, const Array<int> &dofs);
505 
506  /** Set pointers to ParNCMesh & FECollection (needed to encode the message),
507  set the space size to be sent. */
509  { this->pncmesh = pncmesh; this->fec = fec; this->ndofs = ndofs; }
510 
511  /** Get vertex/edge/face DOFs from a received message. 'ndofs' receives
512  the remote space size. */
513  void GetDofs(int type, const NCMesh::MeshId& id,
514  Array<int>& dofs, int &ndofs);
515 
516  typedef std::map<int, NeighborDofMessage> Map;
517 
518 protected:
519  typedef std::map<NCMesh::MeshId, std::vector<int> > IdToDofs;
521 
524  int ndofs;
525 
526  virtual void Encode();
527  virtual void Decode();
528 
529  void ReorderEdgeDofs(const NCMesh::MeshId &id, std::vector<int> &dofs);
530 };
531 
532 /** Used by ParFiniteElementSpace::GetConformingInterpolation() to request
533  * finished non-local rows of the P matrix. This message is only sent once
534  * to each neighbor.
535  */
536 class NeighborRowRequest: public VarMessage<312>
537 {
538 public:
539  std::set<int> rows;
540 
541  void RequestRow(int row) { rows.insert(row); }
542  void RemoveRequest(int row) { rows.erase(row); }
543 
544  typedef std::map<int, NeighborRowRequest> Map;
545 
546 protected:
547  virtual void Encode();
548  virtual void Decode();
549 };
550 
551 /** Represents a reply to NeighborRowRequest. The reply contains a batch of
552  * P matrix rows that have been finished by the sending processor. Multiple
553  * batches may be sent depending on the number of iterations of the final part
554  * of the function ParFiniteElementSpace::GetConformingInterpolation(). All
555  * rows that are sent accumulate in the same NeighborRowReply instance.
556  */
557 class NeighborRowReply: public VarMessage<313>
558 {
559 public:
560  void AddRow(int row, const Array<int> &cols, const Vector &srow);
561 
562  bool HaveRow(int row) const { return rows.find(row) != rows.end(); }
563  void GetRow(int row, Array<int> &cols, Vector &srow);
564 
565  typedef std::map<int, NeighborRowReply> Map;
566 
567 protected:
568  struct Row { std::vector<int> cols; Vector srow; };
569  std::map<int, Row> rows;
570 
571  virtual void Encode();
572  virtual void Decode();
573 };
574 
575 
576 // comparison operator so that MeshId can be used as key in std::map
577 inline bool operator< (const NCMesh::MeshId &a, const NCMesh::MeshId &b)
578 {
579  return a.index < b.index;
580 }
581 
582 } // namespace mfem
583 
584 #endif // MFEM_USE_MPI
585 
586 #endif // MFEM_PNCMESH
NCList face_list
lazy-initialized list of faces, see GetFaceList
Definition: ncmesh.hpp:435
NCList edge_list
lazy-initialized list of edges, see GetEdgeList
Definition: ncmesh.hpp:436
NCList shared_edges
Definition: pncmesh.hpp:245
void SetNCMesh(NCMesh *ncmesh)
Definition: pncmesh.hpp:456
int Partition(long index, long total_elements) const
Return the processor number for a global element number.
Definition: pncmesh.hpp:274
ElementSet(NCMesh *ncmesh=NULL, bool include_ref_types=false)
Definition: pncmesh.hpp:323
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:1547
void DecodeMeshIds(std::istream &is, Array< MeshId > ids[])
Read from &#39;is&#39; a processor-independent encoding of vertex/edge/face IDs.
Definition: pncmesh.cpp:1826
Array< Element * > ghost_layer
list of elements whose &#39;element_type&#39; == 2.
Definition: pncmesh.hpp:268
void AddElementRank(Element *elem, int rank)
Definition: pncmesh.hpp:442
Array< char > element_type
Definition: pncmesh.hpp:266
std::vector< ValueType > values
Definition: pncmesh.hpp:386
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:282
void CalcFaceOrientations()
Definition: pncmesh.cpp:439
void AddDofs(int type, const NCMesh::MeshId &id, const Array< int > &dofs)
Add vertex/edge/face DOFs to an outgoing message.
Definition: pncmesh.cpp:1884
Array< char > face_orient
Definition: pncmesh.hpp:258
void WriteInt(int value)
Definition: pncmesh.cpp:1625
virtual int GetNumGhosts() const
Definition: pncmesh.hpp:291
MPI_Comm MyComm
Definition: pncmesh.hpp:235
virtual void BuildFaceList()
Definition: pncmesh.cpp:238
void Dump(std::ostream &os) const
Definition: pncmesh.cpp:1769
const NCList & GetSharedVertices()
Definition: pncmesh.hpp:97
Array< int > face_owner
Definition: pncmesh.hpp:251
Lists all edges/faces in the nonconforming mesh.
Definition: ncmesh.hpp:168
void SetNCMesh(ParNCMesh *pncmesh)
Set pointer to ParNCMesh (needed to encode the message).
Definition: pncmesh.hpp:395
std::map< int, NeighborElementRankMessage > Map
Definition: pncmesh.hpp:432
void BuildSharedVertices()
Definition: pncmesh.cpp:366
void Load(std::istream &is)
Definition: pncmesh.cpp:1775
void GetRow(int i, Array< int > &row) const
Return row i in array row (the Table must be finalized)
Definition: table.cpp:179
void DecodeTree(Element *elem, int &pos, Array< Element * > &elements) const
Definition: pncmesh.cpp:1714
void SynchronizeDerefinementData(Array< Type > &elem_data, const Table &deref_table)
Definition: pncmesh.cpp:1173
int GetInt(int pos) const
Definition: pncmesh.cpp:1634
virtual void OnMeshUpdated(Mesh *mesh)
Definition: pncmesh.cpp:147
virtual void Derefine(const Array< int > &derefs)
Definition: pncmesh.cpp:1001
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:32
std::map< int, NeighborRowRequest > Map
Definition: pncmesh.hpp:544
void AddRefinement(Element *elem, char ref_type)
Definition: pncmesh.hpp:412
int GetOwner(int type, int index) const
Return vertex/edge/face (&#39;type&#39; == 0/1/2, resp.) owner.
Definition: pncmesh.hpp:138
virtual void AssignLeafIndices()
Definition: pncmesh.cpp:67
const NCList & GetSharedEdges()
Definition: pncmesh.hpp:106
void MakeShared(const Table &groups, const NCList &list, NCList &shared)
Definition: pncmesh.cpp:338
bool RankInGroup(int type, int index, int rank) const
Definition: pncmesh.hpp:165
virtual bool IsGhost(const Element *elem) const
Definition: pncmesh.hpp:288
virtual void Decode()
Definition: pncmesh.cpp:2037
std::vector< int > cols
Definition: pncmesh.hpp:568
A parallel extension of the NCMesh class.
Definition: pncmesh.hpp:65
ParNCMesh(MPI_Comm comm, const NCMesh &ncmesh)
Definition: pncmesh.cpp:27
bool Empty() const
Definition: ncmesh.hpp:177
Array< int > vertex_owner
Definition: pncmesh.hpp:249
RebalanceDofMessage::Map send_rebalance_dofs
Definition: pncmesh.hpp:475
virtual void Update()
Definition: pncmesh.cpp:54
const FiniteElementCollection * fec
Definition: pncmesh.hpp:523
virtual void Decode()
Definition: pncmesh.cpp:1996
Table face_group
Definition: pncmesh.hpp:256
bool PruneTree(Element *elem)
Internal. Recursive part of Prune().
Definition: pncmesh.cpp:841
std::vector< Element * > elements
Definition: pncmesh.hpp:385
Array< DenseMatrix * > aux_pm_store
Stores modified point matrices created by GetFaceNeighbors.
Definition: pncmesh.hpp:484
void RedistributeElements(Array< int > &new_ranks, int target_elements, bool record_comm)
Definition: pncmesh.cpp:1361
void FlagElements(const Array< Element * > &elements, char flag)
Definition: pncmesh.cpp:1643
Array< int > old_index_or_rank
Definition: pncmesh.hpp:481
RebalanceDofMessage::Map recv_rebalance_dofs
Definition: pncmesh.hpp:476
int InitialPartition(int index) const
Helper to get the partition when the serial mesh is being split initially.
Definition: pncmesh.hpp:278
bool HaveRow(int row) const
Definition: pncmesh.hpp:562
void EncodeTree(Element *elem)
Definition: pncmesh.cpp:1657
Array< Element * > boundary_layer
list of type 3 elements
Definition: pncmesh.hpp:269
NCList shared_vertices
Definition: pncmesh.hpp:244
Identifies a vertex/edge/face in both Mesh and NCMesh.
Definition: ncmesh.hpp:132
std::map< int, NeighborRefinementMessage > Map
Definition: pncmesh.hpp:413
Table edge_group
Definition: pncmesh.hpp:255
A class for non-conforming AMR on higher-order hexahedral, quadrilateral or triangular meshes...
Definition: ncmesh.hpp:80
void ClearAuxPM()
Definition: pncmesh.cpp:829
NCList shared_faces
Definition: pncmesh.hpp:246
void SetElements(const Array< Element * > &elems, NCMesh *ncmesh)
Definition: pncmesh.cpp:2173
virtual void GetBoundaryClosure(const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges)
Definition: pncmesh.cpp:463
void Rebalance()
Definition: pncmesh.cpp:1309
void RemoveRequest(int row)
Definition: pncmesh.hpp:542
Table vertex_group
Definition: pncmesh.hpp:254
std::map< int, RebalanceDofMessage > Map
Definition: pncmesh.hpp:458
std::map< int, NeighborDerefinementMessage > Map
Definition: pncmesh.hpp:422
const Array< int > & GetRebalanceOldIndex() const
Definition: pncmesh.hpp:211
void AddDerefinement(Element *elem, int rank)
Definition: pncmesh.hpp:421
virtual void BuildEdgeList()
Definition: pncmesh.cpp:214
static bool compare_ranks(const Element *a, const Element *b)
Definition: pncmesh.cpp:1356
void GetDebugMesh(Mesh &debug_mesh) const
Definition: pncmesh.cpp:2224
int ElementRank(int index) const
Definition: pncmesh.hpp:189
void GetDofs(int type, const NCMesh::MeshId &id, Array< int > &dofs, int &ndofs)
Definition: pncmesh.cpp:1891
std::map< int, Row > rows
Definition: pncmesh.hpp:569
Array< Element * > leaf_elements
Definition: ncmesh.hpp:431
void SetNCMesh(NCMesh *ncmesh)
Definition: pncmesh.hpp:333
std::map< NCMesh::MeshId, std::vector< int > > IdToDofs
Definition: pncmesh.hpp:519
virtual void Encode()
Definition: pncmesh.cpp:2071
void UpdateLayers()
Definition: pncmesh.cpp:488
void ElementNeighborProcessors(Element *elem, Array< int > &ranks)
Definition: pncmesh.cpp:543
virtual void ElementSharesFace(Element *elem, Face *face)
Definition: pncmesh.cpp:204
virtual void ElementSharesEdge(Element *elem, Edge *edge)
Definition: pncmesh.cpp:192
void Decode(Array< Element * > &elements) const
Definition: pncmesh.cpp:1745
bool CheckElementType(Element *elem, int type)
Definition: pncmesh.cpp:526
virtual void Decode()
Definition: pncmesh.cpp:2091
void Init(ParNCMesh *pncmesh, const FiniteElementCollection *fec, int ndofs)
Definition: pncmesh.hpp:508
virtual void Refine(const Array< Refinement > &refinements)
Definition: pncmesh.cpp:911
virtual ~ParNCMesh()
Definition: pncmesh.cpp:49
static bool compare_ranks_indices(const Element *a, const Element *b)
Definition: pncmesh.cpp:588
virtual void Encode()
Definition: pncmesh.cpp:1959
void RecvRebalanceDofs(Array< int > &elements, Array< long > &dofs)
Receive element DOFs sent by SendRebalanceDofs().
Definition: pncmesh.cpp:1580
void GetRow(int row, Array< int > &cols, Vector &srow)
Definition: pncmesh.cpp:2061
Array< Connection > index_rank
Definition: pncmesh.hpp:309
Array< int > edge_owner
Definition: pncmesh.hpp:250
int GetFaceOrientation(int index) const
Return (shared) face orientation relative to the owner element.
Definition: pncmesh.hpp:132
virtual void CheckDerefinementNCLevel(const Table &deref_table, Array< int > &level_ok, int max_nc_level)
Definition: pncmesh.cpp:1253
std::map< int, NeighborDofMessage > Map
Definition: pncmesh.hpp:516
void AddElementRank(Element *elem, int rank)
Definition: pncmesh.hpp:431
const NCList & GetSharedList(int type)
Helper to get shared vertices/edges/faces (&#39;type&#39; == 0/1/2 resp.).
Definition: pncmesh.hpp:121
void EncodeMeshIds(std::ostream &os, Array< MeshId > ids[])
Write to &#39;os&#39; a processor-independent encoding of vertex/edge/face IDs.
Definition: pncmesh.cpp:1784
Vector data type.
Definition: vector.hpp:36
void AddRow(int row, const Array< int > &cols, const Vector &srow)
Definition: pncmesh.cpp:2052
void AddMasterSlaveRanks(int nitems, const NCList &list)
Definition: pncmesh.cpp:271
void Encode(const Array< Element * > &elements)
Definition: pncmesh.cpp:1693
std::set< int > rows
Definition: pncmesh.hpp:539
bool IsGhost(int type, int index) const
Returns true if the specified vertex/edge/face is a ghost.
Definition: pncmesh.hpp:177
const NCList & GetSharedFaces()
Definition: pncmesh.hpp:114
std::map< int, RebalanceMessage > Map
Definition: pncmesh.hpp:443
std::map< int, NeighborRowReply > Map
Definition: pncmesh.hpp:565
void RequestRow(int row)
Definition: pncmesh.hpp:541
void ReorderEdgeDofs(const NCMesh::MeshId &id, std::vector< int > &dofs)
Definition: pncmesh.cpp:1908
Array< Element * > tmp_neighbors
Definition: pncmesh.hpp:356
const int * GetGroup(int type, int index, int &size) const
Definition: pncmesh.hpp:150
void NeighborProcessors(Array< int > &neighbors)
Definition: pncmesh.cpp:576
int RowSize(int i) const
Definition: table.hpp:102
void Add(Element *elem, ValueType val)
Definition: pncmesh.hpp:391
static int get_face_orientation(Face *face, Element *e1, Element *e2, int local[2]=NULL)
Definition: pncmesh.cpp:416
virtual void Encode()
Definition: pncmesh.cpp:2022
virtual void UpdateVertices()
update Vertex::index and vertex_nodeId
Definition: pncmesh.cpp:101
int index
Mesh number.
Definition: ncmesh.hpp:134
Class for parallel meshes.
Definition: pmesh.hpp:28
Abstract data type element.
Definition: element.hpp:27
Variable-length MPI message containing unspecific binary data.
int rank
processor number (ParNCMesh)
Definition: ncmesh.hpp:398
virtual void LimitNCLevel(int max_nc_level)
Parallel version of NCMesh::LimitNCLevel.
Definition: pncmesh.cpp:983
Array< unsigned char > data
encoded refinement (sub-)trees
Definition: pncmesh.hpp:336
const Array< int > & GetDerefineOldRanks() const
Definition: pncmesh.hpp:215
void GetFaceNeighbors(ParMesh &pmesh)
Definition: pncmesh.cpp:594