IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
Creating Custom Solver

Here, we'll provide detailed guidelines on how to extend this base class of the 'SolverAlgorithm' to develop your own solver algorithm, using the PCG (Preconditioned Conjugate Gradient) solver as an example.

Introduction to SolverAlgorithm Base Class

The SolverAlgorithm class is a template abstract class designed to serve as a foundation for various numerical solver algorithms. It provides a common interface for solving problems of the form Op(lhs) = rhs, where Op is a differential operator and lhs and rhs are fields.

Key Components of SolverAlgorithm **

  • Template Parameters: The class template parameters FieldLHS and FieldRHS define the types for the left-hand side (LHS) and right-hand side (RHS) of the equation respectively.

  • Virtual Function: The operator() function is a pure virtual function that must be implemented by derived classes. It is where the main logic of the solver is implemented.

#include <functional>
namespace ippl {
template <typename FieldLHS, typename FieldRHS>
class SolverAlgorithm {
public:
using lhs_type = FieldLHS;
using rhs_type = FieldRHS;

Steps to Create a Custom Solver

1. Define the Solver Class

Start by defining your solver class that inherits from SolverAlgorithm. Specify any additional data members or methods needed for your solver.

2. Implement the Solver Logic

Implement the operator() function, which contains the core logic for the solver. This function should use the provided lhs, rhs, and params to compute the solution to the problem.