Skip to content

Commit

Permalink
Remove deprecated ddc features
Browse files Browse the repository at this point in the history
- remove deprecated `PdiEvent::and_with` functions calls, use `Pdi::with` instead,
- remove deprecated `continuous_element_type` type uses, use `ddc::Coordinate<continuous_dimension_type>` instead,
- fix minor linter issues.

See merge request gysela-developpers/gyselalibxx!859

--------------------------------------------
  • Loading branch information
tpadioleau committed Feb 5, 2025
1 parent 8210080 commit 8ec1919
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 65 deletions.
8 changes: 4 additions & 4 deletions simulations/geometryRTheta/diocotron/diocotron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ int main(int argc, char** argv)
// --- Save initial data --------------------------------------------------------------------------
ddc::PdiEvent("initialization")
.with("x_coords", coords_x)
.and_with("y_coords", coords_y)
.and_with("jacobian", jacobian)
.and_with("density_eq", rho_eq)
.and_with("electrical_potential_eq", phi_eq_host);
.with("y_coords", coords_y)
.with("jacobian", jacobian)
.with("density_eq", rho_eq)
.with("electrical_potential_eq", phi_eq_host);


// ================================================================================================
Expand Down
8 changes: 4 additions & 4 deletions simulations/geometryRTheta/vortex_merger/vortex_merger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ int main(int argc, char** argv)
// --- Save initial data --------------------------------------------------------------------------
ddc::PdiEvent("initialization")
.with("x_coords", coords_x)
.and_with("y_coords", coords_y)
.and_with("jacobian", jacobian)
.and_with("density_eq", rho_eq)
.and_with("electrical_potential_eq", phi_eq);
.with("y_coords", coords_y)
.with("jacobian", jacobian)
.with("density_eq", rho_eq)
.with("electrical_potential_eq", phi_eq);



Expand Down
4 changes: 2 additions & 2 deletions simulations/geometryVparMu/collisions/test_collSpVparMu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ int main(int argc, char** argv)
// Write distribution function
ddc::PdiEvent("write_fdistribu")
.with("iter", iter)
.and_with("time_saved", time_iter)
.and_with("fdistribu", allfdistribu_host);
.with("time_saved", time_iter)
.with("fdistribu", allfdistribu_host);

// Apply collision operator
collision_operator(get_field(allfdistribu), deltat);
Expand Down
10 changes: 5 additions & 5 deletions simulations/geometryXY/guiding_center/guiding_center.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ int main(int argc, char** argv)
auto electric_field_y_host = ddc::create_mirror_and_copy(ddcHelper::get<Y>(electric_field));
ddc::PdiEvent("iteration")
.with("iter", iter)
.and_with("time_saved", iter * delta_t)
.and_with("fdistribu", allfdistribu_host)
.and_with("electrostatic_potential", electrostatic_potential_host)
.and_with("electric_field_x", electric_field_x_host)
.and_with("electric_field_y", electric_field_y_host);
.with("time_saved", iter * delta_t)
.with("fdistribu", allfdistribu_host)
.with("electrostatic_potential", electrostatic_potential_host)
.with("electric_field_x", electric_field_x_host)
.with("electric_field_y", electric_field_y_host);

// // SIMULATION --------------------------------------------------------------------------------
std::chrono::time_point<std::chrono::system_clock> const start
Expand Down
22 changes: 8 additions & 14 deletions src/geometryRTheta/time_solver/bsl_predcorr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ class BslPredCorrRTheta : public ITimeSolverRTheta
host_t<DFieldRTheta> operator()(
host_t<DFieldRTheta> allfdistribu,
double const dt,
int const steps) const
int const steps) const override
{
std::chrono::time_point<std::chrono::system_clock> start_time
= std::chrono::system_clock::now();
std::chrono::time_point<std::chrono::system_clock> start_time;
std::chrono::time_point<std::chrono::system_clock> end_time;


Expand Down Expand Up @@ -142,9 +141,9 @@ class BslPredCorrRTheta : public ITimeSolverRTheta
ddc::parallel_deepcopy(electrical_potential0, electrical_potential0_host);
ddc::PdiEvent("iteration")
.with("iter", 0)
.and_with("time", 0)
.and_with("density", allfdistribu)
.and_with("electrical_potential", electrical_potential0_host);
.with("time", 0)
.with("density", allfdistribu)
.with("electrical_potential", electrical_potential0_host);


std::function<void(host_t<DVectorFieldRTheta<X, Y>>, host_t<DConstFieldRTheta>)>
Expand All @@ -153,9 +152,6 @@ class BslPredCorrRTheta : public ITimeSolverRTheta
// --- compute electrostatic potential:
host_t<Spline2DMem> allfdistribu_coef(get_spline_idx_range(m_builder));
m_builder(get_field(allfdistribu_coef), get_const_field(allfdistribu));
PoissonLikeRHSFunction const charge_density_coord(
get_const_field(allfdistribu_coef),
m_spline_evaluator);
m_poisson_solver(charge_density_coord, electrostatic_potential_coef);

// --- compute advection field:
Expand Down Expand Up @@ -185,15 +181,13 @@ class BslPredCorrRTheta : public ITimeSolverRTheta


m_builder(get_field(allfdistribu_coef), get_const_field(allfdistribu));
PoissonLikeRHSFunction const
charge_density_coord(get_const_field(allfdistribu_coef), m_spline_evaluator);
m_poisson_solver(charge_density_coord, get_field(electrical_potential));
ddc::parallel_deepcopy(electrical_potential_host, electrical_potential);
ddc::PdiEvent("iteration")
.with("iter", iter + 1)
.and_with("time", iter * dt)
.and_with("density", allfdistribu)
.and_with("electrical_potential", electrical_potential_host);
.with("time", iter * dt)
.with("density", allfdistribu)
.with("electrical_potential", electrical_potential_host);
}
end_time = std::chrono::system_clock::now();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ class BslExplicitPredCorrRTheta : public ITimeSolverRTheta

ddc::PdiEvent("iteration")
.with("iter", iter)
.and_with("time", time)
.and_with("density", allfdistribu)
.and_with("electrical_potential", electrical_potential_host);
.with("time", time)
.with("density", allfdistribu)
.with("electrical_potential", electrical_potential_host);

// STEP 2: From phi^n, we compute A^n:
advection_field_computer(electrostatic_potential_coef, advection_field);
Expand Down Expand Up @@ -291,9 +291,9 @@ class BslExplicitPredCorrRTheta : public ITimeSolverRTheta
ddc::parallel_deepcopy(electrical_potential_host, electrical_potential);
ddc::PdiEvent("last_iteration")
.with("iter", steps)
.and_with("time", steps * dt)
.and_with("density", allfdistribu)
.and_with("electrical_potential", electrical_potential_host);
.with("time", steps * dt)
.with("density", allfdistribu)
.with("electrical_potential", electrical_potential_host);


end_time = std::chrono::system_clock::now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ class BslImplicitPredCorrRTheta : public ITimeSolverRTheta

ddc::PdiEvent("iteration")
.with("iter", iter)
.and_with("time", iter * dt)
.and_with("density", allfdistribu)
.and_with("electrical_potential", electrical_potential_host);
.with("time", iter * dt)
.with("density", allfdistribu)
.with("electrical_potential", electrical_potential_host);


// STEP 2: From phi^n, we compute A^n:
Expand Down Expand Up @@ -346,9 +346,9 @@ class BslImplicitPredCorrRTheta : public ITimeSolverRTheta

ddc::PdiEvent("last_iteration")
.with("iter", steps)
.and_with("time", steps * dt)
.and_with("density", allfdistribu)
.and_with("electrical_potential", electrical_potential_host);
.with("time", steps * dt)
.with("density", allfdistribu)
.with("electrical_potential", electrical_potential_host);

end_time = std::chrono::system_clock::now();
display_time_difference("Iterations time: ", start_time, end_time);
Expand Down
12 changes: 6 additions & 6 deletions src/geometryXVx/time_integration/predcorr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ DFieldSpXVx PredCorr::operator()(
Kokkos::Profiling::pushRegion("HDF5_Output");
ddc::PdiEvent("iteration")
.with("iter", iter)
.and_with("time_saved", iter_time)
.and_with("fdistribu", allfdistribu_host)
.and_with("electrostatic_potential", electrostatic_potential_host);
.with("time_saved", iter_time)
.with("fdistribu", allfdistribu_host)
.with("electrostatic_potential", electrostatic_potential_host);
Kokkos::Profiling::popRegion();

// copy fdistribu
Expand Down Expand Up @@ -90,9 +90,9 @@ DFieldSpXVx PredCorr::operator()(
ddc::parallel_deepcopy(electrostatic_potential_host, electrostatic_potential);
ddc::PdiEvent("last_iteration")
.with("iter", iter)
.and_with("time_saved", final_time)
.and_with("fdistribu", allfdistribu_host)
.and_with("electrostatic_potential", electrostatic_potential_host);
.with("time_saved", final_time)
.with("fdistribu", allfdistribu_host)
.with("electrostatic_potential", electrostatic_potential_host);

return allfdistribu;
}
10 changes: 5 additions & 5 deletions src/geometryXY/time_integration/predcorr_RK2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ class PredCorrRK2XY
= ddc::create_mirror_and_copy(ddcHelper::get<Y>(electric_field));
ddc::PdiEvent("iteration")
.with("iter", iter)
.and_with("time_saved", iter * dt)
.and_with("fdistribu", allfdistribu_host)
.and_with("electrostatic_potential", electrostatic_potential_host)
.and_with("electric_field_x", electric_field_x_host)
.and_with("electric_field_y", electric_field_y_host);
.with("time_saved", iter * dt)
.with("fdistribu", allfdistribu_host)
.with("electrostatic_potential", electrostatic_potential_host)
.with("electric_field_x", electric_field_x_host)
.with("electric_field_y", electric_field_y_host);
}
};
};
12 changes: 6 additions & 6 deletions src/geometryXYVxVy/time_integration/predcorr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ DFieldSpXYVxVy PredCorr::operator()(
ddc::parallel_deepcopy(electrostatic_potential_host, electrostatic_potential);
ddc::PdiEvent("iteration")
.with("iter", iter)
.and_with("time_saved", iter_time)
.and_with("fdistribu", allfdistribu_host)
.and_with("electrostatic_potential", electrostatic_potential_host);
.with("time_saved", iter_time)
.with("fdistribu", allfdistribu_host)
.with("electrostatic_potential", electrostatic_potential_host);

// copy fdistribu
ddc::parallel_deepcopy(allfdistribu_half_t, allfdistribu);
Expand Down Expand Up @@ -99,9 +99,9 @@ DFieldSpXYVxVy PredCorr::operator()(
ddc::parallel_deepcopy(electrostatic_potential_host, electrostatic_potential);
ddc::PdiEvent("last_iteration")
.with("iter", iter)
.and_with("time_saved", final_time)
.and_with("fdistribu", allfdistribu_host)
.and_with("electrostatic_potential", electrostatic_potential_host);
.with("time_saved", final_time)
.with("fdistribu", allfdistribu_host)
.with("electrostatic_potential", electrostatic_potential_host);

return allfdistribu;
}
12 changes: 7 additions & 5 deletions src/utils/ddc_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ total_interval_length(IdxRange<IDim> const& idx_range)
template <class IDim>
constexpr std::enable_if_t<
IDim::continuous_dimension_type::PERIODIC,
typename IDim::continuous_element_type>
restrict_to_idx_range(typename IDim::continuous_element_type coord, IdxRange<IDim> const& idx_range)
Coord<typename IDim::continuous_dimension_type>>
restrict_to_idx_range(
Coord<typename IDim::continuous_dimension_type> coord,
IdxRange<IDim> const& idx_range)
{
using Coord = typename IDim::continuous_element_type;
using Coord1D = Coord<typename IDim::continuous_dimension_type>;
double const x_min = ddc::rmin(idx_range);
double const length = total_interval_length(idx_range);
double const x_max = x_min + length;
Expand All @@ -98,8 +100,8 @@ restrict_to_idx_range(typename IDim::continuous_element_type coord, IdxRange<IDi
double periodic_factor = 2 * M_PI / length;
double coord_2pi = double(coord) * periodic_factor;
coord_2pi = std::copysign(std::acos(std::cos(coord_2pi)), std::sin(coord_2pi));
coord = coord_2pi < 0 ? Coord((coord_2pi + 2 * M_PI) / periodic_factor)
: Coord((coord_2pi) / periodic_factor);
coord = coord_2pi < 0 ? Coord1D((coord_2pi + 2 * M_PI) / periodic_factor)
: Coord1D((coord_2pi) / periodic_factor);
}
coord += x_min;
while (coord < x_min)
Expand Down
2 changes: 1 addition & 1 deletion tests/math_tools/test_lnorm_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using DFieldXY = DField<IdxRangeXY>;
using DVectorFieldXY = VectorField<double, IdxRangeXY, NDTag<X, Y>>;

template <class Grid1D>
KOKKOS_FUNCTION typename Grid1D::continuous_element_type get_coordinate(Idx<Grid1D> x)
KOKKOS_FUNCTION Coord<typename Grid1D::continuous_dimension_type> get_coordinate(Idx<Grid1D> x)
{
using Dim = typename Grid1D::continuous_dimension_type;
CoordXY const origin(0.0, 0.0);
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ using DFieldZXY = host_t<DField<IdxRangeZXY>>;
using DFieldZYX = host_t<DField<IdxRangeZYX>>;

template <class Grid1D>
KOKKOS_FUNCTION typename Grid1D::continuous_element_type get_coordinate(Idx<Grid1D> x)
KOKKOS_FUNCTION Coord<typename Grid1D::continuous_dimension_type> get_coordinate(Idx<Grid1D> x)
{
using Dim = typename Grid1D::continuous_dimension_type;
CoordXYZ const origin(-1.0, 10.0, 100.0);
Expand Down

0 comments on commit 8ec1919

Please sign in to comment.