14template <
typename ScalarT >
30 : operator_apply_mode_( operator_apply_mode )
43 if ( src_.extent( 0 ) != dst_.extent( 0 ) )
45 throw std::runtime_error(
"Prolongation: src and dst must have the same number of subdomains." );
48 for (
int i = 1; i <= 3; i++ )
50 if ( 2 * ( src_.extent( i ) - 1 ) != dst_.extent( i ) - 1 )
52 throw std::runtime_error(
"Prolongation: src and dst must have a compatible number of cells." );
59 Kokkos::MDRangePolicy< Kokkos::Rank< 4 > >(
72 KOKKOS_INLINE_FUNCTION
void
73 operator()(
const int local_subdomain_id,
const int x_coarse,
const int y_coarse,
const int r_coarse )
const
75 const auto x_fine = 2 * x_coarse;
76 const auto y_fine = 2 * y_coarse;
77 const auto r_fine = 2 * r_coarse;
82 for (
const auto& offset : offsets )
84 const auto fine_stencil_x = x_fine + offset( 0 );
85 const auto fine_stencil_y = y_fine + offset( 1 );
86 const auto fine_stencil_r = r_fine + offset( 2 );
88 if ( fine_stencil_x >= 0 && fine_stencil_x < dst_.extent( 1 ) && fine_stencil_y >= 0 &&
89 fine_stencil_y < dst_.extent( 2 ) && fine_stencil_r >= 0 && fine_stencil_r < dst_.extent( 3 ) )
91 const auto weight = wedge::shell::prolongation_constant_weight< ScalarType >(
92 fine_stencil_x, fine_stencil_y, fine_stencil_r, x_coarse, y_coarse, r_coarse );
95 &dst_( local_subdomain_id, fine_stencil_x, fine_stencil_y, fine_stencil_r ),
96 weight * src_( local_subdomain_id, x_coarse, y_coarse, r_coarse ) );
102template <
typename ScalarT,
int VecDim = 3 >
119 : operator_apply_mode_( operator_apply_mode )
132 if ( src_.extent( 0 ) != dst_.extent( 0 ) )
134 throw std::runtime_error(
"Prolongation: src and dst must have the same number of subdomains." );
137 for (
int i = 1; i <= 3; i++ )
139 if ( 2 * ( src_.extent( i ) - 1 ) != dst_.extent( i ) - 1 )
141 throw std::runtime_error(
"Prolongation: src and dst must have a compatible number of cells." );
146 Kokkos::parallel_for(
148 Kokkos::MDRangePolicy< Kokkos::Rank< 4 > >(
161 KOKKOS_INLINE_FUNCTION
void
162 operator()(
const int local_subdomain_id,
const int x_coarse,
const int y_coarse,
const int r_coarse )
const
164 const auto x_fine = 2 * x_coarse;
165 const auto y_fine = 2 * y_coarse;
166 const auto r_fine = 2 * r_coarse;
171 for (
const auto& offset : offsets )
173 const auto fine_stencil_x = x_fine + offset( 0 );
174 const auto fine_stencil_y = y_fine + offset( 1 );
175 const auto fine_stencil_r = r_fine + offset( 2 );
177 if ( fine_stencil_x >= 0 && fine_stencil_x < dst_.extent( 1 ) && fine_stencil_y >= 0 &&
178 fine_stencil_y < dst_.extent( 2 ) && fine_stencil_r >= 0 && fine_stencil_r < dst_.extent( 3 ) )
180 const auto weight = wedge::shell::prolongation_constant_weight< ScalarType >(
181 fine_stencil_x, fine_stencil_y, fine_stencil_r, x_coarse, y_coarse, r_coarse );
183 for (
int d = 0; d < VecDim; ++d )
186 &dst_( local_subdomain_id, fine_stencil_x, fine_stencil_y, fine_stencil_r, d ),
187 weight * src_( local_subdomain_id, x_coarse, y_coarse, r_coarse, d ) );
Definition prolongation_constant.hpp:16
void operator()(const int local_subdomain_id, const int x_coarse, const int y_coarse, const int r_coarse) const
Definition prolongation_constant.hpp:73
void apply_impl(const SrcVectorType &src, DstVectorType &dst)
Definition prolongation_constant.hpp:33
ScalarT ScalarType
Definition prolongation_constant.hpp:20
ProlongationConstant(linalg::OperatorApplyMode operator_apply_mode=linalg::OperatorApplyMode::Replace)
Definition prolongation_constant.hpp:29
Definition prolongation_constant.hpp:104
void operator()(const int local_subdomain_id, const int x_coarse, const int y_coarse, const int r_coarse) const
Definition prolongation_constant.hpp:162
void apply_impl(const SrcVectorType &src, DstVectorType &dst)
Definition prolongation_constant.hpp:122
ScalarT ScalarType
Definition prolongation_constant.hpp:108
ProlongationVecConstant(linalg::OperatorApplyMode operator_apply_mode=linalg::OperatorApplyMode::Replace)
Definition prolongation_constant.hpp:117
Q1 scalar finite element vector on a distributed shell grid.
Definition vector_q1.hpp:21
const grid::Grid4DDataScalar< ScalarType > & grid_data() const
Get const reference to grid data.
Definition vector_q1.hpp:137
Static assertion: VectorQ1Scalar satisfies VectorLike concept.
Definition vector_q1.hpp:162
const grid::Grid4DDataVec< ScalarType, VecDim > & grid_data() const
Get const reference to grid data.
Definition vector_q1.hpp:280
Definition boundary_mass.hpp:14
constexpr void prolongation_constant_fine_grid_stencil_offsets_at_coarse_vertex(dense::Vec< int, 3 >(&offsets)[21])
Definition grid_transfer_constant.hpp:9
Kokkos::View< ScalarType ****[VecDim], Layout > Grid4DDataVec
Definition grid_types.hpp:43
Kokkos::View< ScalarType ****, Layout > Grid4DDataScalar
Definition grid_types.hpp:25
OperatorApplyMode
Modes for applying an operator to a vector.
Definition operator.hpp:30
@ Replace
Overwrite the destination vector.