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) 2016-2022 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  It might be better if this class were organised as a hierarchy starting
38  from an empty matrix, then deriving diagonal, symmetric and asymmetric
39  matrices.
40 
41 SourceFiles
42  lduMatrixATmul.C
43  lduMatrix.C
44  lduMatrixTemplates.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 "primitiveFieldsFwd.H"
58 #include "FieldField.H"
60 #include "typeInfo.H"
61 #include "autoPtr.H"
62 #include "runTimeSelectionTables.H"
63 #include "solverPerformance.H"
64 #include "InfoProxy.H"
65 #include "Enum.H"
66 #include "profilingTrigger.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 // Forward Declarations
74 class lduMatrix;
75 
76 Ostream& operator<<(Ostream&, const lduMatrix&);
77 Ostream& operator<<(Ostream&, const InfoProxy<lduMatrix>&);
78 
79 
80 /*---------------------------------------------------------------------------*\
81  Class lduMatrix Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 class lduMatrix
85 {
86  // Private Data
87 
88  //- LDU mesh reference
89  //const lduMesh& lduMesh_;
90  std::reference_wrapper<const lduMesh> lduMesh_;
91 
92  //- Coefficients (not including interfaces)
93  scalarField *lowerPtr_, *diagPtr_, *upperPtr_;
94 
95 
96 public:
97 
98  // Public Types
99 
100  //- Enumerated matrix normalisation types
101  enum class normTypes : char
102  {
104  DEFAULT_NORM,
106  };
107 
108  //- Names for the normTypes
109  static const Enum<normTypes> normTypesNames_;
110 
111  //- Default maximum number of iterations for solvers (1000)
112  static constexpr const label defaultMaxIter = 1000;
114  //- Default (absolute) tolerance (1e-6)
115  static const scalar defaultTolerance;
116 
117 
118  //- Abstract base-class for lduMatrix solvers
119  class solver
120  {
121  protected:
122 
123  // Protected Data
124 
126  const lduMatrix& matrix_;
130 
131  //- Dictionary of solution controls
133 
134  //- Verbosity level for solver output statements
135  int log_;
137  //- Minimum number of iterations in the solver
138  label minIter_;
140  //- Maximum number of iterations in the solver
141  label maxIter_;
142 
143  //- The normalisation type
145 
146  //- Final convergence tolerance
147  scalar tolerance_;
148 
149  //- Convergence tolerance relative to the initial
150  scalar relTol_;
151 
152  //- Profiling instrumentation
155 
156  // Protected Member Functions
157 
158  //- Read the control parameters from controlDict_
159  virtual void readControls();
160 
161 
162  public:
163 
164  //- Runtime type information
165  virtual const word& type() const = 0;
166 
167 
168  // Declare run-time constructor selection tables
171  (
172  autoPtr,
173  solver,
174  symMatrix,
175  (
176  const word& fieldName,
177  const lduMatrix& matrix,
181  const dictionary& solverControls
182  ),
183  (
184  fieldName,
185  matrix,
188  interfaces,
189  solverControls
190  )
191  );
192 
194  (
195  autoPtr,
196  solver,
197  asymMatrix,
198  (
199  const word& fieldName,
200  const lduMatrix& matrix,
204  const dictionary& solverControls
205  ),
206  (
207  fieldName,
208  matrix,
211  interfaces,
212  solverControls
213  )
214  );
215 
216 
217  // Constructors
218 
219  //- Construct solver for given field name, matrix etc
220  solver
221  (
222  const word& fieldName,
223  const lduMatrix& matrix,
227  const dictionary& solverControls
228  );
229 
230  // Selectors
231 
232  //- Return a new solver
233  static autoPtr<solver> New
234  (
235  const word& fieldName,
236  const lduMatrix& matrix,
240  const dictionary& solverControls
241  );
242 
243 
244 
245  //- Destructor
246  virtual ~solver() = default;
247 
248 
249  // Member Functions
250 
251  const word& fieldName() const noexcept
252  {
253  return fieldName_;
254  }
255 
256  const lduMatrix& matrix() const noexcept
257  {
258  return matrix_;
259  }
260 
262  {
263  return interfaceBouCoeffs_;
264  }
265 
266  const FieldField<Field, scalar>& interfaceIntCoeffs() const noexcept
267  {
268  return interfaceIntCoeffs_;
269  }
270 
272  {
273  return interfaces_;
274  }
275 
276 
277  //- Read and reset the solver parameters from the given stream
278  virtual void read(const dictionary&);
279 
280  //- Solve with given field and rhs
281  virtual solverPerformance solve
282  (
283  scalarField& psi,
284  const scalarField& source,
285  const direction cmpt=0
286  ) const = 0;
288  //- Solve with given field and rhs (in solveScalar precision).
289  // Default is to call solve routine
291  (
293  const solveScalarField& source,
294  const direction cmpt=0
295  ) const;
296 
297  //- Return the matrix norm using the specified norm method
299  (
300  const solveScalarField& psi,
301  const solveScalarField& source,
302  const solveScalarField& Apsi,
303  solveScalarField& tmpField,
304  const lduMatrix::normTypes normType
305  ) const;
306 
307  //- Return the matrix norm used to normalise the residual for the
308  //- stopping criterion
310  (
311  const solveScalarField& psi,
312  const solveScalarField& source,
313  const solveScalarField& Apsi,
314  solveScalarField& tmpField
315  ) const
316  {
317  return this->normFactor(psi, source, Apsi, tmpField, normType_);
318  }
319  };
320 
321 
322  //- Abstract base-class for lduMatrix smoothers
323  class smoother
324  {
325  protected:
326 
327  // Protected Data
328 
330  const lduMatrix& matrix_;
334 
335 
336  public:
337 
338  //- Find the smoother name (directly or from a sub-dictionary)
339  static word getName(const dictionary&);
340 
341  //- Runtime type information
342  virtual const word& type() const = 0;
343 
344 
345  // Declare run-time constructor selection tables
346 
348  (
349  autoPtr,
350  smoother,
351  symMatrix,
352  (
353  const word& fieldName,
354  const lduMatrix& matrix,
358  ),
359  (
360  fieldName,
361  matrix,
364  interfaces
365  )
366  );
367 
369  (
370  autoPtr,
371  smoother,
372  asymMatrix,
373  (
374  const word& fieldName,
375  const lduMatrix& matrix,
379  ),
380  (
385  interfaces
386  )
387  );
388 
389 
390  // Constructors
391 
392  //- Construct for given field name, matrix etc
393  smoother
394  (
395  const word& fieldName,
396  const lduMatrix& matrix,
400  );
401 
402 
403  // Selectors
404 
405  //- Return a new smoother
406  static autoPtr<smoother> New
407  (
408  const word& fieldName,
409  const lduMatrix& matrix,
413  const dictionary& solverControls
414  );
415 
416 
417  //- Destructor
418  virtual ~smoother() = default;
419 
420 
421  // Member Functions
422 
423  const word& fieldName() const noexcept
424  {
425  return fieldName_;
426  }
427 
428  const lduMatrix& matrix() const noexcept
429  {
430  return matrix_;
431  }
432 
434  {
435  return interfaceBouCoeffs_;
436  }
437 
438  const FieldField<Field, scalar>& interfaceIntCoeffs() const noexcept
439  {
440  return interfaceIntCoeffs_;
441  }
442 
444  {
445  return interfaces_;
446  }
447 
448 
449  //- Smooth the solution for a given number of sweeps
450  virtual void smooth
451  (
453  const scalarField& source,
454  const direction cmpt,
455  const label nSweeps
456  ) const = 0;
457 
458  //- Smooth the solution for a given number of sweeps
459  virtual void scalarSmooth
460  (
462  const solveScalarField& source,
463  const direction cmpt,
464  const label nSweeps
465  ) const = 0;
466  };
467 
468 
469  //- Abstract base-class for lduMatrix preconditioners
470  class preconditioner
471  {
472  protected:
473 
474  // Protected Data
475 
476  //- Reference to the base-solver this preconditioner is used with
477  const solver& solver_;
478 
479 
480  public:
481 
482  //- Find the preconditioner name (directly or from a sub-dictionary)
483  static word getName(const dictionary&);
484 
485  //- Runtime type information
486  virtual const word& type() const = 0;
488 
489  // Declare run-time constructor selection tables
490 
492  (
493  autoPtr,
495  symMatrix,
496  (
497  const solver& sol,
498  const dictionary& solverControls
499  ),
500  (sol, solverControls)
501  );
504  (
505  autoPtr,
507  asymMatrix,
508  (
509  const solver& sol,
510  const dictionary& solverControls
511  ),
512  (sol, solverControls)
513  );
514 
515 
516  // Constructors
517 
518  //- Construct for given solver
519  explicit preconditioner(const solver& sol)
520  :
521  solver_(sol)
522  {}
523 
524 
525  // Selectors
526 
527  //- Return a new preconditioner
529  (
530  const solver& sol,
531  const dictionary& solverControls
532  );
533 
534 
535  //- Destructor
536  virtual ~preconditioner() = default;
537 
538 
539  // Member Functions
540 
541  //- Read and reset the preconditioner parameters
542  //- from the given stream
543  virtual void read(const dictionary&)
544  {}
545 
546  //- Return wA the preconditioned form of residual rA
547  virtual void precondition
548  (
549  solveScalarField& wA,
550  const solveScalarField& rA,
551  const direction cmpt=0
552  ) const = 0;
553 
554  //- Return wT the transpose-matrix preconditioned form of
555  //- residual rT.
556  // This is only required for preconditioning asymmetric matrices.
557  virtual void preconditionT
558  (
559  solveScalarField& wT,
560  const solveScalarField& rT,
561  const direction cmpt=0
562  ) const
563  {
565  }
566  };
567 
568 
569  // Static Data
570 
571  // Declare name of the class and its debug switch
572  ClassName("lduMatrix");
573 
574 
575  // Constructors
576 
577  //- Construct given an LDU addressed mesh.
578  // The coefficients are initially empty for subsequent setting.
579  lduMatrix(const lduMesh&);
580 
581  //- Construct as copy
582  lduMatrix(const lduMatrix&);
583 
584  //- Construct as copy or re-use as specified.
585  lduMatrix(lduMatrix&, bool reuse);
586 
587  //- Construct given an LDU addressed mesh and an Istream
588  //- from which the coefficients are read
589  lduMatrix(const lduMesh&, Istream&);
590 
591 
592  //- Destructor
593  ~lduMatrix();
594 
595 
596  // Member Functions
597 
598  // Access to addressing
599 
600  //- Return the LDU mesh from which the addressing is obtained
601  const lduMesh& mesh() const noexcept
602  {
603  return lduMesh_;
604  }
605 
606  //- Set the LDU mesh containing the addressing is obtained
607  void setLduMesh(const lduMesh& m)
608  {
609  lduMesh_ = m;
610  }
611 
612  //- Return the LDU addressing
613  const lduAddressing& lduAddr() const
614  {
615  return mesh().lduAddr();
616  }
617 
618  //- Return the patch evaluation schedule
619  const lduSchedule& patchSchedule() const
620  {
621  return lduAddr().patchSchedule();
622  }
623 
624 
625  // Access to coefficients
626 
627  scalarField& lower();
628  scalarField& diag();
629  scalarField& upper();
630 
631  // Size with externally provided sizes (for constructing with 'fake'
632  // mesh in GAMG)
633 
634  scalarField& lower(const label size);
635  scalarField& diag(const label nCoeffs);
636  scalarField& upper(const label nCoeffs);
637 
638 
639  const scalarField& lower() const;
640  const scalarField& diag() const;
641  const scalarField& upper() const;
643  bool hasDiag() const noexcept
644  {
645  return (diagPtr_);
646  }
647 
648  bool hasUpper() const noexcept
649  {
650  return (upperPtr_);
651  }
652 
653  bool hasLower() const noexcept
654  {
655  return (lowerPtr_);
656  }
657 
658  bool diagonal() const noexcept
659  {
660  return (diagPtr_ && !lowerPtr_ && !upperPtr_);
661  }
662 
663  bool symmetric() const noexcept
664  {
665  return (diagPtr_ && (!lowerPtr_ && upperPtr_));
666  }
667 
668  bool asymmetric() const noexcept
669  {
670  return (diagPtr_ && lowerPtr_ && upperPtr_);
671  }
672 
673 
674  // Operations
675 
676  void sumDiag();
677  void negSumDiag();
678 
679  void sumMagOffDiag(scalarField& sumOff) const;
680 
681  //- Matrix multiplication with updated interfaces.
682  void Amul
683  (
685  const tmp<solveScalarField>&,
686  const FieldField<Field, scalar>&,
688  const direction cmpt
689  ) const;
690 
691  //- Matrix transpose multiplication with updated interfaces.
692  void Tmul
693  (
695  const tmp<solveScalarField>&,
696  const FieldField<Field, scalar>&,
698  const direction cmpt
699  ) const;
700 
701 
702  //- Sum the coefficients on each row of the matrix
703  void sumA
704  (
708  ) const;
709 
710 
711  void residual
712  (
713  solveScalarField& rA,
715  const scalarField& source,
716  const FieldField<Field, scalar>& interfaceBouCoeffs,
717  const lduInterfaceFieldPtrsList& interfaces,
718  const direction cmpt
719  ) const;
720 
722  (
723  const solveScalarField& psi,
724  const scalarField& source,
725  const FieldField<Field, scalar>& interfaceBouCoeffs,
726  const lduInterfaceFieldPtrsList& interfaces,
727  const direction cmpt
728  ) const;
729 
730 
731  //- Initialise the update of interfaced interfaces
732  //- for matrix operations
734  (
735  const bool add,
736  const FieldField<Field, scalar>& interfaceCoeffs,
737  const lduInterfaceFieldPtrsList& interfaces,
738  const solveScalarField& psiif,
739  solveScalarField& result,
740  const direction cmpt
741  ) const;
742 
743  //- Update interfaced interfaces for matrix operations
745  (
746  const bool add,
747  const FieldField<Field, scalar>& interfaceCoeffs,
748  const lduInterfaceFieldPtrsList& interfaces,
749  const solveScalarField& psiif,
750  solveScalarField& result,
751  const direction cmpt,
752  const label startRequest // starting request (for non-blocking)
753  ) const;
754 
755  //- Set the residual field using an IOField on the object registry
756  //- if it exists
757  void setResidualField
758  (
759  const scalarField& residual,
760  const word& fieldName,
761  const bool initial
762  ) const;
763 
764  template<class Type>
765  tmp<Field<Type>> H(const Field<Type>&) const;
767  template<class Type>
768  tmp<Field<Type>> H(const tmp<Field<Type>>&) const;
769 
770  tmp<scalarField> H1() const;
772  template<class Type>
773  tmp<Field<Type>> faceH(const Field<Type>&) const;
774 
775  template<class Type>
776  tmp<Field<Type>> faceH(const tmp<Field<Type>>&) const;
777 
778 
779  // Info
780 
781  //- Return info proxy.
782  // Used to print matrix information to a stream
783  InfoProxy<lduMatrix> info() const
784  {
785  return *this;
786  }
787 
788 
789  // Member operators
790 
791  void operator=(const lduMatrix&);
792 
793  void negate();
794 
795  void operator+=(const lduMatrix&);
796  void operator-=(const lduMatrix&);
797 
798  void operator*=(const scalarField&);
799  void operator*=(scalar);
800 
801 
802  // Ostream operator
803 
804  friend Ostream& operator<<(Ostream&, const lduMatrix&);
805  friend Ostream& operator<<(Ostream&, const InfoProxy<lduMatrix>&);
806 };
807 
808 
809 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
810 
811 } // End namespace Foam
812 
813 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
814 
815 #ifdef NoRepository
816  #include "lduMatrixTemplates.C"
817 #endif
818 
819 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
820 
821 #endif
822 
823 // ************************************************************************* //
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.
Definition: lduMatrix.H:622
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_
Definition: lduMatrix.H:382
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
Definition: lduMatrix.H:297
tmp< Field< Type > > faceH(const Field< Type > &) const
const lduInterfaceFieldPtrsList & interfaces() const noexcept
Definition: lduMatrix.H:502
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
Definition: lduMatrix.H:766
virtual void read(const dictionary &)
Read and reset the solver parameters from the given stream.
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
Definition: lduMatrix.H:497
uint8_t direction
Definition: direction.H:46
const FieldField< Field, scalar > & interfaceIntCoeffs_
Definition: lduMatrix.H:138
const lduMatrix & matrix() const noexcept
Definition: lduMatrix.H:487
preconditioner(const solver &sol)
Construct for given solver.
Definition: lduMatrix.H:592
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...
Definition: dictionary.H:120
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.
Definition: lduMatrix.H:544
lduMatrix(const lduMesh &)
Construct given an LDU addressed mesh.
Definition: lduMatrix.C:53
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.
Definition: lduMatrix.C:326
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_
Definition: lduMatrix.H:137
virtual void preconditionT(solveScalarField &wT, const solveScalarField &rT, const direction cmpt=0) const
Return wT the transpose-matrix preconditioned form of residual rT.
Definition: lduMatrix.H:642
pTraits< solveScalar >::cmptType cmptType
Component type.
Definition: Field.H:123
const lduMatrix & matrix() const noexcept
Definition: lduMatrix.H:292
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:53
InfoProxy< lduMatrix > info() const
Return info proxy.
Definition: lduMatrix.H:901
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
Definition: lduSchedule.H:46
Triggers for starting/stopping code profiling.
scalarField & upper()
Definition: lduMatrix.C:207
ClassName("lduMatrix")
tmp< scalarField > H1() const
void sumMagOffDiag(scalarField &sumOff) const
static constexpr const label defaultMaxIter
Default maximum number of iterations for solvers (1000)
Definition: lduMatrix.H:118
int log_
Verbosity level for solver output statements.
Definition: lduMatrix.H:149
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:51
static const Enum< normTypes > normTypesNames_
Names for the normTypes.
Definition: lduMatrix.H:113
label minIter_
Minimum number of iterations in the solver.
Definition: lduMatrix.H:154
lduMatrix::normTypes normType_
The normalisation type.
Definition: lduMatrix.H:164
virtual ~preconditioner()=default
Destructor.
const lduMatrix & matrix_
Definition: lduMatrix.H:379
static word getName(const dictionary &)
Find the smoother name (directly or from a sub-dictionary)
const lduSchedule & patchSchedule() const
Return the patch evaluation schedule.
Definition: lduMatrix.H:722
Abstract base-class for lduMatrix smoothers.
Definition: lduMatrix.H:372
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
scalar tolerance_
Final convergence tolerance.
Definition: lduMatrix.H:169
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.
Definition: word.H:63
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics...
label maxIter_
Maximum number of iterations in the solver.
Definition: lduMatrix.H:159
static autoPtr< preconditioner > New(const solver &sol, const dictionary &solverControls)
Return a new preconditioner.
Abstract base-class for lduMatrix solvers.
Definition: lduMatrix.H:129
const word & fieldName() const noexcept
Definition: lduMatrix.H:482
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.
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
Definition: lduMatrix.H:307
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
Definition: lduMatrix.H:492
static const scalar defaultTolerance
Default (absolute) tolerance (1e-6)
Definition: lduMatrix.H:123
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_
Definition: lduMatrix.H:380
static autoPtr< solver > 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 solver.
normTypes
Enumerated matrix normalisation types.
Definition: lduMatrix.H:103
void operator=(const lduMatrix &)
const lduMatrix & matrix_
Definition: lduMatrix.H:136
bool hasUpper() const noexcept
Definition: lduMatrix.H:751
bool asymmetric() const noexcept
Definition: lduMatrix.H:771
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
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.
const direction noexcept
Definition: Scalar.H:258
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void operator*=(const scalarField &)
lduInterfaceFieldPtrsList interfaces_
Definition: lduMatrix.H:139
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
Definition: lduMatrix.H:761
virtual ~smoother()=default
Destructor.
virtual const word & type() const =0
Runtime type information.
dictionary controlDict_
Dictionary of solution controls.
Definition: lduMatrix.H:144
"default" norm (== L1_scaled)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: lduMatrix.H:79
"none" norm (returns 1)
Abstract base-class for lduMatrix preconditioners.
Definition: lduMatrix.H:535
A helper class for outputting values to Ostream.
Definition: ensightCells.H:43
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
Definition: lduMatrix.H:698
const lduAddressing & lduAddr() const
Return the LDU addressing.
Definition: lduMatrix.H:714
scalarField & lower()
Definition: lduMatrix.C:178
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 is obtained.
Definition: lduMatrix.H:706
virtual ~solver()=default
Destructor.
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
Definition: lduMatrix.H:302
const FieldField< Field, scalar > & interfaceIntCoeffs_
Definition: lduMatrix.H:381
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...
Definition: HashPtrTable.H:48
bool hasDiag() const noexcept
Definition: lduMatrix.H:746
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.
Definition: HashPtrTable.H:50
scalarField & diag()
Definition: lduMatrix.C:196
profilingTrigger profiling_
Profiling instrumentation.
Definition: lduMatrix.H:179
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:666
bool hasLower() const noexcept
Definition: lduMatrix.H:756
const word & fieldName() const noexcept
Definition: lduMatrix.H:287
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.
Namespace for OpenFOAM.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
~lduMatrix()
Destructor.
Definition: lduMatrix.C:159
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.
Definition: lduMatrix.H:174
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))