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-2025 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, template<class> class GeoField>
100 void Foam::fvMesh::storeOldTimeFields()
101 {
102  UPtrList<GeoField<Type>> curFields(this->curFields<GeoField<Type>>());
103 
104  forAll(curFields, i)
105  {
106  curFields[i].storeOldTimes();
107  }
108 }
109 
110 
111 template<template<class> class GeoField>
112 void Foam::fvMesh::storeOldTimeFields()
113 {
114  #define StoreOldTimeFields(Type, nullArg) \
115  storeOldTimeFields<Type, GeoField>();
117  #undef StoreOldTimeFields
118 }
119 
120 
121 template<class Type, template<class> class GeoField>
122 void Foam::fvMesh::nullOldestTimeFields()
123 {
124  UPtrList<GeoField<Type>> curFields(this->curFields<GeoField<Type>>());
125 
126  forAll(curFields, i)
127  {
128  curFields[i].nullOldestTime();
129  }
130 }
131 
132 
133 template<template<class> class GeoField>
134 void Foam::fvMesh::nullOldestTimeFields()
135 {
136  #define nullOldestTimeFields(Type, nullArg) \
137  nullOldestTimeFields<Type, GeoField>();
139  #undef nullOldestTimeFields
140 }
141 
142 
143 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:458
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:96
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.
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:1029
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
void pow(LagrangianPatchField< typename powProduct< Type, r >::type > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488