Loading...
Searching...
No Matches
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-2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::lduMatrix
29
30Description
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
41SourceFiles
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 "solverPerformance.H"
61#include "typeInfo.H"
62#include "autoPtr.H"
64#include "InfoProxy.H"
65#include "Enum.H"
66#include "profilingTrigger.H"
67#include <functional> // For reference_wrapper
68
69// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70
71namespace Foam
72{
73
74// Forward Declarations
75class lduMatrix;
76
79
81/*---------------------------------------------------------------------------*\
82 Class lduMatrix Declaration
83\*---------------------------------------------------------------------------*/
84
85class lduMatrix
86{
87 // Private Data
88
89 //- LDU mesh reference
90 //const lduMesh& lduMesh_;
91 std::reference_wrapper<const lduMesh> lduMesh_;
92
93 //- Diagonal coefficients
94 std::unique_ptr<scalarField> diagPtr_;
95
96 //- Off-diagonal coefficients (not including interfaces)
97 std::unique_ptr<scalarField> lowerPtr_;
98
99 //- Off-diagonal coefficients (not including interfaces)
100 std::unique_ptr<scalarField> upperPtr_;
101
102 //- Off-diagonal coefficients (not including interfaces) in CSR ordering
103 mutable std::unique_ptr<scalarField> lowerCSRPtr_;
104
105 //- Work space
106 mutable std::unique_ptr<solveScalarField> workPtr_;
107
108
109public:
110
111 // Public Types
112
113 //- Enumerated matrix normalisation types
114 enum class normTypes : char
115 {
116 NO_NORM,
119 };
120
121 //- Names for the normTypes
122 static const Enum<normTypes> normTypesNames_;
123
124 //- Default maximum number of iterations for solvers (1000)
125 static constexpr const label defaultMaxIter = 1000;
127 //- Default (absolute) tolerance (1e-6)
128 static const scalar defaultTolerance;
129
130
131 // -----------------------------------------------------------------------
132 //- Abstract base-class for lduMatrix solvers
133 class solver
135 protected:
136
137 // Protected Data
138
140 const lduMatrix& matrix_;
145 //- Dictionary of solution controls
147
148 //- Verbosity level for solver output statements
149 int log_;
150
151 //- Minimum number of iterations in the solver
152 label minIter_;
153
154 //- Maximum number of iterations in the solver
155 label maxIter_;
156
157 //- The normalisation type
160 //- Final convergence tolerance
162
163 //- Convergence tolerance relative to the initial
164 scalar relTol_;
165
166 //- Profiling instrumentation
168
169
170 // Protected Member Functions
172 //- Read the control parameters from controlDict_
173 virtual void readControls();
174
175
176 public:
177
178 //- Runtime type information
179 virtual const word& type() const = 0;
180
182 // Declare run-time constructor selection tables
183
185 (
187 solver,
188 symMatrix,
189 (
190 const word& fieldName,
195 const dictionary& solverControls
196 ),
197 (
198 fieldName,
199 matrix,
203 solverControls
204 )
205 );
206
208 (
209 autoPtr,
210 solver,
211 asymMatrix,
212 (
213 const word& fieldName,
214 const lduMatrix& matrix,
218 const dictionary& solverControls
219 ),
220 (
221 fieldName,
226 solverControls
227 )
228 );
229
230
231 // Constructors
232
233 //- Construct solver for given field name, matrix etc
234 solver
235 (
236 const word& fieldName,
237 const lduMatrix& matrix,
241 const dictionary& solverControls
242 );
243
244 // Selectors
246 //- Return a new solver of given type
247 static autoPtr<solver> New
248 (
249 const word& solverName,
250 const word& fieldName,
251 const lduMatrix& matrix,
255 const dictionary& solverControls
256 );
257
258 //- Return a new solver given dictionary
259 static autoPtr<solver> New
260 (
261 const word& fieldName,
262 const lduMatrix& matrix,
266 const dictionary& solverControls
267 );
268
269
270
271 //- Destructor
272 virtual ~solver() = default;
273
274
275 // Member Functions
276
277 const word& fieldName() const noexcept
278 {
279 return fieldName_;
280 }
281
282 const lduMatrix& matrix() const noexcept
283 {
284 return matrix_;
285 }
286
288 {
289 return interfaceBouCoeffs_;
290 }
291
292 const FieldField<Field, scalar>& interfaceIntCoeffs() const noexcept
293 {
294 return interfaceIntCoeffs_;
295 }
296
298 {
299 return interfaces_;
300 }
301
302
303 //- Read and reset the solver parameters from the given stream
304 virtual void read(const dictionary&);
305
306 //- Solve with given field and rhs
308 (
310 const scalarField& source,
311 const direction cmpt=0
312 ) const = 0;
313
314 //- Solve with given field and rhs (in solveScalar precision).
315 // Default is to call solve routine
317 (
319 const solveScalarField& source,
320 const direction cmpt=0
321 ) const;
322
323 //- Return the matrix norm using the specified norm method
325 (
326 const solveScalarField& psi,
327 const solveScalarField& source,
328 const solveScalarField& Apsi,
329 solveScalarField& tmpField,
330 const lduMatrix::normTypes normType
331 ) const;
332
333 //- Return the matrix norm used to normalise the residual for the
334 //- stopping criterion
336 (
337 const solveScalarField& psi,
338 const solveScalarField& source,
339 const solveScalarField& Apsi,
340 solveScalarField& tmpField
341 ) const
342 {
343 return this->normFactor(psi, source, Apsi, tmpField, normType_);
344 }
345 };
346
347
348 // -----------------------------------------------------------------------
349 //- Abstract base-class for lduMatrix smoothers
350 class smoother
351 {
352 protected:
353
354 // Protected Data
355
361
362
363 public:
364
365 //- Find the smoother name (directly or from a sub-dictionary)
366 static word getName(const dictionary&);
367
368 //- Runtime type information
369 virtual const word& type() const = 0;
370
371
372 // Declare run-time constructor selection tables
373
375 (
376 autoPtr,
377 smoother,
378 symMatrix,
379 (
380 const word& fieldName,
381 const lduMatrix& matrix,
385 const dictionary& solverControls
386 ),
387 (
388 fieldName,
389 matrix,
393 solverControls
394 )
395 );
396
398 (
399 autoPtr,
400 smoother,
401 asymMatrix,
402 (
403 const word& fieldName,
404 const lduMatrix& matrix,
408 const dictionary& solverControls
409 ),
410 (
411 fieldName,
412 matrix,
416 solverControls
418 );
420
421 // Constructors
422
423 //- Construct for given field name, matrix etc
425 (
426 const word& fieldName,
427 const lduMatrix& matrix,
431 );
433
434 // Selectors
435
436 //- Return a new smoother
438 (
439 const word& fieldName,
440 const lduMatrix& matrix,
444 const dictionary& solverControls
445 );
446
447
448 //- Destructor
449 virtual ~smoother() = default;
450
451
452 // Member Functions
453
454 const word& fieldName() const noexcept
455 {
456 return fieldName_;
457 }
458
459 const lduMatrix& matrix() const noexcept
461 return matrix_;
462 }
463
465 {
466 return interfaceBouCoeffs_;
467 }
468
470 {
471 return interfaceIntCoeffs_;
472 }
473
475 {
476 return interfaces_;
477 }
478
479
480 //- Smooth the solution for a given number of sweeps
481 virtual void smooth
482 (
484 const scalarField& source,
485 const direction cmpt,
486 const label nSweeps
487 ) const = 0;
488
489 //- Smooth the solution for a given number of sweeps
490 virtual void scalarSmooth
491 (
493 const solveScalarField& source,
494 const direction cmpt,
495 const label nSweeps
496 ) const = 0;
497 };
498
499
500 // -----------------------------------------------------------------------
501 //- Abstract base-class for lduMatrix preconditioners
502 class preconditioner
503 {
504 protected:
505
506 // Protected Data
507
508 //- Reference to the base-solver this preconditioner is used with
509 const solver& solver_;
510
511
512 public:
513
514 //- Find the preconditioner name (directly or from a sub-dictionary)
515 static word getName(const dictionary&);
516
517 //- Runtime type information
518 virtual const word& type() const = 0;
519
520
521 // Declare run-time constructor selection tables
522
527 symMatrix,
529 const solver& sol,
530 const dictionary& solverControls
531 ),
532 (sol, solverControls)
537 autoPtr,
539 asymMatrix,
540 (
541 const solver& sol,
542 const dictionary& solverControls
543 ),
544 (sol, solverControls)
545 );
546
547
548 // Constructors
549
550 //- Construct for given solver
551 explicit preconditioner(const solver& sol)
553 solver_(sol)
554 {}
555
556
557 // Selectors
558
559 //- Return a new preconditioner
561 (
562 const solver& sol,
563 const dictionary& solverControls
564 );
565
566
567 //- Destructor
568 virtual ~preconditioner() = default;
569
570
571 // Member Functions
572
573 //- Read and reset the preconditioner parameters
574 //- from the given stream
575 virtual void read(const dictionary&)
576 {}
578 //- Return wA the preconditioned form of residual rA
579 virtual void precondition
580 (
582 const solveScalarField& rA,
583 const direction cmpt=0
584 ) const = 0;
585
586 //- Return wT the transpose-matrix preconditioned form of
587 //- residual rT.
588 // This is only required for preconditioning asymmetric matrices.
589 virtual void preconditionT
590 (
592 const solveScalarField& rT,
593 const direction cmpt=0
594 ) const
595 {
597 }
598
599 //- Signal end of solver
600 virtual void setFinished(const solverPerformance& perf) const
601 {}
602 };
603
605 // -----------------------------------------------------------------------
606
607 // Static Data
608
609 // Declare name of the class and its debug switch
610 ClassName("lduMatrix");
611
612
613 // Constructors
614
615 //- Construct (without coefficients) for an LDU addressed mesh.
616 // Not yet 'explicit' (legacy code may rely on implicit construct)
617 lduMatrix(const lduMesh& mesh);
618
619 //- Copy construct
620 lduMatrix(const lduMatrix&);
621
622 //- Move construct
624
625 //- Construct as copy or re-use as specified.
626 lduMatrix(lduMatrix&, bool reuse);
627
628 //- Construct given an LDU addressed mesh and an Istream
629 //- from which the coefficients are read
630 lduMatrix(const lduMesh& mesh, Istream& is);
631
632
633 //- Destructor
634 ~lduMatrix() = default;
635
636
637 // Member Functions
638
639 // Addressing
640
641 //- Return the LDU mesh from which the addressing is obtained
642 const lduMesh& mesh() const noexcept
643 {
644 return lduMesh_;
645 }
646
647 //- Set the LDU mesh containing the addressing
648 void setLduMesh(const lduMesh& m)
649 {
650 lduMesh_ = m;
651 }
652
653 //- Return the LDU addressing
654 const lduAddressing& lduAddr() const
656 return mesh().lduAddr();
657 }
658
659 //- Return the patch evaluation schedule
660 const lduSchedule& patchSchedule() const
661 {
662 return mesh().lduAddr().patchSchedule();
663 }
665
666 // Coefficients
667
668 const scalarField& diag() const;
669 const scalarField& upper() const;
670 const scalarField& lower() const;
671
672 scalarField& diag();
675
676 // Size with externally provided sizes
677 // (for constructing with 'fake' mesh in GAMG)
678
679 scalarField& diag(label size);
680 scalarField& upper(label nCoeffs);
681 scalarField& lower(label nCoeffs);
682
684 // CSR
685
686 bool hasLowerCSR() const noexcept { return bool(lowerCSRPtr_); }
687
688 const scalarField& lowerCSR() const;
689
691
692 //- Work array
693 const solveScalarField& work() const;
694
695 //- Work array
696 solveScalarField& work(label size) const;
697
698
699 // Characteristics
700
701 //- The matrix type (empty, diagonal, symmetric, ...)
702 word matrixTypeName() const;
703
704 bool hasDiag() const noexcept { return bool(diagPtr_); }
705 bool hasUpper() const noexcept { return bool(upperPtr_); }
706 bool hasLower() const noexcept { return bool(lowerPtr_); }
707
708 //- Matrix has diagonal only
709 bool diagonal() const noexcept
710 {
711 return (diagPtr_ && !lowerPtr_ && !upperPtr_);
712 }
713
714 //- Matrix is symmetric
715 bool symmetric() const noexcept
716 {
717 return (diagPtr_ && !lowerPtr_ && upperPtr_);
718 }
719
720 //- Matrix is asymmetric (ie, full)
721 bool asymmetric() const noexcept
722 {
723 return (diagPtr_ && lowerPtr_ && upperPtr_);
724 }
725
726
727 // Operations
728
729 void sumDiag();
730 void negSumDiag();
731
732 void sumMagOffDiag(scalarField& sumOff) const;
733
734 //- Matrix multiplication with updated interfaces.
735 void Amul
736 (
738 const tmp<solveScalarField>&,
739 const FieldField<Field, scalar>&,
741 const direction cmpt
742 ) const;
744 //- Matrix transpose multiplication with updated interfaces.
745 void Tmul
746 (
751 const direction cmpt
752 ) const;
754
755 //- Sum the coefficients on each row of the matrix
756 void sumA
757 (
761 ) const;
762
763
764 void residual
765 (
767 const solveScalarField& psi,
768 const scalarField& source,
769 const FieldField<Field, scalar>& interfaceBouCoeffs,
770 const lduInterfaceFieldPtrsList& interfaces,
771 const direction cmpt
772 ) const;
773
775 (
776 const solveScalarField& psi,
777 const scalarField& source,
778 const FieldField<Field, scalar>& interfaceBouCoeffs,
779 const lduInterfaceFieldPtrsList& interfaces,
780 const direction cmpt
781 ) const;
782
783
784 //- Initialise the update of interfaced interfaces
785 //- for matrix operations
787 (
788 const bool add,
789 const FieldField<Field, scalar>& interfaceCoeffs,
790 const lduInterfaceFieldPtrsList& interfaces,
791 const solveScalarField& psiif,
792 solveScalarField& result,
793 const direction cmpt
794 ) const;
795
796 //- Update interfaced interfaces for matrix operations
798 (
799 const bool add,
800 const FieldField<Field, scalar>& interfaceCoeffs,
801 const lduInterfaceFieldPtrsList& interfaces,
802 const solveScalarField& psiif,
804 const direction cmpt,
805 const label startRequest // starting request (for non-blocking)
806 ) const;
807
808 //- Set the residual field using an IOField on the object registry
809 //- if it exists
811 (
812 const scalarField& residual,
813 const word& fieldName,
814 const bool initial
815 ) const;
816
817 template<class Type>
818 tmp<Field<Type>> H(const Field<Type>&) const;
819
820 template<class Type>
821 tmp<Field<Type>> H(const tmp<Field<Type>>&) const;
822
823 tmp<scalarField> H1() const;
824
825 template<class Type>
826 tmp<Field<Type>> faceH(const Field<Type>&) const;
828 template<class Type>
830
831
832 // Info
833
834 //- Return info proxy,
835 //- used to print matrix information to a stream
836 InfoProxy<lduMatrix> info() const noexcept { return *this; }
837
838
839 // Member Operators
840
841 //- Copy assignment
842 void operator=(const lduMatrix&);
843
844 //- Move assignment
845 void operator=(lduMatrix&&);
846
847 void negate();
848
849 void operator+=(const lduMatrix&);
850 void operator-=(const lduMatrix&);
851
852 void operator*=(const scalarField&);
853 void operator*=(scalar);
854
855
856 // Ostream Operators
857
858 friend Ostream& operator<<(Ostream&, const lduMatrix&);
860};
861
862
863// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
864
865} // End namespace Foam
866
867// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
868
869#ifdef NoRepository
870 #include "lduMatrixTemplates.C"
871#endif
872
873// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
874
875#endif
876
877// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
A field of fields is a PtrList of fields with reference counting.
Definition FieldField.H:77
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
pTraits< solveScalar >::cmptType cmptType
Definition Field.H:178
A helper class for outputting values to Ostream.
Definition InfoProxy.H:49
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
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 lduMatrix preconditioners.
Definition lduMatrix.H:578
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:586
static autoPtr< preconditioner > New(const solver &sol, const dictionary &solverControls)
Return a new preconditioner.
preconditioner(const solver &sol)
Construct for given solver.
Definition lduMatrix.H:634
declareRunTimeSelectionTable(autoPtr, preconditioner, asymMatrix,(const solver &sol, const dictionary &solverControls),(sol, solverControls))
virtual void precondition(solveScalarField &wA, const solveScalarField &rA, const direction cmpt=0) const =0
Return wA the preconditioned form of residual rA.
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:684
virtual void read(const dictionary &)
Read and reset the preconditioner parameters from the given stream.
Definition lduMatrix.H:664
virtual void setFinished(const solverPerformance &perf) const
Signal end of solver.
Definition lduMatrix.H:696
static word getName(const dictionary &)
Find the preconditioner name (directly or from a sub-dictionary).
virtual const word & type() const =0
Runtime type information.
virtual ~preconditioner()=default
Destructor.
Abstract base-class for lduMatrix smoothers.
Definition lduMatrix.H:410
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
Definition lduMatrix.H:538
const lduMatrix & matrix_
Definition lduMatrix.H:416
declareRunTimeSelectionTable(autoPtr, smoother, asymMatrix,(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))
const lduInterfaceFieldPtrsList & interfaces_
Definition lduMatrix.H:419
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.
declareRunTimeSelectionTable(autoPtr, smoother, 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))
const lduInterfaceFieldPtrsList & interfaces() const noexcept
Definition lduMatrix.H:543
virtual ~smoother()=default
Destructor.
const FieldField< Field, scalar > & interfaceBouCoeffs_
Definition lduMatrix.H:417
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.
const lduMatrix & matrix() const noexcept
Definition lduMatrix.H:528
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.
const FieldField< Field, scalar > & interfaceIntCoeffs_
Definition lduMatrix.H:418
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.
static word getName(const dictionary &)
Find the smoother name (directly or from a sub-dictionary).
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
Definition lduMatrix.H:533
virtual const word & type() const =0
Runtime type information.
const word & fieldName() const noexcept
Definition lduMatrix.H:523
Abstract base-class for lduMatrix solvers.
Definition lduMatrix.H:152
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
Definition lduMatrix.H:338
const lduMatrix & matrix_
Definition lduMatrix.H:158
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))
label maxIter_
Maximum number of iterations in the solver.
Definition lduMatrix.H:181
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.
profilingTrigger profiling_
Profiling instrumentation.
Definition lduMatrix.H:201
scalar tolerance_
Final convergence tolerance.
Definition lduMatrix.H:191
const lduInterfaceFieldPtrsList & interfaces() const noexcept
Definition lduMatrix.H:343
solveScalarField::cmptType normFactor(const solveScalarField &psi, const solveScalarField &source, const solveScalarField &Apsi, solveScalarField &tmpField) const
Return the matrix norm used to normalise the residual for the stopping criterion.
Definition lduMatrix.H:393
lduInterfaceFieldPtrsList interfaces_
Definition lduMatrix.H:161
const FieldField< Field, scalar > & interfaceBouCoeffs_
Definition lduMatrix.H:159
declareRunTimeSelectionTable(autoPtr, solver, asymMatrix,(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))
label minIter_
Minimum number of iterations in the solver.
Definition lduMatrix.H:176
const lduMatrix & matrix() const noexcept
Definition lduMatrix.H:328
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.
lduMatrix::normTypes normType_
The normalisation type.
Definition lduMatrix.H:186
static autoPtr< solver > New(const word &solverName, 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 of given type.
int log_
Verbosity level for solver output statements.
Definition lduMatrix.H:171
virtual solverPerformance scalarSolve(solveScalarField &psi, const solveScalarField &source, const direction cmpt=0) const
Solve with given field and rhs (in solveScalar precision).
virtual ~solver()=default
Destructor.
scalar relTol_
Convergence tolerance relative to the initial.
Definition lduMatrix.H:196
const FieldField< Field, scalar > & interfaceIntCoeffs_
Definition lduMatrix.H:160
virtual void readControls()
Read the control parameters from controlDict_.
virtual void read(const dictionary &)
Read and reset the solver parameters from the given stream.
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
Definition lduMatrix.H:333
dictionary controlDict_
Dictionary of solution controls.
Definition lduMatrix.H:166
virtual const word & type() const =0
Runtime type information.
const word & fieldName() const noexcept
Definition lduMatrix.H:323
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const =0
Solve with given field and rhs.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition lduMatrix.H:81
lduMatrix(const lduMesh &mesh)
Construct (without coefficients) for an LDU addressed mesh.
Definition lduMatrix.C:54
tmp< scalarField > H1() const
void operator=(const lduMatrix &)
Copy assignment.
bool hasUpper() const noexcept
Definition lduMatrix.H:828
tmp< Field< Type > > faceH(const Field< Type > &) const
const lduAddressing & lduAddr() const
Return the LDU addressing.
Definition lduMatrix.H:769
friend Ostream & operator<<(Ostream &, const InfoProxy< lduMatrix > &)
normTypes
Enumerated matrix normalisation types.
Definition lduMatrix.H:125
@ DEFAULT_NORM
"default" norm (== L1_scaled)
Definition lduMatrix.H:127
@ L1_SCALED_NORM
"L1_scaled" norm
Definition lduMatrix.H:128
@ NO_NORM
"none" norm (returns 1)
Definition lduMatrix.H:126
ClassName("lduMatrix")
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full).
Definition lduMatrix.H:850
void residual(solveScalarField &rA, const solveScalarField &psi, const scalarField &source, const FieldField< Field, scalar > &interfaceBouCoeffs, const lduInterfaceFieldPtrsList &interfaces, const direction cmpt) const
InfoProxy< lduMatrix > info() const noexcept
Return info proxy, used to print matrix information to a stream.
Definition lduMatrix.H:979
void Tmul(solveScalarField &, const tmp< solveScalarField > &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &, const direction cmpt) const
Matrix transpose multiplication with updated interfaces.
friend Ostream & operator<<(Ostream &, const lduMatrix &)
tmp< Field< Type > > faceH(const tmp< Field< Type > > &) const
const scalarField & diag() const
Definition lduMatrix.C:195
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.
bool symmetric() const noexcept
Matrix is symmetric.
Definition lduMatrix.H:842
const scalarField & upper() const
Definition lduMatrix.C:235
void setLduMesh(const lduMesh &m)
Set the LDU mesh containing the addressing.
Definition lduMatrix.H:761
void sumA(solveScalarField &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &) const
Sum the coefficients on each row of the matrix.
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:457
const lduSchedule & patchSchedule() const
Return the patch evaluation schedule.
Definition lduMatrix.H:777
const scalarField & lowerCSR() const
Definition lduMatrix.C:376
void operator*=(const scalarField &)
bool diagonal() const noexcept
Matrix has diagonal only.
Definition lduMatrix.H:834
static constexpr const label defaultMaxIter
Default maximum number of iterations for solvers (1000).
Definition lduMatrix.H:139
static const Enum< normTypes > normTypesNames_
Names for the normTypes.
Definition lduMatrix.H:134
bool hasLower() const noexcept
Definition lduMatrix.H:829
tmp< Field< Type > > H(const Field< Type > &) const
void operator+=(const lduMatrix &)
const scalarField & lower() const
Definition lduMatrix.C:306
void sumMagOffDiag(scalarField &sumOff) const
~lduMatrix()=default
Destructor.
void Amul(solveScalarField &, const tmp< solveScalarField > &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &, const direction cmpt) const
Matrix multiplication with updated interfaces.
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
Definition lduMatrix.H:753
void operator-=(const lduMatrix &)
static const scalar defaultTolerance
Default (absolute) tolerance (1e-6).
Definition lduMatrix.H:144
tmp< Field< Type > > H(const tmp< Field< Type > > &) const
word matrixTypeName() const
The matrix type (empty, diagonal, symmetric, ...).
Definition lduMatrix.C:178
const solveScalarField & work() const
Work array.
Definition lduMatrix.C:443
bool hasDiag() const noexcept
Definition lduMatrix.H:827
bool hasLowerCSR() const noexcept
Definition lduMatrix.H:803
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.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition lduMesh.H:54
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
Triggers for starting/stopping code profiling.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:74
const volScalarField & psi
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
lduMatrix member H operations.
Namespace for OpenFOAM.
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
Definition lduSchedule.H:46
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
Field< solveScalar > solveScalarField
uint8_t direction
Definition direction.H:49
const direction noexcept
Definition scalarImpl.H:265
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
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).
CEqn solve()
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...