fvExprDriverI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2010-2018 Bernhard Gschaider
9  Copyright (C) 2019-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "Time.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
34 (
35  const word& name
36 ) const
37 {
38  return delayedVariables_.found(name) || variables_.found(name);
39 }
40 
41 
44 (
45  const word& name
46 ) const
47 {
48  if (delayedVariables_.found(name))
49  {
50  return delayedVariables_[name];
51  }
52 
53  return variables_[name];
54 }
55 
56 
59 (
60  const word& name
61 )
62 {
63  if (delayedVariables_.found(name))
64  {
65  return delayedVariables_[name];
66  }
67 
68  return variables_[name];
69 }
70 
71 
72 template<class Type>
74 (
75  const word& name,
76  const bool wantPointData,
77  const label expectedSize
78 ) const
79 {
80  return
81  (
82  this->isLocalVariable<Type>(name, wantPointData, expectedSize)
83  || this->isGlobalVariable<Type>(name, wantPointData, expectedSize)
84  );
85 }
86 
87 
88 template<class Type>
90 (
91  const word& name,
92  const bool wantPointData,
93  const label expectedSize
94 )
95 const
96 {
97  return
98  (
99  this->isVariable<Type>(name, wantPointData, expectedSize)
100  || this->isField<Type>(name, wantPointData)
101  );
102 }
103 
104 
105 template<class GeomField>
108 (
109  const word& name,
110  const bool mandatory,
111  const bool getOldTime
112 )
113 {
114  return this->getOrReadFieldImpl<GeomField>
115  (
116  name,
117  this->mesh(),
118  mandatory,
119  getOldTime
120  );
121 }
122 
123 
124 template<class GeomField>
127 (
128  const word& name,
129  const bool mandatory,
130  const bool getOldTime
131 )
132 {
133  return this->getOrReadFieldImpl<GeomField>
134  (
135  name,
136  pointMesh::New(this->mesh()),
137  mandatory,
138  getOldTime
139  );
140 }
141 
142 
143 template<class GeomField, class Mesh>
146 (
147  const word& name,
148  const Mesh& meshRef
149 )
150 {
151  GeomField* ptr = new GeomField
152  (
153  IOobject
154  (
155  name,
156  meshRef.thisDb().time().timeName(),
157  meshRef.thisDb(),
158  IOobject::MUST_READ,
159  IOobject::NO_WRITE,
160  false // Unregistered
161  ),
162  meshRef
163  );
164 
165  if (cacheReadFields())
166  {
167  DebugInfo
168  << "Registering a copy of " << name << " with mesh" << nl;
169 
170  // This is clunky
171  ptr->checkIn();
172  return tmp<GeomField>(regIOobject::store(ptr));
173  }
174 
175  return tmp<GeomField>(ptr);
176 }
177 
178 
179 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::expressions::fvExprDriver::getOrReadField
tmp< GeomField > getOrReadField(const word &name, const bool mandatory=true, const bool getOldTime=false)
Retrieve field from memory or disk.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::expressions::fvExprDriver::isVariable
bool isVariable(const word &name, bool wantPointData=false, label expectSize=-1) const
Test existence of a local/global variable.
Definition: fvExprDriverI.H:74
Foam::expressions::exprResult
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:124
Foam::expressions::fvExprDriver::hasVariable
virtual bool hasVariable(const word &name) const
True if named variable exists.
Definition: fvExprDriverI.H:34
Foam::expressions::fvExprDriver::getOrReadPointField
tmp< GeomField > getOrReadPointField(const word &name, const bool mandatory=true, const bool getOldTime=false)
Retrieve point field from memory or disk.
Foam::expressions::fvExprDriver::readAndRegister
tmp< GeomField > readAndRegister(const word &name, const MeshRef &meshRef)
Helper function for getOrReadField.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Time.H
Foam::expressions::fvExprDriver::variable
virtual exprResult & variable(const word &name)
Non-const access to the named variable (sub-classes only)
Definition: fvExprDriverI.H:59
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::expressions::fvExprDriver::isVariableOrField
bool isVariableOrField(const word &name, const bool wantPointData=false, const label expectSize=-1) const
Test for existence of a local/global variable or a field.
Definition: fvExprDriverI.H:90
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59