All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2019 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 {
37 
38  if (obr_.foundObject<fieldType>(fieldName))
39  {
40  typename pTraits<Type>::labelType validComponents
41  (
42  mesh_.validComponents<Type>()
43  );
44 
45  for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
46  {
47  if (component(validComponents, cmpt) != -1)
48  {
50  (
51  file(),
52  fieldName + word(pTraits<Type>::componentNames[cmpt])
53  );
54  }
55  }
56  }
57 }
58 
59 
60 template<class Type>
62 {
64 
65  if (obr_.foundObject<fieldType>(fieldName))
66  {
67  if (Residuals<Type>::found(mesh_, fieldName))
68  {
70  (
71  Residuals<Type>::field(mesh_, fieldName)
72  );
73 
74  const Type& residual = sp.first().initialResidual();
75 
76  typename pTraits<Type>::labelType validComponents
77  (
78  mesh_.validComponents<Type>()
79  );
80 
81  for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
82  {
83  if (component(validComponents, cmpt) != -1)
84  {
85  file() << tab << component(residual, cmpt);
86  }
87  }
88  }
89  else
90  {
91  file() << tab << "N/A";
92  }
93  }
94 }
95 
96 
97 // ************************************************************************* //
void writeResidual(const word &fieldName)
Calculate the field min/max.
static const char tab
Definition: Ostream.H:259
void writeFileHeader(const word &fieldName)
Output field header information.
uint8_t direction
Definition: direction.H:45
Traits class for primitives.
Definition: pTraits.H:50
bool foundObject(const word &name) const
Is the named Type found?
Generic GeometricField class.
T & first()
Return the first element of the list.
Definition: UListI.H:114
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:56
A class for handling words, derived from string.
Definition: word.H:59
pTraits< Type >::labelType validComponents() const
Return a labelType of valid component indicators.
const objectRegistry & obr_
Reference to the region objectRegistry.
OFstream & file()
Return access to the file (if only 1)
Definition: logFiles.C:120
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
const fvMesh & mesh_
Reference to the fvMesh.
MeshObject to store the solver performance residuals of all the fields of the type it is instantiated...
Definition: Residuals.H:52
void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
Definition: writeFile.C:135