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>
291 virtual const word&
type()
const = 0;
388 virtual const word&
type()
const = 0;
400 const dictionary& preconditionerDict
402 (sol, preconditionerDict)
414 (sol, preconditionerDict)
482 LduMatrix(
const LduMatrix<Type, DType, LUType>&);
509 return lduMesh_.lduAddr();
540 return interfacesUpper_;
545 return interfacesLower_;
556 return interfacesUpper_;
561 return interfacesLower_;
587 return (diagPtr_ && !lowerPtr_ && !upperPtr_);
592 return (diagPtr_ && (!lowerPtr_ && upperPtr_));
597 return (diagPtr_ && lowerPtr_ && upperPtr_);
641 const label startRequest
667 friend Ostream& operator<< <Type, DType, LUType>
681 #define makeLduMatrix(Type, DType, LUType) \ 683 typedef Foam::LduMatrix<Type, DType, LUType> \ 684 ldu##Type##DType##LUType##Matrix; \ 686 defineNamedTemplateTypeNameAndDebug(ldu##Type##DType##LUType##Matrix, 0); \ 689 typedef LduMatrix<Type, DType, LUType>::smoother \ 690 ldu##Type##DType##LUType##Smoother; \ 692 defineTemplateRunTimeSelectionTable \ 694 ldu##Type##DType##LUType##Smoother, \ 698 defineTemplateRunTimeSelectionTable \ 700 ldu##Type##DType##LUType##Smoother, \ 705 typedef LduMatrix<Type, DType, LUType>::preconditioner \ 706 ldu##Type##DType##LUType##Preconditioner; \ 708 defineTemplateRunTimeSelectionTable \ 710 ldu##Type##DType##LUType##Preconditioner, \ 714 defineTemplateRunTimeSelectionTable \ 716 ldu##Type##DType##LUType##Preconditioner, \ 721 typedef LduMatrix<Type, DType, LUType>::solver \ 722 ldu##Type##DType##LUType##Solver; \ 724 defineTemplateRunTimeSelectionTable \ 726 ldu##Type##DType##LUType##Solver, \ 730 defineTemplateRunTimeSelectionTable \ 732 ldu##Type##DType##LUType##Solver, \ 737 #define makeLduPreconditioner(Precon, Type, DType, LUType) \ 739 typedef Precon<Type, DType, LUType> \ 740 Precon##Type##DType##LUType##Preconditioner; \ 741 defineNamedTemplateTypeNameAndDebug \ 743 Precon##Type##DType##LUType##Preconditioner, \ 747 #define makeLduSymPreconditioner(Precon, Type, DType, LUType) \ 749 LduMatrix<Type, DType, LUType>::preconditioner:: \ 750 addsymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \ 751 add##Precon##Type##DType##LUType##PreconditionerSymMatrixConstructorToTable_; 753 #define makeLduAsymPreconditioner(Precon, Type, DType, LUType) \ 755 LduMatrix<Type, DType, LUType>::preconditioner:: \ 756 addasymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \ 757 add##Precon##Type##DType##LUType##PreconditionerAsymMatrixConstructorToTable_; 760 #define makeLduSmoother(Smoother, Type, DType, LUType) \ 762 typedef Smoother<Type, DType, LUType> \ 763 Smoother##Type##DType##LUType##Smoother; \ 765 defineNamedTemplateTypeNameAndDebug \ 767 Smoother##Type##DType##LUType##Smoother, \ 771 #define makeLduSymSmoother(Smoother, Type, DType, LUType) \ 773 LduMatrix<Type, DType, LUType>::smoother:: \ 774 addsymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \ 775 add##Smoother##Type##DType##LUType##SymMatrixConstructorToTable_; 777 #define makeLduAsymSmoother(Smoother, Type, DType, LUType) \ 779 LduMatrix<Type, DType, LUType>::smoother:: \ 780 addasymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \ 781 add##Smoother##Type##DType##LUType##AsymMatrixConstructorToTable_; 784 #define makeLduSolver(Solver, Type, DType, LUType) \ 786 typedef Solver<Type, DType, LUType> \ 787 Solver##Type##DType##LUType##Solver; \ 789 defineNamedTemplateTypeNameAndDebug \ 791 Solver##Type##DType##LUType##Solver, \ 795 #define makeLduSymSolver(Solver, Type, DType, LUType) \ 797 LduMatrix<Type, DType, LUType>::solver:: \ 798 addsymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \ 799 add##Solver##Type##DType##LUType##SymMatrixConstructorToTable_; 801 #define makeLduAsymSolver(Solver, Type, DType, LUType) \ 803 LduMatrix<Type, DType, LUType>::solver:: \ 804 addasymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \ 805 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.
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...
FieldField< Field, LUType > & interfacesLower()
const LduMatrix< Type, DType, LUType > & matrix() const noexcept
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
LduMatrix(const lduMesh &)
Construct given an LDU addressed mesh.
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.
Field< LUType > & lower()
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.
Abstract base-class for LduMatrix smoothers.
A class for handling words, derived from Foam::string.
lduMatrix::normTypes normType_
The matrix normalisation type.
Abstract base-class for LduMatrix preconditioners.
bool hasSource() const noexcept
tmp< Field< Type > > H(const Field< Type > &) const
bool asymmetric() const noexcept
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 &)
Field< LUType > & upper()
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 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
declareRunTimeSelectionTable(autoPtr, preconditioner, symMatrix,(const solver &sol, const dictionary &preconditionerDict),(sol, preconditionerDict))
virtual ~solver()=default
Destructor.
const LduInterfaceFieldPtrsList< Type > & interfaces() const
Return interfaces.
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
FieldField< Field, LUType > & interfacesUpper()
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_.
A class for managing temporary objects.
virtual ~preconditioner()=default
Destructor.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
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 > &)
List of coupled interface fields to be used in coupling.
bool hasDiag() const noexcept
Type tolerance_
Final convergence tolerance.
bool symmetric() const noexcept
virtual const lduSchedule & patchSchedule() const =0
Return patch field evaluation schedule.