File invertable_operator.hxx¶
-
namespace
bout
SNB model
-
namespace
inversion
¶ Functions
-
template<typename
T
>
Tidentity
(const T &in)¶ No-op function to use as a default may wish to remove once testing phase complete.
-
template<typename
T
>
classInvertableOperator
¶ - #include <invertable_operator.hxx>
Class to define an invertable operator. Provides interface to PETSc routines for solving A.x = b
Public Types
-
template<>
usingdata_type
= T¶ What type of field does the operator take?
-
template<>
usingfunction_signature
= std::function<T(const T&)>¶ The signature of the functor that applies the operator.
Public Functions
-
InvertableOperator
(const function_signature &func = identity<T>, Options *optIn = nullptr, Mesh *localmeshIn = nullptr)¶ Almost empty constructor currently don’t actually use Options for anything.
-
~InvertableOperator
()¶ Destructor just has to cleanup the PETSc owned objects.
-
void
setOperatorFunction
(const function_signature &func, bool alsoSetPreconditioner = true)¶ Allow the user to override the existing function Note by default we set the preconditioner function to match this as this is the usual mode of operation. If the user doesn’t want to do this they can set alsoSetPreconditioner to false.
-
void
setPreconditionerFunction
(const function_signature &func)¶ Allow the user to override the existing preconditioner function.
-
PetscErrorCode
setup
()¶ Sets up the PETSc objects required for inverting the operator Currently also takes the functor that applies the operator this class represents. Not actually required by any of the setup so this should probably be moved to a separate place (maybe the constructor).
-
T
invert
(const T &rhsField, const T &guess)¶
-
T
invert
(const T &rhsField)¶ Triggers the solve of A.x = b for x, where b = rhs and A is the matrix representation of the operator we represent. Should probably provide an overload or similar as a way of setting the initial guess.
Public Static Functions
-
static void
reportTime
()¶ Reports the time spent in various parts of InvertableOperator. Note that as the Timer “labels” are not unique to an instance the time reported is summed across all different instances.
Private Members
-
Mat
matOperator
¶
-
Mat
matPreconditioner
¶
-
Vec
rhs
¶
-
Vec
lhs
¶
-
KSP
ksp
¶
-
function_signature
operatorFunction
= identity<T>¶ The function that represents the operator that we wish to invert.
-
function_signature
preconditionerFunction
= identity<T>¶ The function that represents the preconditioner for the operator that we wish to invert
-
bool
doneSetup
= false¶
Private Static Functions
-
static PetscErrorCode
functionWrapper
(Mat m, Vec v1, Vec v2)¶ Wrapper that gets a pointer to the parent InvertableOperator instance from the Matrix m and uses this to get the actual function to call. Copies data from v1 into a field of type T, calls the function on this and then copies the result into the v2 argument.
-
static PetscErrorCode
preconditionerWrapper
(Mat m, Vec v1, Vec v2)¶ Wrapper that gets a pointer to the parent InvertableOperator instance from the Matrix m and uses this to get the actual function to call. Copies data from v1 into a field of type T, calls the function on this and then copies the result into the v2 argument.
-
template<>
-
template<typename
-
namespace