residualsTemplates.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) 2015-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 #include "volFields.H"
28 #include "Residuals.H"
29 #include "ListOps.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 {
36  if (obr_.foundObject<VolField<Type>>(fieldName))
37  {
38  typename pTraits<Type>::labelType validComponents
39  (
40  mesh_.validComponents<Type>()
41  );
42 
43  for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
44  {
45  if (component(validComponents, cmpt) != -1)
46  {
48  (
49  file(),
50  fieldName + word(pTraits<Type>::componentNames[cmpt])
51  );
52  }
53  }
54  }
55 }
56 
57 
58 template<class Type>
60 {
61  if (obr_.foundObject<VolField<Type>>(fieldName))
62  {
63  if (Residuals<Type>::found(mesh_, fieldName))
64  {
66  (
67  Residuals<Type>::field(mesh_, fieldName)
68  );
69 
70  const Type& residual = sp.first().initialResidual();
71 
72  typename pTraits<Type>::labelType validComponents
73  (
74  mesh_.validComponents<Type>()
75  );
76 
77  for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
78  {
79  if (component(validComponents, cmpt) != -1)
80  {
81  file() << tab << component(residual, cmpt);
82  }
83  }
84  }
85  else
86  {
87  file() << tab << "N/A";
88  }
89  }
90 }
91 
92 
93 // ************************************************************************* //
Various functions to operate on Lists.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:78
Generic GeometricField class.
DemandDrivenMeshObject to store the solver performance residuals of all the fields of the type it is ...
Definition: Residuals.H:61
T & first()
Return the first element of the list.
Definition: UListI.H:114
const fvMesh & mesh_
Reference to the fvMesh.
OFstream & file()
Return access to the file (if only 1)
Definition: logFiles.C:107
const objectRegistry & obr_
Reference to the region objectRegistry.
void writeResidual(const word &fieldName)
Calculate the field min/max.
void writeFileHeader(const word &fieldName)
Output field header information.
void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
Definition: writeFile.C:121
pTraits< Type >::labelType validComponents() const
Return a labelType of valid component indicators.
bool foundObject(const word &name) const
Is the named Type in registry.
Traits class for primitives.
Definition: pTraits.H:53
A class for handling words, derived from string.
Definition: word.H:62
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
static const char tab
Definition: Ostream.H:259
uint8_t direction
Definition: direction.H:45