Template Class DistributedSparseGridUniform
Defined in File DistributedSparseGridUniform.hpp
Inheritance Relationships
Base Type
public combigrid::AnyDistributedSparseGrid(Class AnyDistributedSparseGrid)
Class Documentation
-
template<typename FG_ELEMENT>
class DistributedSparseGridUniform : public combigrid::AnyDistributedSparseGrid a distributed sparse grid with uniform domain decomposition (on all process groups)
This class can store a distributed sparse grid with a uniform space decomposition. During construction no data is created and the data size of the subspaces is initialized to zero (data sizes are usually set the first time by registering the dsg in a distributed fullgrid during local reduce). The data can be explicitly created by calling the createSubspaceData() method or is implicitly generated as soon as it is accessed. By calling deleteSubspaceData() the data can be deallocated.
Public Types
-
using ElementType = FG_ELEMENT
Public Functions
-
explicit DistributedSparseGridUniform(DimType dim, const LevelVector &lmax, const LevelVector &lmin, CommunicatorType comm)
create sparse grid
No data is allocated and the sizes of the subspace data is initialized to 0.
- Parameters:
dim – dimensionality of the grid
lmax – maximum level of the grid
lmin – minimum level of the grid
comm – communicator for the grid
-
explicit DistributedSparseGridUniform(DimType dim, const std::vector<LevelVector> &subspaces, CommunicatorType comm)
create an empty (no data) sparse grid with given subspaces.
-
virtual ~DistributedSparseGridUniform() = default
-
DistributedSparseGridDataContainer<FG_ELEMENT> &getDataContainer()
-
void swapDataContainers(DistributedSparseGridDataContainer<FG_ELEMENT> &otherContainer)
-
void allocateDifferentSubspaces(std::set<SubspaceIndexType> &&subspaces)
(re-)allocate memory for (another) set of subspaces
-
const std::set<SubspaceIndexType> &getCurrentlyAllocatedSubspaces() const
-
bool isSubspaceCurrentlyAllocated(SubspaceIndexType subspaceIndex) const
-
void print(std::ostream &os) const
print the subspace sizes of the grid to the output stream
-
void createSubspaceData()
allocates memory for subspace data
Zero initializes the dsgu data in case no data is already present. Otherwise nothing happens.
-
void createKahanBuffer()
allocates memory for kahan term data
-
void deleteSubspaceData()
deletes memory for subspace data and invalidates pointers to subspaces
Deallocates the dsgu data. This affects the values stored at the grid points and pointers which address the subspaces data.
-
void setZero()
sets all data elements to value zero, allocates if not yet allocated
-
inline const std::vector<LevelVector> &getAllLevelVectors() const
get the level vectors of all subspaces
-
inline const LevelVector &getLevelVector(SubspaceIndexType i) const
get the level vector of subspace i
-
inline const LevelVector &getLevelVector(size_t i) const
-
inline SubspaceIndexType getIndexInRange(const LevelVector &l, IndexType lowerBound) const
get the subspace index corresponding to a level vector
uses a lowerBound to search for the level vector in the range of levels_
- Parameters:
l – level vector
lowerBound – lower bound for the search
-
inline SubspaceIndexType getIndex(const LevelVector &l) const
get the subspace index corresponding to a level vector
for an optimized search,
See also
-
inline FG_ELEMENT *getData(SubspaceIndexType i)
returns a pointer to first element in subspace i
-
inline const FG_ELEMENT *getData(SubspaceIndexType i) const
-
inline FG_ELEMENT *getRawData()
returns a pointer to first element in subspace 0
-
inline const FG_ELEMENT *getRawData() const
-
void resetLevels()
clear the levels_ vector
used for registration of full grids
-
inline virtual void setDataSize(SubspaceIndexType i, SubspaceSizeType newSize) override
re-set the size of a subspace
this does not change allocated memory
-
SubspaceSizeType getAllocatedDataSize(SubspaceIndexType i) const
get the number of allocated numbers in subspace i
- Returns:
getSubspaceDataSizes()[i] if i is allocated, 0 otherwise
-
std::vector<combigrid::real> &getMinCoefficientsPerSubspace()
get the minimum value stored in every subspace
make sure to call accumulateMinMaxCoefficients() first
-
std::vector<combigrid::real> &getMaxCoefficientsPerSubspace()
get the maximum value stored in every subspace
make sure to call accumulateMinMaxCoefficients() first
-
void clearMinMaxCoefficientsPerSubspace()
clear the min/max coefficient vectors
-
void accumulateMinMaxCoefficients()
accumulate the min/max coefficients of all subspaces
-
template<DimType DIM>
inline void registerDistributedFullGrid(const DistributedFullGrid<FG_ELEMENT, DIM> &dfg) register a DistributedFullGrid in this DistributedSparseGridUniform
“registers” the DistributedFullGrid with this DistributedSparseGridUniform: sets the dsg’s subspaceSizes where they are not yet set to contain all of the DFG’s subspaces. The size of a subspace in the dsg is chosen according to the corresponding subspace size in the dfg.
overwrites this’ subspace sizes for all subspaces contained in the full grid, but does not allocate memory
- Parameters:
dfg – the DFG to register
-
template<bool sparseGridFullyAllocated = true, DimType DIM>
inline void addDistributedFullGrid(const DistributedFullGrid<FG_ELEMENT, DIM> &dfg, combigrid::real coeff) add a DistributedFullGrid to this DistributedSparseGridUniform
adds the (hopefully) hierarchical coefficients from the DFG to the DSG’s data structure, multiplied by coeff
data of subspaces that are in the DistributedFullGrid AND allocated in this DistributedSparseGridUniform are filled with the data from the DistributedFullGrid
- Parameters:
dfg – the DistributedFullGrid to add
coeff – the coefficient to multiply the data with
dfg – the DFG to add
coeff – the coefficient that gets multiplied to all entries in DFG
- Template Parameters:
sparseGridFullyAllocated – if true, assumes that all subspaces are allocated here
-
inline size_t getRawDataSize() const
returns the number of allocated grid points
to get the size of the raw data vector in bytes, multiply by sizeof(FG_ELEMENT)
-
bool isSubspaceDataCreated() const
returns true if the subspace data has been allocated
also retuns true if only a part of the subspaces have been allocated
-
void maxReduceSubspaceSizes(const DistributedSparseGridUniform<FG_ELEMENT> &other)
max-reduce subspace sizes from another DistributedSparseGridUniform
the other DistributedSparseGridUniform must have the same subspaces as this one, but their sizes may or may not be populated the same way as in this DistributedSparseGridUniform
-
void copyDataFrom(const DistributedSparseGridUniform<FG_ELEMENT> &other)
copy data from another DistributedSparseGridUniform
only copies data that has been allocated in both this and the other DistributedSparseGridUniform
- Parameters:
other – the DistributedSparseGridUniform, needs to have the same subspaces as this
-
template<typename SubspaceIndexContainer>
void copyDataFrom(const DistributedSparseGridUniform<FG_ELEMENT> &other, const SubspaceIndexContainer &subspaceIndices) copy data from another DistributedSparseGridUniform
only copies data in the subspaces that are in the subspaceIndices set (or other iterable); they must be allocated in both this and the other DistributedSparseGridUniform
-
using ElementType = FG_ELEMENT