directionalPressureGradientExplicitSource.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
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 Class
25  Foam::fv::directionalPressureGradientExplicitSource
26 
27 Description
28  Creates an explicit pressure gradient source in such a way to deflect the
29  flow towards an specific direction (flowDir). Alternatively add an extra
30  pressure drop in the flowDir direction using a model.
31 
32  \heading Source usage
33  Example usage:
34  \verbatim
35  airDeflection
36  {
37  type directionalPressureGradientExplicitSource;
38  active true;
39 
40  directionalPressureGradientExplicitSourceCoeffs
41  {
42  selectionMode cellZone;
43  cellZone cZone;
44 
45  fieldNames (U); // Name of the field
46  flowDir (1 1 0); // Desired flow direction
47  faceZone f0Zone; // Face zone upstream cell zone
48  relaxationFactor 0.3; // Relaxation factor for flow
49  // deflection (default 0.3)
50 
51  //Pressure drop model [Pa]
52  model volumetricFlowRateTable;//constant;//DarcyForchheimer;
53 
54  //DarcyForchheimer model
55  // deltaP = (D*mu + 0.5*rho*magUn)*magUn*length_
56 
57  D 5e7;
58  I 0;
59  length 1e-3;
60 
61  //constant model
62  pressureDrop 40;
63 
64  //volumetricFlowRateTable model
65  outOfBounds clamp;
66  fileName "volFlowRateTable";
67  }
68  }
69  \endverbatim
70 
71  NOTE: In order to obtain the upwind velocities this function loops over
72  the slaves cells of the faceZone specified in the dictionary, on the other
73  hand, the cellZone to which this source term is applied should be composed
74  of the master cells and they should be 'downwind' the faceZone.
75 
76 SourceFiles
77  directionalPressureGradientExplicitSource.C
78 
79 \*---------------------------------------------------------------------------*/
80 
81 #ifndef directionalPressureGradientExplicitSource_H
82 #define directionalPressureGradientExplicitSource_H
83 
84 #include "cellSetOption.H"
85 #include "autoPtr.H"
86 #include "topoSetSource.H"
87 #include "cellSet.H"
88 #include "fvMesh.H"
89 #include "volFields.H"
90 #include "fvOption.H"
91 #include "interpolationTable.H"
92 
93 
94 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 
96 namespace Foam
97 {
98 namespace fv
99 {
100 
101 /*---------------------------------------------------------------------------*\
102  Class directionalPressureGradientExplicitSource Declaration
103 \*---------------------------------------------------------------------------*/
104 
106 :
107  public cellSetOption
108 {
109 public:
110 
111  // Public enumeration
112 
113  //- Modes of pressure drop
114  enum pressureDropModel
115  {
119  };
120 
121 
122 private:
123 
124  // Private data
125 
127 
128  //- Pressure drop model
130 
131  //- Pressure gradient before correction
133 
134  //- Change in pressure gradient
136 
137  //- Pressure drop due to porous media
139 
140  //- Flow direction
142 
143  //- Matrix 1/A coefficients field pointer
145 
146  //- Darcy pressure loss coefficient
147  scalar D_;
148 
149  //- Inertia pressure lost coefficient
150  scalar I_;
151 
152  //- Porous media length
153  scalar length_;
154 
155  //- Constant pressure drop
156  scalar pressureDrop_;
157 
158  //- Volumetric flow rate vs pressure drop table
160 
161  //- Name of the faceZone at the heat exchange inlet
163 
164  //- Id for the face zone
165  label zoneID_;
166 
167  //- Local list of face IDs
169 
170  //- Local list of patch ID per face
172 
173  //- Relaxation factor
174  scalar relaxationFactor_;
175 
176  //- Cells faces mapping
178 
179 
180  // Private Member Functions
181 
182  //- Init
183  void initialise();
184 
185  //- Write the pressure gradient to file (for restarts etc)
186  void writeProps(const vectorField& gradP) const;
187 
188  //- Correct driving force for a constant mass flow rate
189  void update(fvMatrix<vector>& eqn);
190 
191  //- Disallow default bitwise copy construct
193  (
195  );
196 
197  //- Disallow default bitwise assignment
199 
200 
201 public:
202 
203  //- Runtime type information
204  TypeName("directionalPressureGradientExplicitSource");
205 
206 
207  // Constructors
208 
209  //- Construct from explicit source name and mesh
211  (
212  const word& sourceName,
213  const word& modelType,
214  const dictionary& dict,
215  const fvMesh& mesh
216  );
217 
218 
219  // Member Functions
220 
221  // Evaluate
222 
223  //- Correct the pressure gradient
224  virtual void correct(volVectorField& U);
225 
226  //- Add explicit contribution to momentum equation
227  virtual void addSup
228  (
229  fvMatrix<vector>& eqn,
230  const label fieldI
231  );
232 
233  //- Add explicit contribution to compressible momentum equation
234  virtual void addSup
235  (
236  const volScalarField& rho,
237  fvMatrix<vector>& eqn,
238  const label fieldI
239  );
240 
241  //- Set 1/A coefficient
242  virtual void constrain
243  (
244  fvMatrix<vector>& eqn,
245  const label fieldI
246  );
247 
248 
249  // I-O
250 
251  //- Write the source properties
252  virtual void writeData(Ostream&) const;
253 
254  //- Read source dictionary
255  virtual bool read(const dictionary& dict);
256 };
257 
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 } // End namespace fv
262 } // End namespace Foam
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 #endif
267 
268 // ************************************************************************* //
volFields.H
Foam::fv::directionalPressureGradientExplicitSource::relaxationFactor_
scalar relaxationFactor_
Relaxation factor.
Definition: directionalPressureGradientExplicitSource.H:173
Foam::fv::directionalPressureGradientExplicitSource::pVolumetricFlowRateTable
@ pVolumetricFlowRateTable
Definition: directionalPressureGradientExplicitSource.H:115
Foam::fv::directionalPressureGradientExplicitSource::pressureDrop_
scalar pressureDrop_
Constant pressure drop.
Definition: directionalPressureGradientExplicitSource.H:155
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fv::cellSetOption
Cell-set options abtract base class. Provides a base set of controls, e.g.
Definition: cellSetOption.H:71
Foam::fv::directionalPressureGradientExplicitSource::model_
pressureDropModel model_
Pressure drop model.
Definition: directionalPressureGradientExplicitSource.H:128
Foam::fv::directionalPressureGradientExplicitSource::flowRate_
interpolationTable< scalar > flowRate_
Volumetric flow rate vs pressure drop table.
Definition: directionalPressureGradientExplicitSource.H:158
Foam::fv::directionalPressureGradientExplicitSource::length_
scalar length_
Porous media length.
Definition: directionalPressureGradientExplicitSource.H:152
Foam::fv::directionalPressureGradientExplicitSource::faceZoneName_
word faceZoneName_
Name of the faceZone at the heat exchange inlet.
Definition: directionalPressureGradientExplicitSource.H:161
Foam::fv::directionalPressureGradientExplicitSource::gradP0_
vectorField gradP0_
Pressure gradient before correction.
Definition: directionalPressureGradientExplicitSource.H:131
Foam::fv::directionalPressureGradientExplicitSource::flowDir_
vector flowDir_
Flow direction.
Definition: directionalPressureGradientExplicitSource.H:140
Foam::fv::directionalPressureGradientExplicitSource::constrain
virtual void constrain(fvMatrix< vector > &eqn, const label fieldI)
Set 1/A coefficient.
Definition: directionalPressureGradientExplicitSource.C:510
Foam::fv::directionalPressureGradientExplicitSource::pDarcyForchheimer
@ pDarcyForchheimer
Definition: directionalPressureGradientExplicitSource.H:117
Foam::fv::directionalPressureGradientExplicitSource::zoneID_
label zoneID_
Id for the face zone.
Definition: directionalPressureGradientExplicitSource.H:164
interpolationTable.H
Foam::fv::directionalPressureGradientExplicitSource::writeData
virtual void writeData(Ostream &) const
Write the source properties.
Definition: directionalPressureGradientExplicitSourceIO.C:31
Foam::fv::directionalPressureGradientExplicitSource::pConstant
@ pConstant
Definition: directionalPressureGradientExplicitSource.H:116
cellSetOption.H
U
U
Definition: pEqn.H:46
Foam::fv::directionalPressureGradientExplicitSource::directionalPressureGradientExplicitSource
directionalPressureGradientExplicitSource(const directionalPressureGradientExplicitSource &)
Disallow default bitwise copy construct.
Foam::fv::directionalPressureGradientExplicitSource::PressureDropModelNames_
static const NamedEnum< pressureDropModel, 3 > PressureDropModelNames_
Definition: directionalPressureGradientExplicitSource.H:125
Foam::fv::directionalPressureGradientExplicitSource::initialise
void initialise()
Init.
Definition: directionalPressureGradientExplicitSource.C:86
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::fv::directionalPressureGradientExplicitSource::D_
scalar D_
Darcy pressure loss coefficient.
Definition: directionalPressureGradientExplicitSource.H:146
Foam::fv::directionalPressureGradientExplicitSource::TypeName
TypeName("directionalPressureGradientExplicitSource")
Runtime type information.
Foam::fv::directionalPressureGradientExplicitSource::facePatchId_
labelList facePatchId_
Local list of patch ID per face.
Definition: directionalPressureGradientExplicitSource.H:170
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fv::directionalPressureGradientExplicitSource::I_
scalar I_
Inertia pressure lost coefficient.
Definition: directionalPressureGradientExplicitSource.H:149
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
gradP
dimensionedVector gradP("gradP", dimensionSet(0, 1, -2, 0, 0), vector::zero)
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fv::directionalPressureGradientExplicitSource::pressureDropModel
pressureDropModel
Modes of pressure drop.
Definition: directionalPressureGradientExplicitSource.H:113
Foam::fv::directionalPressureGradientExplicitSource
Creates an explicit pressure gradient source in such a way to deflect the flow towards an specific di...
Definition: directionalPressureGradientExplicitSource.H:104
rho
rho
Definition: pEqn.H:3
Foam::fv::directionalPressureGradientExplicitSource::cellFaceMap_
labelList cellFaceMap_
Cells faces mapping.
Definition: directionalPressureGradientExplicitSource.H:176
fv
labelList fv(nPoints)
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::fv::directionalPressureGradientExplicitSource::dGradP_
vectorField dGradP_
Change in pressure gradient.
Definition: directionalPressureGradientExplicitSource.H:134
Foam::fv::directionalPressureGradientExplicitSource::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldI)
Add explicit contribution to momentum equation.
Definition: directionalPressureGradientExplicitSource.C:473
Foam::fv::directionalPressureGradientExplicitSource::operator=
void operator=(const directionalPressureGradientExplicitSource &)
Disallow default bitwise assignment.
Foam::Vector< scalar >
fvOption.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
topoSetSource.H
Foam::fv::directionalPressureGradientExplicitSource::invAPtr_
autoPtr< volScalarField > invAPtr_
Matrix 1/A coefficients field pointer.
Definition: directionalPressureGradientExplicitSource.H:143
Foam::fv::directionalPressureGradientExplicitSource::writeProps
void writeProps(const vectorField &gradP) const
Write the pressure gradient to file (for restarts etc)
Definition: directionalPressureGradientExplicitSource.C:144
Foam::fv::option::mesh
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::fv::directionalPressureGradientExplicitSource::faceId_
labelList faceId_
Local list of face IDs.
Definition: directionalPressureGradientExplicitSource.H:167
Foam::fv::directionalPressureGradientExplicitSource::gradPporous_
vectorField gradPporous_
Pressure drop due to porous media.
Definition: directionalPressureGradientExplicitSource.H:137
Foam::interpolationTable< scalar >
cellSet.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::fv::directionalPressureGradientExplicitSource::correct
virtual void correct(volVectorField &U)
Correct the pressure gradient.
Definition: directionalPressureGradientExplicitSource.C:267
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::fv::directionalPressureGradientExplicitSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: directionalPressureGradientExplicitSourceIO.C:40
Foam::fv::directionalPressureGradientExplicitSource::update
void update(fvMatrix< vector > &eqn)
Correct driving force for a constant mass flow rate.
Foam::NamedEnum< pressureDropModel, 3 >
autoPtr.H