Loading...
Searching...
No Matches
fv/hex/operators/mass.hpp
Go to the documentation of this file.
1
2#pragma once
9
11
12template < typename ScalarT >
13class Mass
14{
15 public:
18 using ScalarType = ScalarT;
19
20 private:
22
26
29
30 public:
36 : domain_( domain )
37 , grid_( grid )
38 , radii_( radii )
39 , boundary_mask_( boundary_mask )
40 {}
41
42 void apply_impl( const SrcVectorType& src, DstVectorType& dst )
43 {
44 // TODO: communicate ghost layers
45
46 src_ = src.grid_data();
47 dst_ = dst.grid_data();
48
49 Kokkos::parallel_for(
50 "matvec",
51 Kokkos::MDRangePolicy(
52 { 0, 1, 1, 1 },
53 { src.grid_data().extent( 0 ),
54 src.grid_data().extent( 1 ) - 1,
55 src.grid_data().extent( 2 ) - 1,
56 src.grid_data().extent( 3 ) - 1 } ),
57 *this );
58 }
59
60 private:
61 using Vec3 = dense::Vec< ScalarType, 3 >;
62
63 public:
64 KOKKOS_INLINE_FUNCTION void
65 operator()( const int local_subdomain_id, const int x_cell, const int y_cell, const int r_cell ) const
66 {
67 // Gather surface points for each wedge.
70 fe::wedge::wedge_surface_physical_coords( wedge_phy_surf, grid_, local_subdomain_id, x_cell - 1, y_cell - 1 );
71
72 // Gather wedge radii.
73 const ScalarT r_1 = radii_( local_subdomain_id, r_cell - 1 );
74 const ScalarT r_2 = radii_( local_subdomain_id, r_cell );
75
76 // Quadrature points.
77 constexpr auto num_quad_points = fe::wedge::quadrature::quad_felippa_3x2_num_quad_points;
78
79 dense::Vec< ScalarT, 3 > quad_points[num_quad_points];
80 ScalarT quad_weights[num_quad_points];
81
84
85 // Cell volume
86 ScalarType M_ii = 0;
87 for ( int wedge = 0; wedge < fe::wedge::num_wedges_per_hex_cell; ++wedge )
88 {
89 for ( int q = 0; q < num_quad_points; ++q )
90 {
91 const auto J = fe::wedge::jac( wedge_phy_surf[wedge], r_1, r_2, quad_points[q] );
92 const auto det = J.det();
93 const auto abs_det = Kokkos::abs( det );
94 const auto Jw = abs_det * quad_weights[q];
95 M_ii += Jw;
96 }
97 }
98
99 // Mass is diagonal.
100 dst_( local_subdomain_id, x_cell, y_cell, r_cell ) = M_ii * src_( local_subdomain_id, x_cell, y_cell, r_cell );
101 }
102};
103
104} // namespace terra::fv::hex::operators
Definition fv/hex/operators/mass.hpp:14
ScalarT ScalarType
Definition fv/hex/operators/mass.hpp:18
Mass(const grid::shell::DistributedDomain &domain, const grid::Grid3DDataVec< ScalarT, 3 > &grid, const grid::Grid2DDataScalar< ScalarT > &radii, const grid::Grid4DDataScalar< grid::shell::ShellBoundaryFlag > &boundary_mask)
Definition fv/hex/operators/mass.hpp:31
void apply_impl(const SrcVectorType &src, DstVectorType &dst)
Definition fv/hex/operators/mass.hpp:42
void operator()(const int local_subdomain_id, const int x_cell, const int y_cell, const int r_cell) const
Definition fv/hex/operators/mass.hpp:65
Parallel data structure organizing the thick spherical shell metadata for distributed (MPI parallel) ...
Definition spherical_shell.hpp:2518
Finite volume vector on distributed shell grid with one DoF per hex (merging 2 wedges) and ghost-laye...
Definition vector_fv.hpp:23
const grid::Grid4DDataScalar< ScalarType > & grid_data() const
Get const reference to grid data.
Definition vector_fv.hpp:145
constexpr void quad_felippa_3x2_quad_weights(T(&quad_weights)[quad_felippa_3x2_num_quad_points])
Definition wedge/quadrature/quadrature.hpp:93
constexpr int quad_felippa_3x2_num_quad_points
Definition wedge/quadrature/quadrature.hpp:66
constexpr void quad_felippa_3x2_quad_points(dense::Vec< T, 3 >(&quad_points)[quad_felippa_3x2_num_quad_points])
Definition wedge/quadrature/quadrature.hpp:70
constexpr int num_nodes_per_wedge_surface
Definition kernel_helpers.hpp:6
void wedge_surface_physical_coords(dense::Vec< T, 3 >(&wedge_surf_phy_coords)[num_wedges_per_hex_cell][num_nodes_per_wedge_surface], const grid::Grid3DDataVec< T, 3 > &lateral_grid, const int local_subdomain_id, const int x_cell, const int y_cell)
Extracts the (unit sphere) surface vertex coords of the two wedges of a hex cell.
Definition kernel_helpers.hpp:26
constexpr int num_wedges_per_hex_cell
Definition kernel_helpers.hpp:5
constexpr dense::Mat< T, 3, 3 > jac(const dense::Vec< T, 3 > &p1_phy, const dense::Vec< T, 3 > &p2_phy, const dense::Vec< T, 3 > &p3_phy, const T r_1, const T r_2, const T xi, const T eta, const T zeta)
Definition integrands.hpp:657
Definition advection_diffusion.hpp:9
Kokkos::View< ScalarType ***[VecDim], Layout > Grid3DDataVec
Definition grid_types.hpp:42
Kokkos::View< ScalarType ****, Layout > Grid4DDataScalar
Definition grid_types.hpp:27
Kokkos::View< ScalarType **, Layout > Grid2DDataScalar
Definition grid_types.hpp:21