331 ExecSpace exec_space,
332 Mapping
const& analytical_mapping,
333 SplineBuilder
const& builder,
334 SplineEvaluator
const& evaluator)
336 evaluator.lower_extrapolation_rule_dim_1(),
337 evaluator.upper_extrapolation_rule_dim_1(),
338 evaluator.lower_extrapolation_rule_dim_2(),
339 evaluator.upper_extrapolation_rule_dim_2())
341 using CoordR = ddc::Coordinate<R>;
342 using CoordTheta = ddc::Coordinate<Theta>;
344 const CoordR r_min = ddc::discrete_space<BSplinesROriginal>().rmin();
345 const CoordR r_max = ddc::discrete_space<BSplinesROriginal>().rmax();
347 const CoordTheta theta_min = ddc::discrete_space<BSplinesThetaOriginal>().rmin();
348 const CoordTheta theta_max = ddc::discrete_space<BSplinesThetaOriginal>().rmax();
350 ddc::DiscreteVector<BSplinesRRefined>
const r_ncells_idx_step(ncells_r);
351 ddc::DiscreteVector<BSplinesThetaRefined>
const theta_ncells_idx_step(ncells_theta);
353 if constexpr (BSplinesRRefined::is_uniform()) {
354 ddc::init_discrete_space<BSplinesRRefined>(r_min, r_max, r_ncells_idx_step);
355 ddc::init_discrete_space<
358 double const dr((r_max - r_min) / ncells_r);
359 double const dp((theta_max - theta_min) / ncells_theta);
361 std::vector<CoordR> r_break_points(ncells_r + 1);
362 std::vector<CoordTheta> theta_break_points(ncells_theta + 1);
364 for (
int i(0); i < ncells_r + 1; ++i) {
365 r_break_points[i] = r_min + i * dr;
367 for (
int i(0); i < ncells_theta + 1; ++i) {
368 theta_break_points[i] = theta_min + i * dp;
371 ddc::init_discrete_space<BSplinesRRefined>(r_break_points);
372 ddc::init_discrete_space<BSplinesThetaRefined>(theta_break_points);
375 ddc::init_discrete_space<GridRRefined>(
376 GrevillePointsR::template get_sampling<GridRRefined>());
377 ddc::init_discrete_space<GridThetaRefined>(
378 GrevillePointsTheta::template get_sampling<GridThetaRefined>());
380 ddc::DiscreteDomain<GridRRefined>
const interpolation_domain_r(
381 GrevillePointsR::template get_domain<GridRRefined>());
382 ddc::DiscreteDomain<GridThetaRefined>
const interpolation_domain_theta(
383 GrevillePointsTheta::template get_domain<GridThetaRefined>());
384 ddc::DiscreteDomain<GridRRefined, GridThetaRefined>
const
385 refined_domain(interpolation_domain_r, interpolation_domain_theta);
387 ddc::DiscreteVector<GridRRefined, GridThetaRefined> n_points_singular_domain(
389 refined_domain.template extent<GridThetaRefined>().value());
390 m_idx_range_singular_point = refined_domain.take_first(n_points_singular_domain);
393 RefinedSplineBuilder refined_builder(refined_domain);
395 ddc::DiscreteDomain<BSplinesRRefined, BSplinesThetaRefined>
const spline_domain
396 = refined_builder.spline_domain();
399 m_curvilinear_to_x_spline_alloc = SplineCoeffsMem(spline_domain);
400 m_curvilinear_to_y_spline_alloc = SplineCoeffsMem(spline_domain);
401 SplineCoeffs curvilinear_to_x_spline = m_curvilinear_to_x_spline_alloc.span_view();
402 SplineCoeffs curvilinear_to_y_spline = m_curvilinear_to_y_spline_alloc.span_view();
403 InterpolationFieldMem curvilinear_to_x_vals_alloc(refined_domain);
404 InterpolationFieldMem curvilinear_to_y_vals_alloc(refined_domain);
405 InterpolationField curvilinear_to_x_vals = curvilinear_to_x_vals_alloc.span_view();
406 InterpolationField curvilinear_to_y_vals = curvilinear_to_y_vals_alloc.span_view();
409 curvilinear_to_x_vals,
410 curvilinear_to_y_vals,
412 refined_builder.interpolation_domain());
414 refined_builder(curvilinear_to_x_spline, curvilinear_to_x_vals.span_cview());
415 refined_builder(curvilinear_to_y_spline, curvilinear_to_y_vals.span_cview());
446 InterpolationField curvilinear_to_x_vals,
447 InterpolationField curvilinear_to_y_vals,
448 Mapping
const& analytical_mapping,
449 IdxRangeInterpolationPoints
const& interpolation_idx_range)
451 using CurvilinearCoeff = ddc::Coordinate<
452 typename Mapping::curvilinear_tag_r,
453 typename Mapping::curvilinear_tag_theta>;
454 using CartesianCoeff = ddc::Coordinate<X, Y>;
456 ddc::parallel_for_each(
458 interpolation_idx_range,
459 KOKKOS_LAMBDA(IdxInterpolationPoints el) {
460 CurvilinearCoeff polar_coord(ddc::coordinate(el));
461 CartesianCoeff cart_coord = analytical_mapping(polar_coord);
462 curvilinear_to_x_vals(el) = ddc::select<X>(cart_coord);
463 curvilinear_to_y_vals(el) = ddc::select<Y>(cart_coord);