Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solver design refactoring #230

Merged
merged 60 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
78166b5
add an initial FDTDSolver header file
s-mayani Aug 22, 2022
bc043d5
clean up header
s-mayani Aug 22, 2022
f1c8fb1
add timestep size as attribute
s-mayani Aug 23, 2022
516335b
implemented computation of scalar and vector potentials from current …
s-mayani Aug 31, 2022
2350752
added field evaluation
s-mayani Sep 14, 2022
4635f8a
add initialization
s-mayani Sep 16, 2022
545704d
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Sep 16, 2022
efd374b
add methods to get E and B fields
s-mayani Oct 19, 2022
b789fda
linking works now - wrong macro in .hpp
s-mayani Nov 1, 2022
2add7b3
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Nov 1, 2022
21bc89b
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Nov 3, 2022
0478e08
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Mar 3, 2023
d674ee8
fix indentation
s-mayani Mar 3, 2023
0961ad8
added 1st order ABCs
s-mayani Mar 7, 2023
0b26d71
changed to match MITHRA's 1st order ABCs
s-mayani Mar 7, 2023
61c62ea
fixed syntax which was causing compiler error
s-mayani Mar 7, 2023
ac544e2
forgot to declare physical constants
s-mayani Mar 7, 2023
7bfdca8
fix some more compilation bugs
s-mayani Mar 7, 2023
aca77b7
changed test to be a gaussian pulse at center
s-mayani Mar 15, 2023
1cb98c6
fix small bug
s-mayani Mar 15, 2023
c201ad3
fixed a bug
s-mayani Mar 17, 2023
79b55e4
changed the gaussian pulse back to center; small mistake left from te…
s-mayani Mar 17, 2023
d3d92ba
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Mar 17, 2023
3094e05
changed test to sinusoidal rho
s-mayani Mar 22, 2023
e0a5174
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Mar 22, 2023
ee2f627
changed field signatures to contain mesh and centering and compile wi…
s-mayani Mar 22, 2023
8ec9e0c
Merge remote-tracking branch 'origin' into 123-fdtd-electromagnetic-s…
s-mayani May 8, 2023
f116985
changed to ippl::getRangePolicy in Kokkos loops
s-mayani May 8, 2023
d5f8596
clang formatting
s-mayani May 8, 2023
67c375f
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Jun 5, 2023
93cf100
fix bugs
s-mayani Jun 5, 2023
2c94020
rewrite header
s-mayani Jun 5, 2023
b6a4c2c
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Jun 6, 2023
a342a04
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Jul 4, 2023
2ebc5d3
typo in header
s-mayani Jul 4, 2023
c043275
add TF/SF seed -- doesn't work currently
s-mayani Jul 11, 2023
aaabc61
merge master into branch
s-mayani Jul 27, 2023
959c541
fix some things due to merge with master
s-mayani Jul 27, 2023
26a8097
fix typo
s-mayani Jul 28, 2023
e0ce2f8
uncomment TF/SF
s-mayani Aug 21, 2023
3d9309e
comment sine source at center - test only TF/SF seeding
s-mayani Aug 21, 2023
b1ea6da
Merge branch 'master' of gitlab.psi.ch:OPAL/Libraries/ippl into 123-f…
s-mayani Aug 21, 2023
198636d
forgot to comment out unused variables for compilation
s-mayani Aug 21, 2023
e2db507
fixed bug that broke sine pulse test
s-mayani Aug 21, 2023
14381a1
make it easy to switch between seed and sine pulse
s-mayani Aug 21, 2023
b4a3c82
fix bug in constructor
s-mayani Aug 28, 2023
521696b
Merge branch 'master' into 123-fdtd-electromagnetic-solver
s-mayani Sep 19, 2023
5ac15ab
change Electrostatics -> Poisson
s-mayani Sep 20, 2023
56ba3fc
change electrostatics -> Poisson in headers and macros
s-mayani Sep 20, 2023
be898fc
added Maxwell class and modified FDTDSolver and test files
s-mayani Sep 20, 2023
f31bb91
move solver algorithm to LinearSolvers
s-mayani Sep 26, 2023
853ff7e
remove FDTDSolver from CMakeLists for PR into master
s-mayani Sep 26, 2023
8e5cd5a
delete FDTDSolver for PR into master
s-mayani Sep 26, 2023
844d611
Delete src/Solver/FDTDSolver.hpp
s-mayani Sep 26, 2023
2b1f5f6
Delete src/Solver/FDTDSolver.h
s-mayani Sep 26, 2023
fa98792
Delete test/solver/TestFDTDSolver.cpp
s-mayani Sep 26, 2023
439d2d7
Merge 'master' into solver-design-refactoring
s-mayani Sep 26, 2023
cc5607c
remove virtual from setEMFields() in Maxwell
s-mayani Sep 27, 2023
d6bfb26
add reference to FFTPeriodicPoissonSolver.h/hpp
s-mayani Sep 27, 2023
9cf7888
changed to PoissonSolvers and MaxwellSolvers directories, and FFTPois…
s-mayani Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 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/ElectrostaticsCG.h"
#include "Solver/FFTPeriodicPoissonSolver.h"
#include "Solver/FFTPoissonSolver.h"
#include "Solver/P3MSolver.h"
#include "Solver/PoissonCG.h"

unsigned LoggingPeriod = 1;

Expand Down Expand Up @@ -54,7 +54,7 @@ using VField_t = Field<Vector_t<T, Dim>, Dim, ViewArgs...>;

// heFFTe does not support 1D FFTs, so we switch to CG in the 1D case
template <typename T = double, unsigned Dim = 3>
using CGSolver_t = ippl::ElectrostaticsCG<Field<T, Dim>, Field_t<Dim>>;
using CGSolver_t = ippl::PoissonCG<Field<T, Dim>, Field_t<Dim>>;

using ippl::detail::ConditionalType, ippl::detail::VariantFromConditionalTypes;

Expand Down
16 changes: 16 additions & 0 deletions src/LinearSolvers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set (_SRCS
)

set (_HDRS
SolverAlgorithm.h
PCG.h
)

include_DIRECTORIES (
${CMAKE_CURRENT_SOURCE_DIR}
)

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

install (FILES ${_HDRS} DESTINATION include/LinearSolvers)
File renamed without changes.
File renamed without changes.
7 changes: 2 additions & 5 deletions src/Solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ set (_SRCS
)

set (_HDRS
SolverAlgorithm.h
ElectrostaticsCG.h
Electrostatics.h
PCG.h
Solver.h
PoissonCG.h
Poisson.h
)

if (ENABLE_FFT)
Expand Down
75 changes: 0 additions & 75 deletions src/Solver/Electrostatics.h

This file was deleted.

9 changes: 5 additions & 4 deletions src/Solver/FFTPeriodicPoissonSolver.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Class FFTPeriodicPoissonSolver
// Solves periodic electrostatics problems using Fourier transforms
// Solves the periodic Poisson problem using Fourier transforms
s-mayani marked this conversation as resolved.
Show resolved Hide resolved
// cf. https://math.mit.edu/~stevenj/fft-deriv.pdf Algorithm 5
//
//

Expand All @@ -11,15 +12,15 @@

#include "Types/ViewTypes.h"

#include "Electrostatics.h"
#include "FFT/FFT.h"
#include "FieldLayout/FieldLayout.h"
#include "Index/NDIndex.h"
#include "Poisson.h"

namespace ippl {

template <typename FieldLHS, typename FieldRHS>
class FFTPeriodicPoissonSolver : public Electrostatics<FieldLHS, FieldRHS> {
class FFTPeriodicPoissonSolver : public Poisson<FieldLHS, FieldRHS> {
constexpr static unsigned Dim = FieldLHS::dim;
using Trhs = typename FieldRHS::value_type;
using mesh_type = typename FieldRHS::Mesh_t;
Expand All @@ -32,7 +33,7 @@ namespace ippl {
using Layout_t = FieldLayout<Dim>;
using Vector_t = Vector<Trhs, Dim>;

using Base = Electrostatics<FieldLHS, FieldRHS>;
using Base = Poisson<FieldLHS, FieldRHS>;
using typename Base::lhs_type, typename Base::rhs_type;
using scalar_type = typename FieldLHS::Mesh_t::value_type;
using vector_type = typename FieldLHS::Mesh_t::vector_type;
Expand Down
3 changes: 2 additions & 1 deletion src/Solver/FFTPeriodicPoissonSolver.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Class FFTPeriodicPoissonSolver
// Solves periodic electrostatics problems using Fourier transforms
// Solves the periodic Poisson problem using Fourier transforms
// cf. https://math.mit.edu/~stevenj/fft-deriv.pdf Algorithm 5
//
//

Expand Down
6 changes: 3 additions & 3 deletions src/Solver/FFTPoissonSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#include "Field/Field.h"

#include "Communicate/Archive.h"
#include "Electrostatics.h"
#include "FFT/FFT.h"
#include "Field/HaloCells.h"
#include "FieldLayout/FieldLayout.h"
#include "Meshes/UniformCartesian.h"
#include "Poisson.h"

namespace ippl {

Expand Down Expand Up @@ -70,15 +70,15 @@ namespace ippl {
} // namespace detail

template <typename FieldLHS, typename FieldRHS>
class FFTPoissonSolver : public Electrostatics<FieldLHS, FieldRHS> {
class FFTPoissonSolver : public Poisson<FieldLHS, FieldRHS> {
s-mayani marked this conversation as resolved.
Show resolved Hide resolved
constexpr static unsigned Dim = FieldLHS::dim;
using Trhs = typename FieldRHS::value_type;
using mesh_type = typename FieldLHS::Mesh_t;
using Tg = typename FieldLHS::value_type::value_type;

public:
// type of output
using Base = Electrostatics<FieldLHS, FieldRHS>;
using Base = Poisson<FieldLHS, FieldRHS>;

// types for LHS and RHS
using typename Base::lhs_type, typename Base::rhs_type;
Expand Down
85 changes: 85 additions & 0 deletions src/Solver/Maxwell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// Class Maxwell
// Base class for solvers for Maxwell's equations
//
s-mayani marked this conversation as resolved.
Show resolved Hide resolved

#ifndef IPPL_MAXWELL_H
#define IPPL_MAXWELL_H

#include "Types/Vector.h"

#include "Field/Field.h"

#include "FieldLayout/FieldLayout.h"
#include "Meshes/UniformCartesian.h"

namespace ippl {

template <typename EMField, typename SourceField>
class Maxwell {
public:
// typedefs for the different fields and vector fields
using typeR = typename SourceField::value_type;

constexpr static unsigned Dim = EMField::dim;
typedef typename EMField::Mesh_t Mesh_t;
typedef typename EMField::Centering_t Centering_t;
typedef Vector<typeR, Dim> Vector_t;
typedef Field<Vector_t, Dim, Mesh_t, Centering_t> VectorSourceField_t;

// define type for field layout
typedef FieldLayout<Dim> FieldLayout_t;

// type for communication buffers
using memory_space = typename SourceField::memory_space;
using buffer_type = Communicate::buffer_type<memory_space>;

/*!
* Default constructor for Maxwell solvers;
*/
Maxwell() {}

Maxwell(SourceField& charge, VectorSourceField_t& current, EMField& E, EMField& B) {
setSources(charge, current);
setEMFields(E, B);
}

/*!
* Set the problem RHS (charge & current densities)
* @param charge Reference to rho field
* @param current Reference to J field
*/
virtual void setSources(SourceField& charge, VectorSourceField_t& current) {
s-mayani marked this conversation as resolved.
Show resolved Hide resolved
rhoN_mp = &charge;
JN_mp = &current;
}

/*!
* Set the problem LHS (electromagnetic fields)
* @param E Reference to electric field
* @param B Reference to magnetic field
*/
void setEMFields(EMField& E, EMField& B) {
En_mp = &E;
Bn_mp = &B;
}

/*!
* Solve the electromagnetic problem (Maxwell's eqs)
*/
virtual void solve() = 0;

virtual ~Maxwell() {}

protected:
// fields containing reference to charge and current
SourceField* rhoN_mp = nullptr;
matt-frey marked this conversation as resolved.
Show resolved Hide resolved
VectorSourceField_t* JN_mp = nullptr;

// E and B fields
EMField* En_mp = nullptr;
EMField* Bn_mp = nullptr;
};
} // namespace ippl

#endif
6 changes: 3 additions & 3 deletions src/Solver/P3MSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@

#include "Field/Field.h"

#include "Electrostatics.h"
#include "FFT/FFT.h"
#include "FieldLayout/FieldLayout.h"
#include "Meshes/UniformCartesian.h"
#include "Poisson.h"

namespace ippl {
template <typename FieldLHS, typename FieldRHS>
class P3MSolver : public Electrostatics<FieldLHS, FieldRHS> {
class P3MSolver : public Poisson<FieldLHS, FieldRHS> {
constexpr static unsigned Dim = FieldLHS::dim;
using Trhs = typename FieldRHS::value_type;
using mesh_type = typename FieldRHS::Mesh_t;

public:
// type of output
using Base = Electrostatics<FieldLHS, FieldRHS>;
using Base = Poisson<FieldLHS, FieldRHS>;

// types for LHS and RHS
using typename Base::lhs_type, typename Base::rhs_type;
Expand Down
Loading