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

Add a Null Solver that has no action #252

Merged
merged 5 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/PoissonSolvers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set (_SRCS
set (_HDRS
PoissonCG.h
Poisson.h
NullSolver.h
)

if (ENABLE_FFT)
Expand Down
49 changes: 49 additions & 0 deletions src/PoissonSolvers/NullSolver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Class NullSolver
// Dummy solver which can be used when we require no action
// to be done on our LHS in the simulation while keeping the
// software design of the PIC framework in-tact.
//

#ifndef IPPL_NULL_SOLVER_H
#define IPPL_NULL_SOLVER_H

#include "Poisson.h"

namespace ippl {

template <typename FieldLHS, typename FieldRHS>
class NullSolver : public Poisson<FieldLHS, FieldRHS> {
public:
using Base = Poisson<FieldLHS, FieldRHS>;
using typename Base::lhs_type, typename Base::rhs_type;

// constructors
NullSolver()
: Base() {}

NullSolver(rhs_type& rhs) {
using T = typename FieldLHS::value_type::value_type;
static_assert(std::is_floating_point<T>::value, "Not a floating point type");

Base::setRhs(rhs);
this->setDefaultParameters();
}

NullSolver(lhs_type& lhs, rhs_type& rhs)
: Base(lhs, rhs) {}

void solve() override {
// Overwrite the RHS (source rho) with the solution (potential phi), which is 0
*(this->rhs_mp) = 0.0;

// The gradient of the potential, which is the E-field, is also 0
if (this->lhs_mp != nullptr) {
*(this->lhs_mp) = 0.0;
}
}
};

} // namespace ippl

#endif