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-------------------------------------------------------------------------------
11License
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
72template<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
88template<class Type>
90(
91 const word& name,
92 const bool wantPointData,
93 const label expectedSize
94)
95const
96{
97 return
98 (
99 this->isVariable<Type>(name, wantPointData, expectedSize)
100 || this->isField<Type>(name, wantPointData)
101 );
102}
103
104
105template<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
124template<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
143template<class GeomField, class Mesh>
146(
147 const word& name,
148 const Mesh& meshRef
149)
150{
151 GeomField* ptr = new GeomField
152 (
154 (
155 name,
156 meshRef.thisDb().time().timeName(),
157 meshRef.thisDb(),
160 false // Unregistered
161 ),
162 meshRef
163 );
164
165 if (cacheReadFields())
166 {
168 << "Registering a copy of " << name << " with mesh" << nl;
169
170 // This is clunky
171 ptr->checkIn();
173 }
174
175 return tmp<GeomField>(ptr);
176}
177
178
179// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
HashTable< exprResult > variables_
The variables table.
Definition: exprDriver.H:197
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:127
tmp< GeomField > getOrReadPointField(const word &name, const bool mandatory=true, const bool getOldTime=false)
Retrieve point field from memory or disk.
tmp< GeomField > readAndRegister(const word &name, const MeshRef &meshRef)
Helper function for getOrReadField.
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
virtual bool hasVariable(const word &name) const
True if named variable exists.
Definition: fvExprDriverI.H:34
tmp< GeomField > getOrReadField(const word &name, const bool mandatory=true, const bool getOldTime=false)
Retrieve field from memory or disk.
const word & variable() const
Returns the variable on which the model is based.
A class for managing temporary objects.
Definition: tmp.H:65
bool isVariable() const noexcept
Token is VARIABLE (string variant)
Definition: tokenI.H:671
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
#define DebugInfo
Report an information message using Foam::Info.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53