Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana_Grid_Array.hpp File Reference

Grid field arrays. More...

#include <Cabana_Grid_IndexSpace.hpp>
#include <Cabana_Grid_LocalGrid.hpp>
#include <Cabana_Grid_MpiTraits.hpp>
#include <Cabana_Grid_Types.hpp>
#include <Kokkos_Core.hpp>
#include <cmath>
#include <memory>
#include <type_traits>
#include <vector>
#include <mpi.h>
Include dependency graph for Cabana_Grid_Array.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Cabana::Grid::ArrayLayout< EntityType, MeshType >
 Entity layout for array data on the local mesh. More...
 
struct  Cabana::Grid::is_array_layout< class >
 Array static type checker. More...
 
struct  Cabana::Grid::is_array_layout< ArrayLayout< EntityType, MeshType > >
 Array static type checker. More...
 
struct  Cabana::Grid::is_array_layout< const ArrayLayout< EntityType, MeshType > >
 Array static type checker. More...
 
class  Cabana::Grid::Array< Scalar, EntityType, MeshType, Params >
 Array of field data on the local mesh. More...
 
struct  Cabana::Grid::is_array< class >
 
struct  Cabana::Grid::is_array< Array< Scalar, EntityType, MeshType, Params... > >
 
struct  Cabana::Grid::is_array< const Array< Scalar, EntityType, MeshType, Params... > >
 
struct  Cabana::Grid::ArrayOp::DotFunctor< ViewType, NumSpaceDim >
 Dot product functor. More...
 
struct  Cabana::Grid::ArrayOp::NormInfFunctor< ViewType, NumSpaceDim >
 Infinity norm functor. More...
 
struct  Cabana::Grid::ArrayOp::Norm1Functor< ViewType, NumSpaceDim >
 One norm functor. More...
 
struct  Cabana::Grid::ArrayOp::Norm2Functor< ViewType, NumSpaceDim >
 Two norm functor. More...
 

Namespaces

namespace  Cabana
 Core: particle data structures and algorithms.
 

Functions

template<class EntityType, class MeshType>
std::shared_ptr< ArrayLayout< EntityType, MeshType > > Cabana::Grid::createArrayLayout (const std::shared_ptr< LocalGrid< MeshType > > &local_grid, const int dofs_per_entity, EntityType)
 Create an array layout over the entities of a local grid.
 
template<class EntityType, class MeshType>
std::shared_ptr< ArrayLayout< EntityType, MeshType > > Cabana::Grid::createArrayLayout (const std::shared_ptr< GlobalGrid< MeshType > > &global_grid, const int halo_cell_width, const int dofs_per_entity, EntityType)
 Create an array layout over the entities of a grid given local grid parameters. An intermediate local grid will be created and assigned to the layout.
 
template<class Scalar, class... Params, class EntityType, class MeshType>
std::shared_ptr< Array< Scalar, EntityType, MeshType, Params... > > Cabana::Grid::createArray (const std::string &label, const std::shared_ptr< ArrayLayout< EntityType, MeshType > > &layout)
 Create an array with the given array layout. Views are constructed over the ghosted index space of the layout.
 
template<class Scalar, class EntityType, class MeshType, class... Params>
std::shared_ptr< Array< Scalar, EntityType, MeshType, typename Array< Scalar, EntityType, MeshType, Params... >::subview_layout, typename Array< Scalar, EntityType, MeshType, Params... >::memory_space, typename Array< Scalar, EntityType, MeshType, Params... >::subview_memory_traits > > Cabana::Grid::createSubarray (const Array< Scalar, EntityType, MeshType, Params... > &array, const int dof_min, const int dof_max)
 Create a subarray of the given array over the given range of degrees of freedom.
 
template<class Scalar, class... Params, class EntityType, class MeshType>
std::shared_ptr< Array< Scalar, EntityType, MeshType, Params... > > Cabana::Grid::ArrayOp::clone (const Array< Scalar, EntityType, MeshType, Params... > &array)
 Clone an array. Do not initialize the clone.
 
template<class Array_t, class DecompositionTag>
void Cabana::Grid::ArrayOp::assign (Array_t &array, const typename Array_t::value_type alpha, DecompositionTag tag)
 Assign a scalar value to every element of an array.
 
template<class Array_t, class DecompositionTag>
std::enable_if_t< 3==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::scale (Array_t &array, const typename Array_t::value_type alpha, DecompositionTag tag)
 Scale every element of an array by a scalar value. 3D specialization.
 
template<class Array_t, class DecompositionTag>
std::enable_if_t< 2==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::scale (Array_t &array, const typename Array_t::value_type alpha, DecompositionTag tag)
 Scale every element of an array by a scalar value. 2D specialization.
 
template<class Array_t, class DecompositionTag>
std::enable_if_t< 3==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::scale (Array_t &array, const std::vector< typename Array_t::value_type > &alpha, DecompositionTag tag)
 Scale every element of an array by a scalar. 3D specialization.
 
template<class Array_t, class DecompositionTag>
std::enable_if_t< 2==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::scale (Array_t &array, const std::vector< typename Array_t::value_type > &alpha, DecompositionTag tag)
 Scale every element of an array by a scalar. 2D specialization.
 
template<class Array_t, class DecompositionTag>
void Cabana::Grid::ArrayOp::copy (Array_t &a, const Array_t &b, DecompositionTag tag)
 Copy one array into another over the designated decomposition. A <- B.
 
template<class Array_t, class DecompositionTag>
std::shared_ptr< Array_t > Cabana::Grid::ArrayOp::cloneCopy (const Array_t &array, DecompositionTag tag)
 Clone an array and copy its contents into the clone.
 
template<class Array_t, class DecompositionTag>
std::enable_if_t< 3==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::update (Array_t &a, const typename Array_t::value_type alpha, const Array_t &b, const typename Array_t::value_type beta, DecompositionTag tag)
 Update two vectors such that a = alpha * a + beta * b. 3D specialization.
 
template<class Array_t, class DecompositionTag>
std::enable_if_t< 2==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::update (Array_t &a, const typename Array_t::value_type alpha, const Array_t &b, const typename Array_t::value_type beta, DecompositionTag tag)
 Update two vectors such that a = alpha * a + beta * b. 2D specialization.
 
template<class Array_t, class DecompositionTag>
std::enable_if_t< 3==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::update (Array_t &a, const typename Array_t::value_type alpha, const Array_t &b, const typename Array_t::value_type beta, const Array_t &c, const typename Array_t::value_type gamma, DecompositionTag tag)
 Update three vectors such that a = alpha * a + beta * b + gamma * c. 3D specialization.
 
template<class Array_t, class DecompositionTag>
std::enable_if_t< 2==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::update (Array_t &a, const typename Array_t::value_type alpha, const Array_t &b, const typename Array_t::value_type beta, const Array_t &c, const typename Array_t::value_type gamma, DecompositionTag tag)
 Update three vectors such that a = alpha * a + beta * b + gamma * c. 2D specialization.
 
template<class Array_t>
void Cabana::Grid::ArrayOp::dot (const Array_t &a, const Array_t &b, std::vector< typename Array_t::value_type > &products)
 Compute the dot product of owned space of two arrays.
 
template<class Array_t>
void Cabana::Grid::ArrayOp::normInf (const Array_t &array, std::vector< typename Array_t::value_type > &norms)
 Calculate the infinity-norm of the owned elements of the array.
 
template<class Array_t>
void Cabana::Grid::ArrayOp::norm1 (const Array_t &array, std::vector< typename Array_t::value_type > &norms)
 Calculate the one-norm of the owned elements of the array.
 
template<class Array_t>
void Cabana::Grid::ArrayOp::norm2 (const Array_t &array, std::vector< typename Array_t::value_type > &norms)
 Calculate the two-norm of the owned elements of the array.
 

Detailed Description

Grid field arrays.

Function Documentation

◆ assign()

template<class Array_t, class DecompositionTag>
void Cabana::Grid::ArrayOp::assign ( Array_t & array,
const typename Array_t::value_type alpha,
DecompositionTag tag )

Assign a scalar value to every element of an array.

Parameters
arrayThe array to assign the value to.
alphaThe value to assign to the array.
tagThe tag for the decomposition over which to perform the operation.

◆ clone()

template<class Scalar, class... Params, class EntityType, class MeshType>
std::shared_ptr< Array< Scalar, EntityType, MeshType, Params... > > Cabana::Grid::ArrayOp::clone ( const Array< Scalar, EntityType, MeshType, Params... > & array)

Clone an array. Do not initialize the clone.

Parameters
arrayThe array to clone.

◆ cloneCopy()

template<class Array_t, class DecompositionTag>
std::shared_ptr< Array_t > Cabana::Grid::ArrayOp::cloneCopy ( const Array_t & array,
DecompositionTag tag )

Clone an array and copy its contents into the clone.

Parameters
arrayThe array to clone.
tagThe tag for the decomposition over which to perform the copy.

◆ copy()

template<class Array_t, class DecompositionTag>
void Cabana::Grid::ArrayOp::copy ( Array_t & a,
const Array_t & b,
DecompositionTag tag )

Copy one array into another over the designated decomposition. A <- B.

Parameters
aThe array to which the data will be copied.
bThe array from which the data will be copied.
tagThe tag for the decomposition over which to perform the operation.

◆ createArray()

template<class Scalar, class... Params, class EntityType, class MeshType>
std::shared_ptr< Array< Scalar, EntityType, MeshType, Params... > > Cabana::Grid::createArray ( const std::string & label,
const std::shared_ptr< ArrayLayout< EntityType, MeshType > > & layout )

Create an array with the given array layout. Views are constructed over the ghosted index space of the layout.

Parameters
labelA label for the view.
layoutThe array layout over which to construct the view.
Returns
Shared pointer to an Array.

◆ createArrayLayout() [1/2]

template<class EntityType, class MeshType>
std::shared_ptr< ArrayLayout< EntityType, MeshType > > Cabana::Grid::createArrayLayout ( const std::shared_ptr< GlobalGrid< MeshType > > & global_grid,
const int halo_cell_width,
const int dofs_per_entity,
EntityType  )

Create an array layout over the entities of a grid given local grid parameters. An intermediate local grid will be created and assigned to the layout.

Parameters
global_gridThe local grid over which to create the layout.
halo_cell_widthThe number of halo cells surrounding the locally owned cells.
dofs_per_entityThe number of degrees-of-freedom per grid entity.
Returns
Shared pointer to an ArrayLayout.
Note
EntityType The entity: Cell, Node, Face, or Edge

◆ createArrayLayout() [2/2]

template<class EntityType, class MeshType>
std::shared_ptr< ArrayLayout< EntityType, MeshType > > Cabana::Grid::createArrayLayout ( const std::shared_ptr< LocalGrid< MeshType > > & local_grid,
const int dofs_per_entity,
EntityType  )

Create an array layout over the entities of a local grid.

Parameters
local_gridThe local grid over which to create the layout.
dofs_per_entityThe number of degrees-of-freedom per grid entity.
Returns
Shared pointer to an ArrayLayout.
Note
EntityType The entity: Cell, Node, Face, or Edge

◆ createSubarray()

template<class Scalar, class EntityType, class MeshType, class... Params>
std::shared_ptr< Array< Scalar, EntityType, MeshType, typename Array< Scalar, EntityType, MeshType, Params... >::subview_layout, typename Array< Scalar, EntityType, MeshType, Params... >::memory_space, typename Array< Scalar, EntityType, MeshType, Params... >::subview_memory_traits > > Cabana::Grid::createSubarray ( const Array< Scalar, EntityType, MeshType, Params... > & array,
const int dof_min,
const int dof_max )

Create a subarray of the given array over the given range of degrees of freedom.

Parameters
arrayThe array from which to create a subarray
dof_minThe minimum degree-of-freedom index of the subarray.
dof_maxThe maximum degree-of-freedom index of the subarray.
Returns
Shared pointer to a new Array.

◆ dot()

template<class Array_t>
void Cabana::Grid::ArrayOp::dot ( const Array_t & a,
const Array_t & b,
std::vector< typename Array_t::value_type > & products )

Compute the dot product of owned space of two arrays.

Parameters
aThe first array in the dot product.
bThe second array in the dot product.
productsThe dot product of each entity degree-of-freedom in the array. This vector should be pre-sized to the number of degrees-of-freedom per entity.

◆ norm1()

template<class Array_t>
void Cabana::Grid::ArrayOp::norm1 ( const Array_t & array,
std::vector< typename Array_t::value_type > & norms )

Calculate the one-norm of the owned elements of the array.

Parameters
arrayThe array to compute the norm for.
normsThe norms for each degree-of-freedom in the array. This vector should be pre-sized to the number of degrees-of-freedom per entity.

◆ norm2()

template<class Array_t>
void Cabana::Grid::ArrayOp::norm2 ( const Array_t & array,
std::vector< typename Array_t::value_type > & norms )

Calculate the two-norm of the owned elements of the array.

Parameters
arrayThe array to compute the norm for.
normsThe norms for each entity degree-of-freedom in the array. This vector should be pre-sized to the number of degrees-of-freedom per entity.

◆ normInf()

template<class Array_t>
void Cabana::Grid::ArrayOp::normInf ( const Array_t & array,
std::vector< typename Array_t::value_type > & norms )

Calculate the infinity-norm of the owned elements of the array.

Parameters
arrayThe array to compute the norm for.
normsThe norms for each degree-of-freedom in the array. This vector should be pre-sized to the number of degrees-of-freedom per entity.

◆ scale() [1/4]

template<class Array_t, class DecompositionTag>
std::enable_if_t< 3==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::scale ( Array_t & array,
const std::vector< typename Array_t::value_type > & alpha,
DecompositionTag tag )

Scale every element of an array by a scalar. 3D specialization.

Parameters
arrayThe array to scale.
alphaThe values to scale the array by. A value must be provided for each entity degree-of-freedom in the array.
tagThe tag for the decomposition over which to perform the operation.

◆ scale() [2/4]

template<class Array_t, class DecompositionTag>
std::enable_if_t< 2==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::scale ( Array_t & array,
const std::vector< typename Array_t::value_type > & alpha,
DecompositionTag tag )

Scale every element of an array by a scalar. 2D specialization.

Parameters
arrayThe array to scale.
alphaThe values to scale the array by. A value must be provided for each entity degree-of-freedom in the array.
tagThe tag for the decomposition over which to perform the operation.

◆ scale() [3/4]

template<class Array_t, class DecompositionTag>
std::enable_if_t< 3==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::scale ( Array_t & array,
const typename Array_t::value_type alpha,
DecompositionTag tag )

Scale every element of an array by a scalar value. 3D specialization.

Parameters
arrayThe array to scale.
alphaThe value to scale the array by.
tagThe tag for the decomposition over which to perform the operation.

◆ scale() [4/4]

template<class Array_t, class DecompositionTag>
std::enable_if_t< 2==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::scale ( Array_t & array,
const typename Array_t::value_type alpha,
DecompositionTag tag )

Scale every element of an array by a scalar value. 2D specialization.

Parameters
arrayThe array to scale.
alphaThe value to scale the array by.
tagThe tag for the decomposition over which to perform the operation.

◆ update() [1/4]

template<class Array_t, class DecompositionTag>
std::enable_if_t< 3==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::update ( Array_t & a,
const typename Array_t::value_type alpha,
const Array_t & b,
const typename Array_t::value_type beta,
const Array_t & c,
const typename Array_t::value_type gamma,
DecompositionTag tag )

Update three vectors such that a = alpha * a + beta * b + gamma * c. 3D specialization.

Parameters
aThe array that will be updated.
alphaThe value to scale a by.
bThe first array to add to a.
betaThe value to scale b by.
cThe second array to add to a.
gammaThe value to scale b by.
tagThe tag for the decomposition over which to perform the operation.

◆ update() [2/4]

template<class Array_t, class DecompositionTag>
std::enable_if_t< 2==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::update ( Array_t & a,
const typename Array_t::value_type alpha,
const Array_t & b,
const typename Array_t::value_type beta,
const Array_t & c,
const typename Array_t::value_type gamma,
DecompositionTag tag )

Update three vectors such that a = alpha * a + beta * b + gamma * c. 2D specialization.

Parameters
aThe array that will be updated.
alphaThe value to scale a by.
bThe first array to add to a.
betaThe value to scale b by.
cThe second array to add to a.
gammaThe value to scale b by.
tagThe tag for the decomposition over which to perform the operation.

◆ update() [3/4]

template<class Array_t, class DecompositionTag>
std::enable_if_t< 3==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::update ( Array_t & a,
const typename Array_t::value_type alpha,
const Array_t & b,
const typename Array_t::value_type beta,
DecompositionTag tag )

Update two vectors such that a = alpha * a + beta * b. 3D specialization.

Parameters
aThe array that will be updated.
alphaThe value to scale a by.
bThe array to add to a.
betaThe value to scale b by.
tagThe tag for the decomposition over which to perform the operation.

◆ update() [4/4]

template<class Array_t, class DecompositionTag>
std::enable_if_t< 2==Array_t::num_space_dim, void > Cabana::Grid::ArrayOp::update ( Array_t & a,
const typename Array_t::value_type alpha,
const Array_t & b,
const typename Array_t::value_type beta,
DecompositionTag tag )

Update two vectors such that a = alpha * a + beta * b. 2D specialization.

Parameters
aThe array that will be updated.
alphaThe value to scale a by.
bThe array to add to a.
betaThe value to scale b by.
tagThe tag for the decomposition over which to perform the operation.