Skip to content

Commit

Permalink
Rename PoissonSolver -> QNSolver in X-Y-Vx-Vy Geometry
Browse files Browse the repository at this point in the history
Part 2 of #226 fixes X-Y-Vx-Vy Geometry. Closes #226

See merge request gysela-developpers/gyselalibxx!479

--------------------------------------------
  • Loading branch information
EmilyBourne committed May 27, 2024
1 parent 2ebaf3c commit 3062dc8
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 67 deletions.
4 changes: 2 additions & 2 deletions simulations/geometryXYVxVy/landau/landau4d_fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "bsl_advection_vx.hpp"
#include "bsl_advection_x.hpp"
#include "fftpoissonsolver.hpp"
#include "fftqnsolver.hpp"
#include "geometry.hpp"
#include "maxwellianequilibrium.hpp"
#include "neumann_spline_quadrature.hpp"
Expand Down Expand Up @@ -222,7 +222,7 @@ int main(int argc, char** argv)
Kokkos::DefaultExecutionSpace(),
quadrature_coeffs_host.span_view());
ChargeDensityCalculator const rhs(quadrature_coeffs);
FftPoissonSolver const poisson(rhs);
FftQNSolver const poisson(rhs);

// Create predcorr operator
PredCorr const predcorr(vlasov, poisson);
Expand Down
2 changes: 1 addition & 1 deletion src/geometryXYVxVy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The `geoemtryXYVxVy` folder contains all the code describing methods which are s

- [geometry](./geometry/README.md) --> - All the dimension tags used for a simulation in the geoemtry.
<!-- - [initialization](./initialization/README.md) - -->
- [poisson](./poisson/README.md) - Code describing the polar Poisson solver.
- [poisson](./poisson/README.md) - Code describing the Quasi-Neutrality solver.
<!-- - [time\_integration](./time_integration/README.md) - -->
<!-- - [vlasov](./vlasov/README.md) - -->

Expand Down
4 changes: 2 additions & 2 deletions src/geometryXYVxVy/poisson/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

add_library("poisson_xy" STATIC
chargedensitycalculator.cpp
nullpoissonsolver.cpp
fftpoissonsolver.cpp
nullqnsolver.cpp
fftqnsolver.cpp
)

target_compile_features("poisson_xy"
Expand Down
12 changes: 6 additions & 6 deletions src/geometryXYVxVy/poisson/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Poisson Solver
# Quasi-Neutrality Solver

The Poisson solver is designed to solve the following Poisson equation:
The Quasi-Neutrality solver is designed to solve the following Quasi-Neutrality equation:

$$ -\Delta \phi(x) = \sum_s \int q_s f_s(x,y,v_x,v_y) dv_x dv_y $$

Expand All @@ -18,13 +18,13 @@ is solved.

The charge density is calculated by integrating the distribution function.

## Poisson Solver
## Quasi-Neutrality Solver

The Poisson equation can be solved with a variety of different methods. Here we have implemented:
The Quasi-Neutrality equation can be solved with a variety of different methods. Here we have implemented:

- FftPoissonSolver
- FftQNSolver

These classes return the electric potential $\phi$ and the electric field $\frac{d \phi}{dx}$.

The FftPoissonSolver does not calculate the electric field using the Fourier modes. Rather it uses a spline interpolation to approximate this value. This interpolation is calculated by the operator ElectricField.
The FftQNSolver does not calculate the electric field using the Fourier modes. Rather it uses a spline interpolation to approximate this value. This interpolation is calculated by the operator ElectricField.

Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,25 @@

#include <geometry.hpp>

#include "fftpoissonsolver.hpp"
#include "fftqnsolver.hpp"

FftPoissonSolver::FftPoissonSolver(IChargeDensityCalculator const& compute_rho)
: m_compute_rho(compute_rho)
FftQNSolver::FftQNSolver(IChargeDensityCalculator const& compute_rho) : m_compute_rho(compute_rho)
{
}

// 1- Inner solvers shall be passed in the constructor
// 2- Should it take an array of distribution functions ?
void FftPoissonSolver::operator()(
void FftQNSolver::operator()(
DSpanXY const electrostatic_potential,
DSpanXY const electric_field_x,
DSpanXY const electric_field_y,
DViewSpXYVxVy const allfdistribu) const
{
Kokkos::Profiling::pushRegion("PoissonSolver");
Kokkos::Profiling::pushRegion("QNSolver");
assert((electrostatic_potential.domain() == ddc::get_domain<IDimX, IDimY>(allfdistribu)));
IDomainXY const xy_dom = electrostatic_potential.domain();

// Compute the RHS of the Poisson equation.
// Compute the RHS of the Quasi-Neutrality equation.
DFieldXY rho(xy_dom);
DFieldVxVy contiguous_slice_vxvy(allfdistribu.domain<IDimVx, IDimVy>());
m_compute_rho(rho, allfdistribu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@
#pragma once

#include "chargedensitycalculator.hpp"
#include "ipoissonsolver.hpp"
#include "iqnsolver.hpp"

/**
* @brief An operator which solves the Poisson equation using a fast
* @brief An operator which solves the Quasi-Neutrality equation using a fast
* Fourier transform.
*
* An operator which solves the Poisson equation:
* An operator which solves the Quasi-Neutrality equation:
* @f$ - \frac{d^2 \phi}{dx^2} = \rho @f$
* using a fast Fourier transform on a periodic domain.
* This operator only works for equidistant points.
*
* The electric field, @f$ \frac{d \phi}{dx} @f$ is calculated using
* a spline interpolation implemented in ElectricField.
*/
class FftPoissonSolver : public IPoissonSolver
class FftQNSolver : public IQNSolver
{
IChargeDensityCalculator const& m_compute_rho;

public:
/**
* Construct the FftPoissonSolver operator.
* Construct the FftQNSolver operator.
*
* @param compute_rho The operator which calculates the charge density, the right hand side of the equation.
*/
FftPoissonSolver(IChargeDensityCalculator const& compute_rho);
FftQNSolver(IChargeDensityCalculator const& compute_rho);

~FftPoissonSolver() override = default;
~FftQNSolver() override = default;

/**
* The operator which solves the equation using the method described by the class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
#include <geometry.hpp>

/**
* @brief An operator which solves the Poisson equation using a fast
* @brief An operator which solves the Quasi-Neutrality equation using a fast
* Fourier transform.
*
* An operator which solves the Poisson equation:
* An operator which solves the Quasi-Neutrality equation:
* @f$ - \frac{d^2 \phi}{dx^2} = \rho @f$
* using a fast Fourier transform on a periodic domain.
* This operator only works for equidistant points.
*/
class IPoissonSolver
class IQNSolver
{
public:
virtual ~IPoissonSolver() = default;
virtual ~IQNSolver() = default;

/**
* The operator which solves the equation using the method described by the class.
Expand Down
8 changes: 0 additions & 8 deletions src/geometryXYVxVy/poisson/nullpoissonsolver.cpp

This file was deleted.

21 changes: 0 additions & 21 deletions src/geometryXYVxVy/poisson/nullpoissonsolver.hpp

This file was deleted.

8 changes: 8 additions & 0 deletions src/geometryXYVxVy/poisson/nullqnsolver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT

#include "nullqnsolver.hpp"

void NullQNSolver::operator()(DSpanXY const, DSpanXY const, DSpanXY const, DViewSpXYVxVy const)
const
{
}
32 changes: 32 additions & 0 deletions src/geometryXYVxVy/poisson/nullqnsolver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT

#pragma once

#include <geometry.hpp>

#include "iqnsolver.hpp"

/**
* @brief A Quasi-Neutrality solver which does nothing.
* This can potentially be useful when debugging.
*/
class NullQNSolver : public IQNSolver
{
public:
NullQNSolver() = default;

~NullQNSolver() override = default;

/** @brief A QN Solver which does nothing
*
* @param[out] electrostatic_potential The electrostatic potential, the result of the poisson solver.
* @param[out] electric_field_x The x-component of the electric field, the gradient of the electrostatic potential.
* @param[out] electric_field_y The y-component of the electric field, the gradient of the electrostatic potential.
* @param[in] allfdistribu The distribution function.
*/
void operator()(
DSpanXY electrostatic_potential,
DSpanXY electric_field_x,
DSpanXY electric_field_y,
DViewSpXYVxVy allfdistribu) const override;
};
4 changes: 2 additions & 2 deletions src/geometryXYVxVy/time_integration/predcorr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#include <ddc/ddc.hpp>

#include <ipoissonsolver.hpp>
#include <iqnsolver.hpp>
#include <ivlasovsolver.hpp>

#include "predcorr.hpp"

PredCorr::PredCorr(IVlasovSolver const& vlasov_solver, IPoissonSolver const& poisson_solver)
PredCorr::PredCorr(IVlasovSolver const& vlasov_solver, IQNSolver const& poisson_solver)
: m_vlasov_solver(vlasov_solver)
, m_poisson_solver(poisson_solver)
{
Expand Down
30 changes: 27 additions & 3 deletions src/geometryXYVxVy/time_integration/predcorr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,44 @@

#include "itimesolver.hpp"

class IPoissonSolver;
class IQNSolver;
class IVlasovSolver;

/**
* @brief A class that solves a Vlasov-Poisson system of equations using a predictor-corrector scheme.
*
* A class that solves a Vlasov-Poisson system with
* a predictor corrector scheme. This scheme consists in
* estimating the electric potential after a time interval
* of a half-timestep. This potential is then used to compute
* the value of the distribution function at time t+dt, where
* dt is the timestep.
*/
class PredCorr : public ITimeSolver
{
private:
IVlasovSolver const& m_vlasov_solver;

IPoissonSolver const& m_poisson_solver;
IQNSolver const& m_poisson_solver;

public:
PredCorr(IVlasovSolver const& vlasov_solver, IPoissonSolver const& poisson_solver);
/**
* @brief Creates an instance of the predictor-corrector class.
* @param[in] vlasov_solver A solver for a Boltzmann equation.
* @param[in] poisson_solver A solver for a Poisson equation.
*/
PredCorr(IVlasovSolver const& vlasov_solver, IQNSolver const& poisson_solver);

~PredCorr() override = default;

/**
* @brief Solves the Vlasov-Poisson system.
* @param[in, out] allfdistribu On input : the initial value of the distribution function.
* On output : the value of the distribution function after solving
* the Vlasov-Poisson system a given number of iterations.
* @param[in] dt The timestep.
* @param[in] steps The number of iterations to be performed by the predictor-corrector.
* @return The distribution function after solving the system.
*/
DSpanSpXYVxVy operator()(DSpanSpXYVxVy allfdistribu, double dt, int steps = 1) const override;
};
10 changes: 5 additions & 5 deletions tests/geometryXYVxVy/fft_poisson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
#include <gtest/gtest.h>

#include "chargedensitycalculator.hpp"
#include "fftpoissonsolver.hpp"
#include "fftqnsolver.hpp"
#include "geometry.hpp"
#include "neumann_spline_quadrature.hpp"
#include "quadrature.hpp"
#include "species_info.hpp"

namespace {

static void TestFftPoissonSolverCosineSource()
static void TestFftQNSolverCosineSource()
{
CoordX const x_min(0.0);
CoordX const x_max(2.0 * M_PI);
Expand Down Expand Up @@ -82,7 +82,7 @@ static void TestFftPoissonSolverCosineSource()
Kokkos::DefaultExecutionSpace(),
quadrature_coeffs_host.span_view());
ChargeDensityCalculator rhs(quadrature_coeffs);
FftPoissonSolver poisson(rhs);
FftQNSolver poisson(rhs);

DFieldXY electrostatic_potential_alloc(gridxy);
DFieldXY electric_field_x_alloc(gridxy);
Expand Down Expand Up @@ -149,7 +149,7 @@ static void TestFftPoissonSolverCosineSource()

} // namespace

TEST(FftPoissonSolver, CosineSource)
TEST(FftQNSolver, CosineSource)
{
TestFftPoissonSolverCosineSource();
TestFftQNSolverCosineSource();
}

0 comments on commit 3062dc8

Please sign in to comment.