53#ifndef Foam_lduMatrix_H
54#define Foam_lduMatrix_H
91 std::reference_wrapper<const lduMesh> lduMesh_;
94 std::unique_ptr<scalarField> diagPtr_;
97 std::unique_ptr<scalarField> lowerPtr_;
100 std::unique_ptr<scalarField> upperPtr_;
103 mutable std::unique_ptr<scalarField> lowerCSRPtr_;
106 mutable std::unique_ptr<solveScalarField> workPtr_;
179 virtual const word&
type()
const = 0;
249 const word& solverName,
369 virtual const word&
type()
const = 0;
532 (sol, solverControls)
544 (sol, solverControls)
711 return (diagPtr_ && !lowerPtr_ && !upperPtr_);
717 return (diagPtr_ && !lowerPtr_ && upperPtr_);
723 return (diagPtr_ && lowerPtr_ && upperPtr_);
738 const tmp<solveScalarField>&,
739 const FieldField<Field, scalar>&,
805 const label startRequest
813 const word& fieldName,
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
A field of fields is a PtrList of fields with reference counting.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
pTraits< solveScalar >::cmptType cmptType
A helper class for outputting values to Ostream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
The class contains the addressing required by the lduMatrix: upper, lower and losort.
virtual const lduSchedule & patchSchedule() const =0
Return patch field evaluation schedule.
Abstract base-class for lduMatrix preconditioners.
declareRunTimeSelectionTable(autoPtr, preconditioner, symMatrix,(const solver &sol, const dictionary &solverControls),(sol, solverControls))
const solver & solver_
Reference to the base-solver this preconditioner is used with.
static autoPtr< preconditioner > New(const solver &sol, const dictionary &solverControls)
Return a new preconditioner.
preconditioner(const solver &sol)
Construct for given solver.
declareRunTimeSelectionTable(autoPtr, preconditioner, asymMatrix,(const solver &sol, const dictionary &solverControls),(sol, solverControls))
virtual void precondition(solveScalarField &wA, const solveScalarField &rA, const direction cmpt=0) const =0
Return wA the preconditioned form of residual rA.
virtual void preconditionT(solveScalarField &wT, const solveScalarField &rT, const direction cmpt=0) const
Return wT the transpose-matrix preconditioned form of residual rT.
virtual void read(const dictionary &)
Read and reset the preconditioner parameters from the given stream.
virtual void setFinished(const solverPerformance &perf) const
Signal end of solver.
static word getName(const dictionary &)
Find the preconditioner name (directly or from a sub-dictionary).
virtual const word & type() const =0
Runtime type information.
virtual ~preconditioner()=default
Destructor.
Abstract base-class for lduMatrix smoothers.
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
const lduMatrix & matrix_
declareRunTimeSelectionTable(autoPtr, smoother, asymMatrix,(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls),(fieldName, matrix, interfaceBouCoeffs, interfaceIntCoeffs, interfaces, solverControls))
const lduInterfaceFieldPtrsList & interfaces_
smoother(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces)
Construct for given field name, matrix etc.
declareRunTimeSelectionTable(autoPtr, smoother, symMatrix,(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls),(fieldName, matrix, interfaceBouCoeffs, interfaceIntCoeffs, interfaces, solverControls))
const lduInterfaceFieldPtrsList & interfaces() const noexcept
virtual ~smoother()=default
Destructor.
const FieldField< Field, scalar > & interfaceBouCoeffs_
virtual void scalarSmooth(solveScalarField &psi, const solveScalarField &source, const direction cmpt, const label nSweeps) const =0
Smooth the solution for a given number of sweeps.
const lduMatrix & matrix() const noexcept
static autoPtr< smoother > New(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Return a new smoother.
const FieldField< Field, scalar > & interfaceIntCoeffs_
virtual void smooth(solveScalarField &psi, const scalarField &source, const direction cmpt, const label nSweeps) const =0
Smooth the solution for a given number of sweeps.
static word getName(const dictionary &)
Find the smoother name (directly or from a sub-dictionary).
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
virtual const word & type() const =0
Runtime type information.
const word & fieldName() const noexcept
Abstract base-class for lduMatrix solvers.
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
const lduMatrix & matrix_
declareRunTimeSelectionTable(autoPtr, solver, symMatrix,(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls),(fieldName, matrix, interfaceBouCoeffs, interfaceIntCoeffs, interfaces, solverControls))
label maxIter_
Maximum number of iterations in the solver.
solver(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Construct solver for given field name, matrix etc.
profilingTrigger profiling_
Profiling instrumentation.
scalar tolerance_
Final convergence tolerance.
const lduInterfaceFieldPtrsList & interfaces() const noexcept
solveScalarField::cmptType normFactor(const solveScalarField &psi, const solveScalarField &source, const solveScalarField &Apsi, solveScalarField &tmpField) const
Return the matrix norm used to normalise the residual for the stopping criterion.
lduInterfaceFieldPtrsList interfaces_
const FieldField< Field, scalar > & interfaceBouCoeffs_
declareRunTimeSelectionTable(autoPtr, solver, asymMatrix,(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls),(fieldName, matrix, interfaceBouCoeffs, interfaceIntCoeffs, interfaces, solverControls))
label minIter_
Minimum number of iterations in the solver.
const lduMatrix & matrix() const noexcept
solveScalarField::cmptType normFactor(const solveScalarField &psi, const solveScalarField &source, const solveScalarField &Apsi, solveScalarField &tmpField, const lduMatrix::normTypes normType) const
Return the matrix norm using the specified norm method.
lduMatrix::normTypes normType_
The normalisation type.
static autoPtr< solver > New(const word &solverName, const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Return a new solver of given type.
int log_
Verbosity level for solver output statements.
virtual solverPerformance scalarSolve(solveScalarField &psi, const solveScalarField &source, const direction cmpt=0) const
Solve with given field and rhs (in solveScalar precision).
virtual ~solver()=default
Destructor.
scalar relTol_
Convergence tolerance relative to the initial.
const FieldField< Field, scalar > & interfaceIntCoeffs_
virtual void readControls()
Read the control parameters from controlDict_.
virtual void read(const dictionary &)
Read and reset the solver parameters from the given stream.
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
dictionary controlDict_
Dictionary of solution controls.
virtual const word & type() const =0
Runtime type information.
const word & fieldName() const noexcept
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const =0
Solve with given field and rhs.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
lduMatrix(const lduMesh &mesh)
Construct (without coefficients) for an LDU addressed mesh.
tmp< scalarField > H1() const
void operator=(const lduMatrix &)
Copy assignment.
bool hasUpper() const noexcept
tmp< Field< Type > > faceH(const Field< Type > &) const
const lduAddressing & lduAddr() const
Return the LDU addressing.
friend Ostream & operator<<(Ostream &, const InfoProxy< lduMatrix > &)
normTypes
Enumerated matrix normalisation types.
@ DEFAULT_NORM
"default" norm (== L1_scaled)
@ L1_SCALED_NORM
"L1_scaled" norm
@ NO_NORM
"none" norm (returns 1)
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full).
void residual(solveScalarField &rA, const solveScalarField &psi, const scalarField &source, const FieldField< Field, scalar > &interfaceBouCoeffs, const lduInterfaceFieldPtrsList &interfaces, const direction cmpt) const
InfoProxy< lduMatrix > info() const noexcept
Return info proxy, used to print matrix information to a stream.
void Tmul(solveScalarField &, const tmp< solveScalarField > &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &, const direction cmpt) const
Matrix transpose multiplication with updated interfaces.
friend Ostream & operator<<(Ostream &, const lduMatrix &)
tmp< Field< Type > > faceH(const tmp< Field< Type > > &) const
const scalarField & diag() const
void initMatrixInterfaces(const bool add, const FieldField< Field, scalar > &interfaceCoeffs, const lduInterfaceFieldPtrsList &interfaces, const solveScalarField &psiif, solveScalarField &result, const direction cmpt) const
Initialise the update of interfaced interfaces for matrix operations.
bool symmetric() const noexcept
Matrix is symmetric.
const scalarField & upper() const
void setLduMesh(const lduMesh &m)
Set the LDU mesh containing the addressing.
void sumA(solveScalarField &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &) const
Sum the coefficients on each row of the matrix.
void setResidualField(const scalarField &residual, const word &fieldName, const bool initial) const
Set the residual field using an IOField on the object registry if it exists.
const lduSchedule & patchSchedule() const
Return the patch evaluation schedule.
const scalarField & lowerCSR() const
void operator*=(const scalarField &)
bool diagonal() const noexcept
Matrix has diagonal only.
static constexpr const label defaultMaxIter
Default maximum number of iterations for solvers (1000).
static const Enum< normTypes > normTypesNames_
Names for the normTypes.
bool hasLower() const noexcept
tmp< Field< Type > > H(const Field< Type > &) const
void operator+=(const lduMatrix &)
const scalarField & lower() const
void sumMagOffDiag(scalarField &sumOff) const
~lduMatrix()=default
Destructor.
void Amul(solveScalarField &, const tmp< solveScalarField > &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &, const direction cmpt) const
Matrix multiplication with updated interfaces.
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
void operator-=(const lduMatrix &)
static const scalar defaultTolerance
Default (absolute) tolerance (1e-6).
tmp< Field< Type > > H(const tmp< Field< Type > > &) const
word matrixTypeName() const
The matrix type (empty, diagonal, symmetric, ...).
const solveScalarField & work() const
Work array.
bool hasDiag() const noexcept
bool hasLowerCSR() const noexcept
void updateMatrixInterfaces(const bool add, const FieldField< Field, scalar > &interfaceCoeffs, const lduInterfaceFieldPtrsList &interfaces, const solveScalarField &psiif, solveScalarField &result, const direction cmpt, const label startRequest) const
Update interfaced interfaces for matrix operations.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
Triggers for starting/stopping code profiling.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
const volScalarField & psi
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
lduMatrix member H operations.
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
Field< solveScalar > solveScalarField
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...