LduMatrix.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::LduMatrix
29 
30 Description
31  LduMatrix is a general matrix class in which the coefficients are
32  stored as three arrays, one for the upper triangle, one for the
33  lower triangle and a third for the diagonal.
34 
35  Addressing arrays must be supplied for the upper and lower triangles.
36 
37 Note
38  It might be better if this class were organised as a hierarchy starting
39  from an empty matrix, then deriving diagonal, symmetric and asymmetric
40  matrices.
41 
42 SourceFiles
43  LduMatrixATmul.C
44  LduMatrix.C
45  LduMatrixOperations.C
46  LduMatrixSolver.C
47  LduMatrixPreconditioner.C
48  LduMatrixTests.C
49  LduMatrixUpdateMatrixInterfaces.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef Foam_LduMatrix_H
54 #define Foam_LduMatrix_H
55 
56 #include "lduMesh.H"
57 #include "lduMatrix.H"
58 #include "Field.H"
59 #include "FieldField.H"
61 #include "SolverPerformance.H"
62 #include "typeInfo.H"
63 #include "autoPtr.H"
64 #include "runTimeSelectionTables.H"
65 
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 
68 namespace Foam
69 {
70 
71 // Forward Declarations
72 
73 template<class Type, class DType, class LUType> class LduMatrix;
74 
75 template<class Type, class DType, class LUType>
76 Ostream& operator<<
77 (
78  Ostream&,
80 );
81 
82 
83 /*---------------------------------------------------------------------------*\
84  Class LduMatrix Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 template<class Type, class DType, class LUType>
88 class LduMatrix
89 {
90  // Private Data
91 
92  //- LDU mesh reference
93  const lduMesh& lduMesh_;
94 
95  //- Diagonal coefficients
96  std::unique_ptr<Field<DType>> diagPtr_;
97 
98  //- Off-diagonal coefficients
99  std::unique_ptr<Field<LUType>> upperPtr_;
100 
101  //- Off-diagonal coefficients
102  std::unique_ptr<Field<LUType>> lowerPtr_;
103 
104  //- Source
105  std::unique_ptr<Field<Type>> sourcePtr_;
106 
107  //- Field interfaces (processor patches etc.)
109 
110  //- Off-diagonal coefficients for interfaces
111  FieldField<Field, LUType> interfacesUpper_;
112 
113  //- Off-diagonal coefficients for interfaces
114  FieldField<Field, LUType> interfacesLower_;
115 
116 
117 public:
118 
119  friend class SolverPerformance<Type>;
120 
121  // -----------------------------------------------------------------------
122  //- Abstract base-class for LduMatrix solvers
123  class solver
124  {
125  protected:
126 
127  // Protected Data
128 
131 
132  //- Dictionary of solution controls
134 
135  //- Verbosity level for solver output statements
136  int log_;
137 
138  //- Minimum number of iterations in the solver
139  label minIter_;
140 
141  //- Maximum number of iterations in the solver
142  label maxIter_;
144  //- The matrix normalisation type
146 
147  //- Final convergence tolerance
149 
150  //- Convergence tolerance relative to the initial
151  Type relTol_;
152 
154  // Protected Member Functions
155 
156  //- Read the control parameters from controlDict_
157  virtual void readControls();
159 
160  // Housekeeping
161 
162  //- Deprecated(2021-09) Read control parameter from dictionary
163  // \deprecated(2021-09) - use dictionary methods directly
164  template<class T>
165  void readControl(const dictionary& dict, T& val, const word& key)
166  {
167  dict.readIfPresent(key, val);
168  }
169 
170 
171  public:
172 
173  //- Runtime type information
174  virtual const word& type() const = 0;
175 
176 
177  // Declare run-time constructor selection tables
180  (
181  autoPtr,
182  solver,
183  symMatrix,
184  (
185  const word& fieldName,
187  const dictionary& solverDict
188  ),
189  (
190  fieldName,
191  matrix,
192  solverDict
193  )
194  );
195 
197  (
198  autoPtr,
199  solver,
200  asymMatrix,
201  (
202  const word& fieldName,
204  const dictionary& solverDict
205  ),
206  (
207  fieldName,
208  matrix,
209  solverDict
210  )
211  );
212 
213 
214  // Constructors
215 
216  //- Construct for given field name, matrix and controls
217  solver
218  (
219  const word& fieldName,
221  const dictionary& solverDict
222  );
223 
224 
225  // Selectors
226 
227  //- Return a new solver
228  static autoPtr<solver> New
229  (
230  const word& fieldName,
232  const dictionary& solverDict
233  );
234 
235 
236  //- Destructor
237  virtual ~solver() = default;
238 
239 
240  // Member Functions
241 
242  const word& fieldName() const noexcept
243  {
244  return fieldName_;
245  }
246 
248  {
249  return matrix_;
250  }
251 
252 
253  //- Read and reset the solver parameters from the given dictionary
254  virtual void read(const dictionary&);
255 
257  (
259  ) const = 0;
260 
261  //- Return the matrix norm using the specified norm method
262  Type normFactor
263  (
264  const Field<Type>& psi,
265  const Field<Type>& Apsi,
266  Field<Type>& tmpField,
267  const lduMatrix::normTypes normType
268  ) const;
269 
270  //- Return the matrix norm used to normalise the residual for the
271  //- stopping criterion
272  Type normFactor
273  (
274  const Field<Type>& psi,
275  const Field<Type>& Apsi,
276  Field<Type>& tmpField
277  ) const
278  {
279  return this->normFactor(psi, Apsi, tmpField, normType_);
280  }
281  };
283 
284  // -----------------------------------------------------------------------
285  //- Abstract base-class for LduMatrix smoothers
286  class smoother
287  {
288  protected:
289 
290  // Protected Data
291 
294 
295 
296  public:
297 
298  //- Runtime type information
299  virtual const word& type() const = 0;
300 
301 
302  // Declare run-time constructor selection tables
303 
305  (
306  autoPtr,
307  smoother,
308  symMatrix,
309  (
310  const word& fieldName,
312  ),
313  (
314  fieldName,
315  matrix
316  )
317  );
318 
320  (
321  autoPtr,
322  smoother,
323  asymMatrix,
324  (
325  const word& fieldName,
327  ),
328  (
329  fieldName,
330  matrix
331  )
332  );
333 
335  // Constructors
336 
337  //- Construct for given field name and matrix
338  smoother
339  (
340  const word& fieldName,
342  );
343 
344 
345  // Selectors
346 
347  //- Return a new smoother
348  static autoPtr<smoother> New
349  (
350  const word& fieldName,
352  const dictionary& smootherDict
353  );
354 
355 
356  //- Destructor
357  virtual ~smoother() = default;
358 
359 
360  // Member Functions
361 
362  const word& fieldName() const noexcept
363  {
364  return fieldName_;
365  }
366 
368  {
369  return matrix_;
370  }
371 
372 
373  //- Smooth the solution for a given number of sweeps
374  virtual void smooth
375  (
376  Field<Type>& psi,
377  const label nSweeps
378  ) const = 0;
379  };
380 
381 
382  // -----------------------------------------------------------------------
383  //- Abstract base-class for LduMatrix preconditioners
384  class preconditioner
385  {
386  protected:
387 
388  // Protected Data
389 
390  //- Reference to the base-solver this preconditioner is used with
391  const solver& solver_;
392 
393 
394  public:
395 
396  //- Runtime type information
397  virtual const word& type() const = 0;
398 
399 
400  // Declare run-time constructor selection tables
401 
403  (
404  autoPtr,
406  symMatrix,
407  (
408  const solver& sol,
409  const dictionary& preconditionerDict
410  ),
411  (sol, preconditionerDict)
412  );
413 
415  (
416  autoPtr,
418  asymMatrix,
419  (
420  const solver& sol,
421  const dictionary& preconditionerDict
422  ),
423  (sol, preconditionerDict)
424  );
425 
426 
427  // Constructors
428 
429  //- Construct for given solver
430  preconditioner(const solver& sol)
431  :
432  solver_(sol)
433  {}
434 
435 
436  // Selectors
437 
438  //- Return a new preconditioner
440  (
441  const solver& sol,
442  const dictionary& preconditionerDict
443  );
445 
446  //- Destructor
447  virtual ~preconditioner() = default;
448 
449 
450  // Member functions
451 
452  //- Read and reset the preconditioner parameters
453  //- from the given dictionary
454  virtual void read(const dictionary&)
455  {}
456 
457  //- Return wA the preconditioned form of residual rA
458  virtual void precondition
459  (
460  Field<Type>& wA,
461  const Field<Type>& rA
462  ) const = 0;
463 
464  //- Return wT the transpose-matrix preconditioned form of
465  //- residual rT.
466  // This is only required for preconditioning asymmetric matrices.
467  virtual void preconditionT
468  (
469  Field<Type>& wT,
470  const Field<Type>& rT
471  ) const
472  {
474  }
475  };
476 
477 
478  // -----------------------------------------------------------------------
479 
480  // Static Data
481 
482  // Declare name of the class and its debug switch
483  ClassName("LduMatrix");
484 
485 
486  // Constructors
487 
488  //- Construct given an LDU addressed mesh.
489  // The coefficients are initially empty for subsequent setting.
490  // Not yet 'explicit' (legacy code may rely on implicit construct)
491  LduMatrix(const lduMesh& mesh);
492 
493  //- Copy construct
494  LduMatrix(const LduMatrix<Type, DType, LUType>&);
495 
496  //- Move construct
498 
499  //- Construct as copy or re-use as specified.
501 
502  //- Construct given an LDU addressed mesh and an Istream
503  //- from which the coefficients are read
504  LduMatrix(const lduMesh& mesh, Istream& is);
505 
506 
507  //- Destructor
508  ~LduMatrix() = default;
509 
510 
511  // Member Functions
512 
513  // Addressing
514 
515  //- Return the LDU mesh from which the addressing is obtained
516  const lduMesh& mesh() const noexcept
517  {
518  return lduMesh_;
519  }
520 
521  //- Return the LDU addressing
522  const lduAddressing& lduAddr() const
523  {
524  return lduMesh_.lduAddr();
525  }
527  //- Return the patch evaluation schedule
528  const lduSchedule& patchSchedule() const
529  {
530  return lduMesh_.lduAddr().patchSchedule();
531  }
532 
533  //- Const access to the interfaces
535  {
536  return interfaces_;
537  }
538 
539  //- Non-const access to the interfaces
541  {
542  return interfaces_;
543  }
544 
546  // Coefficients
547 
548  const Field<DType>& diag() const;
549  const Field<LUType>& upper() const;
550  const Field<LUType>& lower() const;
551  const Field<Type>& source() const;
552 
553  Field<DType>& diag();
554  Field<LUType>& upper();
555  Field<LUType>& lower();
556  Field<Type>& source();
557 
558 
559  // Interfaces
560 
562  {
563  return interfacesUpper_;
564  }
565 
567  {
568  return interfacesLower_;
569  }
570 
572  {
573  return interfacesUpper_;
574  }
575 
576  FieldField<Field, LUType>& interfacesLower() noexcept
577  {
578  return interfacesLower_;
579  }
580 
581 
582  // Characteristics
583 
584  //- The matrix type (empty, diagonal, symmetric, ...)
585  word matrixTypeName() const;
586 
587  bool hasDiag() const noexcept { return bool(diagPtr_); }
588  bool hasUpper() const noexcept { return bool(upperPtr_); }
589  bool hasLower() const noexcept { return bool(lowerPtr_); }
590  bool hasSource() const noexcept { return bool(sourcePtr_); }
591 
592  //- Matrix has diagonal only
593  bool diagonal() const noexcept
594  {
595  return (diagPtr_ && !lowerPtr_ && !upperPtr_);
596  }
597 
598  //- Matrix is symmetric
599  bool symmetric() const noexcept
600  {
601  return (diagPtr_ && !lowerPtr_ && upperPtr_);
602  }
603 
604  //- Matrix is asymmetric (ie, full)
605  bool asymmetric() const noexcept
606  {
607  return (diagPtr_ && lowerPtr_ && upperPtr_);
608  }
609 
610 
611  // Operations
612 
613  void sumDiag();
614  void negSumDiag();
615 
616  void sumMagOffDiag(Field<LUType>& sumOff) const;
617 
618  //- Matrix multiplication
619  void Amul(Field<Type>&, const tmp<Field<Type>>&) const;
620 
621  //- Matrix transpose multiplication
622  void Tmul(Field<Type>&, const tmp<Field<Type>>&) const;
623 
625  //- Sum the coefficients on each row of the matrix
626  void sumA(Field<Type>&) const;
627 
628 
629  void residual(Field<Type>& rA, const Field<Type>& psi) const;
630 
631  tmp<Field<Type>> residual(const Field<Type>& psi) const;
633 
634  //- Initialise the update of interfaced interfaces
635  // for matrix operations
637  (
638  const bool add,
639  const FieldField<Field, LUType>& interfaceCoeffs,
640  const Field<Type>& psiif,
641  Field<Type>& result
642  ) const;
643 
644  //- Update interfaced interfaces for matrix operations
646  (
647  const bool add,
648  const FieldField<Field, LUType>& interfaceCoeffs,
649  const Field<Type>& psiif,
650  Field<Type>& result,
651  const label startRequest // starting request (for non-blocking)
652  ) const;
653 
654 
655  tmp<Field<Type>> H(const Field<Type>&) const;
656  tmp<Field<Type>> H(const tmp<Field<Type>>&) const;
657 
658  tmp<Field<Type>> faceH(const Field<Type>&) const;
659  tmp<Field<Type>> faceH(const tmp<Field<Type>>&) const;
660 
662  // Member Operators
663 
664  //- Copy assignment
667  //- Move assignment
669 
670  void negate();
674 
675  void operator*=(const scalarField&);
676  void operator*=(scalar);
677 
678 
679  // Ostream Operator
680 
681  friend Ostream& operator<< <Type, DType, LUType>
682  (
683  Ostream&,
685  );
686 };
687 
688 
689 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
691 } // End namespace Foam
693 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
694 
695 #define makeLduMatrix(Type, DType, LUType) \
696  \
697 typedef Foam::LduMatrix<Type, DType, LUType> \
698  ldu##Type##DType##LUType##Matrix; \
699  \
700 defineNamedTemplateTypeNameAndDebug(ldu##Type##DType##LUType##Matrix, 0); \
701  \
702  \
703 typedef LduMatrix<Type, DType, LUType>::smoother \
704  ldu##Type##DType##LUType##Smoother; \
705  \
706 defineTemplateRunTimeSelectionTable \
707 ( \
708  ldu##Type##DType##LUType##Smoother, \
709  symMatrix \
710 ); \
711  \
712 defineTemplateRunTimeSelectionTable \
713 ( \
714  ldu##Type##DType##LUType##Smoother, \
715  asymMatrix \
716 ); \
717  \
718  \
719 typedef LduMatrix<Type, DType, LUType>::preconditioner \
720  ldu##Type##DType##LUType##Preconditioner; \
721  \
722 defineTemplateRunTimeSelectionTable \
723 ( \
724  ldu##Type##DType##LUType##Preconditioner, \
725  symMatrix \
726 ); \
727  \
728 defineTemplateRunTimeSelectionTable \
729 ( \
730  ldu##Type##DType##LUType##Preconditioner, \
731  asymMatrix \
732 ); \
733  \
734  \
735 typedef LduMatrix<Type, DType, LUType>::solver \
736  ldu##Type##DType##LUType##Solver; \
737  \
738 defineTemplateRunTimeSelectionTable \
739 ( \
740  ldu##Type##DType##LUType##Solver, \
741  symMatrix \
742 ); \
743  \
744 defineTemplateRunTimeSelectionTable \
745 ( \
746  ldu##Type##DType##LUType##Solver, \
747  asymMatrix \
748 );
749 
750 
751 #define makeLduPreconditioner(Precon, Type, DType, LUType) \
752  \
753 typedef Precon<Type, DType, LUType> \
754  Precon##Type##DType##LUType##Preconditioner; \
755 defineNamedTemplateTypeNameAndDebug \
756 ( \
757  Precon##Type##DType##LUType##Preconditioner, \
758  0 \
759 );
760 
761 #define makeLduSymPreconditioner(Precon, Type, DType, LUType) \
762  \
763 LduMatrix<Type, DType, LUType>::preconditioner:: \
764 addsymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \
765 add##Precon##Type##DType##LUType##PreconditionerSymMatrixConstructorToTable_;
766 
767 #define makeLduAsymPreconditioner(Precon, Type, DType, LUType) \
768  \
769 LduMatrix<Type, DType, LUType>::preconditioner:: \
770 addasymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \
771 add##Precon##Type##DType##LUType##PreconditionerAsymMatrixConstructorToTable_;
772 
773 
774 #define makeLduSmoother(Smoother, Type, DType, LUType) \
775  \
776 typedef Smoother<Type, DType, LUType> \
777  Smoother##Type##DType##LUType##Smoother; \
778  \
779 defineNamedTemplateTypeNameAndDebug \
780 ( \
781  Smoother##Type##DType##LUType##Smoother, \
782  0 \
783 );
784 
785 #define makeLduSymSmoother(Smoother, Type, DType, LUType) \
786  \
787 LduMatrix<Type, DType, LUType>::smoother:: \
788  addsymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \
789  add##Smoother##Type##DType##LUType##SymMatrixConstructorToTable_;
790 
791 #define makeLduAsymSmoother(Smoother, Type, DType, LUType) \
792  \
793 LduMatrix<Type, DType, LUType>::smoother:: \
794  addasymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \
795  add##Smoother##Type##DType##LUType##AsymMatrixConstructorToTable_;
796 
797 
798 #define makeLduSolver(Solver, Type, DType, LUType) \
799  \
800 typedef Solver<Type, DType, LUType> \
801  Solver##Type##DType##LUType##Solver; \
802  \
803 defineNamedTemplateTypeNameAndDebug \
804 ( \
805  Solver##Type##DType##LUType##Solver, \
806  0 \
807 );
808 
809 #define makeLduSymSolver(Solver, Type, DType, LUType) \
810  \
811 LduMatrix<Type, DType, LUType>::solver:: \
812  addsymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \
813  add##Solver##Type##DType##LUType##SymMatrixConstructorToTable_;
814 
815 #define makeLduAsymSolver(Solver, Type, DType, LUType) \
816  \
817 LduMatrix<Type, DType, LUType>::solver:: \
818  addasymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \
819  add##Solver##Type##DType##LUType##AsymMatrixConstructorToTable_;
820 
821 
822 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
823 
824 #ifdef NoRepository
825  #include "LduMatrix.C"
826 #endif
827 
828 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
829 
830 #endif
831 
832 // ************************************************************************* //
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.
Definition: LduMatrix.H:197
dictionary dict
virtual void preconditionT(Field< Type > &wT, const Field< Type > &rT) const
Return wT the transpose-matrix preconditioned form of residual rT.
Definition: LduMatrix.H:545
virtual const word & type() const =0
Runtime type information.
const Field< DType > & diag() const
Definition: LduMatrix.C:151
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...
Definition: dictionary.H:129
LduMatrix(const lduMesh &mesh)
Construct given an LDU addressed mesh.
Definition: LduMatrix.C:28
const LduMatrix< Type, DType, LUType > & matrix() const noexcept
Definition: LduMatrix.H:423
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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...
Definition: lduMesh.H:53
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.
Definition: LduMatrix.H:158
const LduMatrix< Type, DType, LUType > & matrix() const noexcept
Definition: LduMatrix.H:287
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.
Definition: FieldField.H:51
dictionary controlDict_
Dictionary of solution controls.
Definition: LduMatrix.H:148
virtual const word & type() const =0
Runtime type information.
ClassName("LduMatrix")
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.
Definition: LduMatrix.H:153
Generic templated field type.
Definition: Field.H:62
Abstract base-class for LduMatrix smoothers.
Definition: LduMatrix.H:334
A class for handling words, derived from Foam::string.
Definition: word.H:63
lduMatrix::normTypes normType_
The matrix normalisation type.
Definition: LduMatrix.H:168
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics...
bool hasSource() const noexcept
Definition: LduMatrix.H:692
tmp< Field< Type > > H(const Field< Type > &) const
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full)
Definition: LduMatrix.H:713
const lduSchedule & patchSchedule() const
Return the patch evaluation schedule.
Definition: LduMatrix.H:624
virtual void read(const dictionary &)
Read and reset the preconditioner parameters from the given dictionary.
Definition: LduMatrix.H:526
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.
Definition: lduMatrix.H:124
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
virtual ~smoother()=default
Destructor.
void operator-=(const LduMatrix< Type, DType, LUType > &)
Abstract base-class for LduMatrix solvers.
Definition: LduMatrix.H:136
const word & fieldName() const noexcept
Definition: LduMatrix.H:418
void residual(Field< Type > &rA, const Field< Type > &psi) const
preconditioner(const solver &sol)
Construct for given solver.
Definition: LduMatrix.H:496
const LduMatrix< Type, DType, LUType > & matrix_
Definition: LduMatrix.H:341
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
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.
Definition: LduMatrix.H:632
const word & fieldName() const noexcept
Definition: LduMatrix.H:282
void Tmul(Field< Type > &, const tmp< Field< Type >> &) const
Matrix transpose multiplication.
const lduAddressing & lduAddr() const
Return the LDU addressing.
Definition: LduMatrix.H:616
const solver & solver_
Reference to the base-solver this preconditioner is used with.
Definition: LduMatrix.H:453
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool hasUpper() const noexcept
Definition: LduMatrix.H:690
const FieldField< Field, LUType > & interfacesLower() const noexcept
Definition: LduMatrix.H:666
const Field< LUType > & upper() const
Definition: LduMatrix.C:178
Basic run-time type information using word as the type&#39;s name. Used to enhance the standard RTTI to c...
const Field< LUType > & lower() const
Definition: LduMatrix.C:223
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.
Definition: LduMatrix.H:178
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
bool diagonal() const noexcept
Matrix has diagonal only.
Definition: LduMatrix.H:697
LduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: LduMatrix.H:68
label maxIter_
Maximum number of iterations in the solver.
Definition: LduMatrix.H:163
bool hasLower() const noexcept
Definition: LduMatrix.H:691
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...
Definition: HashPtrTable.H:48
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
Definition: LduMatrix.H:608
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_
Definition: LduMatrix.H:143
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
Definition: LduMatrix.H:661
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual ~preconditioner()=default
Destructor.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:696
const Field< Type > & source() const
Definition: LduMatrix.C:267
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
Definition: LduMatrix.H:689
Type tolerance_
Final convergence tolerance.
Definition: LduMatrix.H:173
~LduMatrix()=default
Destructor.
bool symmetric() const noexcept
Matrix is symmetric.
Definition: LduMatrix.H:705
word matrixTypeName() const
The matrix type (empty, diagonal, symmetric, ...)
Definition: LduMatrix.C:133
Namespace for OpenFOAM.