fvMeshTemplates.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-2026 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 "fvMesh.H"
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type>
32 {
33  return pow
34  (
35  this->solutionD(),
36  pTraits
37  <
38  typename powProduct<Vector<label>,
40  >::zero
41  );
42 }
43 
44 
45 template<class GeoField>
47 (
48  const bool strict,
49  const HashSet<word>& geometryFields
50 ) const
51 {
53  (
54  const_cast<fvMesh&>(*this).lookupClass<GeoField>(strict)
55  );
56  UPtrList<GeoField> curFields(fields.size());
57 
58  label i = 0;
59  forAllIter(typename HashTable<GeoField*>, fields, iter)
60  {
61  if (!geometryFields.found(iter()->name()))
62  {
63  curFields.set(i++, iter());
64  }
65  }
66  curFields.setSize(i);
67 
68  return curFields;
69 }
70 
71 
72 template<class GeoField>
74 (
75  const bool strict,
76  const HashSet<word>& geometryFields
77 ) const
78 {
80  (
81  const_cast<fvMesh&>(*this).lookupClass<GeoField>(strict)
82  );
83  UPtrList<GeoField> curFields(fields.size());
84 
85  label i = 0;
86  forAllIter(typename HashTable<GeoField*>, fields, iter)
87  {
88  if (!geometryFields.found(iter()->name()) && !iter()->isOldTime())
89  {
90  curFields.set(i++, iter());
91  }
92  }
93  curFields.setSize(i);
94 
95  return curFields;
96 }
97 
98 
99 template<class Type>
102 (
103  const word& name
104 ) const
105 {
107  (
108  db().template lookupObject
109  <
111  >(name)
112  );
113 }
114 
115 
116 template<class Type, template<class> class GeoField>
117 void Foam::fvMesh::storeOldTimeFields()
118 {
119  UPtrList<GeoField<Type>> curFields(this->curFields<GeoField<Type>>());
120 
121  forAll(curFields, i)
122  {
123  curFields[i].storeOldTimes();
124  }
125 }
126 
127 
128 template<template<class> class GeoField>
129 void Foam::fvMesh::storeOldTimeFields()
130 {
131  #define StoreOldTimeFields(Type, nullArg) \
132  storeOldTimeFields<Type, GeoField>();
134  #undef StoreOldTimeFields
135 }
136 
137 
138 template<class Type, template<class> class GeoField>
139 void Foam::fvMesh::nullOldestTimeFields()
140 {
141  UPtrList<GeoField<Type>> curFields(this->curFields<GeoField<Type>>());
142 
143  forAll(curFields, i)
144  {
145  curFields[i].nullOldestTime();
146  }
147 }
148 
149 
150 template<template<class> class GeoField>
151 void Foam::fvMesh::nullOldestTimeFields()
152 {
153  #define nullOldestTimeFields(Type, nullArg) \
154  nullOldestTimeFields<Type, GeoField>();
156  #undef nullOldestTimeFields
157 }
158 
159 
160 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:474
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A HashTable with keys but without contents.
Definition: HashSet.H:62
An STL-conforming hash table.
Definition: HashTable.H:127
bool found(const Key &) const
Return true if hashedEntry is found in table.
Definition: HashTable.C:138
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
bool set(const label) const
Is element set.
Definition: UPtrListI.H:87
void setSize(const label)
Reset size of UPtrList. This can only be used to set the size.
Definition: UPtrList.C:61
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
pTraits< Type >::labelType validComponents() const
Return a labelType of valid component indicators.
UPtrList< GeoField > curFields(const bool strict=false, const HashSet< word > &geometryFields=fvMesh::geometryFields) const
Return the list of current fields of type GeoField.
UPtrList< GeoField > fields(bool strict=false, const HashSet< word > &geometryFields=fvMesh::geometryFields) const
Return the list of fields of type GeoField.
tmp< DimensionedField< Type, fvMesh > > lookupField(const word &) const
Lookup a dimensioned field for this geometry.
HashTable< const Type * > lookupClass(const bool strict=false) const
Lookup and return all objects of the given Type.
Traits class for primitives.
Definition: pTraits.H:53
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
Definition: polyMesh.C:1047
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:50
#define StoreOldTimeFields(Type, nullArg)
#define nullOldestTimeFields(Type, nullArg)
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:234
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
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488