turbulenceFieldsTemplates.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) 2012-2023 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 "volFields.H"
27 
28 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const word& fieldName,
34  const tmp<VolField<Type>>& tvalue
35 )
36 {
37  const word scopedName
38  (
40  );
41 
42  if (obr_.foundObject<VolField<Type>>(scopedName))
43  {
44  obr_.lookupObjectRef<VolField<Type>>(scopedName) == tvalue();
45  }
46  else if (obr_.found(scopedName))
47  {
49  << "Cannot store turbulence field " << scopedName
50  << " since an object with that name already exists"
51  << nl << endl;
52  }
53  else
54  {
55  obr_.store
56  (
57  new VolField<Type>
58  (
59  IOobject
60  (
61  scopedName,
62  time_.name(),
63  obr_,
66  ),
67  tvalue
68  )
69  );
70  }
71 }
72 
73 
74 // ************************************************************************* //
Generic GeometricField class.
bool found(const Key &) const
Return true if hashedEntry is found in table.
Definition: HashTable.C:138
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static word groupName(Name name, const word &group)
const word & name() const
Return const reference to name.
const Time & time_
Reference to time.
const objectRegistry & obr_
Reference to the region objectRegistry.
word prefix_
Optional field prefix to avoid name clashes.
void processField(const word &fieldName, const tmp< VolField< Type >> &tvalue)
Process the turbulence field.
Type & lookupObjectRef(const word &name) const
Lookup and return the object reference of the given Type.
bool foundObject(const word &name) const
Is the named Type in registry.
void store()
Transfer ownership of this object to its registry.
Definition: regIOobjectI.H:40
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
#define WarningInFunction
Report a warning using Foam::Warning.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
static const char nl
Definition: Ostream.H:266