Skip to content

Commit

Permalink
changed to PoissonSolvers and MaxwellSolvers directories, and FFTPois…
Browse files Browse the repository at this point in the history
…sonSolver --> FFTOpenPoissonSolver
  • Loading branch information
s-mayani committed Sep 29, 2023
1 parent d6bfb26 commit 9cf7888
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 67 deletions.
10 changes: 5 additions & 5 deletions alpine/ChargedParticles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "Utility/TypeUtils.h"

#include "Solver/FFTPeriodicPoissonSolver.h"
#include "Solver/FFTPoissonSolver.h"
#include "Solver/P3MSolver.h"
#include "Solver/PoissonCG.h"
#include "PoissonSolvers/FFTOpenPoissonSolver.h"
#include "PoissonSolvers/FFTPeriodicPoissonSolver.h"
#include "PoissonSolvers/P3MSolver.h"
#include "PoissonSolvers/PoissonCG.h"

unsigned LoggingPeriod = 1;

Expand Down Expand Up @@ -67,7 +67,7 @@ using P3MSolver_t = ConditionalType<Dim == 3, ippl::P3MSolver<VField_t<T, Dim>,

template <typename T = double, unsigned Dim = 3>
using OpenSolver_t =
ConditionalType<Dim == 3, ippl::FFTPoissonSolver<VField_t<T, Dim>, Field_t<Dim>>>;
ConditionalType<Dim == 3, ippl::FFTOpenPoissonSolver<VField_t<T, Dim>, Field_t<Dim>>>;

template <typename T = double, unsigned Dim = 3>
using Solver_t = VariantFromConditionalTypes<CGSolver_t<T, Dim>, FFTSolver_t<T, Dim>,
Expand Down
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ add_subdirectory (Types)
add_subdirectory (Partition)

if (ENABLE_SOLVERS)
message (STATUS "Adding Solver subdirectory")
add_subdirectory (Solver)
message (STATUS "Adding Solver subdirectories")
add_subdirectory (PoissonSolvers)
add_subdirectory (MaxwellSolvers)
add_subdirectory (LinearSolvers)
endif ()

if (ENABLE_AMR)
Expand Down
2 changes: 1 addition & 1 deletion src/Communicate/Tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace ippl {
#define IPPL_PARTICLE_SEND 9000
#define IPPL_PARTICLE_RECV 10000

// FFT Poisson Solver
// FFT Open Poisson Solver
#define IPPL_SOLVER_SEND 13000
#define IPPL_SOLVER_RECV 14000
#define IPPL_VICO_SEND 16000
Expand Down
15 changes: 15 additions & 0 deletions src/MaxwellSolvers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set (_SRCS
)

set (_HDRS
Maxwell.h
)

include_DIRECTORIES (
${CMAKE_CURRENT_SOURCE_DIR}
)

add_ippl_sources (${_SRCS})
add_ippl_headers (${_HDRS})

install (FILES ${_HDRS} DESTINATION include/MaxwellSolvers)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ set (_HDRS

if (ENABLE_FFT)
list (APPEND _HDRS
FFTPoissonSolver.h
FFTPoissonSolver.hpp
FFTOpenPoissonSolver.h
FFTOpenPoissonSolver.hpp
FFTPeriodicPoissonSolver.h
FFTPeriodicPoissonSolver.hpp
P3MSolver.h
Expand All @@ -24,4 +24,4 @@ include_DIRECTORIES (
add_ippl_sources (${_SRCS})
add_ippl_headers (${_HDRS})

install (FILES ${_HDRS} DESTINATION include/Solver)
install (FILES ${_HDRS} DESTINATION include/PoissonSolvers)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
// Class FFTPoissonSolver
// Class FFTOpenPoissonSolver
// FFT-based Poisson Solver for open boundaries.
// Solves laplace(phi) = -rho, and E = -grad(phi).
//
//

#ifndef FFT_POISSON_SOLVER_H_
#define FFT_POISSON_SOLVER_H_
#ifndef IPPL_FFT_OPEN_POISSON_SOLVER_H_
#define IPPL_FFT_OPEN_POISSON_SOLVER_H_

#include <Kokkos_MathematicalConstants.hpp>
#include <Kokkos_MathematicalFunctions.hpp>
Expand Down Expand Up @@ -70,7 +70,7 @@ namespace ippl {
} // namespace detail

template <typename FieldLHS, typename FieldRHS>
class FFTPoissonSolver : public Poisson<FieldLHS, FieldRHS> {
class FFTOpenPoissonSolver : public Poisson<FieldLHS, FieldRHS> {
constexpr static unsigned Dim = FieldLHS::dim;
using Trhs = typename FieldRHS::value_type;
using mesh_type = typename FieldLHS::Mesh_t;
Expand Down Expand Up @@ -119,10 +119,10 @@ namespace ippl {
using scalar_type = typename mesh_type::value_type;

// constructor and destructor
FFTPoissonSolver();
FFTPoissonSolver(rhs_type& rhs, ParameterList& params);
FFTPoissonSolver(lhs_type& lhs, rhs_type& rhs, ParameterList& params);
~FFTPoissonSolver() = default;
FFTOpenPoissonSolver();
FFTOpenPoissonSolver(rhs_type& rhs, ParameterList& params);
FFTOpenPoissonSolver(lhs_type& lhs, rhs_type& rhs, ParameterList& params);
~FFTOpenPoissonSolver() = default;

// override the setRhs function of the Solver class
// since we need to call initializeFields()
Expand All @@ -141,7 +141,7 @@ namespace ippl {
bool hessian = this->params_m.template get<bool>("hessian");
if (!hessian) {
throw IpplException(
"FFTPoissonSolver::getHessian()",
"FFTOpenPoissonSolver::getHessian()",
"Cannot call getHessian() if 'hessian' flag in ParameterList is false");
}
return &hess_m;
Expand Down Expand Up @@ -251,7 +251,7 @@ namespace ippl {
this->params_m.add("comm", p2p_pl);
break;
default:
throw IpplException("FFTPoissonSolver::setDefaultParameters",
throw IpplException("FFTOpenPoissonSolver::setDefaultParameters",
"Unrecognized heffte communication type");
}

Expand All @@ -261,5 +261,5 @@ namespace ippl {
};
} // namespace ippl

#include "Solver/FFTPoissonSolver.hpp"
#include "PoissonSolvers/FFTOpenPoissonSolver.hpp"
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Class FFTPoissonSolver
// Class FFTOpenPoissonSolver
// FFT-based Poisson Solver for open boundaries.
// Solves laplace(phi) = -rho, and E = -grad(phi).
//
Expand Down Expand Up @@ -111,7 +111,7 @@ namespace ippl {
/////////////////////////////////////////////////////////////////////////
// constructor and destructor
template <typename FieldLHS, typename FieldRHS>
FFTPoissonSolver<FieldLHS, FieldRHS>::FFTPoissonSolver()
FFTOpenPoissonSolver<FieldLHS, FieldRHS>::FFTOpenPoissonSolver()
: Base()
, mesh_mp(nullptr)
, layout_mp(nullptr)
Expand All @@ -126,7 +126,8 @@ namespace ippl {
}

template <typename FieldLHS, typename FieldRHS>
FFTPoissonSolver<FieldLHS, FieldRHS>::FFTPoissonSolver(rhs_type& rhs, ParameterList& params)
FFTOpenPoissonSolver<FieldLHS, FieldRHS>::FFTOpenPoissonSolver(rhs_type& rhs,
ParameterList& params)
: mesh_mp(nullptr)
, layout_mp(nullptr)
, mesh2_m(nullptr)
Expand All @@ -147,8 +148,8 @@ namespace ippl {
}

template <typename FieldLHS, typename FieldRHS>
FFTPoissonSolver<FieldLHS, FieldRHS>::FFTPoissonSolver(lhs_type& lhs, rhs_type& rhs,
ParameterList& params)
FFTOpenPoissonSolver<FieldLHS, FieldRHS>::FFTOpenPoissonSolver(lhs_type& lhs, rhs_type& rhs,
ParameterList& params)
: mesh_mp(nullptr)
, layout_mp(nullptr)
, mesh2_m(nullptr)
Expand All @@ -171,7 +172,7 @@ namespace ippl {
/////////////////////////////////////////////////////////////////////////
// override setRhs to call class-specific initialization
template <typename FieldLHS, typename FieldRHS>
void FFTPoissonSolver<FieldLHS, FieldRHS>::setRhs(rhs_type& rhs) {
void FFTOpenPoissonSolver<FieldLHS, FieldRHS>::setRhs(rhs_type& rhs) {
Base::setRhs(rhs);

// start a timer
Expand All @@ -188,13 +189,13 @@ namespace ippl {
// calculation of Efield (which uses FFTs)

template <typename FieldLHS, typename FieldRHS>
void FFTPoissonSolver<FieldLHS, FieldRHS>::setGradFD() {
void FFTOpenPoissonSolver<FieldLHS, FieldRHS>::setGradFD() {
// get the output type (sol, grad, or sol & grad)
const int out = this->params_m.template get<int>("output_type");

if (out != Base::SOL_AND_GRAD) {
throw IpplException(
"FFTPoissonSolver::setGradFD()",
"FFTOpenPoissonSolver::setGradFD()",
"Cannot use gradient for Efield computation unless output type is SOL_AND_GRAD");
} else {
isGradFD_m = true;
Expand All @@ -205,7 +206,7 @@ namespace ippl {
// initializeFields method, called in constructor

template <typename FieldLHS, typename FieldRHS>
void FFTPoissonSolver<FieldLHS, FieldRHS>::initializeFields() {
void FFTOpenPoissonSolver<FieldLHS, FieldRHS>::initializeFields() {
// get algorithm and hessian flag from parameter list
const int alg = this->params_m.template get<int>("algorithm");
const bool hessian = this->params_m.template get<bool>("hessian");
Expand All @@ -214,7 +215,7 @@ namespace ippl {
if ((alg != Algorithm::VICO) && (alg != Algorithm::HOCKNEY)
&& (alg != Algorithm::BIHARMONIC)) {
throw IpplException(
"FFTPoissonSolver::initializeFields()",
"FFTOpenPoissonSolver::initializeFields()",
"Currently only Hockney, Vico, and Biharmonic are supported for open BCs");
}

Expand Down Expand Up @@ -408,7 +409,7 @@ namespace ippl {
/////////////////////////////////////////////////////////////////////////
// compute electric potential by solving Poisson's eq given a field rho and mesh spacings hr
template <typename FieldLHS, typename FieldRHS>
void FFTPoissonSolver<FieldLHS, FieldRHS>::solve() {
void FFTOpenPoissonSolver<FieldLHS, FieldRHS>::solve() {
// start a timer
static IpplTimings::TimerRef solve = IpplTimings::getTimer("Solve");
IpplTimings::startTimer(solve);
Expand Down Expand Up @@ -973,7 +974,7 @@ namespace ippl {
// calculate FFT of the Green's function

template <typename FieldLHS, typename FieldRHS>
void FFTPoissonSolver<FieldLHS, FieldRHS>::greensFunction() {
void FFTOpenPoissonSolver<FieldLHS, FieldRHS>::greensFunction() {
const scalar_type pi = Kokkos::numbers::pi_v<scalar_type>;
grn_mr = 0.0;

Expand Down Expand Up @@ -1183,7 +1184,7 @@ namespace ippl {
};

template <typename FieldLHS, typename FieldRHS>
void FFTPoissonSolver<FieldLHS, FieldRHS>::communicateVico(
void FFTOpenPoissonSolver<FieldLHS, FieldRHS>::communicateVico(
Vector<int, Dim> size, typename CxField_gt::view_type view_g,
const ippl::NDIndex<Dim> ldom_g, const int nghost_g, typename Field_t::view_type view,
const ippl::NDIndex<Dim> ldom, const int nghost) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ namespace ippl {
};
} // namespace ippl

#include "Solver/FFTPeriodicPoissonSolver.hpp"
#include "PoissonSolvers/FFTPeriodicPoissonSolver.hpp"
#endif
File renamed without changes.
6 changes: 3 additions & 3 deletions src/Solver/P3MSolver.h → src/PoissonSolvers/P3MSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
//
//

#ifndef P3M_SOLVER_H_
#define P3M_SOLVER_H_
#ifndef IPPL_P3M_SOLVER_H_
#define IPPL_P3M_SOLVER_H_

#include "Types/Vector.h"

Expand Down Expand Up @@ -129,5 +129,5 @@ namespace ippl {
};
} // namespace ippl

#include "Solver/P3MSolver.hpp"
#include "PoissonSolvers/P3MSolver.hpp"
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions test/solver/Budiardja_plot.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Budiardja_plot
// This programs tests the FFTPoissonSolver by recreating the
// This programs tests the FFTOpenPoissonSolver by recreating the
// convergence test plot from the Budiardja et al. (2010) paper.
// The solution is the gravitational potential of a sphere.
// Usage:
Expand All @@ -13,7 +13,7 @@
#include <Kokkos_MathematicalConstants.hpp>
#include <Kokkos_MathematicalFunctions.hpp>

#include "Solver/FFTPoissonSolver.h"
#include "PoissonSolvers/FFTOpenPoissonSolver.h"

KOKKOS_INLINE_FUNCTION double source(double x, double y, double z, double density = 1.0,
double R = 1.0, double mu = 1.2) {
Expand Down Expand Up @@ -48,7 +48,7 @@ int main(int argc, char* argv[]) {
using Centering_t = Mesh_t::DefaultCentering;
typedef ippl::Field<double, 3, Mesh_t, Centering_t> field;
using vfield = ippl::Field<ippl::Vector<double, 3>, 3, Mesh_t, Centering_t>;
using Solver_t = ippl::FFTPoissonSolver<vfield, field>;
using Solver_t = ippl::FFTOpenPoissonSolver<vfield, field>;

// number of gridpoints to iterate over
std::array<int, n> N = {48, 144, 288, 384, 576};
Expand Down Expand Up @@ -134,7 +134,7 @@ int main(int argc, char* argv[]) {
// choose Hockney algorithm for Open BCs solver
params.add("algorithm", Solver_t::HOCKNEY);

// define an FFTPoissonSolver object
// define an FFTOpenPoissonSolver object
Solver_t FFTsolver(rho, params);

// solve the Poisson equation -> rho contains the solution (phi) now
Expand Down
2 changes: 1 addition & 1 deletion test/solver/TestCGSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "Utility/Inform.h"
#include "Utility/IpplTimings.h"

#include "Solver/PoissonCG.h"
#include "PoissonSolvers/PoissonCG.h"

int main(int argc, char* argv[]) {
ippl::initialize(argc, argv);
Expand Down
2 changes: 1 addition & 1 deletion test/solver/TestFFTPeriodicPoissonSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <iostream>
#include <typeinfo>

#include "Solver/FFTPeriodicPoissonSolver.h"
#include "PoissonSolvers/FFTPeriodicPoissonSolver.h"

int main(int argc, char* argv[]) {
ippl::initialize(argc, argv);
Expand Down
8 changes: 4 additions & 4 deletions test/solver/TestGaussian.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// TestGaussian
// This program tests the FFTPoissonSolver class with a Gaussian source.
// This program tests the FFTOpenPoissonSolver class with a Gaussian source.
// The solve is iterated 5 times for the purpose of timing studies.
// Usage:
// srun ./TestGaussian
Expand Down Expand Up @@ -31,7 +31,7 @@
#include "Utility/IpplException.h"
#include "Utility/IpplTimings.h"

#include "Solver/FFTPoissonSolver.h"
#include "PoissonSolvers/FFTOpenPoissonSolver.h"

KOKKOS_INLINE_FUNCTION double gaussian(double x, double y, double z, double sigma = 0.05,
double mu = 0.5) {
Expand Down Expand Up @@ -75,7 +75,7 @@ int main(int argc, char* argv[]) {
using Centering_t = Mesh_t::DefaultCentering;
typedef ippl::Field<double, Dim, Mesh_t, Centering_t> field;
typedef ippl::Field<ippl::Vector<double, Dim>, Dim, Mesh_t, Centering_t> fieldV;
using Solver_t = ippl::FFTPoissonSolver<fieldV, field>;
using Solver_t = ippl::FFTOpenPoissonSolver<fieldV, field>;

// start a timer
static IpplTimings::TimerRef allTimer = IpplTimings::getTimer("allTimer");
Expand Down Expand Up @@ -232,7 +232,7 @@ int main(int argc, char* argv[]) {
// add output type
params.add("output_type", Solver_t::SOL_AND_GRAD);

// define an FFTPoissonSolver object
// define an FFTOpenPoissonSolver object
Solver_t FFTsolver(fieldE, rho, params);

// iterate over 5 timesteps
Expand Down
8 changes: 4 additions & 4 deletions test/solver/TestGaussian_biharmonic.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// TestGaussian_biharmonic
// This programs tests the Biharmonic solver from FFTPoissonSolver.
// This programs tests the Biharmonic solver from FFTOpenPoissonSolver.
// The test is done on a Gaussian source.
// Usage:
// srun ./TestGaussian_biharmonic --info 5
Expand All @@ -11,13 +11,13 @@

#include "Utility/IpplTimings.h"

#include "Solver/FFTPoissonSolver.h"
#include "PoissonSolvers/FFTOpenPoissonSolver.h"

using Mesh_t = ippl::UniformCartesian<double, 3>;
using Centering_t = Mesh_t::DefaultCentering;
using ScalarField_t = ippl::Field<double, 3, Mesh_t, Centering_t>;
using VectorField_t = ippl::Field<ippl::Vector<double, 3>, 3, Mesh_t, Centering_t>;
using Solver_t = ippl::FFTPoissonSolver<VectorField_t, ScalarField_t>;
using Solver_t = ippl::FFTOpenPoissonSolver<VectorField_t, ScalarField_t>;

KOKKOS_INLINE_FUNCTION double gaussian(double x, double y, double z, double sigma = 0.05,
double mu = 0.5) {
Expand Down Expand Up @@ -216,7 +216,7 @@ int main(int argc, char* argv[]) {
// add output type
params.add("output_type", Solver_t::SOL_AND_GRAD);

// define an FFTPoissonSolver object
// define an FFTOpenPoissonSolver object
Solver_t FFTsolver(fieldE, rho, params);

// solve the Poisson equation -> rho contains the solution (phi) now
Expand Down
Loading

0 comments on commit 9cf7888

Please sign in to comment.