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 
56 defineTypeNameAndDebug(variablesSet, 0);
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 autoPtr<variablesSet>();
79 }
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
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,
115  useSolverNameForFields
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);
124  if (useSolverNameForFields)
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 
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);
158  setFluxField
159  (
160  fieldPtr,
161  mesh,
162  velocity,
163  baseName,
164  solverName,
165  useSolverNameForFields
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  ),
189  mesh,
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::variablesSet::useSolverNameForFields
bool useSolverNameForFields() const
Append solver name to fields?
Definition: variablesSet.C:90
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::variablesSet::solverName
const word & solverName() const
Return solver name.
Definition: variablesSet.C:84
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
processorFvPatch.H
cyclicFvPatch.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
processorFvPatchField.H
cyclicAMIFvPatchField.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::variablesSet::allocateFluxField
tmp< surfaceScalarField > allocateFluxField(const fvMesh &mesh, const volVectorField &velocity, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Definition: variablesSet.C:149
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
wallFvPatch.H
Foam::variablesSet::setFluxField
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:97
surfaceFields.H
Foam::surfaceFields.
Foam::dimensionSet
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:108
symmetryPlaneFvPatch.H
symmetryPlaneFvPatchField.H
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:50
Foam::variablesSet::clone
virtual autoPtr< variablesSet > clone() const
Clone the variablesSet.
Definition: variablesSet.C:75
Foam::variablesSet
Base class for creating a set of variables.
Definition: variablesSet.H:49
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::variablesSet::transfer
virtual void transfer(variablesSet &vars)
Transfer the fields of another variablesSet to this.
Definition: variablesSet.C:196
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:187
symmetryFvPatchField.H
Foam::autoPtr::ptr
T * ptr() noexcept
Same as release().
Definition: autoPtr.H:172
symmetryFvPatch.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::variablesSet::autoCreateMeshMovementField
static tmp< volVectorField > autoCreateMeshMovementField(const fvMesh &mesh, const word &name, const dimensionSet &dims)
Auto create variable for mesh movement.
Definition: variablesSet.C:173
Foam::variablesSet::solverName_
word solverName_
Solver name owning the variables set.
Definition: variablesSet.H:95
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
emptyFvPatch.H
Foam::autoPtr::reset
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:117
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
emptyFvPatchField.H
Foam::linearInterpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: linear.H:112
fixedValueFvPatchFields.H
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
cyclicFvPatchField.H
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:148
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::variablesSet::useSolverNameForFields_
bool useSolverNameForFields_
Append the solver name to the variables names?
Definition: variablesSet.H:98
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
cyclicAMIFvPatch.H
variablesSet.H
Foam::dictionary::dictName
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionaryI.H:60
Foam::fvMesh::Sf
const surfaceVectorField & Sf() const
Return cell face area vectors.
Definition: fvMeshGeometry.C:319