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-------------------------------------------------------------------------------
12License
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"
40#include "cyclicFvPatch.H"
41#include "cyclicFvPatchField.H"
42#include "cyclicAMIFvPatch.H"
44#include "symmetryFvPatch.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
55
57
58// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59
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,
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
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,
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 (
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// ************************************************************************* //
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
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:117
T * ptr() noexcept
Same as release().
Definition: autoPtr.H:172
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:109
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
const surfaceVectorField & Sf() const
Return cell face area vectors.
A class for managing temporary objects.
Definition: tmp.H:65
Base class for creating a set of variables.
Definition: variablesSet.H:50
static tmp< volVectorField > autoCreateMeshMovementField(const fvMesh &mesh, const word &name, const dimensionSet &dims)
Auto create variable for mesh movement.
Definition: variablesSet.C:173
bool useSolverNameForFields_
Append the solver name to the variables names?
Definition: variablesSet.H:98
tmp< surfaceScalarField > allocateFluxField(const fvMesh &mesh, const volVectorField &velocity, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Definition: variablesSet.C:149
const word & solverName() const
Return solver name.
Definition: variablesSet.C:84
bool useSolverNameForFields() const
Append solver name to fields?
Definition: variablesSet.C:90
word solverName_
Solver name owning the variables set.
Definition: variablesSet.H:95
virtual autoPtr< variablesSet > clone() const
Clone the variablesSet.
Definition: variablesSet.C:75
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
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
bool
Definition: EEqn.H:20
dynamicFvMesh & mesh
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
const word dictName("faMeshDefinition")
Namespace for OpenFOAM.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: linear.H:112
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
dictionary dict
Foam::surfaceFields.