53 #ifndef Foam_lduMatrix_H 54 #define Foam_lduMatrix_H 77 Ostream&
operator<<(Ostream&,
const lduMatrix&);
78 Ostream& operator<<(Ostream&, const InfoProxy<lduMatrix>&);
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_;
173 virtual const word&
type()
const = 0;
243 const word& solverName,
298 virtual void read(
const dictionary&);
363 virtual const word&
type()
const = 0;
505 static word
getName(
const dictionary&);
508 virtual const word&
type()
const = 0;
522 (sol, solverControls)
534 (sol, solverControls)
686 return (diagPtr_ && !lowerPtr_ && !upperPtr_);
692 return (diagPtr_ && !lowerPtr_ && upperPtr_);
698 return (diagPtr_ && lowerPtr_ && upperPtr_);
713 const tmp<solveScalarField>&,
714 const FieldField<Field, scalar>&,
723 const tmp<solveScalarField>&,
724 const FieldField<Field, scalar>&,
734 const FieldField<Field, scalar>&,
780 const label startRequest
788 const word& fieldName,
834 friend Ostream& operator<<(Ostream&, const InfoProxy<lduMatrix>&);
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
virtual void read(const dictionary &)
Read and reset the preconditioner parameters from the given stream.
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.
const lduInterfaceFieldPtrsList & interfaces_
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
const scalarField & diag() const
tmp< Field< Type > > faceH(const Field< Type > &) const
const lduInterfaceFieldPtrsList & interfaces() const noexcept
void Tmul(solveScalarField &, const tmp< solveScalarField > &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &, const direction cmpt) const
Matrix transpose multiplication with updated interfaces.
bool symmetric() const noexcept
Matrix is symmetric.
word matrixTypeName() const
The matrix type (empty, diagonal, symmetric, ...)
virtual void read(const dictionary &)
Read and reset the solver parameters from the given stream.
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
const FieldField< Field, scalar > & interfaceIntCoeffs_
const lduMatrix & matrix() const noexcept
preconditioner(const solver &sol)
Construct for given solver.
~lduMatrix()=default
Destructor.
Field< solveScalar > solveScalarField
virtual const word & type() const =0
Runtime type information.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
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.
void residual(solveScalarField &rA, const solveScalarField &psi, const scalarField &source, const FieldField< Field, scalar > &interfaceBouCoeffs, const lduInterfaceFieldPtrsList &interfaces, const direction cmpt) const
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.
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))
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const =0
Solve with given field and rhs.
const FieldField< Field, scalar > & interfaceBouCoeffs_
virtual void preconditionT(solveScalarField &wT, const solveScalarField &rT, const direction cmpt=0) const
Return wT the transpose-matrix preconditioned form of residual rT.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
pTraits< solveScalar >::cmptType cmptType
Component type.
const lduMatrix & matrix() const noexcept
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
InfoProxy< lduMatrix > info() const noexcept
Return info proxy, used to print matrix information to a stream.
Triggers for starting/stopping code profiling.
tmp< scalarField > H1() const
void sumMagOffDiag(scalarField &sumOff) const
static constexpr const label defaultMaxIter
Default maximum number of iterations for solvers (1000)
int log_
Verbosity level for solver output statements.
A field of fields is a PtrList of fields with reference counting.
static const Enum< normTypes > normTypesNames_
Names for the normTypes.
label minIter_
Minimum number of iterations in the solver.
lduMatrix::normTypes normType_
The normalisation type.
virtual ~preconditioner()=default
Destructor.
const lduMatrix & matrix_
static word getName(const dictionary &)
Find the smoother name (directly or from a sub-dictionary)
const lduSchedule & patchSchedule() const
Return the patch evaluation schedule.
Abstract base-class for lduMatrix smoothers.
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
scalar tolerance_
Final convergence tolerance.
void Amul(solveScalarField &, const tmp< solveScalarField > &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &, const direction cmpt) const
Matrix multiplication with updated interfaces.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label maxIter_
Maximum number of iterations in the solver.
static autoPtr< preconditioner > New(const solver &sol, const dictionary &solverControls)
Return a new preconditioner.
Abstract base-class for lduMatrix solvers.
const word & fieldName() const noexcept
lduMatrix member H operations.
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.
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.
const scalarField & lower() const
friend Ostream & operator<<(Ostream &, const lduMatrix &)
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
void sumA(solveScalarField &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &) const
Sum the coefficients on each row of the matrix.
const lduInterfaceFieldPtrsList & interfaces() const noexcept
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
static const scalar defaultTolerance
Default (absolute) tolerance (1e-6)
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.
virtual const word & type() const =0
Runtime type information.
const FieldField< Field, scalar > & interfaceBouCoeffs_
normTypes
Enumerated matrix normalisation types.
void operator=(const lduMatrix &)
Copy assignment.
const lduMatrix & matrix_
bool hasUpper() const noexcept
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
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.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void operator*=(const scalarField &)
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.
lduInterfaceFieldPtrsList interfaces_
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.
bool diagonal() const noexcept
Matrix has diagonal only.
virtual ~smoother()=default
Destructor.
virtual const word & type() const =0
Runtime type information.
dictionary controlDict_
Dictionary of solution controls.
"default" norm (== L1_scaled)
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
const scalarField & upper() const
Abstract base-class for lduMatrix preconditioners.
A helper class for outputting values to Ostream.
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
const lduAddressing & lduAddr() const
Return the LDU addressing.
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.
virtual void precondition(solveScalarField &wA, const solveScalarField &rA, const direction cmpt=0) const =0
Return wA the preconditioned form of residual rA.
void setLduMesh(const lduMesh &m)
Set the LDU mesh containing the addressing.
virtual ~solver()=default
Destructor.
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
const FieldField< Field, scalar > & interfaceIntCoeffs_
lduMatrix(const lduMesh &mesh)
Construct (without coefficients) for an LDU addressed mesh.
virtual solverPerformance scalarSolve(solveScalarField &psi, const solveScalarField &source, const direction cmpt=0) const
Solve with given field and rhs (in solveScalar precision).
static word getName(const dictionary &)
Find the preconditioner name (directly or from a sub-dictionary)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
bool hasDiag() const noexcept
const volScalarField & psi
The class contains the addressing required by the lduMatrix: upper, lower and losort.
tmp< Field< Type > > H(const Field< Type > &) const
Macros to ease declaration of run-time selection tables.
void operator-=(const lduMatrix &)
void operator+=(const lduMatrix &)
A class for managing temporary objects.
profilingTrigger profiling_
Profiling instrumentation.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
bool hasLower() const noexcept
const word & fieldName() const noexcept
virtual void setFinished(const solverPerformance &perf) const
Signal end of solver.
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.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
virtual void readControls()
Read the control parameters from controlDict_.
virtual const lduSchedule & patchSchedule() const =0
Return patch field evaluation schedule.
scalar relTol_
Convergence tolerance relative to the initial.
declareRunTimeSelectionTable(autoPtr, smoother, symMatrix,(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces),(fieldName, matrix, interfaceBouCoeffs, interfaceIntCoeffs, interfaces))