MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
pncmesh.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_PNCMESH
13#define MFEM_PNCMESH
14
15#include "../config/config.hpp"
16
17#ifdef MFEM_USE_MPI
18
19#include <map>
20#include <set>
21
22#include "ncmesh.hpp"
25#include "../fem/fespace.hpp"
26
27namespace mfem
28{
29
30/** \brief A parallel extension of the NCMesh class.
31 *
32 * The basic idea (and assumption) is that all processors share the coarsest
33 * layer ("root elements"). This has the advantage that refinements can easily
34 * be exchanged between processors when rebalancing since individual elements
35 * can be uniquely identified by the index of the root element and a path in
36 * the refinement tree.
37 *
38 * Each leaf element is owned by one of the processors (NCMesh::Element::rank).
39 * The underlying NCMesh stores not only elements for the current ('MyRank')
40 * processor, but also a minimal layer of adjacent "ghost" elements owned by
41 * other processors. The ghost layer is synchronized after refinement.
42 *
43 * The ghost layer contains all vertex-, edge- and face-neighbors of the
44 * current processor's region. It is used to determine constraining relations
45 * and ownership of DOFs on the processor boundary. Ghost elements are never
46 * seen by the rest of MFEM as they are skipped when a Mesh is created from
47 * the NCMesh.
48 *
49 * The processor that owns a vertex, edge or a face (and in turn its DOFs) is
50 * currently defined to be the one with the lowest rank in the group of
51 * processors that share the entity.
52 *
53 * Vertices, edges and faces that are not owned by this ('MyRank') processor
54 * are ghosts, and are numbered after all real vertices/edges/faces, i.e.,
55 * they have indices greater than NVertices, NEdges, NFaces, respectively.
56 *
57 * A shared vertex/edge/face is identified in an interprocessor message by a
58 * pair of numbers. The first number specifies an element in an ElementSet
59 * (typically sent at the beginning of the message) that contains the v/e/f.
60 * The second number is the local index of the v/e/f in that element.
61 */
62class ParNCMesh : public NCMesh
63{
64protected:
65 ParNCMesh() = default;
66public:
67 /// Construct by partitioning a serial NCMesh.
68 /** SFC partitioning is used by default. A user-specified partition can be
69 passed in 'part', where part[i] is the desired MPI rank for element i. */
70 ParNCMesh(MPI_Comm comm, const NCMesh& ncmesh,
71 const int *partitioning = nullptr);
72
73 /** Load from a stream, parallel version. See the serial NCMesh::NCMesh
74 counterpart for a description of the parameters. */
75 ParNCMesh(MPI_Comm comm, std::istream &input,
76 int version, int &curved, int &is_nc);
77
78 /// Deep copy of another instance.
79 ParNCMesh(const ParNCMesh &other);
80
81 virtual ~ParNCMesh();
82
83 /** An override of NCMesh::Refine, which is called eventually, after making
84 sure that refinements that occur on the processor boundary are sent to
85 the neighbor processors so they can keep their ghost layers up to
86 date. */
87 void Refine(const Array<Refinement> &refinements) override;
88
89 /// Parallel version of NCMesh::LimitNCLevel.
90 void LimitNCLevel(int max_nc_level) override;
91
92 /** Parallel version of NCMesh::CheckDerefinementNCLevel. */
93 void CheckDerefinementNCLevel(const Table &deref_table,
94 Array<int> &level_ok, int max_nc_level) override;
95
96 /** Parallel reimplementation of NCMesh::Derefine, keeps ghost layers
97 in sync. The interface is identical. */
98 void Derefine(const Array<int> &derefs) override;
99
100 /** Gets partitioning for the coarse mesh if the current fine mesh were to
101 be derefined. */
102 void GetFineToCoarsePartitioning(const Array<int> &derefs,
103 Array<int> &new_ranks) const;
104
105 /** Migrate leaf elements of the global refinement hierarchy (including ghost
106 elements) so that each processor owns the same number of leaves (+-1).
107 The default partitioning strategy is based on equal splitting of the
108 space-filling sequence of leaf elements (custom_partition == NULL).
109 Alternatively, a used-defined element-rank assignment array can be
110 passed. */
111 void Rebalance(const Array<int> *custom_partition = NULL);
112
113 // Interface for ParFiniteElementSpace
114 int GetNElements() const { return NElements; }
115
116 int GetNGhostVertices() const { return NGhostVertices; }
117 int GetNGhostEdges() const { return NGhostEdges; }
118 int GetNGhostFaces() const { return NGhostFaces; }
119 int GetNGhostElements() const override { return NGhostElements; }
120
121 // Return a list of vertices/edges/faces shared by this processor and at
122 // least one other processor. These are subsets of NCMesh::<entity>_list. */
126
127 /* Gets the array of global serial indices in NCMesh::elements of all ghost
128 elements for this processor. */
129 void GetGhostElements(Array<int> & gelem);
130
131 /// Helper to get shared vertices/edges/faces ('entity' == 0/1/2 resp.).
132 const NCList& GetSharedList(int entity)
133 {
134 switch (entity)
135 {
136 case 0: return GetSharedVertices();
137 case 1: return GetSharedEdges();
138 default: return GetSharedFaces();
139 }
140 }
141
142 /// Return (shared) face orientation relative to its owner element.
144 {
145 return (index < NFaces) ? face_orient[index] : 0;
146 }
147
148 using GroupId = short;
149 using CommGroup = std::vector<int>;
150
151 /// Return vertex/edge/face ('entity' == 0/1/2, resp.) owner.
153 {
154 MFEM_ASSERT(entity >= 0 && entity < 3, "");
155 MFEM_ASSERT(index >= 0, "");
156 if (!entity_owner[entity].Size())
157 {
158 GetSharedList(entity);
159 }
160 return entity_owner[entity][index];
161 }
162
163 /** Return the P matrix communication group ID for a vertex/edge/face.
164 The groups are calculated specifically to match the P matrix
165 construction algorithm and its communication pattern. */
167 {
168 MFEM_ASSERT(entity >= 0 && entity < 3, "");
169 MFEM_ASSERT(index >= 0, "");
170 if (!entity_pmat_group[entity].Size())
171 {
173 }
174 return entity_pmat_group[entity][index];
175 }
176
177 /// Return a list of ranks contained in the group of the given ID.
178 const CommGroup& GetGroup(GroupId id) const
179 {
180 MFEM_ASSERT(id >= 0, "");
181 return groups[id];
182 }
183
184 /// Return true if group 'id' contains the given rank.
185 bool GroupContains(GroupId id, int rank) const;
186
187 /// Return true if the specified vertex/edge/face is a ghost.
188 bool IsGhost(int entity, int index) const
189 {
190 if (index < 0) // special case prism edge-face constraint
191 {
192 MFEM_ASSERT(entity == 2, "");
193 entity = 1;
194 index = -1 - index;
195 }
196 switch (entity)
197 {
198 case 0: return index >= NVertices;
199 case 1: return index >= NEdges;
200 default: return index >= NFaces;
201 }
202 }
203
204 /** Returns owner processor for element 'index'. This is normally MyRank but
205 for index >= NElements (i.e., for ghosts) it may be something else. */
206 int ElementRank(int index) const
207 {
208 return elements[leaf_elements[index]].rank;
209 }
210
211
212 // utility
213
214 int GetMyRank() const { return MyRank; }
215
216 /// Use the communication pattern from last Rebalance() to send element DOFs.
217 void SendRebalanceDofs(int old_ndofs, const Table &old_element_dofs,
218 long old_global_offset, FiniteElementSpace* space);
219
220 /// Receive element DOFs sent by SendRebalanceDofs().
222
223 /** Get previous indices (pre-Rebalance) of current elements. Index of -1
224 indicates that an element didn't exist in the mesh before. */
226
227 /** Get previous (pre-Derefine) fine element ranks. This complements the
228 CoarseFineTransformations::embeddings array in parallel. */
230
231 /** Exchange element data for derefinements that straddle processor
232 boundaries. 'elem_data' is enlarged and filled with ghost values. */
233 template<typename Type>
235 const Table &deref_table);
236
237 /** Extension of NCMesh::GetBoundaryClosure. Filters out ghost vertices and
238 ghost edges from 'bdr_vertices' and 'bdr_edges', and uncovers hidden
239 internal boundary faces. */
240 void GetBoundaryClosure(const Array<int> &bdr_attr_is_ess,
241 Array<int> &bdr_vertices,
242 Array<int> &bdr_edges, Array<int> &bdr_faces) override;
243
244 /// Save memory by releasing all non-essential and cached data.
245 void Trim() override;
246
247 /// Return total number of bytes allocated.
248 std::size_t MemoryUsage(bool with_base = true) const;
249
250 int PrintMemoryDetail(bool with_base = true) const;
251
252 /** Extract a debugging Mesh containing all leaf elements, including ghosts.
253 The debug mesh will have element attributes set to element rank + 1. */
254 void GetDebugMesh(Mesh &debug_mesh) const;
255
256 // Ghost element indices and their orders, for parallel p-refinement.
258 {
259 unsigned int element; // Element index
260 char order; // Element order
261 };
262
264 const Array<VarOrderElemInfo> & sendData,
265 Array<VarOrderElemInfo> & recvData);
266
267 /** For a ghost element with index @a elem, the edge indices are returned in
268 @a edges. */
269 void FindEdgesOfGhostElement(int elem, Array<int> & edges);
270
271 /** For a ghost element with index @a elem, the face indices are returned in
272 @a faces. */
273 void FindFacesOfGhostElement(int elem, Array<int> & faces);
274
275 /** For a ghost face with index @a face, the edge indices are returned in
276 @a edges. */
277 void FindEdgesOfGhostFace(int face, Array<int> & edges);
278
279protected: // interface for ParMesh
280
281 friend class ParMesh;
282 friend class ParSubMesh;
283
284 /** For compatibility with conforming code in ParMesh and ParFESpace.
285 Initializes shared structures in ParMesh: gtopo, shared_*, group_s*,
286 s*_l*. The ParMesh then acts as a parallel mesh cut along the NC
287 interfaces. */
288 void GetConformingSharedStructures(class ParMesh &pmesh);
289
290 /** Populate face neighbor members of ParMesh from the ghost layer, without
291 communication. */
292 void GetFaceNeighbors(class ParMesh &pmesh);
293protected: // implementation
294
295 MPI_Comm MyComm;
297
298 using GroupList = std::vector<CommGroup>;
299 using GroupMap = std::map<CommGroup, GroupId>;
300
301 GroupList groups; // comm group list; NOTE: groups[0] = { MyRank }
302 GroupMap group_id; // search index over groups
303
304 // owner rank for each vertex, edge and face (encoded as singleton group)
306 // P matrix comm pattern groups for each vertex/edge/face (0/1/2)
308
309 // ParMesh-compatible (conforming) groups for each vertex/edge/face (0/1/2)
311 // ParMesh compatibility helper arrays to order groups, also temporary
313
314 // lists of vertices/edges/faces shared by us and at least one more processor
316
317 Array<char> face_orient; // see CalcFaceOrientations
318
319 /** Type of each leaf element:
320 1 - our element (rank == MyRank),
321 3 - our element, and neighbor to the ghost layer,
322 2 - ghost layer element (existing element, but rank != MyRank),
323 0 - element beyond the ghost layer, may not be a real element.
324 Note: indexed by Element::index. See also UpdateLayers(). */
326
327 Array<int> ghost_layer; ///< list of elements whose 'element_type' == 2.
328 Array<int> boundary_layer; ///< list of type 3 elements
329
330 void Update() override;
331
332 /// Return the processor number for a global element number.
333 int Partition(long index, long total_elements) const
334 { return index * NRanks / total_elements; }
335
336 /// Helper to get the partitioning when the serial mesh gets split initially
337 int InitialPartition(int index) const
338 { return Partition(index, leaf_elements.Size()); }
339
340 /// Return the global index of the first element owned by processor 'rank'.
341 long PartitionFirstIndex(int rank, long total_elements) const
342 { return (rank * total_elements + NRanks-1) / NRanks; }
343
344 void BuildFaceList() override;
345 void BuildEdgeList() override;
346 void BuildVertexList() override;
347
348 void ElementSharesFace(int elem, int local, int face) override;
349 void ElementSharesEdge(int elem, int local, int enode) override;
350 void ElementSharesVertex(int elem, int local, int vnode) override;
351
352 GroupId GetGroupId(const CommGroup &group);
353 GroupId GetSingletonGroup(int rank);
354
355 Array<int> tmp_owner; // temporary
358
359 void InitOwners(int num, Array<GroupId> &entity_owner);
360 void MakeSharedList(const NCList &list, NCList &shared);
361
362 void AddConnections(int entity, int index, const Array<int> &ranks);
364 void CreateGroups(int nentities, Array<Connection> &index_rank,
365 Array<GroupId> &entity_group);
366
367 static int get_face_orientation(const Face &face, const Element &e1,
368 const Element &e2,
369 int local[2] = NULL /* optional output */);
371
372 void UpdateLayers();
373
374 void MakeSharedTable(int ngroups, int ent, Array<int> &shared_local,
375 Table &group_shared, Array<char> *entity_geom = NULL,
376 char geom = 0);
377
378 /** Uniquely encodes a set of leaf elements in the refinement hierarchy of
379 an NCMesh. Can be dumped to a stream, sent to another processor, loaded,
380 and decoded to identify the same set of elements (refinements) in a
381 different but compatible NCMesh. The encoding can optionally include
382 the refinement types needed to reach the leaves, so the element set can
383 be decoded (recreated) even if the receiver has an incomplete tree. */
385 {
386 public:
389 ElementSet(const ElementSet &other);
390
391 void Encode(const Array<int> &elements);
392 void Dump(std::ostream &os) const;
393
394 void Load(std::istream &is);
395 void Decode(Array<int> &elements) const;
396
397 void SetNCMesh(NCMesh *ncmesh_) { this->ncmesh = ncmesh_; }
398 const NCMesh* GetNCMesh() const { return ncmesh; }
399
400 protected:
401 Array<unsigned char> data; ///< encoded refinement (sub-)trees
404
405 void EncodeTree(int elem);
406 void DecodeTree(int elem, int &pos, Array<int> &elements) const;
407
408 void WriteInt(int value);
409 int GetInt(int pos) const;
410 void FlagElements(const Array<int> &elements, char flag);
411
412#ifdef MFEM_DEBUG
414 std::string RefPath() const;
415#endif
416 };
417
418 /** Adjust some of the MeshIds before encoding for recipient 'rank', so that
419 they only reference elements that exist in the recipient's ref. tree. */
420 void AdjustMeshIds(Array<MeshId> ids[], int rank);
421
422 void ChangeVertexMeshIdElement(NCMesh::MeshId &id, int elem);
423 void ChangeEdgeMeshIdElement(NCMesh::MeshId &id, int elem);
424 void ChangeRemainingMeshIds(Array<MeshId> &ids, int pos,
425 const Array<Pair<int, int> > &find);
426
427 // Write/read a processor-independent encoding of vertex/edge/face IDs.
428 void EncodeMeshIds(std::ostream &os, Array<MeshId> ids[]);
429 void DecodeMeshIds(std::istream &is, Array<MeshId> ids[]);
430
431 // Write/read comm groups and a list of their IDs.
432 void EncodeGroups(std::ostream &os, const Array<GroupId> &ids);
433 void DecodeGroups(std::istream &is, Array<GroupId> &ids);
434
435 bool CheckElementType(int elem, int type);
436
437 Array<int> tmp_neighbors; // temporary, used by ElementNeighborProcessors
438
439 /** Return a list of processors that own elements in the immediate
440 neighborhood of 'elem' (i.e., vertex, edge and face neighbors),
441 and are not 'MyRank'. */
442 void ElementNeighborProcessors(int elem, Array<int> &ranks);
443
444 /** Get a list of ranks that own elements in the neighborhood of our region.
445 NOTE: MyRank is not included. */
446 void NeighborProcessors(Array<int> &neighbors);
447
448 /** Traverse the (local) refinement tree and determine which subtrees are
449 no longer needed, i.e., their leaves are not owned by us nor are they our
450 ghosts. These subtrees are then derefined. */
451 void Prune();
452
453 /// Internal. Recursive part of Prune().
454 bool PruneTree(int elem);
455
456
457 /** A base for internal messages used by Refine(), Derefine() and Rebalance().
458 * Allows sending values associated with elements in a set.
459 * If RefType == true, the element set is recreated on the receiving end.
460 */
461 template<class ValueType, bool RefTypes, int Tag>
462 class ElementValueMessage : public VarMessage<Tag>
463 {
464 public:
465 using VarMessage<Tag>::data;
466 std::vector<int> elements;
467 std::vector<ValueType> values;
468
469 int Size() const { return static_cast<int>(elements.size()); }
470 void Reserve(int size) { elements.reserve(size); values.reserve(size); }
471
472 void Add(int elem, ValueType val)
473 { elements.push_back(elem); values.push_back(val); }
474
475 /// Set pointer to ParNCMesh (needed to encode the message).
476 void SetNCMesh(ParNCMesh* pncmesh_) { this->pncmesh = pncmesh_; }
477
479
480 protected:
482
483 void Encode(int) override;
484 void Decode(int) override;
485 };
486
487 /** Used by ParNCMesh::Refine() to inform neighbors about refinements at
488 * the processor boundary. This keeps their ghost layers synchronized.
489 */
491 VarMessageTag::NEIGHBOR_REFINEMENT_VM>
492 {
493 public:
494 void AddRefinement(int elem, char ref_type) { Add(elem, ref_type); }
495 typedef std::map<int, NeighborRefinementMessage> Map;
496 };
497
498 /** Used by ParNCMesh::Derefine() to keep the ghost layers synchronized.
499 */
501 VarMessageTag::NEIGHBOR_DEREFINEMENT_VM>
502 {
503 public:
504 void AddDerefinement(int elem, int rank) { Add(elem, rank); }
505 typedef std::map<int, NeighborDerefinementMessage> Map;
506 };
507
508 /** Used in Step 2 of Rebalance() to synchronize new rank assignments in
509 * the ghost layer.
510 */
512 VarMessageTag::NEIGHBOR_ELEMENT_RANK_VM>
513 {
514 public:
515 void AddElementRank(int elem, int rank) { Add(elem, rank); }
516 typedef std::map<int, NeighborElementRankMessage> Map;
517 };
518
519 /** Used by Rebalance() to send elements and their ranks. Note that
520 * RefTypes == true which means the refinement hierarchy will be recreated
521 * on the receiving side.
522 */
523 class RebalanceMessage : public ElementValueMessage<int, true,
524 VarMessageTag::REBALANCE_VM>
525 {
526 public:
527 void AddElementRank(int elem, int rank) { Add(elem, rank); }
528 typedef std::map<int, RebalanceMessage> Map;
529 };
530
531 /** Allows migrating element data (DOFs) after Rebalance().
532 * Used by SendRebalanceDofs and RecvRebalanceDofs.
533 */
534 class RebalanceDofMessage : public VarMessage<VarMessageTag::REBALANCE_DOF_VM>
535 {
536 public:
537 std::vector<int> elem_ids, dofs;
539
540 void SetElements(const Array<int> &elems, NCMesh *ncmesh);
541 void SetNCMesh(NCMesh* ncmesh) { eset.SetNCMesh(ncmesh); }
542 std::size_t MemoryUsage() const;
543
544 typedef std::map<int, RebalanceDofMessage> Map;
545
546 protected:
548
549 void Encode(int) override;
550 void Decode(int) override;
551 };
552
553 /** Used by CommunicateGhostData to send p-refined element indices and
554 their order. */
556 VarMessageTag::NEIGHBOR_PREFINEMENT_VM>
557 {
558 public:
559 void AddRefinement(int elem, int order) { Add(elem, order); }
560 typedef std::map<int, NeighborPRefinementMessage> Map;
561 };
562
563 /** Assign new Element::rank to leaf elements and send them to their new
564 owners, keeping the ghost layer up to date. Used by Rebalance() and
565 Derefine(). 'target_elements' is the number of elements this rank
566 is supposed to own after the exchange. If this number is not known
567 a priori, the parameter can be set to -1, but more expensive
568 communication (synchronous sends and a barrier) will be used in that
569 case. */
570 void RedistributeElements(Array<int> &new_ranks, int target_elements,
571 bool record_comm);
572
573 /** Recorded communication pattern from last Rebalance. Used by
574 Send/RecvRebalanceDofs to ship element DOFs. */
577
578 /** After Rebalance, this array holds the old element indices, or -1 if an
579 element didn't exist in the mesh previously. After Derefine, it holds
580 the ranks of the old (potentially non-existent) fine elements. */
582
583 /// Stores modified point matrices created by GetFaceNeighbors
585 void ClearAuxPM();
586
587 std::size_t GroupsMemoryUsage() const;
588
589 friend class NeighborRowMessage;
590 friend class NeighborOrderMessage;
591};
592
593
594// comparison operator so that MeshId can be used as key in std::map
595inline bool operator< (const NCMesh::MeshId &a, const NCMesh::MeshId &b)
596{
597 return a.index < b.index;
598}
599
600// equality of MeshId is based on 'index' (element/local are not unique)
601inline bool operator== (const NCMesh::MeshId &a, const NCMesh::MeshId &b)
602{
603 return a.index == b.index;
604}
605
606} // namespace mfem
607
608#endif // MFEM_USE_MPI
609
610#endif // MFEM_PNCMESH
int Size() const
Return the logical size of the array.
Definition array.hpp:147
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
Mesh data type.
Definition mesh.hpp:64
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
Definition ncmesh.hpp:140
int NGhostElements
Definition ncmesh.hpp:721
int PrintMemoryDetail() const
Definition ncmesh.cpp:6905
HashTable< Face > faces
Definition ncmesh.hpp:620
BlockArray< Element > elements
Definition ncmesh.hpp:624
Array< int > leaf_elements
finest elements, in Mesh ordering (+ ghosts)
Definition ncmesh.hpp:723
int NGhostVertices
Definition ncmesh.hpp:721
const NCList & GetVertexList()
Definition ncmesh.hpp:334
const NCList & GetFaceList()
Return the current list of conforming and nonconforming faces.
Definition ncmesh.hpp:319
const NCList & GetEdgeList()
Return the current list of conforming and nonconforming edges.
Definition ncmesh.hpp:326
int MyRank
used in parallel, or when loading a parallel file in serial
Definition ncmesh.hpp:525
int NGhostEdges
Definition ncmesh.hpp:721
long MemoryUsage() const
Return total number of bytes allocated.
Definition ncmesh.cpp:6882
int NGhostFaces
Definition ncmesh.hpp:721
A pair of objects.
Class for parallel meshes.
Definition pmesh.hpp:34
void DecodeTree(int elem, int &pos, Array< int > &elements) const
Definition pncmesh.cpp:2472
Array< unsigned char > data
encoded refinement (sub-)trees
Definition pncmesh.hpp:401
const NCMesh * GetNCMesh() const
Definition pncmesh.hpp:398
void Encode(const Array< int > &elements)
Definition pncmesh.cpp:2433
ElementSet(NCMesh *ncmesh=NULL, bool include_ref_types=false)
Definition pncmesh.hpp:387
int GetInt(int pos) const
Definition pncmesh.cpp:2372
void Decode(Array< int > &elements) const
Definition pncmesh.cpp:2514
void FlagElements(const Array< int > &elements, char flag)
Definition pncmesh.cpp:2381
std::string RefPath() const
Definition pncmesh.cpp:2454
void Load(std::istream &is)
Definition pncmesh.cpp:2530
void Dump(std::ostream &os) const
Definition pncmesh.cpp:2524
void SetNCMesh(NCMesh *ncmesh_)
Definition pncmesh.hpp:397
std::vector< ValueType > values
Definition pncmesh.hpp:467
void Add(int elem, ValueType val)
Definition pncmesh.hpp:472
void SetNCMesh(ParNCMesh *pncmesh_)
Set pointer to ParNCMesh (needed to encode the message).
Definition pncmesh.hpp:476
std::map< int, NeighborDerefinementMessage > Map
Definition pncmesh.hpp:505
void AddDerefinement(int elem, int rank)
Definition pncmesh.hpp:504
void AddElementRank(int elem, int rank)
Definition pncmesh.hpp:515
std::map< int, NeighborElementRankMessage > Map
Definition pncmesh.hpp:516
void AddRefinement(int elem, int order)
Definition pncmesh.hpp:559
std::map< int, NeighborPRefinementMessage > Map
Definition pncmesh.hpp:560
void AddRefinement(int elem, char ref_type)
Definition pncmesh.hpp:494
std::map< int, NeighborRefinementMessage > Map
Definition pncmesh.hpp:495
void SetElements(const Array< int > &elems, NCMesh *ncmesh)
Definition pncmesh.cpp:2919
std::map< int, RebalanceDofMessage > Map
Definition pncmesh.hpp:544
std::map< int, RebalanceMessage > Map
Definition pncmesh.hpp:528
void AddElementRank(int elem, int rank)
Definition pncmesh.hpp:527
A parallel extension of the NCMesh class.
Definition pncmesh.hpp:63
Array< int > entity_elem_local[3]
Definition pncmesh.hpp:312
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:2285
void MakeSharedTable(int ngroups, int ent, Array< int > &shared_local, Table &group_shared, Array< char > *entity_geom=NULL, char geom=0)
Definition pncmesh.cpp:832
Array< int > tmp_neighbors
Definition pncmesh.hpp:437
bool IsGhost(int entity, int index) const
Return true if the specified vertex/edge/face is a ghost.
Definition pncmesh.hpp:188
NCList shared_edges
Definition pncmesh.hpp:315
int GetFaceOrientation(int index) const
Return (shared) face orientation relative to its owner element.
Definition pncmesh.hpp:143
Array< Connection > entity_index_rank[3]
Definition pncmesh.hpp:357
GroupMap group_id
Definition pncmesh.hpp:302
std::map< CommGroup, GroupId > GroupMap
Definition pncmesh.hpp:299
GroupId GetEntityGroupId(int entity, int index)
Definition pncmesh.hpp:166
int GetNGhostEdges() const
Definition pncmesh.hpp:117
RebalanceDofMessage::Map send_rebalance_dofs
Definition pncmesh.hpp:575
void CalcFaceOrientations()
Definition pncmesh.cpp:637
const Array< int > & GetDerefineOldRanks() const
Definition pncmesh.hpp:229
void DecodeGroups(std::istream &is, Array< GroupId > &ids)
Definition pncmesh.cpp:2819
bool PruneTree(int elem)
Internal. Recursive part of Prune().
Definition pncmesh.cpp:1437
bool CheckElementType(int elem, int type)
Definition pncmesh.cpp:766
const CommGroup & GetGroup(GroupId id) const
Return a list of ranks contained in the group of the given ID.
Definition pncmesh.hpp:178
void GetGhostElements(Array< int > &gelem)
Definition pncmesh.cpp:3119
void Trim() override
Save memory by releasing all non-essential and cached data.
Definition pncmesh.cpp:3000
void BuildVertexList() override
Definition pncmesh.cpp:339
void FindEdgesOfGhostElement(int elem, Array< int > &edges)
Definition pncmesh.cpp:277
void FindFacesOfGhostElement(int elem, Array< int > &faces)
Definition pncmesh.cpp:303
Array< int > ghost_layer
list of elements whose 'element_type' == 2.
Definition pncmesh.hpp:327
void BuildFaceList() override
Definition pncmesh.cpp:151
void GetFaceNeighbors(class ParMesh &pmesh)
Definition pncmesh.cpp:993
int GetNGhostFaces() const
Definition pncmesh.hpp:118
void LimitNCLevel(int max_nc_level) override
Parallel version of NCMesh::LimitNCLevel.
Definition pncmesh.cpp:1586
RebalanceDofMessage::Map recv_rebalance_dofs
Definition pncmesh.hpp:576
void ChangeVertexMeshIdElement(NCMesh::MeshId &id, int elem)
Definition pncmesh.cpp:2621
void UpdateLayers()
Definition pncmesh.cpp:728
void EncodeGroups(std::ostream &os, const Array< GroupId > &ids)
Definition pncmesh.cpp:2777
virtual ~ParNCMesh()
Definition pncmesh.cpp:93
void Refine(const Array< Refinement > &refinements) override
Definition pncmesh.cpp:1508
int ElementRank(int index) const
Definition pncmesh.hpp:206
void FindEdgesOfGhostFace(int face, Array< int > &edges)
Definition pncmesh.cpp:256
Array< GroupId > entity_conf_group[3]
Definition pncmesh.hpp:310
Array< int > boundary_layer
list of type 3 elements
Definition pncmesh.hpp:328
int Partition(long index, long total_elements) const
Return the processor number for a global element number.
Definition pncmesh.hpp:333
void AdjustMeshIds(Array< MeshId > ids[], int rank)
Definition pncmesh.cpp:2539
NCList shared_vertices
Definition pncmesh.hpp:315
std::size_t GroupsMemoryUsage() const
Definition pncmesh.cpp:3041
const NCList & GetSharedVertices()
Definition pncmesh.hpp:123
void ChangeEdgeMeshIdElement(NCMesh::MeshId &id, int elem)
Definition pncmesh.cpp:2639
void GetConformingSharedStructures(class ParMesh &pmesh)
Definition pncmesh.cpp:892
void Derefine(const Array< int > &derefs) override
Definition pncmesh.cpp:1635
void Rebalance(const Array< int > *custom_partition=NULL)
Definition pncmesh.cpp:1947
int GetNGhostElements() const override
Definition pncmesh.hpp:119
void ElementNeighborProcessors(int elem, Array< int > &ranks)
Definition pncmesh.cpp:783
void RecvRebalanceDofs(Array< int > &elements, Array< long > &dofs)
Receive element DOFs sent by SendRebalanceDofs().
Definition pncmesh.cpp:2318
static int get_face_orientation(const Face &face, const Element &e1, const Element &e2, int local[2]=NULL)
Definition pncmesh.cpp:607
void GetFineToCoarsePartitioning(const Array< int > &derefs, Array< int > &new_ranks) const
Definition pncmesh.cpp:1604
void ElementSharesFace(int elem, int local, int face) override
Definition pncmesh.cpp:128
void BuildEdgeList() override
Definition pncmesh.cpp:218
Array< char > tmp_shared_flag
Definition pncmesh.hpp:356
NCList shared_faces
Definition pncmesh.hpp:315
Array< int > old_index_or_rank
Definition pncmesh.hpp:581
MPI_Comm MyComm
Definition pncmesh.hpp:295
std::vector< int > CommGroup
Definition pncmesh.hpp:149
void DecodeMeshIds(std::istream &is, Array< MeshId > ids[])
Definition pncmesh.cpp:2720
void GetBoundaryClosure(const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges, Array< int > &bdr_faces) override
Definition pncmesh.cpp:663
void EncodeMeshIds(std::ostream &os, Array< MeshId > ids[])
Definition pncmesh.cpp:2677
Array< DenseMatrix * > aux_pm_store
Stores modified point matrices created by GetFaceNeighbors.
Definition pncmesh.hpp:584
void CheckDerefinementNCLevel(const Table &deref_table, Array< int > &level_ok, int max_nc_level) override
Definition pncmesh.cpp:1889
void RedistributeElements(Array< int > &new_ranks, int target_elements, bool record_comm)
Definition pncmesh.cpp:2008
const NCList & GetSharedList(int entity)
Helper to get shared vertices/edges/faces ('entity' == 0/1/2 resp.).
Definition pncmesh.hpp:132
Array< int > tmp_owner
Definition pncmesh.hpp:355
int GetMyRank() const
Definition pncmesh.hpp:214
int GetNElements() const
Definition pncmesh.hpp:114
GroupId GetSingletonGroup(int rank)
Definition pncmesh.cpp:477
void ChangeRemainingMeshIds(Array< MeshId > &ids, int pos, const Array< Pair< int, int > > &find)
Definition pncmesh.cpp:2665
Array< char > face_orient
Definition pncmesh.hpp:317
GroupId GetEntityOwnerId(int entity, int index)
Return vertex/edge/face ('entity' == 0/1/2, resp.) owner.
Definition pncmesh.hpp:152
Array< char > element_type
Definition pncmesh.hpp:325
void InitOwners(int num, Array< GroupId > &entity_owner)
Definition pncmesh.cpp:371
int GetNGhostVertices() const
Definition pncmesh.hpp:116
GroupList groups
Definition pncmesh.hpp:301
Array< GroupId > entity_owner[3]
Definition pncmesh.hpp:305
void CalculatePMatrixGroups()
Definition pncmesh.cpp:535
void ElementSharesEdge(int elem, int local, int enode) override
Definition pncmesh.cpp:193
ParNCMesh()=default
const NCList & GetSharedEdges()
Definition pncmesh.hpp:124
void GetDebugMesh(Mesh &debug_mesh) const
Definition pncmesh.cpp:2983
void Update() override
Definition pncmesh.cpp:98
std::vector< CommGroup > GroupList
Definition pncmesh.hpp:298
bool GroupContains(GroupId id, int rank) const
Return true if group 'id' contains the given rank.
Definition pncmesh.cpp:486
const NCList & GetSharedFaces()
Definition pncmesh.hpp:125
const Array< int > & GetRebalanceOldIndex() const
Definition pncmesh.hpp:225
Array< GroupId > entity_pmat_group[3]
Definition pncmesh.hpp:307
void MakeSharedList(const NCList &list, NCList &shared)
Definition pncmesh.cpp:381
void AddConnections(int entity, int index, const Array< int > &ranks)
Definition pncmesh.cpp:527
int InitialPartition(int index) const
Helper to get the partitioning when the serial mesh gets split initially.
Definition pncmesh.hpp:337
void NeighborProcessors(Array< int > &neighbors)
Definition pncmesh.cpp:815
void CreateGroups(int nentities, Array< Connection > &index_rank, Array< GroupId > &entity_group)
Definition pncmesh.cpp:497
void SynchronizeDerefinementData(Array< Type > &elem_data, const Table &deref_table)
Definition pncmesh.cpp:1807
GroupId GetGroupId(const CommGroup &group)
Definition pncmesh.cpp:461
void CommunicateGhostData(const Array< VarOrderElemInfo > &sendData, Array< VarOrderElemInfo > &recvData)
Definition pncmesh.cpp:3132
long PartitionFirstIndex(int rank, long total_elements) const
Return the global index of the first element owned by processor 'rank'.
Definition pncmesh.hpp:341
void ElementSharesVertex(int elem, int local, int vnode) override
Definition pncmesh.cpp:316
Subdomain representation of a topological parent in another ParMesh.
Definition psubmesh.hpp:54
int index(int i, int j, int nx, int ny)
Definition life.cpp:236
real_t b
Definition lissajous.cpp:42
real_t a
Definition lissajous.cpp:41
string space
bool operator==(const Array< T > &LHS, const Array< T > &RHS)
Definition array.hpp:362
bool operator<(const Pair< A, B > &p, const Pair< A, B > &q)
Comparison operator for class Pair, based on the first element only.
Identifies a vertex/edge/face in both Mesh and NCMesh.
Definition ncmesh.hpp:210
Lists all edges/faces in the nonconforming mesh.
Definition ncmesh.hpp:251
Variable-length MPI message containing unspecific binary data.