Grid¶
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
MeshType
= Mesh Type of mesh.
-
using
IndexRangeType
= typename MeshType::IndexRangeType Index range type.
-
using
MultiIndex
= typename IndexRangeType::MultiIndex Type for higher dimensional index.
-
using
RangeType
= typename MeshType::RangeType Type for physical domain ranges spanned by
MeshType
-
using
PointType
= typename MeshType::PointType Type of point in physical domain.
-
using
RealType
= typename MeshType::RealType Type float used to describe the mesh topology.
-
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
-
Cartesian
(const Cartesian &c) = delete Deleted copy constructor.
-
Cartesian
(Cartesian &&c) = delete Deleted move constructor.
-
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 iterator
begin
() noexcept - Return
Iterator to first block field
-
inline const_iterator
begin
() const noexcept - Return
Iterator to first block field
-
inline iterator
end
() noexcept - Return
Iterator to last 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
Public Static Attributes
-
static constexpr size_t
Dim
= MeshType::Dim Field dimension.
-
static constexpr size_t
Rank
= RANK Field rank.
-
static constexpr size_t
NComponents
= BaseType::NComponents Number of field components.
-
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.Public Members
-
MultiIndex
block_index
Block index.
-
MeshType *
mesh
Block mesh.
-
UserState
user
User extension.
-
MultiIndex
CartesianMPI.h¶
-
template<typename
T
, typenameMesh
, Cubism::EntityTypeEntity
= Cubism::EntityType::Cell, size_tRANK
= 0, typenameUserState
= Block::FieldState, template<typename> classAlloc
= AlignedBlockAllocator>
classCubism::Grid
::
CartesianMPI
: public Cubism::Grid::Cartesian<T, Mesh, Entity, RANK, UserState, Alloc> Cartesian MPI 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 rank local Cartesian topology instead of just individual blocks. See the Cartesian.h grid section for a non-distributed variant of this class as well as the
UserState
extension.- Template Parameters
T
: Field data typeMesh
: Mesh type to be associated with fieldsEntity
: Entity typeRANK
: Rank of (tensor) fieldsAlloc
: Allocator for field data
Public Types
-
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
IndexRangeType
= typename MeshType::IndexRangeType Index range type.
-
using
MeshType
= Mesh Type of mesh.
-
using
MultiIndex
= typename IndexRangeType::MultiIndex Type for higher dimensional index.
-
using
PointType
= typename MeshType::PointType Type of point in physical domain.
-
using
RangeType
= typename MeshType::RangeType Type for physical domain ranges spanned by
MeshType
-
using
RealType
= typename MeshType::RealType Type float used to describe the mesh topology.
Public Functions
-
inline
CartesianMPI
(const MPI_Comm &comm, const MultiIndex &nprocs, 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 MPI block field topology.
- Parameters
comm
: MPI communicator for this Cartesian topologynprocs
: Number of MPI processes in each dimensionnblocks
: Number of blocks per rankblock_cells
: Number of cells in each blockbegin
: Physical origin for the full (all ranks) Cartesian grid (lower left)end
: Physical end for the full (all ranks) Cartesian grid (top right)gbegin
: Global begin of physical domaingend
: Global end of physical domain
-
CartesianMPI
() = default Default constructor.
-
CartesianMPI
(const CartesianMPI &c) = delete Deleted copy constructor.
-
CartesianMPI
(CartesianMPI &&c) = delete Deleted move constructor.
-
CartesianMPI &
operator=
(const CartesianMPI &c) = default Default copy assignment.
-
CartesianMPI &
operator=
(CartesianMPI &&c) = delete Deleted move assignment.
-
inline virtual MultiIndex
getGlobalSize
() const override Global size of the grid in all dimensions.
- Return
Number of blocks in all dimensions in the global grid
-
inline MultiIndex
getNumProcs
() const MPI processes in the topology.
- Return
Number of processes in the MPI topology
-
inline MultiIndex
getProcIndex
() const Cartesian index of MPI process.
- Return
Multi-dimensional index of the process
-
inline int
getCartRank
() const MPI rank.
- Return
Rank of the process in the Cartesian communicator
-
inline MPI_Comm
getCartComm
() const MPI communicator.
- Return
Cartesian MPI communicator
-
inline bool
isRoot
() const Test for root process.
- Return
True if this is the root rank