Block¶
Data.h¶
-
class
Cubism::Block
::
DataBase
Type-less base class for a data block.
For byte-level operations on the data only.
Subclassed by Cubism::Block::Data< T, Entity, DIM, BlockAlloc >, Cubism::Block::Data< T, Entity, DIM, Alloc< T > >, Cubism::Block::Data< TField::DataType, TField::EntityType, TField::IndexRangeType::Dim, Cubism::AlignedBlockAllocator< TField::DataType > >
Public Functions
-
inline virtual void *
getBlockPtr
() Mutable pointer to address of first data element.
- Return
Address of first data block byte
-
inline virtual const void *
getBlockPtr
() const Immutable pointer to address of first data element.
- Return
Address of first data block byte
-
inline virtual size_t
getBlockBytes
() const Number of bytes occupied by block.
- Return
Number of block bytes
-
inline virtual size_t
getDataElementBytes
() const Number of bytes occupied by a single data element.
- Return
Number of block bytes
-
inline virtual size_t
getBlockSize
() const Number of data elements contained in block.
- Return
Number of block data elements
-
inline virtual void *
-
template<typename
T
, Cubism::EntityTypeEntity
, size_tDIM
, typenameBlockAlloc
= AlignedBlockAllocator<T>>
classCubism::Block
::
Data
: public Cubism::Block::DataBase Generic block data.
Data type that manages memory allocation and data access for the specified index range spanned by the data.
Note
The memory allocation for a block may be larger than the minimum required data specified by the index range.
- Template Parameters
T
: Data typeEntity
: Entity typeDIM
: Data dimensionalityBlockAlloc
: Allocator type
Public Types
-
enum
MemoryOwner
Specifies memory ownership.
Values:
-
enumerator
No
-
enumerator
Yes
-
enumerator
Public Functions
-
inline explicit
Data
(const IndexRangeType &r) Base constructor for single block allocation.
The index range defines the spatial dimensionality of the data. The block memory is touched by the thread that calls the constructor.
- Parameters
r
: Index range of data
-
inline
Data
(const Data &c, const MemoryOwner owner) General purpose copy-constructor mainly for data views.
The block memory is touched by the thread that calls the constructor.
- Parameters
c
: Data block to copy fromowner
: Memory ownership
-
inline
Data
(const IndexRangeType &r, DataType *ptr, const size_t bytes) Low-level constructor for externally managed memory.
The block owns the memory but does not deallocate it at destruction.
- Parameters
r
: Index range of data pointed to by ptrptr
: Block data pointer to first elementbytes
: Number of bytes of block data.
-
inline
Data
(const Data &c) Copy constructor.
Depending on ownership of the memory, copy is deep or shallow. Relevant for views.
- Parameters
c
: Block data to copy from
-
inline
Data
(Data &&c) noexcept Move constructor.
Move constructions are always shallow. Ownership of the memory is inherited from the source.
- Parameters
c
: Block data to copy from
-
inline
~Data
() override Virtual destructor.
-
inline virtual void *
getBlockPtr
() override Mutable pointer to address of first data element.
- Return
Address of first data block byte
-
inline virtual const void *
getBlockPtr
() const override Immutable pointer to address of first data element.
- Return
Address of first data block byte
-
inline virtual size_t
getBlockBytes
() const override Number of bytes occupied by block.
- Return
Number of block bytes
-
inline virtual size_t
getDataElementBytes
() const override Number of bytes occupied by a single data element.
- Return
Number of block bytes
-
inline virtual size_t
getBlockSize
() const override Number of data elements contained in block.
- Return
Number of block data elements
-
inline DataType *
getData
() Get pointer to data.
- Return
Pointer to first data element
-
inline const DataType *
getData
() const Get pointer to data.
- Return
const
pointer to first data element
-
inline Data &
operator=
(const Data &c) Copy assignment operator.
Depending on ownership of memory, copy is deep or shallow. Relevant for views.
- Return
This instance with updated data
- Parameters
c
: Block data to assign from
-
inline Data &
operator=
(Data &&c) Move assignment operator.
Move constructions are always shallow. Ownership of the memory is inherited from the source.
- Return
This instance with moved data
- Parameters
c
:
-
inline DataType &
operator[]
(size_t i) Linear data access.
- Return
Reference to data element
- Parameters
i
: Local flat index
-
inline const DataType &
operator[]
(size_t i) const Linear data access.
- Return
const
reference to data element- Parameters
i
: Local flat index
-
inline DataType &
operator[]
(const MultiIndex &p) Linear data access.
- Return
Reference to data element
- Parameters
p
: Local multi-dimensional index
-
inline const DataType &
operator[]
(const MultiIndex &p) const Linear data access.
- Return
const
reference 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
const
reference to data element- Parameters
ix
: Index for first dimensioniy
: Index for second dimensioniz
: Index for third dimension
-
inline void
copyData
(const Data &c) Deep copy data.
Copies data unconditionally.
- Parameters
c
: Block data to copy from
-
inline IndexRangeType
getIndexRange
(const size_t = 0) const Get index range.
- Return
Index range spanned by the data
-
inline bool
isMemoryOwner
() const Test for memory ownership.
- Return
True if memory is owned by this instance
-
inline MemoryOwner
getMemoryOwnership
() const Get memory ownership.
- Return
Enumeration type describing the memory ownership
-
inline virtual BlockBytes
getMemoryFootprint
() const Get byte utilization of block.
- Return
Structure of byte usage for this instance
Public Static Attributes
-
static constexpr Cubism::EntityType
EntityType
= Entity Specifies entity type of data.
-
struct
BlockBytes
Byte utilization compound.
Field.h¶
This header defines various block field types. The essential block field is a
scalar field. Components of higher rank tensors are built using the
corresponding scalar field type. The memory layout of a field is a structure of
arrays. Face fields are handled separately for each dimension in DIM
. The
FaceContainer
type is a convenience type for a compound of DIM
face
fields with the corresponding index range for each direction.
-
struct
FieldState
Default meta data (state) of a block field.
Minimal (default) state of a field is empty. Custom field state types my add additional state to describe meta data of a field. A field state type must define copy semantics. Components in
TensorField
types andFaceContainer
types share one instance of a state.
-
template<typename
T
, Cubism::EntityTypeEntity
, size_tDIM
= CUBISM_DIMENSION, typenameState
= FieldState, template<typename> classAlloc
= AlignedBlockAllocator>
classCubism::Block
::
Field
: public Cubism::Block::Data<T, Entity, DIM, Alloc<T>> Block scalar field base class.
Generic block scalar field type used by Grid classes to compose a certain topology of block fields.
- Template Parameters
T
: Field data typeEntity
: Entity typeDIM
: Field dimensionState
: Field state typeAlloc
: Memory allocator
Public Types
-
using
iterator
= IteratorBase<DataType> Iterator for underlying data.
-
using
const_iterator
= IteratorBase<const DataType> const
iterator for underlying data
Public Functions
-
Field
() = delete Default constructor.
-
inline explicit
Field
(const IndexRangeType &r, const FieldStateType &fs = FieldStateType()) Main field constructor.
- Parameters
r
: Index range that spans the datafs
: Field state
-
inline explicit
Field
(const IndexRangeType &r, FieldStateType *pfs) Low-level field constructor (for higher rank tensors)
- Parameters
r
: Index range that spans the datapfs
: Field state pointer (externally managed)
-
inline
Field
(const Field &f, const typename BlockDataType::MemoryOwner o) Low-level copy constructor for deep and shallow copies.
- Parameters
f
: Field to be copiedo
: Memory ownership (BlockDataType::MemoryOwner::Yes
: deep copy)
-
inline
Field
(const Field &f, const typename BlockDataType::MemoryOwner o, FieldStateType *pfs) Low-level copy constructor for deep and shallow copies (for higher rank tensors)
- Parameters
f
: Field to be copiedo
: Memory ownership (BlockDataType::MemoryOwner::Yes
: deep copy)pfs
: External field state
-
inline
Field
(const NestedVector<IndexRangeType> &range_list, const NestedVector<DataType*> &ptr_list, const NestedVector<size_t> &bytes_list, const NestedVector<FieldStateType*> &state_list, const bool subfield = false) Low-level constructor for external memory management.
The nested vector data structure is used to simplify the interface between scalar fields, tensor fields and face field containers. A subfield component applies to higher rank tensors and face field containers which share the field state among each others.
- Parameters
range_list
: Vector of index rangeptr_list
: Vector of block data pointerbytes_list
: Number of bytes pointed to by pointer in ptr_liststate_list
: Vector of field state pointersubfield
: Subfield component indicator
-
inline
Field
(const BlockDataType &d) Low-level constructor for use with a block data type.
Useful for a
FieldLab
andCubsim::IO
routines for example.- Parameters
d
: Base block data object (owns memory)
-
inline
Field
(const Field &c) Standard copy constructor for a scalar field.
This constructor is not designed to be used with individual components of a
rank > 0
tensor or face containers. The copy constructors of these data structures should be used instead (unless you know what you do).- Parameters
c
: Field to copy from
-
inline
Field
(Field &&c) noexcept Standard move constructor.
- Parameters
c
: Field to move from
-
inline
~Field
() override Virtual destructor.
-
inline Field &
operator=
(const Field &c) Standard copy assignment operator.
Note
Only field data is copied by this operator, not state.
- Return
This field with contents copied from c
- Parameters
c
: Field to copy from
-
inline Field &
operator=
(Field &&c) Standard move assignment operator.
Note
This operator moves data and state.
- Return
This field with contents moved from c
- Parameters
c
: Field to move from
-
inline iterator
begin
() noexcept Begin of data.
- Return
Iterator
-
inline iterator
end
() noexcept End of data.
- Return
Iterator
-
inline const_iterator
cbegin
() const noexcept Begin of data.
- Return
const
iterator
-
inline const_iterator
cend
() const noexcept End of data.
- Return
const
iterator
-
inline size_t
size
() const Number of data elements carried by field.
- Return
Size of data index range
-
inline bool
isScalar
() const Test if field belongs to scalar class.
- Return
Boolean (true if scalar, false if higher rank tensor class)
-
inline FieldStateType &
getState
() Get field state.
- Return
reference to state
-
inline const FieldStateType &
getState
() const Get field state.
- Return
const
reference to state
-
inline BCVector &
getBC
() Get list of boundary conditions.
- Return
Reference to vector of BC’s
-
inline const BCVector &
getBC
() const Get list of boundary conditions.
- Return
const
reference to vector of BC’s
-
template<typename
T
, size_tRANK
, Cubism::EntityTypeEntity
, size_tDIM
= CUBISM_DIMENSION, typenameState
= FieldState, template<typename> classAlloc
= AlignedBlockAllocator>
classCubism::Block
::
TensorField
: public Cubism::Block::FieldContainer<Field<T, Entity, DIM, State, Alloc>> Generic tensor field.
- Template Parameters
T
: Field data typeRANK
: Tensor rankEntity
: Entity typeDIM
: Field dimensionState
: Field state typeAlloc
: Memory allocator
Public Functions
-
TensorField
() = delete Default constructor.
-
inline explicit
TensorField
(const IndexRangeType &r, const FieldStateType &fs = FieldStateType()) Main constructor to generate a tensor field.
- Parameters
r
: Index range spanned by the field datafs
: Field state initial value
-
inline explicit
TensorField
(const IndexRangeType &r, FieldStateType *pfs) Low-level field constructor (for higher rank tensors)
- Parameters
r
: Index range that spans the datapfs
: Field state pointer (externally managed)
-
inline
TensorField
(const TensorField &tfc, const MemoryOwner o) Low-level copy constructor for deep and shallow copies.
- Parameters
tfc
: Tensor field container to be copiedo
: Memory ownership (BlockDataType::MemoryOwner::Yes
: deep copy)
-
inline
TensorField
(const TensorField &tfc, const MemoryOwner o, const FieldStateType *pfs) Low-level copy constructor for deep and shallow copies (for higher rank tensors)
- Parameters
tfc
: Tensor field container to be copiedo
: Memory ownership (BlockDataType::MemoryOwner::Yes
: deep copy)pfs
: External field state
-
inline
TensorField
(const NestedVector<IndexRangeType> &range_list, const NestedVector<DataType*> &ptr_list, const NestedVector<size_t> &bytes_list, const NestedVector<FieldStateType*> &state_list, const bool subfield = false) Low-level constructor for external memory management.
The nested vector data structure is used to simplify the interface between scalar fields, tensor fields and face field containers. A subfield component applies to higher rank tensors and face field containers which share the field state among each others.
- Parameters
range_list
: Vector of index rangeptr_list
: Vector of block data pointerbytes_list
: Number of bytes pointed to by pointer in ptr_liststate_list
: Vector of field state pointersubfield
: Subfield component indicator
-
inline
TensorField
(const TensorField &c) Copy constructor.
- Parameters
c
: Tensor field to copy from
-
inline IndexRangeType
getIndexRange
(const size_t = 0) const Get index range.
- Return
Index range spanned by the data
-
inline FieldStateType &
getState
() Get field state.
A tensor field shares one field state instance with all its components.
- Return
Reference to state
-
inline const FieldStateType &
getState
() const Get field state.
A tensor field shares one field state instance with all its components.
- Return
const
reference to state
-
inline MemoryOwner
getMemoryOwnership
() const Get memory ownership.
- Return
Enumeration type describing the memory ownership
-
inline FieldType &
operator[]
(const size_t i) Component field access.
- Parameters
i
: Component index
-
inline const FieldType &
operator[]
(const size_t i) const Component field access.
- Parameters
i
: Component index
-
template<typename
TComp
>
inline FieldType &operator[]
(const TComp &t) Component field access.
- Template Parameters
TComp
: Special type that defines a cast tosize_t
- Parameters
t
: Component of tensor
-
template<typename
TComp
>
inline const FieldType &operator[]
(const TComp &t) const Component field access.
- Template Parameters
TComp
: Special type that defines a cast tosize_t
- Parameters
t
: Component of tensor
-
template<typename
TField
>
classCubism::Block
::
FaceContainer
: public Cubism::Block::FieldContainer<TField> Container class for all faces in a
CUBISM_DIMENSION
-ional problem.For
CUBISM_DIMENSION
in{1,2,3}
, the face field for faces with normal in theX
direction can be obtained withff[0]
orff[Cubism::Dir::X]
for example, whereff
is of typeFaceContainer
.- Template Parameters
TField
: Face field type (scalar or tensor)
Public Functions
-
FaceContainer
() = delete Default constructor.
-
inline explicit
FaceContainer
(const IndexRangeType &cell_domain, const FieldStateType &fs = FieldStateType()) Main constructor to generate a face container.
- Parameters
cell_domain
: Index range spanned by the cell domainfs
: Field state initial value
-
inline
FaceContainer
(const FaceContainer &ffc, const MemoryOwner o) Low-level copy constructor for deep and shallow copies.
- Parameters
ffc
: Face field container to be copiedo
: Memory ownership (BlockDataType::MemoryOwner::Yes
: deep copy)
-
inline
FaceContainer
(const NestedVector<IndexRangeType> &range_list, const NestedVector<DataType*> &ptr_list, const NestedVector<size_t> &bytes_list, const NestedVector<FieldStateType*> &state_list, const bool subfield = false) Low-level constructor for external memory management.
The nested vector data structure is used to simplify the interface between scalar fields, tensor fields and face field containers. A subfield component applies to higher rank tensors and face field containers which share the field state among each others.
- Parameters
range_list
: Vector of index rangeptr_list
: Vector of block data pointerbytes_list
: Number of bytes pointed to by pointer in ptr_liststate_list
: Vector of field state pointersubfield
: Subfield component indicator
-
inline
FaceContainer
(const FaceContainer &c) Copy constructor.
- Parameters
c
: Face container to copy from
-
inline IndexRangeType
getIndexRange
(const size_t i) const Get index range.
- Return
Index range spanned by the data
- Parameters
i
: Direction index
-
template<typename
Dir
>
inline IndexRangeTypegetIndexRange
(const Dir t) const Get index range.
- Return
Index range spanned by the data
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
t
: Direction of face
-
inline FieldStateType &
getState
() Get field state.
A face field container shares one field state instance with all its components.
- Return
Reference to state
-
inline const FieldStateType &
getState
() const Get field state.
A face field container shares one field state instance with all its components.
- Return
const
reference to state
-
inline MemoryOwner
getMemoryOwnership
() const Get memory ownership.
- Return
Enumeration type describing the memory ownership
-
inline FaceComponentType &
operator[]
(const size_t i) Face component access.
- Return
Reference to face component
- Parameters
i
: Direction index
-
inline const FaceComponentType &
operator[]
(const size_t i) const Face component access.
- Return
const
reference to face component- Parameters
i
: Direction index
-
template<typename
Dir
>
inline FaceComponentType &operator[]
(const Dir &t) Face component access.
- Return
Reference to face component
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
t
: Direction of face
-
template<typename
Dir
>
inline const FaceComponentType &operator[]
(const Dir &t) const Face component access.
- Return
const
reference to face component- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
t
: Direction of face
-
template<typename
TField
>
classCubism::Block
::
FieldContainer
Field container type.
This is an actively managed field container. Unlike
std::vector
, the destructors of the container elements are called upon destruction of the container. An incomplete container containsnullptr
for some of its components.- Template Parameters
TField
: Type of field
Subclassed by Cubism::Block::FaceContainer< TField >
Public Types
-
using
iterator
= typename ContainerType::iterator Iterator for field pointers in ContainerType.
-
using
const_iterator
= typename ContainerType::const_iterator const
iterator for field pointers in ContainerType
-
using
reverse_iterator
= typename ContainerType::reverse_iterator Reverse iterator for field pointers in ContainerType.
-
using
const_reverse_iterator
= typename ContainerType::const_reverse_iterator const
reverse iterator for field pointers in ContainerType
Public Functions
-
FieldContainer
() = default Default constructor.
-
inline
FieldContainer
(const size_t n, const IndexRangeType &r, const FieldStateType &fs = FieldStateType()) Standard constructor for field container.
- Parameters
n
: Number of componentsr
: Index range spanned by field datafs
: Field state initial value
-
inline
FieldContainer
(const std::vector<BaseType*> &vf) Construct from a list of pointers.
- Parameters
vf
: Vector of pointers to underlying type (may benullptr
)
-
inline
FieldContainer
(const FieldContainer &c) Standard copy constructor.
- Parameters
c
: Field container to copy from
-
inline
FieldContainer
(FieldContainer &&c) noexcept Standard move constructor.
- Parameters
c
: Field container to move from
-
inline virtual
~FieldContainer
() Virtual destructor.
-
inline FieldContainer &
operator=
(const FieldContainer &rhs) Standard copy assignment operator.
- Return
This field container with copied contents from
rhs
- Parameters
rhs
: Field container to assign from
-
inline FieldContainer &
operator=
(FieldContainer &&rhs) Standard move assignment operator.
- Return
This field container with moved contents from
rhs
- Parameters
rhs
: Field container to assign from
-
inline iterator
begin
() noexcept Begin of fields.
- Return
Iterator
-
inline iterator
end
() noexcept End of fields.
- Return
Iterator
-
inline reverse_iterator
rbegin
() noexcept Begin of reversed fields.
- Return
Reverse iterator
-
inline reverse_iterator
rend
() noexcept End of reversed fields.
- Return
Reverse iterator
-
inline const_iterator
cbegin
() const noexcept Begin of fields.
- Return
const
iterator
-
inline const_iterator
cend
() const noexcept End of fields.
- Return
const
iterator
-
inline const_reverse_iterator
crbegin
() const noexcept Begin of reversed fields.
- Return
const
reverse iterator
-
inline const_reverse_iterator
crend
() const noexcept End of reversed fields.
- Return
const
reverse iterator
-
inline size_t
size
() const Number of fields contained.
- Return
Size of container
-
inline ContainerType &
getContainer
() Get container of raw data.
- Return
STL vector with
BaseType
pointers
-
inline const ContainerType &
getContainer
() const Get container of raw data.
- Return
const
STL vector withBaseType
pointers
-
inline bool
contains
(const BaseType &element) const Check if element is contained.
- Return
True if element is in this container
- Parameters
element
: Reference element
-
inline void
copyData
(const FieldContainer &rhs) Forced deep copy of underlying fields.
This copies
FieldType::BaseType
data only.Example:
fv
is a field view andf
is another field (either view or memory owner)fv = f; // shallow copy of f to fv [updates pointers in fv only] fv.copyData(f); // deep copy of data in f to fv [expensive operation]
- Parameters
rhs
: Field container to copy from
-
inline void
pushBack
(BaseType *p) Append new component at the end of container.
The destructor of
FieldContainer
calls the destructor ofp
when the object is destroyed.- Parameters
p
: Pointer to new component
-
inline void
clear
() Destroy container components.
Unlike to
std::vector
, this calls the destructor of each container component effectively destroying the object. The size of the container after this operation is zero.
-
inline BaseType &
operator[]
(const size_t i) Access to fields.
This method throws a
std::runtime_error
if the component is anullptr
.- Return
Reference to component
i
- Parameters
i
: Component ID of field to be accessed
-
inline const BaseType &
operator[]
(const size_t i) const Access to fields.
This method throws a
std::runtime_error
if the component is anullptr
.- Return
const
reference to componenti
- Parameters
i
: Component ID of field to be accessed
-
template<typename
T
>
inline BaseType &operator[]
(const T &t) Generic access to fields.
This method throws a
std::runtime_error
if the component is anullptr
.- Return
Reference to component
t
- Template Parameters
T
: Generic index type that defines casting tosize_t
- Parameters
t
: Component ID of field to be accessed
-
template<typename
T
>
inline const BaseType &operator[]
(const T &t) const Generic access to fields.
This method throws a
std::runtime_error
if the component is anullptr
.- Return
const
reference to componentt
- Template Parameters
T
: Generic index type that defines casting tosize_t
- Parameters
t
: Component ID of field to be accessed
-
template<typename
TField
>
classCubism::Block
::
FieldView
: public TField Field view type.
Provides a view (shallow copy) for scalar fields, tensor fields or face field containers. The corresponding field interface is inherited.
Note
A view type never owns memory.
- Template Parameters
TField
: Field type
Public Functions
-
inline
FieldView
(const BaseType &f) Main constructor to generate a field view.
- Parameters
f
: Field for which to generate the view
-
inline void
setView
(const BaseType &c) Set new internal view.
- Parameters
c
: Base field be be viewed at
-
inline BaseType
copy
() const Force a deep copy of the viewed field.
- Return
Deep copy (new allocation) of field view
-
using
Cubism::Block
::
CellField
= Field<T, EntityType::Cell, DIM, State, Alloc> Basic cell-centered data field.
- Template Parameters
T
: Data type (must be POD)DIM
: Field dimensionState
: State typeAlloc
: Allocator type
-
using
Cubism::Block
::
NodeField
= Field<T, EntityType::Node, DIM, State, Alloc> Basic node-centered data field.
- Template Parameters
T
: Data type (must be POD)DIM
: Field dimensionState
: State typeAlloc
: Allocator type
-
using
Cubism::Block
::
FaceField
= Field<T, EntityType::Face, DIM, State, Alloc> Basic face-centered data field.
Faces are stored individually for the dimensionality specified by
CUBISM_DIMENSION
at compile time. See theFaceContainer
type for a container of sizeCUBISM_DIMENSION
.- Template Parameters
T
: Data type (must be POD)DIM
: Field dimensionState
: State typeAlloc
: Allocator type
-
using
Cubism::Block
::
VectorField
= TensorField<T, 1, Entity, DIM, State, Alloc> Convenience type for vector fields.
- Template Parameters
T
: Field data typeEntity
: Entity typeDIM
: Field dimensionState
: Field state typeAlloc
: Memory allocator
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
FieldLab
is 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
force
flag 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
id2field
mapping 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
boundaries
instead of the boundary conditions specified in the block field with indexfid
(if any). The vectorboundaries
may 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
p
may reference halo cells. For example,p{-1,0}
indexes the first halo cell in thex
direction 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
p
may reference halo cells. For example,p{-1,0}
indexes the first halo cell in thex
direction that is adjacent to the inner domain.- Return
const
reference 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
const
reference 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
const
reference toStencilType
-
inline const IndexRangeType &
getActiveRange
() const Get currently active (loaded) index range.
- Return
const
reference 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
const
reference 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