MFEM  v3.3.2
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 owned 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 elements[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().
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  Note: indexed by Element::index. See also UpdateLayers(). */
267 
268  Array<int> ghost_layer; ///< list of elements whose 'element_type' == 2.
269  Array<int> 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 partitioning when the serial mesh gets 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& el) const
289  { return el.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(int elem, int enode);
299  virtual void ElementSharesFace(int elem, int face);
300 
301  void BuildSharedVertices();
302 
303  static int get_face_orientation(Face &face, Element &e1, Element &e2,
304  int local[2] = NULL /* optional output */);
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<int> &elements);
328  void Dump(std::ostream &os) const;
329 
330  void Load(std::istream &is);
331  void Decode(Array<int> &elements) const;
332 
333  void SetNCMesh(NCMesh *ncmesh) { this->ncmesh = ncmesh; }
334  const NCMesh* GetNCMesh() const { return ncmesh; }
335 
336  protected:
337  Array<unsigned char> data; ///< encoded refinement (sub-)trees
340 
341  void EncodeTree(int elem);
342  void DecodeTree(int elem, int &pos, Array<int> &elements) const;
343 
344  void WriteInt(int value);
345  int GetInt(int pos) const;
346  void FlagElements(const Array<int> &elements, char flag);
347  };
348 
349  /// Write to 'os' a processor-independent encoding of vertex/edge/face IDs.
350  void EncodeMeshIds(std::ostream &os, Array<MeshId> ids[]);
351 
352  /// Read from 'is' a processor-independent encoding of vertex/edge/face IDs.
353  void DecodeMeshIds(std::istream &is, Array<MeshId> ids[]);
354 
355  bool CheckElementType(int elem, int type);
356 
357  Array<int> tmp_neighbors; // temporary, used by ElementNeighborProcessors
358 
359  /** Return a list of processors that own elements in the immediate
360  neighborhood of 'elem' (i.e., vertex, edge and face neighbors),
361  and are not 'MyRank'. */
362  void ElementNeighborProcessors(int elem, Array<int> &ranks);
363 
364  /** Get a list of ranks that own elements in the neighborhood of our region.
365  NOTE: MyRank is not included. */
366  void NeighborProcessors(Array<int> &neighbors);
367 
368  /** Traverse the (local) refinement tree and determine which subtrees are
369  no longer needed, i.e., their leaves are not owned by us nor are they our
370  ghosts. These subtrees are then derefined. */
371  void Prune();
372 
373  /// Internal. Recursive part of Prune().
374  bool PruneTree(int elem);
375 
376 
377  /** A base for internal messages used by Refine(), Derefine() and Rebalance().
378  * Allows sending values associated with elements in a set.
379  * If RefType == true, the element set is recreated on the receiving end.
380  */
381  template<class ValueType, bool RefTypes, int Tag>
382  class ElementValueMessage : public VarMessage<Tag>
383  {
384  public:
385  using VarMessage<Tag>::data;
386  std::vector<int> elements;
387  std::vector<ValueType> values;
388 
389  int Size() const { return elements.size(); }
390  void Reserve(int size) { elements.reserve(size); values.reserve(size); }
391 
392  void Add(int elem, ValueType val)
393  { elements.push_back(elem); values.push_back(val); }
394 
395  /// Set pointer to ParNCMesh (needed to encode the message).
396  void SetNCMesh(ParNCMesh* pncmesh) { this->pncmesh = pncmesh; }
397 
399 
400  protected:
402 
403  virtual void Encode();
404  virtual void Decode();
405  };
406 
407  /** Used by ParNCMesh::Refine() to inform neighbors about refinements at
408  * the processor boundary. This keeps their ghost layers synchronized.
409  */
410  class NeighborRefinementMessage : public ElementValueMessage<char, false, 289>
411  {
412  public:
413  void AddRefinement(int elem, char ref_type) { Add(elem, ref_type); }
414  typedef std::map<int, NeighborRefinementMessage> Map;
415  };
416 
417  /** Used by ParNCMesh::Derefine() to keep the ghost layers synchronized.
418  */
419  class NeighborDerefinementMessage : public ElementValueMessage<int, false, 290>
420  {
421  public:
422  void AddDerefinement(int elem, int rank) { Add(elem, rank); }
423  typedef std::map<int, NeighborDerefinementMessage> Map;
424  };
425 
426  /** Used in Step 2 of Rebalance() to synchronize new rank assignments in
427  * the ghost layer.
428  */
429  class NeighborElementRankMessage : public ElementValueMessage<int, false, 156>
430  {
431  public:
432  void AddElementRank(int elem, int rank) { Add(elem, rank); }
433  typedef std::map<int, NeighborElementRankMessage> Map;
434  };
435 
436  /** Used by Rebalance() to send elements and their ranks. Note that
437  * RefTypes == true which means the refinement hierarchy will be recreated
438  * on the receiving side.
439  */
440  class RebalanceMessage : public ElementValueMessage<int, true, 157>
441  {
442  public:
443  void AddElementRank(int elem, int rank) { Add(elem, rank); }
444  typedef std::map<int, RebalanceMessage> Map;
445  };
446 
447  /** Allows migrating element data (DOFs) after Rebalance().
448  * Used by SendRebalanceDofs and RecvRebalanceDofs.
449  */
450  class RebalanceDofMessage : public VarMessage<158>
451  {
452  public:
453  std::vector<int> elem_ids, dofs;
455 
456  void SetElements(const Array<int> &elems, NCMesh *ncmesh);
457  void SetNCMesh(NCMesh* ncmesh) { eset.SetNCMesh(ncmesh); }
458 
459  typedef std::map<int, RebalanceDofMessage> Map;
460 
461  protected:
463 
464  virtual void Encode();
465  virtual void Decode();
466  };
467 
468  /** Assign new Element::rank to leaf elements and send them to their new
469  owners, keeping the ghost layer up to date. Used by Rebalance() and
470  Derefine(). */
471  void RedistributeElements(Array<int> &new_ranks, int target_elements,
472  bool record_comm);
473 
474  /** Recorded communication pattern from last Rebalance. Used by
475  Send/RecvRebalanceDofs to ship element DOFs. */
478 
479  /** After Rebalance, this array holds the old element indices, or -1 if an
480  element didn't exist in the mesh previously. After Derefine, it holds
481  the ranks of the old (potentially non-existent) fine elements. */
483 
484  /// Stores modified point matrices created by GetFaceNeighbors
486  void ClearAuxPM();
487 
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:385
NCList edge_list
lazy-initialized list of edges, see GetEdgeList
Definition: ncmesh.hpp:386
NCList shared_edges
Definition: pncmesh.hpp:245
void SetNCMesh(NCMesh *ncmesh)
Definition: pncmesh.hpp:457
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:1592
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:1874
Array< char > element_type
Definition: pncmesh.hpp:266
int Size() const
Logical size of the array.
Definition: array.hpp:110
std::vector< ValueType > values
Definition: pncmesh.hpp:387
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:450
void AddDofs(int type, const NCMesh::MeshId &id, const Array< int > &dofs)
Add vertex/edge/face DOFs to an outgoing message.
Definition: pncmesh.cpp:1934
Array< char > face_orient
Definition: pncmesh.hpp:258
void WriteInt(int value)
Definition: pncmesh.cpp:1670
virtual int GetNumGhosts() const
Definition: pncmesh.hpp:291
MPI_Comm MyComm
Definition: pncmesh.hpp:235
virtual void BuildFaceList()
Definition: pncmesh.cpp:244
void Dump(std::ostream &os) const
Definition: pncmesh.cpp:1816
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:166
void SetNCMesh(ParNCMesh *pncmesh)
Set pointer to ParNCMesh (needed to encode the message).
Definition: pncmesh.hpp:396
std::map< int, NeighborElementRankMessage > Map
Definition: pncmesh.hpp:433
const NCMesh * GetNCMesh() const
Definition: pncmesh.hpp:334
void BuildSharedVertices()
Definition: pncmesh.cpp:372
void Load(std::istream &is)
Definition: pncmesh.cpp:1822
void GetRow(int i, Array< int > &row) const
Return row i in array row (the Table must be finalized)
Definition: table.cpp:179
void Add(int elem, ValueType val)
Definition: pncmesh.hpp:392
void SynchronizeDerefinementData(Array< Type > &elem_data, const Table &deref_table)
Definition: pncmesh.cpp:1208
int GetInt(int pos) const
Definition: pncmesh.cpp:1679
virtual void OnMeshUpdated(Mesh *mesh)
Definition: pncmesh.cpp:147
virtual void Derefine(const Array< int > &derefs)
Definition: pncmesh.cpp:1036
void SetElements(const Array< int > &elems, NCMesh *ncmesh)
Definition: pncmesh.cpp:2225
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
int GetOwner(int type, int index) const
Return vertex/edge/face (&#39;type&#39; == 0/1/2, resp.) owner.
Definition: pncmesh.hpp:138
void EncodeTree(int elem)
Definition: pncmesh.cpp:1703
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:344
bool RankInGroup(int type, int index, int rank) const
Definition: pncmesh.hpp:165
virtual void Decode()
Definition: pncmesh.cpp:2088
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:175
Array< int > vertex_owner
Definition: pncmesh.hpp:249
RebalanceDofMessage::Map send_rebalance_dofs
Definition: pncmesh.hpp:476
void FlagElements(const Array< int > &elements, char flag)
Definition: pncmesh.cpp:1688
virtual void Update()
Definition: pncmesh.cpp:54
const FiniteElementCollection * fec
Definition: pncmesh.hpp:523
void Decode(Array< int > &elements) const
Definition: pncmesh.cpp:1792
virtual void Decode()
Definition: pncmesh.cpp:2047
Table face_group
Definition: pncmesh.hpp:256
void AddElementRank(int elem, int rank)
Definition: pncmesh.hpp:443
virtual bool IsGhost(const Element &el) const
Definition: pncmesh.hpp:288
Array< DenseMatrix * > aux_pm_store
Stores modified point matrices created by GetFaceNeighbors.
Definition: pncmesh.hpp:485
void RedistributeElements(Array< int > &new_ranks, int target_elements, bool record_comm)
Definition: pncmesh.cpp:1404
void ElementNeighborProcessors(int elem, Array< int > &ranks)
Definition: pncmesh.cpp:556
Array< int > old_index_or_rank
Definition: pncmesh.hpp:482
RebalanceDofMessage::Map recv_rebalance_dofs
Definition: pncmesh.hpp:477
int InitialPartition(int index) const
Helper to get the partitioning when the serial mesh gets split initially.
Definition: pncmesh.hpp:278
bool HaveRow(int row) const
Definition: pncmesh.hpp:562
NCList shared_vertices
Definition: pncmesh.hpp:244
void AddRefinement(int elem, char ref_type)
Definition: pncmesh.hpp:413
Identifies a vertex/edge/face in both Mesh and NCMesh.
Definition: ncmesh.hpp:130
std::map< int, NeighborRefinementMessage > Map
Definition: pncmesh.hpp:414
Table edge_group
Definition: pncmesh.hpp:255
A class for non-conforming AMR on higher-order hexahedral, quadrilateral or triangular meshes...
Definition: ncmesh.hpp:83
void ClearAuxPM()
Definition: pncmesh.cpp:866
NCList shared_faces
Definition: pncmesh.hpp:246
virtual void GetBoundaryClosure(const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges)
Definition: pncmesh.cpp:476
void Rebalance()
Definition: pncmesh.cpp:1346
void RemoveRequest(int row)
Definition: pncmesh.hpp:542
virtual void ElementSharesEdge(int elem, int enode)
Definition: pncmesh.cpp:192
Table vertex_group
Definition: pncmesh.hpp:254
Array< int > tmp_neighbors
Definition: pncmesh.hpp:357
std::map< int, RebalanceDofMessage > Map
Definition: pncmesh.hpp:459
std::map< int, NeighborDerefinementMessage > Map
Definition: pncmesh.hpp:423
const Array< int > & GetRebalanceOldIndex() const
Definition: pncmesh.hpp:211
virtual void BuildEdgeList()
Definition: pncmesh.cpp:220
void Encode(const Array< int > &elements)
Definition: pncmesh.cpp:1740
void GetDebugMesh(Mesh &debug_mesh) const
Definition: pncmesh.cpp:2276
int ElementRank(int index) const
Definition: pncmesh.hpp:189
bool PruneTree(int elem)
Internal. Recursive part of Prune().
Definition: pncmesh.cpp:878
void GetDofs(int type, const NCMesh::MeshId &id, Array< int > &dofs, int &ndofs)
Definition: pncmesh.cpp:1941
std::map< int, Row > rows
Definition: pncmesh.hpp:569
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:2122
void UpdateLayers()
Definition: pncmesh.cpp:501
virtual void Decode()
Definition: pncmesh.cpp:2142
void Init(ParNCMesh *pncmesh, const FiniteElementCollection *fec, int ndofs)
Definition: pncmesh.hpp:508
virtual void Refine(const Array< Refinement > &refinements)
Definition: pncmesh.cpp:946
virtual ~ParNCMesh()
Definition: pncmesh.cpp:49
static bool compare_ranks_indices(const Element *a, const Element *b)
Definition: pncmesh.cpp:600
virtual void Encode()
Definition: pncmesh.cpp:2010
void RecvRebalanceDofs(Array< int > &elements, Array< long > &dofs)
Receive element DOFs sent by SendRebalanceDofs().
Definition: pncmesh.cpp:1625
Array< int > leaf_elements
Definition: ncmesh.hpp:382
void GetRow(int row, Array< int > &cols, Vector &srow)
Definition: pncmesh.cpp:2112
Array< int > boundary_layer
list of type 3 elements
Definition: pncmesh.hpp:269
void AddElementRank(int elem, int rank)
Definition: pncmesh.hpp:432
Array< Connection > index_rank
Definition: pncmesh.hpp:309
Array< int > edge_owner
Definition: pncmesh.hpp:250
void DecodeTree(int elem, int &pos, Array< int > &elements) const
Definition: pncmesh.cpp:1760
int GetFaceOrientation(int index) const
Return (shared) face orientation relative to the owner element.
Definition: pncmesh.hpp:132
BlockArray< Element > elements
Definition: ncmesh.hpp:360
virtual void CheckDerefinementNCLevel(const Table &deref_table, Array< int > &level_ok, int max_nc_level)
Definition: pncmesh.cpp:1288
std::map< int, NeighborDofMessage > Map
Definition: pncmesh.hpp:516
Array< int > ghost_layer
list of elements whose &#39;element_type&#39; == 2.
Definition: pncmesh.hpp:268
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:1831
Vector data type.
Definition: vector.hpp:41
void AddRow(int row, const Array< int > &cols, const Vector &srow)
Definition: pncmesh.cpp:2103
void AddMasterSlaveRanks(int nitems, const NCList &list)
Definition: pncmesh.cpp:277
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
void AddDerefinement(int elem, int rank)
Definition: pncmesh.hpp:422
std::map< int, RebalanceMessage > Map
Definition: pncmesh.hpp:444
static int get_face_orientation(Face &face, Element &e1, Element &e2, int local[2]=NULL)
Definition: pncmesh.cpp:424
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:1958
const int * GetGroup(int type, int index, int &size) const
Definition: pncmesh.hpp:150
void NeighborProcessors(Array< int > &neighbors)
Definition: pncmesh.cpp:588
int RowSize(int i) const
Definition: table.hpp:105
virtual void Encode()
Definition: pncmesh.cpp:2073
bool CheckElementType(int elem, int type)
Definition: pncmesh.cpp:539
virtual void UpdateVertices()
update Vertex::index and vertex_nodeId
Definition: pncmesh.cpp:101
int index
Mesh number.
Definition: ncmesh.hpp:132
Class for parallel meshes.
Definition: pmesh.hpp:29
Abstract data type element.
Definition: element.hpp:27
virtual void ElementSharesFace(int elem, int face)
Definition: pncmesh.cpp:207
Variable-length MPI message containing unspecific binary data.
int rank
processor number (ParNCMesh), -1 if undefined/unknown
Definition: ncmesh.hpp:338
virtual void LimitNCLevel(int max_nc_level)
Parallel version of NCMesh::LimitNCLevel.
Definition: pncmesh.cpp:1018
Array< unsigned char > data
encoded refinement (sub-)trees
Definition: pncmesh.hpp:337
const Array< int > & GetDerefineOldRanks() const
Definition: pncmesh.hpp:215
void GetFaceNeighbors(ParMesh &pmesh)
Definition: pncmesh.cpp:606