53#ifndef Foam_LduMatrix_H
54#define Foam_LduMatrix_H
72template<
class Type,
class DType,
class LUType>
75template<
class Type,
class DType,
class LUType>
87template<
class Type,
class DType,
class LUType>
167 virtual const word&
type()
const = 0;
279 virtual const word&
type()
const = 0;
376 virtual const word&
type()
const = 0;
390 (sol, preconditionerDict)
402 (sol, preconditionerDict)
532 return interfacesUpper_;
537 return interfacesLower_;
548 return interfacesUpper_;
553 return interfacesLower_;
579 return (diagPtr_ && !lowerPtr_ && !upperPtr_);
584 return (diagPtr_ && (!lowerPtr_ && upperPtr_));
589 return (diagPtr_ && lowerPtr_ && upperPtr_);
658 friend Ostream& operator<< <Type, DType, LUType>
672#define makeLduMatrix(Type, DType, LUType) \
674typedef Foam::LduMatrix<Type, DType, LUType> \
675 ldu##Type##DType##LUType##Matrix; \
677defineNamedTemplateTypeNameAndDebug(ldu##Type##DType##LUType##Matrix, 0); \
680typedef LduMatrix<Type, DType, LUType>::smoother \
681 ldu##Type##DType##LUType##Smoother; \
683defineTemplateRunTimeSelectionTable \
685 ldu##Type##DType##LUType##Smoother, \
689defineTemplateRunTimeSelectionTable \
691 ldu##Type##DType##LUType##Smoother, \
696typedef LduMatrix<Type, DType, LUType>::preconditioner \
697 ldu##Type##DType##LUType##Preconditioner; \
699defineTemplateRunTimeSelectionTable \
701 ldu##Type##DType##LUType##Preconditioner, \
705defineTemplateRunTimeSelectionTable \
707 ldu##Type##DType##LUType##Preconditioner, \
712typedef LduMatrix<Type, DType, LUType>::solver \
713 ldu##Type##DType##LUType##Solver; \
715defineTemplateRunTimeSelectionTable \
717 ldu##Type##DType##LUType##Solver, \
721defineTemplateRunTimeSelectionTable \
723 ldu##Type##DType##LUType##Solver, \
728#define makeLduPreconditioner(Precon, Type, DType, LUType) \
730typedef Precon<Type, DType, LUType> \
731 Precon##Type##DType##LUType##Preconditioner; \
732defineNamedTemplateTypeNameAndDebug \
734 Precon##Type##DType##LUType##Preconditioner, \
738#define makeLduSymPreconditioner(Precon, Type, DType, LUType) \
740LduMatrix<Type, DType, LUType>::preconditioner:: \
741addsymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \
742add##Precon##Type##DType##LUType##PreconditionerSymMatrixConstructorToTable_;
744#define makeLduAsymPreconditioner(Precon, Type, DType, LUType) \
746LduMatrix<Type, DType, LUType>::preconditioner:: \
747addasymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \
748add##Precon##Type##DType##LUType##PreconditionerAsymMatrixConstructorToTable_;
751#define makeLduSmoother(Smoother, Type, DType, LUType) \
753typedef Smoother<Type, DType, LUType> \
754 Smoother##Type##DType##LUType##Smoother; \
756defineNamedTemplateTypeNameAndDebug \
758 Smoother##Type##DType##LUType##Smoother, \
762#define makeLduSymSmoother(Smoother, Type, DType, LUType) \
764LduMatrix<Type, DType, LUType>::smoother:: \
765 addsymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \
766 add##Smoother##Type##DType##LUType##SymMatrixConstructorToTable_;
768#define makeLduAsymSmoother(Smoother, Type, DType, LUType) \
770LduMatrix<Type, DType, LUType>::smoother:: \
771 addasymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \
772 add##Smoother##Type##DType##LUType##AsymMatrixConstructorToTable_;
775#define makeLduSolver(Solver, Type, DType, LUType) \
777typedef Solver<Type, DType, LUType> \
778 Solver##Type##DType##LUType##Solver; \
780defineNamedTemplateTypeNameAndDebug \
782 Solver##Type##DType##LUType##Solver, \
786#define makeLduSymSolver(Solver, Type, DType, LUType) \
788LduMatrix<Type, DType, LUType>::solver:: \
789 addsymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \
790 add##Solver##Type##DType##LUType##SymMatrixConstructorToTable_;
792#define makeLduAsymSolver(Solver, Type, DType, LUType) \
794LduMatrix<Type, DType, LUType>::solver:: \
795 addasymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \
796 add##Solver##Type##DType##LUType##AsymMatrixConstructorToTable_;
List of coupled interface fields to be used in coupling.
A field of fields is a PtrList of fields with reference counting.
Generic templated field type.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Abstract base-class for LduMatrix preconditioners.
const solver & solver_
Reference to the base-solver this preconditioner is used with.
preconditioner(const solver &sol)
declareRunTimeSelectionTable(autoPtr, preconditioner, symMatrix,(const solver &sol, const dictionary &preconditionerDict),(sol, preconditionerDict))
static autoPtr< preconditioner > New(const solver &sol, const dictionary &preconditionerDict)
Return a new preconditioner.
virtual void read(const dictionary &preconditionerDict)
Read and reset the preconditioner parameters.
declareRunTimeSelectionTable(autoPtr, preconditioner, asymMatrix,(const solver &sol, const dictionary &preconditionerDict),(sol, preconditionerDict))
virtual void preconditionT(Field< Type > &wT, const Field< Type > &rT) const
Return wT the transpose-matrix preconditioned form of.
virtual void precondition(Field< Type > &wA, const Field< Type > &rA) const =0
Return wA the preconditioned form of residual rA.
virtual const word & type() const =0
Runtime type information.
virtual ~preconditioner()=default
Abstract base-class for LduMatrix smoothers.
declareRunTimeSelectionTable(autoPtr, smoother, symMatrix,(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix),(fieldName, matrix))
const LduMatrix< Type, DType, LUType > & matrix() const noexcept
virtual ~smoother()=default
declareRunTimeSelectionTable(autoPtr, smoother, asymMatrix,(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix),(fieldName, matrix))
const LduMatrix< Type, DType, LUType > & matrix_
virtual void smooth(Field< Type > &psi, const label nSweeps) const =0
Smooth the solution for a given number of sweeps.
virtual const word & type() const =0
Runtime type information.
const word & fieldName() const noexcept
static autoPtr< smoother > New(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix, const dictionary &smootherDict)
Return a new smoother.
Abstract base-class for LduMatrix solvers.
label maxIter_
Maximum number of iterations in the solver.
static const label defaultMaxIter_
Default maximum number of iterations in the solver.
const LduMatrix< Type, DType, LUType > & matrix() const noexcept
Type relTol_
Convergence tolerance relative to the initial.
void readControl(const dictionary &dict, T &val, const word &key)
Deprecated(2021-09) Read control parameter from dictionary.
virtual void read(const dictionary &solverDict)
Read and reset the solver parameters from the given dictionary.
virtual SolverPerformance< Type > solve(Field< Type > &psi) const =0
Type normFactor(const Field< Type > &psi, const Field< Type > &Apsi, Field< Type > &tmpField) const
Return the matrix norm used to normalise the residual for the.
label minIter_
Minimum number of iterations in the solver.
Type tolerance_
Final convergence tolerance.
declareRunTimeSelectionTable(autoPtr, solver, asymMatrix,(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix, const dictionary &solverDict),(fieldName, matrix, solverDict))
int log_
Level of verbosity in the solver output statements.
virtual ~solver()=default
virtual void readControls()
Read the control parameters from the controlDict_.
const LduMatrix< Type, DType, LUType > & matrix_
declareRunTimeSelectionTable(autoPtr, solver, symMatrix,(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix, const dictionary &solverDict),(fieldName, matrix, solverDict))
static autoPtr< solver > New(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix, const dictionary &solverDict)
Return a new solver.
dictionary controlDict_
Dictionary of controls.
virtual const word & type() const =0
Runtime type information.
const word & fieldName() const noexcept
LduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
FieldField< Field, LUType > & interfacesLower()
void Amul(Field< Type > &, const tmp< Field< Type > > &) const
Matrix multiplication.
LduMatrix(const LduMatrix< Type, DType, LUType > &)
Construct as copy.
FieldField< Field, LUType > & interfacesUpper()
void sumA(Field< Type > &) const
Sum the coefficients on each row of the matrix.
const lduAddressing & lduAddr() const
Return the LDU addressing.
const LduInterfaceFieldPtrsList< Type > & interfaces() const
Return interfaces.
void updateMatrixInterfaces(const bool add, const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Update interfaced interfaces for matrix operations.
tmp< Field< Type > > H(const Field< Type > &) const
Field< LUType > & upper()
LduMatrix(LduMatrix< Type, DType, LUType > &, bool reuse)
Construct as copy or re-use as specified.
const FieldField< Field, LUType > & interfacesUpper() const
void operator+=(const LduMatrix< Type, DType, LUType > &)
const lduMesh & mesh() const
Return the LDU mesh from which the addressing is obtained.
LduInterfaceFieldPtrsList< Type > & interfaces()
Return interfaces.
const lduSchedule & patchSchedule() const
Return the patch evaluation schedule.
void operator=(const LduMatrix< Type, DType, LUType > &)
void operator*=(const scalarField &)
void sumMagOffDiag(Field< LUType > &sumOff) const
void residual(Field< Type > &rA, const Field< Type > &psi) const
tmp< Field< Type > > faceH(const Field< Type > &) const
void initMatrixInterfaces(const bool add, const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Initialise the update of interfaced interfaces.
const FieldField< Field, LUType > & interfacesLower() const
void operator-=(const LduMatrix< Type, DType, LUType > &)
void Tmul(Field< Type > &, const tmp< Field< Type > > &) const
Matrix transpose multiplication.
Field< LUType > & lower()
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
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,...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
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 meshes which provide LDU addressing for the construction of lduMatrix and LDU...
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
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.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
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)