53 #ifndef Foam_LduMatrix_H 54 #define Foam_LduMatrix_H 73 template<
class Type,
class DType,
class LUType>
class LduMatrix;
75 template<
class Type,
class DType,
class LUType>
87 template<
class Type,
class DType,
class LUType>
96 std::unique_ptr<Field<DType>> diagPtr_;
99 std::unique_ptr<Field<LUType>> upperPtr_;
102 std::unique_ptr<Field<LUType>> lowerPtr_;
105 std::unique_ptr<Field<Type>> sourcePtr_;
174 virtual const word&
type()
const = 0;
299 virtual const word&
type()
const = 0;
397 virtual const word&
type()
const = 0;
409 const dictionary& preconditionerDict
411 (sol, preconditionerDict)
423 (sol, preconditionerDict)
494 LduMatrix(
const LduMatrix<Type, DType, LUType>&);
524 return lduMesh_.lduAddr();
530 return lduMesh_.lduAddr().patchSchedule();
563 return interfacesUpper_;
568 return interfacesLower_;
573 return interfacesUpper_;
578 return interfacesLower_;
595 return (diagPtr_ && !lowerPtr_ && !upperPtr_);
601 return (diagPtr_ && !lowerPtr_ && upperPtr_);
607 return (diagPtr_ && lowerPtr_ && upperPtr_);
651 const label startRequest
681 friend Ostream& operator<< <Type, DType, LUType>
695 #define makeLduMatrix(Type, DType, LUType) \ 697 typedef Foam::LduMatrix<Type, DType, LUType> \ 698 ldu##Type##DType##LUType##Matrix; \ 700 defineNamedTemplateTypeNameAndDebug(ldu##Type##DType##LUType##Matrix, 0); \ 703 typedef LduMatrix<Type, DType, LUType>::smoother \ 704 ldu##Type##DType##LUType##Smoother; \ 706 defineTemplateRunTimeSelectionTable \ 708 ldu##Type##DType##LUType##Smoother, \ 712 defineTemplateRunTimeSelectionTable \ 714 ldu##Type##DType##LUType##Smoother, \ 719 typedef LduMatrix<Type, DType, LUType>::preconditioner \ 720 ldu##Type##DType##LUType##Preconditioner; \ 722 defineTemplateRunTimeSelectionTable \ 724 ldu##Type##DType##LUType##Preconditioner, \ 728 defineTemplateRunTimeSelectionTable \ 730 ldu##Type##DType##LUType##Preconditioner, \ 735 typedef LduMatrix<Type, DType, LUType>::solver \ 736 ldu##Type##DType##LUType##Solver; \ 738 defineTemplateRunTimeSelectionTable \ 740 ldu##Type##DType##LUType##Solver, \ 744 defineTemplateRunTimeSelectionTable \ 746 ldu##Type##DType##LUType##Solver, \ 751 #define makeLduPreconditioner(Precon, Type, DType, LUType) \ 753 typedef Precon<Type, DType, LUType> \ 754 Precon##Type##DType##LUType##Preconditioner; \ 755 defineNamedTemplateTypeNameAndDebug \ 757 Precon##Type##DType##LUType##Preconditioner, \ 761 #define makeLduSymPreconditioner(Precon, Type, DType, LUType) \ 763 LduMatrix<Type, DType, LUType>::preconditioner:: \ 764 addsymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \ 765 add##Precon##Type##DType##LUType##PreconditionerSymMatrixConstructorToTable_; 767 #define makeLduAsymPreconditioner(Precon, Type, DType, LUType) \ 769 LduMatrix<Type, DType, LUType>::preconditioner:: \ 770 addasymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \ 771 add##Precon##Type##DType##LUType##PreconditionerAsymMatrixConstructorToTable_; 774 #define makeLduSmoother(Smoother, Type, DType, LUType) \ 776 typedef Smoother<Type, DType, LUType> \ 777 Smoother##Type##DType##LUType##Smoother; \ 779 defineNamedTemplateTypeNameAndDebug \ 781 Smoother##Type##DType##LUType##Smoother, \ 785 #define makeLduSymSmoother(Smoother, Type, DType, LUType) \ 787 LduMatrix<Type, DType, LUType>::smoother:: \ 788 addsymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \ 789 add##Smoother##Type##DType##LUType##SymMatrixConstructorToTable_; 791 #define makeLduAsymSmoother(Smoother, Type, DType, LUType) \ 793 LduMatrix<Type, DType, LUType>::smoother:: \ 794 addasymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \ 795 add##Smoother##Type##DType##LUType##AsymMatrixConstructorToTable_; 798 #define makeLduSolver(Solver, Type, DType, LUType) \ 800 typedef Solver<Type, DType, LUType> \ 801 Solver##Type##DType##LUType##Solver; \ 803 defineNamedTemplateTypeNameAndDebug \ 805 Solver##Type##DType##LUType##Solver, \ 809 #define makeLduSymSolver(Solver, Type, DType, LUType) \ 811 LduMatrix<Type, DType, LUType>::solver:: \ 812 addsymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \ 813 add##Solver##Type##DType##LUType##SymMatrixConstructorToTable_; 815 #define makeLduAsymSolver(Solver, Type, DType, LUType) \ 817 LduMatrix<Type, DType, LUType>::solver:: \ 818 addasymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \ 819 add##Solver##Type##DType##LUType##AsymMatrixConstructorToTable_; smoother(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix)
Construct for given field name and matrix.
void initMatrixInterfaces(const bool add, const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Initialise the update of interfaced interfaces.
virtual const word & type() const =0
Runtime type information.
void readControl(const dictionary &dict, T &val, const word &key)
Deprecated(2021-09) Read control parameter from dictionary.
virtual void preconditionT(Field< Type > &wT, const Field< Type > &rT) const
Return wT the transpose-matrix preconditioned form of residual rT.
virtual const word & type() const =0
Runtime type information.
const Field< DType > & diag() const
static autoPtr< preconditioner > New(const solver &sol, const dictionary &preconditionerDict)
Return a new preconditioner.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
LduMatrix(const lduMesh &mesh)
Construct given an LDU addressed mesh.
const LduMatrix< Type, DType, LUType > & matrix() const noexcept
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Type normFactor(const Field< Type > &psi, const Field< Type > &Apsi, Field< Type > &tmpField, const lduMatrix::normTypes normType) const
Return the matrix norm using the specified norm method.
void sumMagOffDiag(Field< LUType > &sumOff) const
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
static autoPtr< smoother > New(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix, const dictionary &smootherDict)
Return a new smoother.
virtual void precondition(Field< Type > &wA, const Field< Type > &rA) const =0
Return wA the preconditioned form of residual rA.
label minIter_
Minimum number of iterations in the solver.
const LduMatrix< Type, DType, LUType > & matrix() const noexcept
void sumA(Field< Type > &) const
Sum the coefficients on each row of the matrix.
A field of fields is a PtrList of fields with reference counting.
dictionary controlDict_
Dictionary of solution controls.
virtual const word & type() const =0
Runtime type information.
virtual void smooth(Field< Type > &psi, const label nSweeps) const =0
Smooth the solution for a given number of sweeps.
void Amul(Field< Type > &, const tmp< Field< Type >> &) const
Matrix multiplication.
int log_
Verbosity level for solver output statements.
Generic templated field type.
Abstract base-class for LduMatrix smoothers.
A class for handling words, derived from Foam::string.
lduMatrix::normTypes normType_
The matrix normalisation type.
bool hasSource() const noexcept
tmp< Field< Type > > H(const Field< Type > &) const
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full)
const lduSchedule & patchSchedule() const
Return the patch evaluation schedule.
virtual void read(const dictionary &)
Read and reset the preconditioner parameters from the given dictionary.
void operator*=(const scalarField &)
void updateMatrixInterfaces(const bool add, const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result, const label startRequest) const
Update interfaced interfaces for matrix operations.
normTypes
Enumerated matrix normalisation types.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
virtual ~smoother()=default
Destructor.
void operator-=(const LduMatrix< Type, DType, LUType > &)
Abstract base-class for LduMatrix solvers.
const word & fieldName() const noexcept
void residual(Field< Type > &rA, const Field< Type > &psi) const
preconditioner(const solver &sol)
Construct for given solver.
const LduMatrix< Type, DType, LUType > & matrix_
An Ostream is an abstract base class for all output systems (streams, files, token lists...
solver(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix, const dictionary &solverDict)
Construct for given field name, matrix and controls.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
const LduInterfaceFieldPtrsList< Type > & interfaces() const noexcept
Const access to the interfaces.
const word & fieldName() const noexcept
void Tmul(Field< Type > &, const tmp< Field< Type >> &) const
Matrix transpose multiplication.
const lduAddressing & lduAddr() const
Return the LDU addressing.
const solver & solver_
Reference to the base-solver this preconditioner is used with.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool hasUpper() const noexcept
const FieldField< Field, LUType > & interfacesLower() const noexcept
const Field< LUType > & upper() const
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...
const Field< LUType > & lower() const
declareRunTimeSelectionTable(autoPtr, preconditioner, symMatrix,(const solver &sol, const dictionary &preconditionerDict),(sol, preconditionerDict))
virtual ~solver()=default
Destructor.
declareRunTimeSelectionTable(autoPtr, smoother, symMatrix,(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix),(fieldName, matrix))
virtual void read(const dictionary &)
Read and reset the solver parameters from the given dictionary.
Type relTol_
Convergence tolerance relative to the initial.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
bool diagonal() const noexcept
Matrix has diagonal only.
LduMatrix is a general matrix class in which the coefficients are stored as three arrays...
label maxIter_
Maximum number of iterations in the solver.
bool hasLower() const noexcept
void operator+=(const LduMatrix< Type, DType, LUType > &)
tmp< Field< Type > > faceH(const Field< Type > &) const
static autoPtr< solver > New(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix, const dictionary &solverDict)
Return a new solver.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
const volScalarField & psi
The class contains the addressing required by the lduMatrix: upper, lower and losort.
virtual SolverPerformance< Type > solve(Field< Type > &psi) const =0
const LduMatrix< Type, DType, LUType > & matrix_
Macros to ease declaration of run-time selection tables.
virtual void readControls()
Read the control parameters from controlDict_.
const FieldField< Field, LUType > & interfacesUpper() const noexcept
A class for managing temporary objects.
virtual ~preconditioner()=default
Destructor.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
const Field< Type > & source() const
declareRunTimeSelectionTable(autoPtr, solver, symMatrix,(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix, const dictionary &solverDict),(fieldName, matrix, solverDict))
void operator=(const LduMatrix< Type, DType, LUType > &)
Copy assignment.
List of coupled interface fields to be used in coupling.
bool hasDiag() const noexcept
Type tolerance_
Final convergence tolerance.
~LduMatrix()=default
Destructor.
bool symmetric() const noexcept
Matrix is symmetric.
word matrixTypeName() const
The matrix type (empty, diagonal, symmetric, ...)