Shard class
#include <Rodin/Geometry/Shard.h>
Advanced mesh shard for distributed parallel computing.
A Shard is a specialized mesh that represents a portion of a larger mesh in a distributed computing context. Unlike the simplified MeshShard, this class provides full support for ghost polytopes and ownership tracking, which are essential for parallel finite element computations.
Distributed Computing Concepts
In parallel mesh decomposition, each process owns a subset of mesh elements:
- Owned polytopes: Elements that this process is responsible for computing
- Ghost polytopes: Elements owned by other processes but needed for boundary computations
- Halo: The set of processes that need ghost information from this shard
Mathematical Foundation
For a mesh decomposed into shards:
where each shard contains both owned and ghost elements.
Usage in MPI Applications
// Build a shard from a parent mesh Shard::Builder builder; builder.initialize(parentMesh); // Include owned polytopes for (Index idx : ownedCells) builder.include({dimension, idx}, Shard::Flags::Owned); // Include ghost polytopes from neighboring processes for (Index idx : ghostCells) builder.include({dimension, idx}, Shard::Flags::Ghost); Shard shard = builder.finalize(); // Check polytope ownership if (shard.isOwned(d, localIdx)) // Compute on this element
Thread Safety
Shard objects are not thread-safe during construction. Once finalized, read-only operations are thread-safe.
Base classes
-
template<>class Mesh<Context::Local>
- Represents the subdivision of some domain into faces of (possibly) different geometries.
Public types
- class Builder
- Builder for constructing Shard instances.
- class Flags
- Bitmask flags indicating polytope state.
- struct PolytopeMap
- Bidirectional polytope index mapping.
-
using ContextType = Rodin::
Context:: Local - Context type (always local for shards).
- using Parent = Mesh<ContextType>
- Parent mesh type.
Constructors, destructors, conversion operators
Public functions
- auto operator=(Shard&& other) -> Shard&
- Move assignment operator.
- auto isGhost(size_t d, Index idx) const -> bool
- Checks if a polytope is a ghost element.
- auto isOwned(size_t d, Index idx) const -> bool
- Checks if a polytope is owned by this shard.
- auto getOwner(size_t d) const -> const FlatMap<Index, Index>&
- Gets the owner map for a dimension.
- auto getHalo(size_t d) const -> const FlatMap<Index, IndexSet>&
- Gets the halo map for a dimension.
- auto getPolytopeMap(size_t d) const -> const PolytopeMap&
- Gets the polytope index map for a dimension.
-
template<class Archive>void serialize(Archive& ar, const unsigned int version)
- Serialization method for Boost.Serialization.
Function documentation
bool Rodin:: Geometry:: Shard:: isGhost(size_t d,
Index idx) const
Checks if a polytope is a ghost element.
| Parameters | |
|---|---|
| d in | Dimension of the polytope |
| idx in | Local index of the polytope |
| Returns | True if the polytope is ghosted from another process |
Ghost elements are owned by another process but included in this shard for boundary calculations.
bool Rodin:: Geometry:: Shard:: isOwned(size_t d,
Index idx) const
Checks if a polytope is owned by this shard.
| Parameters | |
|---|---|
| d in | Dimension of the polytope |
| idx in | Local index of the polytope |
| Returns | True if the polytope is owned by this process |
Owned elements are those this process is responsible for computing.
const FlatMap<Index, IndexSet>& Rodin:: Geometry:: Shard:: getHalo(size_t d) const
Gets the halo map for a dimension.
| Parameters | |
|---|---|
| d in | Dimension |
| Returns | Map from owned polytope index to set of processes needing it |
The halo identifies which neighboring processes need ghost copies of this shard's owned elements.
const PolytopeMap& Rodin:: Geometry:: Shard:: getPolytopeMap(size_t d) const
Gets the polytope index map for a dimension.
| Parameters | |
|---|---|
| d in | Dimension |
| Returns | Bidirectional mapping between shard and parent indices |
template<class Archive>
void Rodin:: Geometry:: Shard:: serialize(Archive& ar,
const unsigned int version)
Serialization method for Boost.Serialization.
| Template parameters | |
|---|---|
| Archive | Archive type |
| Parameters | |
| ar in/out | Archive object |
| version in | Serialization version |