parProfilingSolver.C
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) 2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "lduMatrix.H"
29 #include "parProfilingSolver.H"
30 #include "profilingPstream.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
38 
40 
42  (
43  baseType,
45  symMatrix,
46  parProfiling
47  );
48 
50  (
51  baseType,
53  asymMatrix,
54  parProfiling
55  );
56 }
57 
58 
59 // Has been initialised
60 static bool initialised_(false);
61 
62 
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64 
65 Foam::parProfilingSolver::parProfilingSolver
66 (
67  const word& fieldName,
68  const lduMatrix& matrix,
69  const FieldField<Field, scalar>& interfaceBouCoeffs,
70  const FieldField<Field, scalar>& interfaceIntCoeffs,
71  const lduInterfaceFieldPtrsList& interfaces,
72  const dictionary& solverControls
73 )
74 :
76  (
77  fieldName,
78  matrix,
79  interfaceBouCoeffs,
80  interfaceIntCoeffs,
81  interfaces,
82  solverControls
83  )
84 {
85  if (!initialised_)
86  {
87  initialised_ = true;
90  }
91 
92  const word baseSolver(solverControls.get<word>("baseSolver"));
93 
94  solvePtr_.reset
95  (
97  (
98  baseSolver,
99  fieldName,
100  matrix,
103  interfaces,
104  solverControls
105  )
106  );
107 }
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
113 (
114  scalarField& psi_s,
115  const scalarField& source,
116  const direction cmpt
117 ) const
118 {
120  Foam::solverPerformance perf(solvePtr_->solve(psi_s, source, cmpt));
122 
123  return perf;
124 }
125 
126 
127 // ************************************************************************* //
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
Definition: lduMatrix.H:311
uint8_t direction
Definition: direction.H:46
static bool initialised_(false)
Base solver class.
Definition: solver.H:45
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with forwarding to the base solver.
const lduMatrix & matrix() const noexcept
Definition: lduMatrix.H:306
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
Macros for easy insertion into run-time selection tables.
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:51
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
A class for handling words, derived from Foam::string.
Definition: word.H:63
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics...
Abstract base-class for lduMatrix solvers.
Definition: lduMatrix.H:129
const lduInterfaceFieldPtrsList & interfaces() const noexcept
Definition: lduMatrix.H:321
Wrapper to switch on parProfiling around a linear solver.
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.
lduMatrix::solver baseType
defineTypeNameAndDebug(combustionModel, 0)
static void reset()
Reset times/counts. Does not affect the timer itself.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: lduMatrix.H:79
static bool suspend() noexcept
Suspend use of timer. Return old status.
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
Definition: lduMatrix.H:316
const word & fieldName() const noexcept
Definition: lduMatrix.H:301
static void enable()
Create timer for measuring communication or un-suspend existing.
Namespace for OpenFOAM.