4 #include <sll/mapping/curvilinear2d_to_cartesian.hpp>
5 #include <sll/mapping/metric_tensor.hpp>
7 #include "advection_domain.hpp"
8 #include "ddc_alias_inline_functions.hpp"
9 #include "ddc_aliases.hpp"
10 #include "directional_tag.hpp"
11 #include "geometry.hpp"
12 #include "i_interpolator_2d_rp.hpp"
13 #include "iadvectionrp.hpp"
14 #include "spline_foot_finder.hpp"
15 #include "spline_interpolator_2d_rp.hpp"
16 #include "vector_field.hpp"
17 #include "vector_field_mem.hpp"
58 template <
class FootFinder,
class Mapping>
64 FootFinder
const& m_find_feet;
87 function_interpolator,
88 FootFinder
const& foot_finder,
90 : m_interpolator(function_interpolator)
91 , m_find_feet(foot_finder)
113 host_t<DFieldRTheta> allfdistribu,
118 std::unique_ptr<IInterpolatorRTheta>
const interpolator_ptr = m_interpolator.
preallocate();
121 host_t<FieldMemRTheta<CoordRTheta>> feet_rp(get_idx_range(advection_field_xy));
122 ddc::for_each(get_idx_range(advection_field_xy), [&](IdxRTheta
const irp) {
123 feet_rp(irp) = ddc::coordinate(irp);
127 m_find_feet(get_field(feet_rp), advection_field_xy, dt);
130 (*interpolator_ptr)(allfdistribu, get_const_field(feet_rp));
153 host_t<DFieldRTheta> allfdistribu,
155 CoordXY
const& advection_field_xy_center,
158 IdxRangeRTheta grid(get_idx_range<GridR, GridTheta>(allfdistribu));
160 const int npoints_p = IdxRangeTheta(grid).size();
161 IdxRangeRTheta
const grid_without_Opoint(grid.remove_first(IdxStepRTheta(1, 0)));
162 IdxRangeRTheta
const Opoint_grid(grid.take_first(IdxStepRTheta(1, npoints_p)));
166 host_t<DVectorFieldMemRTheta<X, Y>> advection_field_xy(grid);
170 ddc::for_each(grid_without_Opoint, [&](IdxRTheta
const irp) {
171 CoordRTheta
const coord_rp(ddc::coordinate(irp));
173 std::array<std::array<double, 2>, 2> J;
175 std::array<std::array<double, 2>, 2> G;
176 metric_tensor(G, coord_rp);
178 ddcHelper::get<X>(advection_field_xy)(irp)
179 = ddcHelper::get<R>(advection_field_rp)(irp) * J[1][1] / std::sqrt(G[1][1])
180 + ddcHelper::get<Theta>(advection_field_rp)(irp) * -J[1][0]
181 / std::sqrt(G[0][0]);
182 ddcHelper::get<Y>(advection_field_xy)(irp)
183 = ddcHelper::get<R>(advection_field_rp)(irp) * -J[0][1] / std::sqrt(G[1][1])
184 + ddcHelper::get<Theta>(advection_field_rp)(irp) * J[0][0]
185 / std::sqrt(G[0][0]);
188 ddc::for_each(Opoint_grid, [&](IdxRTheta
const irp) {
189 ddcHelper::get<X>(advection_field_xy)(irp) = CoordX(advection_field_xy_center);
190 ddcHelper::get<Y>(advection_field_xy)(irp) = CoordY(advection_field_xy_center);
194 std::unique_ptr<IInterpolatorRTheta>
const interpolator_ptr = m_interpolator.
preallocate();
197 host_t<FieldMemRTheta<CoordRTheta>> feet_rp(grid);
198 ddc::for_each(grid, [&](IdxRTheta
const irp) { feet_rp(irp) = ddc::coordinate(irp); });
201 m_find_feet(get_field(feet_rp), get_const_field(advection_field_xy), dt);
204 (*interpolator_ptr)(allfdistribu, get_const_field(feet_rp));
Define an advection operator on 2D index range.
Definition: bsl_advection_rp.hpp:60
host_t< DFieldRTheta > operator()(host_t< DFieldRTheta > allfdistribu, host_t< DConstVectorFieldRTheta< R, Theta >> advection_field_rp, CoordXY const &advection_field_xy_center, double dt) const
Allocate a Field to the advected function.
Definition: bsl_advection_rp.hpp:152
host_t< DFieldRTheta > operator()(host_t< DFieldRTheta > allfdistribu, host_t< DConstVectorFieldRTheta< X, Y >> advection_field_xy, double dt) const
Allocate a Field of the advected function.
Definition: bsl_advection_rp.hpp:112
BslAdvectionRTheta(PreallocatableSplineInterpolatorRTheta< ddc::NullExtrapolationRule > const &function_interpolator, FootFinder const &foot_finder, Mapping const &mapping)
Instantiate an advection operator.
Definition: bsl_advection_rp.hpp:85
A class for describing the circular 2D mapping.
Definition: circular_to_cartesian.hpp:45
KOKKOS_FUNCTION void jacobian_matrix(ddc::Coordinate< R, Theta > const &coord, Matrix_2x2 &matrix) const
Compute full Jacobian matrix.
Definition: circular_to_cartesian.hpp:164
Define the base class of 2D advection operators in polar index range.
Definition: iadvectionrp.hpp:13
An operator for calculating the metric tensor.
Definition: metric_tensor.hpp:15
std::unique_ptr< IInterpolatorRTheta > preallocate() const override
Create a pointer to an instance of the SplineInterpolatorRTheta class.
Definition: spline_interpolator_2d_rp.hpp:153
A class which holds multiple (scalar) fields in order to represent a vector field.
Definition: vector_field.hpp:64