convergenceControlTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
27 
28 template<class ResidualData>
30 (
31  const word& fieldName,
32  const List<ResidualData>& residualControl,
33  const bool useRegEx
34 )
35 {
36  forAll(residualControl, i)
37  {
38  if (useRegEx && residualControl[i].name.match(fieldName))
39  {
40  return i;
41  }
42  else if (residualControl[i].name == fieldName)
43  {
44  return i;
45  }
46  }
47 
48  return -1;
49 }
50 
51 
52 template<class Type>
54 (
55  const fvMesh& mesh,
56  const word& fieldName,
57  const label solvei,
58  ITstream& data,
59  scalar& r0,
60  scalar& r
61 )
62 {
64 
65  if (mesh.foundObject<fieldType>(fieldName))
66  {
67  const List<SolverPerformance<Type>> sp(data);
68  r0 = cmptMax(sp[0].initialResidual());
69  r = cmptMax(sp[solvei].initialResidual());
70  }
71 }
72 
73 
74 // ************************************************************************* //
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
bool foundObject(const word &name) const
Is the named Type found?
Generic GeometricField class.
bool match(const std::string &) const
True when strings match literally.
Definition: stringI.H:185
A class for handling words, derived from string.
Definition: word.H:59
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static label residualControlIndex(const word &fieldName, const List< ResidualData > &residualControl, const bool useRegEx=true)
Return the index of the named field in residual control data, or -1.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Input token stream.
Definition: ITstream.H:49
static void getInitialTypeResiduals(const fvMesh &mesh, const word &fieldName, const label solvei, ITstream &data, scalar &r0, scalar &r)
Get the initial residuals for the first and the i-th solves in this.