DimensionedFieldNew.C
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) 2022-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
29 
30 template<class Type, class GeoMesh>
33 (
34  const word& name,
35  const Mesh& mesh,
36  const dimensionSet& dims,
37  const Field<Type>& iField
38 )
39 {
40  const bool caching = mesh.thisDb().cacheTemporaryObject(name);
41 
42  return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
43  (
44  caching, // (true: immovable, false: movable)
45  IOobject
46  (
47  name,
48  mesh.thisDb().time().timeName(),
49  mesh.thisDb(),
50  IOobjectOption::NO_READ,
51  IOobjectOption::NO_WRITE,
52  caching // (true: REGISTER, false: NO_REGISTER)
53  ),
54  mesh,
55  dims,
56  iField
57  );
58 }
59 
60 
61 template<class Type, class GeoMesh>
64 (
65  const word& name,
66  const Mesh& mesh,
67  const dimensionSet& dims,
68  Field<Type>&& iField
69 )
70 {
71  const bool caching = mesh.thisDb().cacheTemporaryObject(name);
72 
73  return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
74  (
75  caching, // (true: immovable, false: movable)
76  IOobject
77  (
78  name,
79  mesh.thisDb().time().timeName(),
80  mesh.thisDb(),
81  IOobjectOption::NO_READ,
82  IOobjectOption::NO_WRITE,
83  caching // (true: REGISTER, false: NO_REGISTER)
84  ),
85  mesh,
86  dims,
87  std::move(iField)
88  );
89 }
90 
91 
92 template<class Type, class GeoMesh>
95 (
96  const word& name,
97  const Mesh& mesh,
98  const dimensionSet& dims
99 )
100 {
101  const bool caching = mesh.thisDb().cacheTemporaryObject(name);
102 
103  return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
104  (
105  caching, // (true: immovable, false: movable)
106  IOobject
107  (
108  name,
109  mesh.thisDb().time().timeName(),
110  mesh.thisDb(),
111  IOobjectOption::NO_READ,
112  IOobjectOption::NO_WRITE,
113  caching // (true: REGISTER, false: NO_REGISTER)
114  ),
115  mesh,
116  dims,
117  false // checkIOFlags off
118  );
119 }
120 
121 
122 template<class Type, class GeoMesh>
125 (
126  const word& name,
127  const Mesh& mesh,
128  const Type& value,
129  const dimensionSet& dims
130 )
131 {
132  const bool caching = mesh.thisDb().cacheTemporaryObject(name);
133 
134  return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
135  (
136  caching, // (true: immovable, false: movable)
137  IOobject
138  (
139  name,
140  mesh.thisDb().time().timeName(),
141  mesh.thisDb(),
142  IOobjectOption::NO_READ,
143  IOobjectOption::NO_WRITE,
144  caching // (true: REGISTER, false: NO_REGISTER)
145  ),
146  mesh,
147  value,
148  dims,
149  false // checkIOFlags off
150  );
151 }
152 
153 
154 template<class Type, class GeoMesh>
157 (
158  const word& name,
159  const Mesh& mesh,
160  const dimensioned<Type>& dt
161 )
162 {
164  (
165  name,
166  mesh,
167  dt.value(),
168  dt.dimensions()
169  );
170 }
171 
172 
173 template<class Type, class GeoMesh>
176 (
177  const word& name,
179 )
180 {
181  const bool caching = tfld().db().cacheTemporaryObject(name);
182 
183  return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
184  (
185  caching, // (true: immovable, false: movable)
186  IOobject
187  (
188  name,
189  tfld().instance(),
190  tfld().local(),
191  tfld().db(),
192  IOobjectOption::NO_READ,
193  IOobjectOption::NO_WRITE,
194  caching // (true: REGISTER, false: NO_REGISTER)
195  ),
196  tfld
197  );
198 }
199 
200 
201 template<class Type, class GeoMesh>
202 template<class AnyType>
205 (
207  const word& name,
208  const dimensionSet& dims
209 )
210 {
211  const bool caching = fld.db().cacheTemporaryObject(name);
212 
213  return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
214  (
215  caching, // (true: immovable, false: movable)
216  IOobject
217  (
218  name,
219  fld.instance(),
220  fld.db(),
221  IOobjectOption::NO_READ,
222  IOobjectOption::NO_WRITE,
223  caching // (true: REGISTER, false: NO_REGISTER)
224  ),
225  fld.mesh(),
226  dims
227  );
228 }
229 
230 
231 template<class Type, class GeoMesh>
232 template<class AnyType>
235 (
237  const word& name,
238  const dimensioned<Type>& dt
239 )
240 {
241  const bool caching = fld.db().cacheTemporaryObject(name);
242 
243  return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
244  (
245  caching, // (true: immovable, false: movable)
246  IOobject
247  (
248  name,
249  fld.instance(),
250  fld.db(),
251  IOobjectOption::NO_READ,
252  IOobjectOption::NO_WRITE,
253  caching // (true: REGISTER, false: NO_REGISTER)
254  ),
255  fld.mesh(),
256  dt.value(),
257  dt.dimensions()
258  );
259 }
260 
261 
262 // ************************************************************************* //
const Type & value() const noexcept
Return const reference to value.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Generic dimensioned Type class.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:105
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:52
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
bool local
Definition: EEqn.H:20
const dimensionSet & dimensions() const noexcept
Return const reference to dimensions.
Foam::pointMesh ::Mesh Mesh
Type of mesh on which this DimensionedField is instantiated.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:171
static tmp< DimensionedField< Type, GeoMesh > > New(const word &name, const Mesh &mesh, const dimensionSet &dims, const Field< Type > &iField)
Return tmp field from name, mesh, dimensions, copy of internal field.