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-2022 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 #include "Residuals.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template<class ResidualData>
32 (
33  const word& fieldName,
34  const List<ResidualData>& residualControl,
35  const bool useRegEx
36 )
37 {
38  forAll(residualControl, i)
39  {
40  if (useRegEx && residualControl[i].name.match(fieldName))
41  {
42  return i;
43  }
44  else if (residualControl[i].name == fieldName)
45  {
46  return i;
47  }
48  }
49 
50  return -1;
51 }
52 
53 
54 template<class Type>
56 (
57  const fvMesh& mesh,
59 )
60 {
62 }
63 
64 
65 template<class Type>
67 (
68  const fvMesh& mesh,
69  const word& fieldName,
70  const label solvei,
71  scalar& r0,
72  scalar& r
73 )
74 {
75  if (mesh.foundObject<VolField<Type>>(fieldName))
76  {
78  (
79  Residuals<Type>::field(mesh, fieldName)
80  );
81 
82  r0 = cmptMax(sp[0].initialResidual());
83  r = cmptMax(sp[solvei].initialResidual());
84  }
85 }
86 
87 
88 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Generic GeometricField class.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
DemandDrivenMeshObject to store the solver performance residuals of all the fields of the type it is ...
Definition: Residuals.H:61
static void getFieldTypeNames(const fvMesh &mesh, DynamicList< word > &fieldNames)
Append the of names of the fields of this Type to the given list.
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.
static void getInitialTypeResiduals(const fvMesh &mesh, const word &fieldName, const label solvei, scalar &r0, scalar &r)
Get the initial residuals for the first and the i-th solves in this.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
bool foundObject(const word &name) const
Is the named Type in registry.
bool match(const std::string &) const
True when strings match literally.
Definition: stringI.H:194
A class for handling words, derived from string.
Definition: word.H:62
static List< word > fieldNames
Definition: globalFoam.H:46
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
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47