Cartesian.h¶
-
template<typename
T
, typenameMesh
, Cubism::EntityTypeEntity
= Cubism::EntityType::Cell, size_tRANK
= 0, typenameUserState
= Block::FieldState, template<typename> classAlloc
= AlignedBlockAllocator>
classCubism::Grid
::
Cartesian
¶ Cartesian block (tensor) field.
Cartesian topology composed of block Field.h for the specified entity type. As opposed to an individual block Field.h, this class manages a structure of arrays (SoA) memory layout for all the blocks in the Cartesian topology instead of just individual blocks. See the CartesianMPI.h grid section for a distributed variant of this class. The field state can be extended with the
UserState
extension. TheUserState
type must be trivially copyable.- Template Parameters
T
: Field data typeMesh
: Mesh type to be associated with fieldsEntity
: Entity typeRANK
: Rank of (tensor) fieldsUserState
: Type for field state user extensionAlloc
: Allocator for field data
Subclassed by Cubism::Grid::CartesianMPI< T, Mesh, Entity, RANK, UserState, Alloc >
Public Types
-
using
MultiIndex
= typename IndexRangeType::MultiIndex¶ Type for higher dimensional index.
-
using
BaseType
= typename Assembler::BaseType¶ Block (scalar, tensor, face) field type.
-
using
DataType
= typename Assembler::DataType¶ Data type of carried fields.
-
using
FieldContainer
= typename Assembler::FieldContainer¶ Container type for field views.
-
using
IndexFunctor
= Block::PeriodicIndexFunctor<FieldContainer, BaseType::Class, RANK>¶ Periodic block field access by index.
-
using
iterator
= typename FieldContainer::iterator¶ Block field iterator.
-
using
const_iterator
= typename FieldContainer::const_iterator¶ Block field iterator.
-
using
reverse_iterator
= typename FieldContainer::reverse_iterator¶ Reverse block field iterator.
-
using
const_reverse_iterator
= typename FieldContainer::const_reverse_iterator¶ Reverse block field iterator.
Public Functions
-
inline
Cartesian
()¶ Default constructor (empty topology)
-
inline
Cartesian
(const MultiIndex &nblocks, const MultiIndex &block_cells, const PointType &begin = PointType(0), const PointType &end = PointType(1), const PointType &gbegin = PointType(0), const PointType &gend = PointType(1))¶ Main constructor for a Cartesian block field topology.
- Parameters
nblocks
: Number of blocksblock_cells
: Number of cells in each blockbegin
: Physical origin for this Cartesian grid (lower left)end
: Physical end for this Cartesian grid (top right)gbegin
: Global begin of physical domaingend
: Global end of physical domain
-
inline Cartesian &
operator=
(const Cartesian &c)¶ Copy assign field data only.
This copies the block data only.
- Parameters
c
: Other Cartesian topology of same type
-
inline virtual
~Cartesian
()¶ Default destructor.
-
inline const_iterator
begin
() const noexcept¶ - Return
Iterator to first block field
-
inline const_iterator
end
() const noexcept¶ - Return
Iterator to last block field
-
inline reverse_iterator
rbegin
() noexcept¶ - Return
Reverse iterator to first block field
-
inline const_reverse_iterator
rbegin
() const noexcept¶ - Return
Reverse iterator to first block field
-
inline reverse_iterator
rend
() noexcept¶ - Return
Reverse iterator to last block field
-
inline const_reverse_iterator
rend
() const noexcept¶ - Return
Reverse iterator to last block field
-
inline const_iterator
cbegin
() const noexcept¶ - Return
Iterator to first block field
-
inline const_iterator
cend
() const noexcept¶ - Return
Iterator to last block field
-
inline const_reverse_iterator
crbegin
() const noexcept¶ - Return
Reverse iterator to first block field
-
inline const_reverse_iterator
crend
() const noexcept¶ - Return
Reverse iterator to last block field
-
inline size_t
size
() const¶ Local size of the grid.
- Return
Number of block fields in the local grid
-
inline MultiIndex
getSize
() const¶ Local size of the grid in all dimensions.
- Return
Number of blocks in all dimensions in the local grid
-
inline MultiIndex
getGlobalBlockIndex
(const MultiIndex &bi) const¶ Get the global block index.
- Return
Global Cartesian block index
- Parameters
bi
: Local Cartesian block index
-
inline MultiIndex
getBlockCells
() const¶ Get the number of cells per block.
- Return
Number of cells in a block along all dimensions
-
inline IndexRangeType
getBlockRange
() const¶ Get the block range spanned by this grid.
- Return
Local block index range
-
inline const MeshType &
getMesh
() const¶ Local mesh for the grid.
Returns the local mesh associated to the Cartesian grid
- Return
const
reference to local mesh
-
inline const MeshType &
getGlobalMesh
() const¶ Global mesh for the grid.
Returns the global mesh associated to the Cartesian grid. For a non-MPI instance the return value is identical to
getMesh()
.- Return
const
reference to global mesh
-
inline FieldContainer &
getFields
()¶ Field container.
The container has type
Block::FieldContainer
- Return
Reference to container of block fields
-
inline const FieldContainer &
getFields
() const¶ Field container.
The container has type
Block::FieldContainer
- Return
const
reference to container of block fields
-
inline std::vector<FieldState*> &
getFieldStates
()¶ Field states.
- Return
Reference to vector of field states
-
inline const std::vector<FieldState*> &
getFieldStates
() const¶ Field states.
- Return
const
reference to vector of field states
-
inline BaseType &
operator[]
(const MultiIndex &p)¶ Block field access.
- Return
Reference to block field
- Parameters
p
: Multi-dimensional block index
-
inline const BaseType &
operator[]
(const MultiIndex &p) const¶ Block field access.
- Return
const
reference to block field- Parameters
p
: Multi-dimensional block index
-
inline BaseType &
operator[]
(const size_t i)¶ Linear block field access.
- Return
Reference to block field
- Parameters
i
: One-dimensional block index
-
inline const BaseType &
operator[]
(const size_t i) const¶ Linear block field access.
- Return
const
reference to block field- Parameters
i
: One-dimensional block index
-
template<typename
Comp
= size_t, typenameDir
= size_t>
inline IndexFunctorgetIndexFunctor
(const Comp c = 0, const Dir d = 0)¶ Get field access functor.
- Return
Periodic field access functor given the block index
- Template Parameters
Comp
: Type for components that defines a cast tosize_t
Dir
: Type for direction that defines a cast tosize_t
- Parameters
c
: Component indexd
: Face direction
-
inline virtual MultiIndex
getGlobalSize
() const¶ Global size of the grid in all dimensions.
- Return
Number of blocks in all dimensions in the global grid
-
template<typename
Comp
= size_t, typenameDir
= size_t>
inline voidloadLab
(const BaseType &field, Block::FieldLab<typename BaseType::FieldType> &lab, const Comp c = 0, const Dir d = 0)¶ Field lab loader utility to load data from
field
intolab
The
field
must be contained in within this Cartesian grid.- Template Parameters
Comp
: Type for components that defines a cast tosize_t
Dir
: Type for direction that defines a cast tosize_t
- Parameters
field
: Source field data to be loadedlab
: Laboratory where data is loaded intoc
: Component indexd
: Face direction
Public Static Attributes
-
static constexpr Cubism::EntityType
EntityType
= Entity¶ Entity type of field.
-
struct
FieldState
¶ Field state.
State (meta data) for individual block fields. This data structure carries individual meta data information for each block field in the Cartesian topology. The mesh pointer points to the block (sub) mesh if topological information is required. The
user
addition can be customized depending on the needs of the application. Theuser
field is not initialized during construction.