variablesSet.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) 2007-2019 PCOpt/NTUA
9  Copyright (C) 2013-2019 FOSS GP
10  Copyright (C) 2019-2020 OpenCFD Ltd.
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 \*---------------------------------------------------------------------------*/
29 
30 #include "variablesSet.H"
31 #include "surfaceFields.H"
33 #include "linear.H"
34 
35 #include "wallFvPatch.H"
36 #include "emptyFvPatch.H"
37 #include "emptyFvPatchField.H"
38 #include "processorFvPatch.H"
39 #include "processorFvPatchField.H"
40 #include "cyclicFvPatch.H"
41 #include "cyclicFvPatchField.H"
42 #include "cyclicAMIFvPatch.H"
43 #include "cyclicAMIFvPatchField.H"
44 #include "symmetryFvPatch.H"
45 #include "symmetryFvPatchField.H"
46 #include "symmetryPlaneFvPatch.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
55 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
60 variablesSet::variablesSet
61 (
62  fvMesh& mesh,
63  const dictionary& dict
64 )
65 :
66  mesh_(mesh),
67  solverName_(dict.dictName()),
68  useSolverNameForFields_
69  (
70  dict.getOrDefault<bool>("useSolverNameForFields", false)
71  )
72 {}
73 
74 
76 {
78  return nullptr;
79 }
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
84 const word& variablesSet::solverName() const
85 {
86  return solverName_;
87 }
88 
89 
91 {
93 }
94 
95 
97 (
99  const fvMesh& mesh,
100  const volVectorField& velocity,
101  const word& baseName,
102  const word& solverName,
103  const bool useSolverNameForFields
104 )
105 {
106  // Try to read in field with custom or base name
107  bool fieldFound
108  (
109  readFieldOK
110  (
111  fieldPtr,
112  mesh,
113  baseName,
114  solverName,
116  )
117  );
118 
119  // No base or custom field found.
120  // Construct field based on linear interpolation
121  if (!fieldFound)
122  {
123  word phiName(baseName);
125  {
126  phiName += solverName;
127  }
128  IOobject header
129  (
130  phiName,
131  mesh.time().timeName(),
132  mesh,
135  );
136  fieldPtr.reset
137  (
139  (
140  header,
141  linearInterpolate(velocity) & mesh.Sf()
142  )
143  );
144  }
145 }
146 
147 
148 tmp<surfaceScalarField> variablesSet::allocateFluxField
149 (
150  const fvMesh& mesh,
151  const volVectorField& velocity,
152  const word& baseName,
153  const word& solverName,
154  const bool useSolverNameForFields
155 )
156 {
157  autoPtr<surfaceScalarField> fieldPtr(nullptr);
159  (
160  fieldPtr,
161  mesh,
162  velocity,
163  baseName,
164  solverName,
166  );
167 
168  return tmp<surfaceScalarField>(fieldPtr.ptr());
169 }
170 
171 
173 (
174  const fvMesh& mesh,
175  const word& fieldName,
176  const dimensionSet& dims
177 )
178 {
180  (
181  IOobject
182  (
183  fieldName,
184  mesh.time().timeName(),
185  mesh,
188  ),
190  dimensionedVector(dims, Zero),
191  fixedValueFvPatchVectorField::typeName
192  );
193 }
194 
195 
197 {
198  // Does nothing in base
199 }
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace Foam
205 
206 // ************************************************************************* //
Foam::surfaceFields.
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: linear.H:120
virtual void transfer(variablesSet &vars)
Transfer the fields of another variablesSet to this.
Definition: variablesSet.C:189
const word dictName("faMeshDefinition")
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Ignore writing from objectRegistry::writeObject()
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:82
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:37
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:105
dynamicFvMesh & mesh
bool useSolverNameForFields() const
Append solver name to fields?
Definition: variablesSet.C:83
A class for handling words, derived from Foam::string.
Definition: word.H:63
bool useSolverNameForFields_
Append the solver name to the variables names?
Definition: variablesSet.H:107
Reading is optional [identical to LAZY_READ].
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
const word & solverName() const
Return solver name.
Definition: variablesSet.C:77
tmp< surfaceScalarField > allocateFluxField(const fvMesh &mesh, const volVectorField &velocity, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Definition: variablesSet.C:142
defineTypeNameAndDebug(combustionModel, 0)
T * ptr() noexcept
Same as release().
Definition: autoPtr.H:248
Base class for creating a set of variables.
Definition: variablesSet.H:43
static void setFluxField(autoPtr< surfaceScalarField > &fieldPtr, const fvMesh &mesh, const volVectorField &velocity, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Set flux field.
Definition: variablesSet.C:90
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Automatically write from objectRegistry::writeObject()
virtual autoPtr< variablesSet > clone() const
Clone the variablesSet.
Definition: variablesSet.C:68
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
A class for managing temporary objects.
Definition: HashPtrTable.H:50
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
static tmp< volVectorField > autoCreateMeshMovementField(const fvMesh &mesh, const word &name, const dimensionSet &dims)
Auto create variable for mesh movement.
Definition: variablesSet.C:166
Namespace for OpenFOAM.
word solverName_
Solver name owning the variables set.
Definition: variablesSet.H:102
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127