16#ifndef CABANA_GRID_ARRAY_HPP
17#define CABANA_GRID_ARRAY_HPP
24#include <Kokkos_Core.hpp>
44template <
class EntityType,
class MeshType>
64 const int dofs_per_entity )
65 : _local_grid( local_grid )
66 , _dofs_per_entity( dofs_per_entity )
71 const std::shared_ptr<LocalGrid<MeshType>>
localGrid()
const
81 template <
class DecompositionTag,
class IndexType>
83 indexSpace( DecompositionTag decomposition_tag, IndexType index_type )
const
101 template <
class DecompositionTag>
104 const std::array<int, num_space_dim>& off_ijk,
105 const int halo_width = -1 )
const
108 _local_grid->sharedIndexSpace( decomposition_tag, EntityType(),
109 off_ijk, halo_width ),
123 template <
class DecompositionTag, std::
size_t NSD = num_space_dim>
124 std::enable_if_t<3 == NSD, IndexSpace<4>>
126 const int off_j,
const int off_k,
127 const int halo_width = -1 )
const
129 std::array<int, 3> off_ijk = { off_i, off_j, off_k };
143 template <
class DecompositionTag, std::
size_t NSD = num_space_dim>
144 std::enable_if_t<2 == NSD, IndexSpace<3>>
146 const int off_j,
const int halo_width = -1 )
const
148 std::array<int, 2> off_ijk = { off_i, off_j };
153 std::shared_ptr<LocalGrid<MeshType>> _local_grid;
154 int _dofs_per_entity;
164template <
class EntityType,
class MeshType>
166 :
public std::true_type
171template <
class EntityType,
class MeshType>
173 :
public std::true_type
187template <
class EntityType,
class MeshType>
188std::shared_ptr<ArrayLayout<EntityType, MeshType>>
190 const int dofs_per_entity, EntityType )
192 return std::make_shared<ArrayLayout<EntityType, MeshType>>(
193 local_grid, dofs_per_entity );
208template <
class EntityType,
class MeshType>
209std::shared_ptr<ArrayLayout<EntityType, MeshType>>
211 const int halo_cell_width,
const int dofs_per_entity,
214 return std::make_shared<ArrayLayout<EntityType, MeshType>>(
227template <
class Scalar,
class EntityType,
class MeshType,
class... Params>
250 Kokkos::View<
value_type***, Params...>,
void>>;
255 using device_type [[deprecated]] =
typename memory_space::device_type;
266 const std::shared_ptr<array_layout>&
layout )
284 if ( (
long)
view.extent( d ) !=
286 throw std::runtime_error(
287 "Cabana::Grid::Array: Layout and "
288 "view dimensions do not match (View label: " +
289 view.label() +
")" );
293 std::shared_ptr<array_layout>
layout()
const {
return _layout; }
299 std::string
label()
const {
return _data.label(); }
302 std::shared_ptr<array_layout> _layout;
308 _data, _layout->indexSpace(
Ghost(),
Local() ) ) );
327template <
class Scalar,
class EntityType,
class MeshType,
class... Params>
329 :
public std::true_type
333template <
class Scalar,
class EntityType,
class MeshType,
class... Params>
335 :
public std::true_type
349template <
class Scalar,
class... Params,
class EntityType,
class MeshType>
350std::shared_ptr<
Array<Scalar, EntityType, MeshType, Params...>>
354 return std::make_shared<
Array<Scalar, EntityType, MeshType, Params...>>(
369template <
class Scalar,
class EntityType,
class MeshType,
class... Params>
370std::shared_ptr<Array<
371 Scalar, EntityType, MeshType,
372 typename Array<Scalar, EntityType, MeshType, Params...>::subview_layout,
373 typename Array<Scalar, EntityType, MeshType, Params...>::memory_space,
374 typename Array<Scalar, EntityType, MeshType,
375 Params...>::subview_memory_traits>>
377 const int dof_min,
const int dof_max )
379 if ( dof_min < 0 || dof_max > array.
layout()->dofsPerEntity() )
380 throw std::logic_error(
"Cabana::Grid::createSubarray: Subarray "
381 "dimensions out of bounds (Label: " +
382 array.
label() +
")" );
385 std::array<long, MeshType::num_space_dim + 1> min;
386 std::array<long, MeshType::num_space_dim + 1> max;
387 for ( std::size_t d = 0; d < MeshType::num_space_dim; ++d )
389 min[d] = space.min( d );
390 max[d] = space.max( d );
392 min.back() = dof_min;
393 max.back() = dof_max;
397 dof_max - dof_min, EntityType() );
398 return std::make_shared<
Array<
399 Scalar, EntityType, MeshType,
400 typename Array<Scalar, EntityType, MeshType, Params...>::subview_layout,
401 typename Array<Scalar, EntityType, MeshType, Params...>::memory_space,
402 typename Array<Scalar, EntityType, MeshType,
403 Params...>::subview_memory_traits>>( sub_layout,
417template <
class Scalar,
class... Params,
class EntityType,
class MeshType>
418std::shared_ptr<Array<Scalar, EntityType, MeshType, Params...>>
431template <
class Array_t,
class DecompositionTag>
432void assign( Array_t& array,
const typename Array_t::value_type alpha,
433 DecompositionTag tag )
437 "Cabana::Grid::ArrayOp::assign: Cabana::Grid::Array required" );
439 array.layout()->indexSpace( tag,
Local() ) );
440 Kokkos::deep_copy( subview, alpha );
450template <
class Array_t,
class DecompositionTag>
451std::enable_if_t<3 == Array_t::num_space_dim, void>
452scale( Array_t& array,
const typename Array_t::value_type alpha,
453 DecompositionTag tag )
457 "Cabana::Grid::ArrayOp::scale: Cabana::Grid::Array required" );
458 auto view = array.view();
459 Kokkos::parallel_for(
460 "Cabana::Grid::ArrayOp::scale",
462 typename Array_t::execution_space() ),
463 KOKKOS_LAMBDA(
const int i,
const int j,
const int k,
const int l ) {
464 view( i, j, k, l ) *= alpha;
474template <
class Array_t,
class DecompositionTag>
475std::enable_if_t<2 == Array_t::num_space_dim, void>
476scale( Array_t& array,
const typename Array_t::value_type alpha,
477 DecompositionTag tag )
481 "Cabana::Grid::ArrayOp::scale: Cabana::Grid::Array required" );
482 auto view = array.view();
483 Kokkos::parallel_for(
484 "Cabana::Grid::ArrayOp::scale",
486 typename Array_t::execution_space() ),
487 KOKKOS_LAMBDA(
const int i,
const int j,
const int l ) {
488 view( i, j, l ) *= alpha;
500template <
class Array_t,
class DecompositionTag>
501std::enable_if_t<3 == Array_t::num_space_dim, void>
502scale( Array_t& array,
const std::vector<typename Array_t::value_type>& alpha,
503 DecompositionTag tag )
507 "Cabana::Grid::ArrayOp::scale: Cabana::Grid::Array required" );
509 static_cast<unsigned>( array.layout()->dofsPerEntity() ) )
510 throw std::runtime_error(
"Cabana::Grid::ArrayOp::scale: Incorrect "
511 "vector size (Label: " +
512 array.label() +
")" );
514 Kokkos::View<
const typename Array_t::value_type*, Kokkos::HostSpace,
515 Kokkos::MemoryUnmanaged>
516 alpha_view_host( alpha.data(), alpha.size() );
517 auto alpha_view = Kokkos::create_mirror_view_and_copy(
518 typename Array_t::memory_space(), alpha_view_host );
520 auto array_view = array.view();
521 Kokkos::parallel_for(
522 "Cabana::Grid::ArrayOp::scale",
524 typename Array_t::execution_space() ),
525 KOKKOS_LAMBDA(
const int i,
const int j,
const int k,
const int l ) {
526 array_view( i, j, k, l ) *= alpha_view( l );
537template <
class Array_t,
class DecompositionTag>
538std::enable_if_t<2 == Array_t::num_space_dim, void>
539scale( Array_t& array,
const std::vector<typename Array_t::value_type>& alpha,
540 DecompositionTag tag )
544 "Cabana::Grid::ArrayOp::scale: Cabana::Grid::Array required" );
546 static_cast<unsigned>( array.layout()->dofsPerEntity() ) )
547 throw std::runtime_error(
"Cabana::Grid::ArrayOp::scale: Incorrect "
548 "vector size (Label: " +
549 array.label() +
")" );
551 Kokkos::View<
const typename Array_t::value_type*, Kokkos::HostSpace,
552 Kokkos::MemoryUnmanaged>
553 alpha_view_host( alpha.data(), alpha.size() );
554 auto alpha_view = Kokkos::create_mirror_view_and_copy(
555 typename Array_t::memory_space(), alpha_view_host );
557 auto array_view = array.view();
558 Kokkos::parallel_for(
559 "Cabana::Grid::ArrayOp::scale",
561 typename Array_t::execution_space() ),
562 KOKKOS_LAMBDA(
const int i,
const int j,
const int l ) {
563 array_view( i, j, l ) *= alpha_view( l );
574template <
class Array_t,
class DecompositionTag>
575void copy( Array_t& a,
const Array_t& b, DecompositionTag tag )
579 "Cabana::Grid::ArrayOp::copy: Cabana::Grid::Array required" );
580 auto a_space = a.layout()->indexSpace( tag,
Local() );
581 auto b_space = b.layout()->indexSpace( tag,
Local() );
582 if ( a_space != b_space )
583 throw std::logic_error(
"Cabana::Grid::ArrayOp::copy: Incompatible "
584 "index spaces (Labels: " +
585 a.label() +
", " + b.label() +
")" );
588 Kokkos::deep_copy( subview_a, subview_b );
597template <
class Array_t,
class DecompositionTag>
598std::shared_ptr<Array_t>
cloneCopy(
const Array_t& array, DecompositionTag tag )
600 auto cln =
clone( array );
601 copy( *cln, array, tag );
615template <
class Array_t,
class DecompositionTag>
616std::enable_if_t<3 == Array_t::num_space_dim, void>
617update( Array_t& a,
const typename Array_t::value_type alpha,
const Array_t& b,
618 const typename Array_t::value_type beta, DecompositionTag tag )
621 auto a_view = a.view();
622 auto b_view = b.view();
623 Kokkos::parallel_for(
624 "Cabana::Grid::ArrayOp::update",
626 typename Array_t::execution_space() ),
627 KOKKOS_LAMBDA(
const int i,
const int j,
const int k,
const int l ) {
628 a_view( i, j, k, l ) =
629 alpha * a_view( i, j, k, l ) + beta * b_view( i, j, k, l );
642template <
class Array_t,
class DecompositionTag>
643std::enable_if_t<2 == Array_t::num_space_dim, void>
644update( Array_t& a,
const typename Array_t::value_type alpha,
const Array_t& b,
645 const typename Array_t::value_type beta, DecompositionTag tag )
648 auto a_view = a.view();
649 auto b_view = b.view();
650 Kokkos::parallel_for(
651 "Cabana::Grid::ArrayOp::update",
653 typename Array_t::execution_space() ),
654 KOKKOS_LAMBDA(
const long i,
const long j,
const long l ) {
656 alpha * a_view( i, j, l ) + beta * b_view( i, j, l );
672template <
class Array_t,
class DecompositionTag>
673std::enable_if_t<3 == Array_t::num_space_dim, void>
674update( Array_t& a,
const typename Array_t::value_type alpha,
const Array_t& b,
675 const typename Array_t::value_type beta,
const Array_t& c,
676 const typename Array_t::value_type gamma, DecompositionTag tag )
679 auto a_view = a.view();
680 auto b_view = b.view();
681 auto c_view = c.view();
682 Kokkos::parallel_for(
683 "Cabana::Grid::ArrayOp::update",
685 typename Array_t::execution_space() ),
686 KOKKOS_LAMBDA(
const int i,
const int j,
const int k,
const int l ) {
687 a_view( i, j, k, l ) = alpha * a_view( i, j, k, l ) +
688 beta * b_view( i, j, k, l ) +
689 gamma * c_view( i, j, k, l );
704template <
class Array_t,
class DecompositionTag>
705std::enable_if_t<2 == Array_t::num_space_dim, void>
706update( Array_t& a,
const typename Array_t::value_type alpha,
const Array_t& b,
707 const typename Array_t::value_type beta,
const Array_t& c,
708 const typename Array_t::value_type gamma, DecompositionTag tag )
711 auto a_view = a.view();
712 auto b_view = b.view();
713 auto c_view = c.view();
714 Kokkos::parallel_for(
715 "Cabana::Grid::ArrayOp::update",
717 typename Array_t::execution_space() ),
718 KOKKOS_LAMBDA(
const int i,
const int j,
const int l ) {
719 a_view( i, j, l ) = alpha * a_view( i, j, l ) +
720 beta * b_view( i, j, l ) +
721 gamma * c_view( i, j, l );
727template <
class ViewType, std::
size_t NumSpaceDim>
752 template <std::
size_t NSD = num_space_dim>
753 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, void>
757 sum[l] +=
_a( i, j, k, l ) *
_b( i, j, k, l );
761 template <std::
size_t NSD = num_space_dim>
762 KOKKOS_INLINE_FUNCTION std::enable_if_t<2 == NSD, void>
766 sum[l] +=
_a( i, j, l ) *
_b( i, j, l );
770 KOKKOS_INLINE_FUNCTION
778 KOKKOS_INLINE_FUNCTION
801template <
class Array_t>
802void dot(
const Array_t& a,
const Array_t& b,
803 std::vector<typename Array_t::value_type>& products )
806 if ( products.size() !=
807 static_cast<unsigned>( a.layout()->dofsPerEntity() ) )
808 throw std::runtime_error(
809 "Cabana::Grid::ArrayOp::dot: Incorrect vector size" );
811 for (
auto& p : products )
815 a.view(), b.view() );
816 typename Array_t::execution_space exec_space;
817 Kokkos::parallel_reduce(
818 "Cabana::Grid::ArrayOp::dot",
822 Kokkos::View<typename Array_t::value_type*, Kokkos::HostSpace>(
823 products.data(), products.size() ) );
824 exec_space.fence(
"Cabana::Grid::ArrayOp::dot before MPI_Allreduce" );
826 MPI_Allreduce( MPI_IN_PLACE, products.data(), products.size(),
828 a.layout()->localGrid()->globalGrid().comm() );
833template <
class ViewType, std::
size_t NumSpaceDim>
855 template <std::
size_t NSD = num_space_dim>
856 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, void>
860 auto v_abs = fabs(
_view( i, j, k, l ) );
861 if ( v_abs > norm[l] )
866 template <std::
size_t NSD = num_space_dim>
867 KOKKOS_INLINE_FUNCTION std::enable_if_t<2 == NSD, void>
871 auto v_abs = fabs(
_view( i, j, l ) );
872 if ( v_abs > norm[l] )
877 KOKKOS_INLINE_FUNCTION
881 if ( src[j] > dst[j] )
886 KOKKOS_INLINE_FUNCTION
890 if ( src[j] > dst[j] )
908template <
class Array_t>
910 std::vector<typename Array_t::value_type>& norms )
914 static_cast<unsigned>( array.layout()->dofsPerEntity() ) )
915 throw std::runtime_error(
916 "Cabana::Grid::ArrayOp::normInf: Incorrect vector size" );
918 for (
auto& n : norms )
923 typename Array_t::execution_space exec_space;
924 Kokkos::parallel_reduce(
925 "Cabana::Grid::ArrayOp::normInf",
929 Kokkos::View<typename Array_t::value_type*, Kokkos::HostSpace>(
930 norms.data(), norms.size() ) );
931 exec_space.fence(
"ArrayOp::normInf before MPI_Allreduce" );
933 MPI_Allreduce( MPI_IN_PLACE, norms.data(), norms.size(),
935 array.layout()->localGrid()->globalGrid().comm() );
940template <
class ViewType, std::
size_t NumSpaceDim>
962 template <std::
size_t NSD = num_space_dim>
963 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, void>
967 norm[l] += fabs(
_view( i, j, k, l ) );
971 template <std::
size_t NSD = num_space_dim>
972 KOKKOS_INLINE_FUNCTION std::enable_if_t<2 == NSD, void>
976 norm[l] += fabs(
_view( i, j, l ) );
980 KOKKOS_INLINE_FUNCTION
988 KOKKOS_INLINE_FUNCTION
1009template <
class Array_t>
1011 std::vector<typename Array_t::value_type>& norms )
1014 if ( norms.size() !=
1015 static_cast<unsigned>( array.layout()->dofsPerEntity() ) )
1016 throw std::runtime_error(
1017 "Cabana::Grid::ArrayOp::norm1: Incorrect vector size" );
1019 for (
auto& n : norms )
1024 typename Array_t::execution_space exec_space;
1025 Kokkos::parallel_reduce(
1026 "Cabana::Grid::ArrayOp::norm1",
1030 Kokkos::View<typename Array_t::value_type*, Kokkos::HostSpace>(
1031 norms.data(), norms.size() ) );
1032 exec_space.fence(
"Cabana::Grid::ArrayOp::norm1 before MPI_Allreduce" );
1034 MPI_Allreduce( MPI_IN_PLACE, norms.data(), norms.size(),
1036 array.layout()->localGrid()->globalGrid().comm() );
1041template <
class ViewType, std::
size_t NumSpaceDim>
1063 template <std::
size_t NSD = num_space_dim>
1064 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, void>
1068 norm[l] +=
_view( i, j, k, l ) *
_view( i, j, k, l );
1072 template <std::
size_t NSD = num_space_dim>
1073 KOKKOS_INLINE_FUNCTION std::enable_if_t<2 == NSD, void>
1077 norm[l] +=
_view( i, j, l ) *
_view( i, j, l );
1081 KOKKOS_INLINE_FUNCTION
1089 KOKKOS_INLINE_FUNCTION
1110template <
class Array_t>
1112 std::vector<typename Array_t::value_type>& norms )
1115 if ( norms.size() !=
1116 static_cast<unsigned>( array.layout()->dofsPerEntity() ) )
1117 throw std::runtime_error(
1118 "Cabana::Grid::ArrayOp::norm2: Incorrect vector size" );
1120 for (
auto& n : norms )
1125 typename Array_t::execution_space exec_space;
1126 Kokkos::parallel_reduce(
1127 "Cabana::Grid::ArrayOp::norm2",
1131 Kokkos::View<typename Array_t::value_type*, Kokkos::HostSpace>(
1132 norms.data(), norms.size() ) );
1133 exec_space.fence(
"Cabana::Grid::ArrayOp::norm2 before MPI_Allreduce" );
1135 MPI_Allreduce( MPI_IN_PLACE, norms.data(), norms.size(),
1137 array.layout()->localGrid()->globalGrid().comm() );
1139 for (
auto& n : norms )
void 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.
Definition Cabana_Grid_Array.hpp:802
std::enable_if_t< 3==Array_t::num_space_dim, void > 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.
Definition Cabana_Grid_Array.hpp:617
std::shared_ptr< Array< Scalar, EntityType, MeshType, Params... > > clone(const Array< Scalar, EntityType, MeshType, Params... > &array)
Clone an array. Do not initialize the clone.
Definition Cabana_Grid_Array.hpp:419
void copy(Array_t &a, const Array_t &b, DecompositionTag tag)
Copy one array into another over the designated decomposition. A <- B.
Definition Cabana_Grid_Array.hpp:575
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 > > 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.
Definition Cabana_Grid_Array.hpp:376
void normInf(const Array_t &array, std::vector< typename Array_t::value_type > &norms)
Calculate the infinity-norm of the owned elements of the array.
Definition Cabana_Grid_Array.hpp:909
std::enable_if_t< 3==Array_t::num_space_dim, void > 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.
Definition Cabana_Grid_Array.hpp:452
void norm2(const Array_t &array, std::vector< typename Array_t::value_type > &norms)
Calculate the two-norm of the owned elements of the array.
Definition Cabana_Grid_Array.hpp:1111
std::shared_ptr< Array< Scalar, EntityType, MeshType, Params... > > 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 th...
Definition Cabana_Grid_Array.hpp:351
void norm1(const Array_t &array, std::vector< typename Array_t::value_type > &norms)
Calculate the one-norm of the owned elements of the array.
Definition Cabana_Grid_Array.hpp:1010
std::shared_ptr< ArrayLayout< EntityType, MeshType > > 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.
Definition Cabana_Grid_Array.hpp:189
std::shared_ptr< Array_t > cloneCopy(const Array_t &array, DecompositionTag tag)
Clone an array and copy its contents into the clone.
Definition Cabana_Grid_Array.hpp:598
void assign(Array_t &array, const typename Array_t::value_type alpha, DecompositionTag tag)
Assign a scalar value to every element of an array.
Definition Cabana_Grid_Array.hpp:432
KOKKOS_INLINE_FUNCTION auto createSubview(const ViewType &view, const IndexSpace< 1 > &index_space) -> decltype(Kokkos::subview(view, index_space.range(0)))
Given a view create a subview over the given index space.
Definition Cabana_Grid_IndexSpace.hpp:369
Kokkos::RangePolicy< ExecutionSpace > createExecutionPolicy(const IndexSpace< 1 > &index_space, const ExecutionSpace &)
Create a multi-dimensional execution policy over an index space.
Definition Cabana_Grid_IndexSpace.hpp:175
Kokkos::View< Scalar *, Params... > createView(const std::string &label, const IndexSpace< 1 > &index_space)
Given an index space create a view over the extent of that index space.
Definition Cabana_Grid_IndexSpace.hpp:235
IndexSpace< N+1 > appendDimension(const IndexSpace< N > &index_space, const long size)
Given an N-dimensional index space append an additional dimension with the given size.
Definition Cabana_Grid_IndexSpace.hpp:442
std::shared_ptr< LocalGrid< MeshType > > createLocalGrid(const std::shared_ptr< GlobalGrid< MeshType > > &global_grid, const int halo_cell_width)
Create a local grid.
Definition Cabana_Grid_LocalGrid.hpp:607
Entity layout for array data on the local mesh.
Definition Cabana_Grid_Array.hpp:46
std::enable_if_t< 3==NSD, IndexSpace< 4 > > sharedIndexSpace(DecompositionTag decomposition_tag, const int off_i, const int off_j, const int off_k, const int halo_width=-1) const
Definition Cabana_Grid_Array.hpp:125
ArrayLayout(const std::shared_ptr< LocalGrid< MeshType > > &local_grid, const int dofs_per_entity)
Constructor.
Definition Cabana_Grid_Array.hpp:63
MeshType mesh_type
Mesh type.
Definition Cabana_Grid_Array.hpp:52
IndexSpace< num_space_dim+1 > indexSpace(DecompositionTag decomposition_tag, IndexType index_type) const
Definition Cabana_Grid_Array.hpp:83
int dofsPerEntity() const
Get the number of degrees-of-freedom on each grid entity.
Definition Cabana_Grid_Array.hpp:77
IndexSpace< num_space_dim+1 > sharedIndexSpace(DecompositionTag decomposition_tag, const std::array< int, num_space_dim > &off_ijk, const int halo_width=-1) const
Definition Cabana_Grid_Array.hpp:103
std::enable_if_t< 2==NSD, IndexSpace< 3 > > sharedIndexSpace(DecompositionTag decomposition_tag, const int off_i, const int off_j, const int halo_width=-1) const
Definition Cabana_Grid_Array.hpp:145
const std::shared_ptr< LocalGrid< MeshType > > localGrid() const
Get the local grid over which this layout is defined.
Definition Cabana_Grid_Array.hpp:71
static constexpr std::size_t num_space_dim
Definition Cabana_Grid_Array.hpp:55
EntityType entity_type
Entity type.
Definition Cabana_Grid_Array.hpp:49
Array of field data on the local mesh.
Definition Cabana_Grid_Array.hpp:229
std::shared_ptr< array_layout > layout() const
Definition Cabana_Grid_Array.hpp:293
view_type view() const
Definition Cabana_Grid_Array.hpp:296
Array(const std::shared_ptr< array_layout > &layout, const view_type &view)
Create an array with the given layout and view. This view should match the array index spaces in size...
Definition Cabana_Grid_Array.hpp:279
typename subview_type::array_layout subview_layout
Subview array layout type.
Definition Cabana_Grid_Array.hpp:310
Array(const std::string &label, const std::shared_ptr< array_layout > &layout)
Create an array with the given layout. Arrays are constructed over the ghosted index space of the lay...
Definition Cabana_Grid_Array.hpp:265
typename subview_type::memory_traits subview_memory_traits
Subview memory traits.
Definition Cabana_Grid_Array.hpp:312
Scalar value_type
Value type.
Definition Cabana_Grid_Array.hpp:232
ArrayLayout< entity_type, mesh_type > array_layout
Array layout type.
Definition Cabana_Grid_Array.hpp:244
MeshType mesh_type
Mesh type.
Definition Cabana_Grid_Array.hpp:238
std::conditional_t< 3==num_space_dim, Kokkos::View< value_type ****, Params... >, std::conditional_t< 2==num_space_dim, Kokkos::View< value_type ***, Params... >, void > > view_type
View type.
Definition Cabana_Grid_Array.hpp:247
decltype(createSubview( _data, _layout->indexSpace(Ghost(), Local()))) subview_type
Subview type.
Definition Cabana_Grid_Array.hpp:307
std::string label() const
Definition Cabana_Grid_Array.hpp:299
typename memory_space::execution_space execution_space
Default execution space.
Definition Cabana_Grid_Array.hpp:257
EntityType entity_type
Entity type.
Definition Cabana_Grid_Array.hpp:235
Array< Scalar, EntityType, MeshType, subview_layout, memory_space, subview_memory_traits > subarray_type
Subarray type.
Definition Cabana_Grid_Array.hpp:314
static constexpr std::size_t num_space_dim
Definition Cabana_Grid_Array.hpp:241
typename view_type::memory_space memory_space
Memory space.
Definition Cabana_Grid_Array.hpp:253
Global logical grid.
Definition Cabana_Grid_GlobalGrid.hpp:39
Structured index space.
Definition Cabana_Grid_IndexSpace.hpp:37
Local logical grid.
Definition Cabana_Grid_LocalGrid.hpp:39
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
Dot product functor.
Definition Cabana_Grid_Array.hpp:729
KOKKOS_INLINE_FUNCTION void join(value_type dst, const value_type src) const
Join operation.
Definition Cabana_Grid_Array.hpp:771
ViewType _a
The first array in the dot product.
Definition Cabana_Grid_Array.hpp:739
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, void > operator()(const size_type i, const size_type j, const size_type k, const size_type l, value_type sum) const
3d dot product operation.
Definition Cabana_Grid_Array.hpp:754
ViewType::size_type size_type
Size type.
Definition Cabana_Grid_Array.hpp:735
KOKKOS_INLINE_FUNCTION void join(volatile value_type dst, const volatile value_type src) const
Join operation.
Definition Cabana_Grid_Array.hpp:779
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_Array.hpp:731
KOKKOS_INLINE_FUNCTION void init(value_type sum) const
Zero initialization.
Definition Cabana_Grid_Array.hpp:786
KOKKOS_INLINE_FUNCTION std::enable_if_t< 2==NSD, void > operator()(const size_type i, const size_type j, const size_type l, value_type sum) const
2d dot product operation.
Definition Cabana_Grid_Array.hpp:763
ViewType::value_type value_type[]
Value type.
Definition Cabana_Grid_Array.hpp:733
size_type value_count
Size of the array.
Definition Cabana_Grid_Array.hpp:737
ViewType _b
The second array in the dot product.
Definition Cabana_Grid_Array.hpp:741
DotFunctor(const ViewType &a, const ViewType &b)
Constructor.
Definition Cabana_Grid_Array.hpp:744
One norm functor.
Definition Cabana_Grid_Array.hpp:942
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_Array.hpp:944
KOKKOS_INLINE_FUNCTION void join(volatile value_type dst, const volatile value_type src) const
Join operation.
Definition Cabana_Grid_Array.hpp:989
ViewType::size_type size_type
Size type.
Definition Cabana_Grid_Array.hpp:948
KOKKOS_INLINE_FUNCTION void join(value_type dst, const value_type src) const
Join operation.
Definition Cabana_Grid_Array.hpp:981
KOKKOS_INLINE_FUNCTION std::enable_if_t< 2==NSD, void > operator()(const size_type i, const size_type j, const size_type l, value_type norm) const
2d one norm operation.
Definition Cabana_Grid_Array.hpp:973
ViewType::value_type value_type[]
Value type.
Definition Cabana_Grid_Array.hpp:946
KOKKOS_INLINE_FUNCTION void init(value_type norm) const
Zero initialization.
Definition Cabana_Grid_Array.hpp:996
size_type value_count
Size of the array.
Definition Cabana_Grid_Array.hpp:950
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, void > operator()(const size_type i, const size_type j, const size_type k, const size_type l, value_type norm) const
3d one norm operation.
Definition Cabana_Grid_Array.hpp:964
Norm1Functor(const ViewType &view)
Constructor.
Definition Cabana_Grid_Array.hpp:955
ViewType _view
Array for the one norm.
Definition Cabana_Grid_Array.hpp:952
Two norm functor.
Definition Cabana_Grid_Array.hpp:1043
ViewType _view
Array for the two norm.
Definition Cabana_Grid_Array.hpp:1053
KOKKOS_INLINE_FUNCTION std::enable_if_t< 2==NSD, void > operator()(const size_type i, const size_type j, const size_type l, value_type norm) const
2d two norm operation.
Definition Cabana_Grid_Array.hpp:1074
ViewType::size_type size_type
Size type.
Definition Cabana_Grid_Array.hpp:1049
KOKKOS_INLINE_FUNCTION void join(value_type dst, const value_type src) const
Join operation.
Definition Cabana_Grid_Array.hpp:1082
KOKKOS_INLINE_FUNCTION void init(value_type norm) const
Zero initialization.
Definition Cabana_Grid_Array.hpp:1097
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, void > operator()(const size_type i, const size_type j, const size_type k, const size_type l, value_type norm) const
3d two norm operation.
Definition Cabana_Grid_Array.hpp:1065
size_type value_count
Size of the array.
Definition Cabana_Grid_Array.hpp:1051
ViewType::value_type value_type[]
Value type.
Definition Cabana_Grid_Array.hpp:1047
KOKKOS_INLINE_FUNCTION void join(volatile value_type dst, const volatile value_type src) const
Join operation.
Definition Cabana_Grid_Array.hpp:1090
Norm2Functor(const ViewType &view)
Constructor.
Definition Cabana_Grid_Array.hpp:1056
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_Array.hpp:1045
Infinity norm functor.
Definition Cabana_Grid_Array.hpp:835
KOKKOS_INLINE_FUNCTION std::enable_if_t< 2==NSD, void > operator()(const size_type i, const size_type j, const size_type l, value_type norm) const
2d infinity norm operation.
Definition Cabana_Grid_Array.hpp:868
ViewType::value_type value_type[]
Value type.
Definition Cabana_Grid_Array.hpp:839
size_type value_count
Size of the array.
Definition Cabana_Grid_Array.hpp:843
KOKKOS_INLINE_FUNCTION void init(value_type norm) const
Zero initialization.
Definition Cabana_Grid_Array.hpp:895
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_Array.hpp:837
NormInfFunctor(const ViewType &view)
Constructor.
Definition Cabana_Grid_Array.hpp:848
ViewType::size_type size_type
Size type.
Definition Cabana_Grid_Array.hpp:841
KOKKOS_INLINE_FUNCTION void join(volatile value_type dst, const volatile value_type src) const
Join operation.
Definition Cabana_Grid_Array.hpp:887
ViewType _view
Array for the infinity norm.
Definition Cabana_Grid_Array.hpp:845
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, void > operator()(const size_type i, const size_type j, const size_type k, const size_type l, value_type norm) const
3d infinity norm operation.
Definition Cabana_Grid_Array.hpp:857
KOKKOS_INLINE_FUNCTION void join(value_type dst, const value_type src) const
Join operation.
Definition Cabana_Grid_Array.hpp:878
Ghosted decomposition tag.
Definition Cabana_Grid_Types.hpp:197
Local index tag.
Definition Cabana_Grid_Types.hpp:208
Definition Cabana_Grid_MpiTraits.hpp:32
Owned decomposition tag.
Definition Cabana_Grid_Types.hpp:190
Array static type checker.
Definition Cabana_Grid_Array.hpp:160
Definition Cabana_Grid_Array.hpp:324