FieldLab.h¶
-
template<typename
TField>
classCubism::Block::FieldLab: public Cubism::Block::Data<TField::DataType, TField::EntityType, TField::IndexRangeType::Dim, Cubism::AlignedBlockAllocator<TField::DataType>>¶ Field laboratory.
A
FieldLabis an extended data structure to include ghost cells for a given stencil. Loading a lab takes care of loading the ghost cells from neighboring block fields and applies boundary conditions if present. The default is periodic if no boundary conditions are specified otherwise.- Template Parameters
TField: Field type to map to the lab
Public Functions
-
inline
FieldLab()¶ Main constructor.
-
inline void
allocate(const StencilType &s, const IndexRangeType &max_range, const bool force = false)¶ Allocate data lab memory block for a given stencil.
The method may be called subsequently.with a different stencil and maximum range. If the new request can be processed using the current allocation no new memory is allocated unless the
forceflag is true.- Parameters
s: Target stencilmax_range: Maximum index range to be processed in the labforce: Force a reallocation for subsequent requests
-
template<typename
Functor= STDFunction>
inline voidloadData(const MultiIndex &fid, Functor &id2field, const bool apply_bc = true, const BCVector *extern_bc = nullptr)¶ Lab data loader.
The
id2fieldmapping function takes a multi-dimensional block field index as an argument and returns a reference to the corresponding block field. The function must map indices periodically.- Parameters
fid: Multi-dimensional index of target block fieldid2field: Index mapping function for block fieldsapply_bc: Flag whether to apply boundary conditionsextern_bc: Pointer to external boundary conditions
-
template<typename
Functor= STDFunction>
inline voidloadData(const MultiIndex &fid, Functor &id2field, const BCVector &boundaries, const bool apply_bc = true)¶ Lab data loader.
This loader is a convenience wrapper around the default loader if boundary conditions need to be enforced. This wrapper applies the boundary conditions specified in
boundariesinstead of the boundary conditions specified in the block field with indexfid(if any). The vectorboundariesmay be empty.- Parameters
fid: Multi-dimensional index of target block fieldid2field: Index mapping function for block fieldsboundaries: Vector of boundary conditionsapply_bc: Flag whether to apply boundary conditions
-
inline DataType &
operator[](const MultiIndex &p)¶ Linear data access.
The local index
pmay reference halo cells. For example,p{-1,0}indexes the first halo cell in thexdirection that is adjacent to the inner domain.- Return
Reference to data element
- Parameters
p: Local multi-dimensional index
-
inline const DataType &
operator[](const MultiIndex &p) const¶ Linear data access.
The local index
pmay reference halo cells. For example,p{-1,0}indexes the first halo cell in thexdirection that is adjacent to the inner domain.- Return
constreference to data element- Parameters
p: Local multi-dimensional index
-
inline DataType &
operator()(const Index ix, const Index iy = 0, const Index iz = 0)¶ Classic data access.
This operator is only supported for dimensions 1, 2 and 3. Accessing data with this operator has less latency than the multi-index sibling.
- Return
Reference to data element
- Parameters
ix: Index for first dimensioniy: Index for second dimensioniz: Index for third dimension
-
inline const DataType &
operator()(const Index ix, const Index iy = 0, const Index iz = 0) const¶ Classic data access.
This operator is only supported for dimensions 1, 2 and 3. Accessing data with this operator has less latency than the multi-index sibling.
- Return
constreference to data element- Parameters
ix: Index for first dimensioniy: Index for second dimensioniz: Index for third dimension
-
inline DataType *
getInnerData()¶ Get pointer to inner block data.
The returned pointer points to the first element defined in
loader_.curr_range.- Return
Pointer to first data element of base field
-
inline const DataType *
getInnerData() const¶ Get pointer to inner block data.
The returned pointer points to the first element defined in
loader_.curr_range.- Return
Pointer to first data element of base field
-
inline const StencilType &
getActiveStencil() const¶ Get currently active (loaded) stencil.
- Return
constreference toStencilType
-
inline const IndexRangeType &
getActiveRange() const¶ Get currently active (loaded) index range.
- Return
constreference toIndexRangeType
-
inline FieldType &
getActiveField()¶ Get reference to currently active (loaded) field.
- Return
Reference to
FieldType
-
inline const FieldType &
getActiveField() const¶ Get reference to currently active (loaded) field.
- Return
constreference toFieldType
-
inline IndexRangeType
getActiveLabRange() const¶ Get currently active (loaded) lab index range.
The index range begin is identical to the active stencil begin, which is
< 0.- Return
Index range including ghost indices
-
inline IndexRangeType
getMaximumRange() const¶ Get the maximum range that the lab can hold.
- Return
Index range of maximum span
-
inline bool
isAllocated() const¶ Check if lab is allocated.
- Return
True if laboratory is allocated
-
inline virtual BlockBytes
getMemoryFootprint() const override¶ Get byte utilization of block.
- Return
Structure of byte usage for this instance