Skip to content

Commit

Permalink
Merge branch 'gdgirard_405-extract-geometrytokamaxi' into 'main'
Browse files Browse the repository at this point in the history
Extract geometryTokamAxi

Closes #405

See merge request gysela-developpers/gyselalibxx!772

--------------------------------------------
  • Loading branch information
gdgirard committed Nov 15, 2024
1 parent e15728c commit 2f9ba28
Show file tree
Hide file tree
Showing 11 changed files with 535 additions and 455 deletions.
14 changes: 11 additions & 3 deletions simulations/geometryRTheta/diocotron/diocotron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@


namespace {
using PoissonSolver = PolarSplineFEMPoissonLikeSolver;
using PoissonSolver = PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound>;
using DiscreteMappingBuilder
= DiscreteToCartesianBuilder<X, Y, SplineRThetaBuilder, SplineRThetaEvaluatorConstBound>;
using Mapping = CircularToCartesian<X, Y, R, Theta>;
Expand Down Expand Up @@ -181,7 +185,11 @@ int main(int argc, char** argv)
builder(get_field(coeff_alpha_spline), get_const_field(coeff_alpha));
builder(get_field(coeff_beta_spline), get_const_field(coeff_beta));

PoissonSolver poisson_solver(coeff_alpha_spline, coeff_beta_spline, discrete_mapping);
PoissonSolver poisson_solver(
coeff_alpha_spline,
coeff_beta_spline,
discrete_mapping,
spline_evaluator);

// --- Predictor corrector operator ---------------------------------------------------------------
#if defined(PREDCORR)
Expand Down Expand Up @@ -280,7 +288,7 @@ int main(int argc, char** argv)
host_t<Spline2DMem> rho_coef_eq(idx_range_bsplinesRTheta);
builder(get_field(rho_coef_eq), get_const_field(rho_eq));
PoissonLikeRHSFunction poisson_rhs_eq(rho_coef_eq, spline_evaluator);
poisson_solver(poisson_rhs_eq, get_const_field(coords), get_field(phi_eq));
poisson_solver(poisson_rhs_eq, get_field(phi_eq));


// --- Save initial data --------------------------------------------------------------------------
Expand Down
17 changes: 11 additions & 6 deletions simulations/geometryRTheta/vortex_merger/vortex_merger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@


namespace {
using PoissonSolver = PolarSplineFEMPoissonLikeSolver;
using PoissonSolver = PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound>;
using DiscreteMappingBuilder
= DiscreteToCartesianBuilder<X, Y, SplineRThetaBuilder, SplineRThetaEvaluatorConstBound>;
using CircularMapping = CircularToCartesian<X, Y, R, Theta>;
Expand Down Expand Up @@ -89,9 +93,6 @@ int main(int argc, char** argv)
SplineInterpPointsTheta>(conf_gyselalibxx, "p");
IdxRangeRTheta const grid(mesh_r, mesh_p);

host_t<FieldMemRTheta<CoordRTheta>> coords(grid);
ddc::for_each(grid, [&](IdxRTheta const irp) { coords(irp) = ddc::coordinate(irp); });


// OPERATORS ======================================================================================
SplineRThetaBuilder const builder(grid);
Expand Down Expand Up @@ -162,7 +163,11 @@ int main(int argc, char** argv)
builder(get_field(coeff_alpha_spline), get_const_field(coeff_alpha));
builder(get_field(coeff_beta_spline), get_const_field(coeff_beta));

PoissonSolver poisson_solver(coeff_alpha_spline, coeff_beta_spline, discrete_mapping);
PoissonSolver poisson_solver(
coeff_alpha_spline,
coeff_beta_spline,
discrete_mapping,
spline_evaluator);

// --- Predictor corrector operator ---------------------------------------------------------------
BslImplicitPredCorrRTheta predcorr_operator(
Expand Down Expand Up @@ -245,7 +250,7 @@ int main(int argc, char** argv)
host_t<Spline2DMem> rho_coef_eq(idx_range_bsplinesRTheta);
builder(get_field(rho_coef_eq), get_const_field(rho_eq));
PoissonLikeRHSFunction poisson_rhs_eq(get_field(rho_coef_eq), spline_evaluator);
poisson_solver(poisson_rhs_eq, get_const_field(coords), get_field(phi_eq));
poisson_solver(poisson_rhs_eq, get_field(phi_eq));


// --- Save initial data --------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/geometryRTheta/advection_field/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ target_link_libraries("advection_field_RTheta" INTERFACE
gslx::speciesinfo
gslx::utils
gslx::poisson_RTheta
gslx::pde_solvers
)
add_library("gslx::advection_field_RTheta" ALIAS "advection_field_RTheta")
17 changes: 11 additions & 6 deletions src/geometryRTheta/initialization/vortex_merger_equilibrium.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class VortexMergerEquilibria
IdxRangeRTheta const& m_grid;
SplineRThetaBuilder const& m_builder;
SplineRThetaEvaluatorNullBound const& m_evaluator;
PolarSplineFEMPoissonLikeSolver const& m_poisson_solver;
PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound> const& m_poisson_solver;

public:
/**
Expand All @@ -52,7 +56,11 @@ class VortexMergerEquilibria
IdxRangeRTheta const& grid,
SplineRThetaBuilder const& builder,
SplineRThetaEvaluatorNullBound const& evaluator,
PolarSplineFEMPoissonLikeSolver const& poisson_solver)
PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound> const& poisson_solver)
: m_mapping(mapping)
, m_grid(grid)
, m_builder(builder)
Expand Down Expand Up @@ -111,9 +119,6 @@ class VortexMergerEquilibria
IdxRangeBSRTheta idx_range_bsplinesRTheta = get_spline_idx_range(m_builder);
host_t<Spline2DMem> rho_coef(idx_range_bsplinesRTheta);

host_t<FieldMemRTheta<CoordRTheta>> coords(m_grid);
ddc::for_each(m_grid, [&](IdxRTheta const irp) { coords(irp) = ddc::coordinate(irp); });

double difference_sigma(0.);
int count = 0;

Expand All @@ -128,7 +133,7 @@ class VortexMergerEquilibria
// STEP 2: compute phi_star^i with PDE solver
m_builder(get_field(rho_coef), get_const_field(rho_eq));
PoissonLikeRHSFunction poisson_rhs(rho_coef, m_evaluator);
m_poisson_solver(poisson_rhs, get_const_field(coords), get_field(phi_star));
m_poisson_solver(poisson_rhs, get_field(phi_star));

// STEP 3: compute c^i
// If phi_max is given:
Expand Down
18 changes: 12 additions & 6 deletions src/geometryRTheta/time_solver/bsl_predcorr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ class BslPredCorrRTheta : public ITimeSolverRTheta

BslAdvectionRTheta<FootFinder, Mapping> const& m_advection_solver;

PolarSplineFEMPoissonLikeSolver const& m_poisson_solver;
PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound> const& m_poisson_solver;

SplineRThetaBuilder const& m_builder;
SplineRThetaEvaluatorNullBound const& m_spline_evaluator;
Expand Down Expand Up @@ -90,7 +94,11 @@ class BslPredCorrRTheta : public ITimeSolverRTheta
BslAdvectionRTheta<FootFinder, Mapping> const& advection_solver,
SplineRThetaBuilder const& builder,
SplineRThetaEvaluatorNullBound const& rhs_evaluator,
PolarSplineFEMPoissonLikeSolver const& poisson_solver)
PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound> const& poisson_solver)
: m_mapping(mapping)
, m_advection_solver(advection_solver)
, m_poisson_solver(poisson_solver)
Expand All @@ -115,8 +123,6 @@ class BslPredCorrRTheta : public ITimeSolverRTheta

// Grid. ------------------------------------------------------------------------------------------
IdxRangeRTheta grid(get_idx_range<GridR, GridTheta>(allfdistribu));
host_t<FieldMemRTheta<CoordRTheta>> coords(grid);
ddc::for_each(grid, [&](IdxRTheta const irp) { coords(irp) = ddc::coordinate(irp); });
AdvectionFieldFinder advection_field_computer(m_mapping);

IdxRangeBSR radial_bsplines(ddc::discrete_space<BSplinesR>().full_domain().remove_first(
Expand All @@ -137,7 +143,7 @@ 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, coords, electrical_potential0);
m_poisson_solver(charge_density_coord, electrical_potential0);

ddc::PdiEvent("iteration")
.with("iter", 0)
Expand Down Expand Up @@ -186,7 +192,7 @@ 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, coords, electrical_potential);
m_poisson_solver(charge_density_coord, electrical_potential);

ddc::PdiEvent("iteration")
.with("iter", iter + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ class BslExplicitPredCorrRTheta : public ITimeSolverRTheta
EulerMethod const m_euler;
SplineFootFinder<EulerMethod, AdvectionDomain> const m_find_feet;

PolarSplineFEMPoissonLikeSolver const& m_poisson_solver;
PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound> const& m_poisson_solver;

SplineRThetaBuilder const& m_builder;
SplineRThetaEvaluatorConstBound const& m_evaluator;
Expand Down Expand Up @@ -119,7 +123,11 @@ class BslExplicitPredCorrRTheta : public ITimeSolverRTheta
IdxRangeRTheta const& grid,
SplineRThetaBuilder const& builder,
SplineRThetaEvaluatorNullBound const& rhs_evaluator,
PolarSplineFEMPoissonLikeSolver const& poisson_solver,
PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound> const& poisson_solver,
SplineRThetaEvaluatorConstBound const& advection_evaluator)
: m_mapping(mapping)
, m_advection_solver(advection_solver)
Expand Down Expand Up @@ -274,7 +282,7 @@ class BslExplicitPredCorrRTheta : public ITimeSolverRTheta
m_builder(get_field(allfdistribu_coef), get_const_field(allfdistribu));
PoissonLikeRHSFunction const
charge_density_coord(get_const_field(allfdistribu_coef), m_evaluator);
m_poisson_solver(charge_density_coord, coords, electrical_potential);
m_poisson_solver(charge_density_coord, electrical_potential);

ddc::PdiEvent("last_iteration")
.with("iter", steps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ class BslImplicitPredCorrRTheta : public ITimeSolverRTheta
EulerMethod const m_euler;
SplineFootFinder<EulerMethod, AdvectionDomain> const m_foot_finder;

PolarSplineFEMPoissonLikeSolver const& m_poisson_solver;
PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound> const& m_poisson_solver;

SplineRThetaBuilder const& m_builder;
SplineRThetaEvaluatorConstBound const& m_evaluator;
Expand Down Expand Up @@ -118,7 +122,11 @@ class BslImplicitPredCorrRTheta : public ITimeSolverRTheta
IdxRangeRTheta const& grid,
SplineRThetaBuilder const& builder,
SplineRThetaEvaluatorNullBound const& rhs_evaluator,
PolarSplineFEMPoissonLikeSolver const& poisson_solver,
PolarSplineFEMPoissonLikeSolver<
GridR,
GridTheta,
PolarBSplinesRTheta,
SplineRThetaEvaluatorNullBound> const& poisson_solver,
SplineRThetaEvaluatorConstBound const& advection_evaluator)
: m_mapping(mapping)
, m_advection_solver(advection_solver)
Expand Down Expand Up @@ -329,7 +337,7 @@ class BslImplicitPredCorrRTheta : public ITimeSolverRTheta
m_builder(get_field(allfdistribu_coef), get_const_field(allfdistribu));
PoissonLikeRHSFunction const
charge_density_coord(get_const_field(allfdistribu_coef), m_evaluator);
m_poisson_solver(charge_density_coord, coords, electrical_potential);
m_poisson_solver(charge_density_coord, electrical_potential);

ddc::PdiEvent("last_iteration")
.with("iter", steps)
Expand Down
Loading

0 comments on commit 2f9ba28

Please sign in to comment.