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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::fv::directionalPressureGradientExplicitSource
28 
29 Group
30  grpFvOptionsSources
31 
32 Description
33  Creates an explicit pressure gradient source in such a way to deflect the
34  flow towards an specific direction (flowDir). Alternatively add an extra
35  pressure drop in the flowDir direction using a model.
36 
37  \heading Source usage
38  Example usage:
39  \verbatim
40  airDeflection
41  {
42  type directionalPressureGradientExplicitSource;
43  active true;
44 
45  directionalPressureGradientExplicitSourceCoeffs
46  {
47  selectionMode cellZone;
48  cellZone cZone;
49 
50  fields (U); // Name of the field
51  flowDir (1 1 0); // Desired flow direction
52  faceZone f0Zone; // Face zone upstream cell zone
53  relaxationFactor 0.3; // Relaxation factor for flow
54  // deflection (default 0.3)
55 
56  //Pressure drop model [Pa]
57  model volumetricFlowRateTable;//constant;//DarcyForchheimer;
58 
59  //DarcyForchheimer model
60  // deltaP = (D*mu + 0.5*rho*magUn)*magUn*length_
61 
62  D 5e7;
63  I 0;
64  length 1e-3;
65 
66  //constant model
67  pressureDrop 40;
68 
69  //volumetricFlowRateTable model
70  outOfBounds clamp;
71  fileName "volFlowRateTable";
72  }
73  }
74  \endverbatim
75 
76  NOTE: In order to obtain the upwind velocities this function loops over
77  the slaves cells of the faceZone specified in the dictionary, on the other
78  hand, the cellZone to which this source term is applied should be composed
79  of the master cells and they should be 'downwind' the faceZone.
80 
81 SourceFiles
82  directionalPressureGradientExplicitSource.C
83 
84 \*---------------------------------------------------------------------------*/
85 
86 #ifndef directionalPressureGradientExplicitSource_H
87 #define directionalPressureGradientExplicitSource_H
88 
89 #include "autoPtr.H"
90 #include "fvMesh.H"
91 #include "volFields.H"
92 #include "fvOption.H"
93 #include "cellSetOption.H"
94 #include "interpolationTable.H"
95 
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 namespace Foam
100 {
101 namespace fv
102 {
103 
104 /*---------------------------------------------------------------------------*\
105  Class directionalPressureGradientExplicitSource Declaration
106 \*---------------------------------------------------------------------------*/
107 
109 :
110  public cellSetOption
111 {
112 public:
113 
114  // Public enumeration
115 
116  //- Modes of pressure drop
117  enum pressureDropModel
118  {
122  };
123 
124 
125 private:
126 
127  // Private data
128 
129  static const Enum<pressureDropModel> pressureDropModelNames_;
130 
131  //- Pressure drop model
132  pressureDropModel model_;
133 
134  //- Pressure gradient before correction
135  vectorField gradP0_;
136 
137  //- Change in pressure gradient
138  vectorField dGradP_;
139 
140  //- Pressure drop due to porous media
141  vectorField gradPporous_;
142 
143  //- Flow direction
144  vector flowDir_;
145 
146  //- Matrix 1/A coefficients field pointer
147  autoPtr<volScalarField> invAPtr_;
148 
149  //- Darcy pressure loss coefficient
150  scalar D_;
151 
152  //- Inertia pressure lost coefficient
153  scalar I_;
154 
155  //- Porous media length
156  scalar length_;
157 
158  //- Constant pressure drop
159  scalar pressureDrop_;
160 
161  //- Volumetric flow rate vs pressure drop table
162  interpolationTable<scalar> flowRate_;
163 
164  //- Name of the faceZone at the heat exchange inlet
165  word faceZoneName_;
166 
167  //- Id for the face zone
168  label zoneID_;
169 
170  //- Local list of face IDs
171  labelList faceId_;
172 
173  //- Local list of patch ID per face
174  labelList facePatchId_;
175 
176  //- Relaxation factor
177  scalar relaxationFactor_;
178 
179  //- Cells faces mapping
180  labelList cellFaceMap_;
181 
182 
183  // Private Member Functions
184 
185  //- Init
186  void initialise();
187 
188  //- Write the pressure gradient to file (for restarts etc)
189  void writeProps(const vectorField& gradP) const;
190 
191  //- Correct driving force for a constant mass flow rate
192  void update(fvMatrix<vector>& eqn);
193 
194  //- No copy construct
196  (
198  ) = delete;
199 
200  //- No copy assignment
201  void operator=
202  (
204  ) = delete;
205 
206 
207 public:
208 
209  //- Runtime type information
210  TypeName("directionalPressureGradientExplicitSource");
211 
212 
213  // Constructors
214 
215  //- Construct from explicit source name and mesh
217  (
218  const word& sourceName,
219  const word& modelType,
220  const dictionary& dict,
221  const fvMesh& mesh
222  );
223 
224 
225  // Member Functions
226 
227  // Evaluate
228 
229  //- Correct the pressure gradient
230  virtual void correct(volVectorField& U);
231 
232  //- Add explicit contribution to momentum equation
233  virtual void addSup
234  (
235  fvMatrix<vector>& eqn,
236  const label fieldI
237  );
238 
239  //- Add explicit contribution to compressible momentum equation
240  virtual void addSup
241  (
242  const volScalarField& rho,
243  fvMatrix<vector>& eqn,
244  const label fieldI
245  );
246 
247  //- Set 1/A coefficient
248  virtual void constrain
249  (
250  fvMatrix<vector>& eqn,
251  const label fieldI
252  );
253 
254 
255  // I-O
256 
257  //- Write the source properties
258  virtual void writeData(Ostream& os) const;
259 
260  //- Read source dictionary
261  virtual bool read(const dictionary& dict);
262 };
263 
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 } // End namespace fv
268 } // End namespace Foam
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 #endif
273 
274 // ************************************************************************* //
volFields.H
Foam::fv::directionalPressureGradientExplicitSource::pVolumetricFlowRateTable
Definition: directionalPressureGradientExplicitSource.H:118
gradP
volVectorField gradP(fvc::grad(p))
Foam::Enum< pressureDropModel >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fv::cellSetOption
Cell-set options abstract base class. Provides a base set of controls, e.g.:
Definition: cellSetOption.H:72
Foam::fv::directionalPressureGradientExplicitSource::constrain
virtual void constrain(fvMatrix< vector > &eqn, const label fieldI)
Set 1/A coefficient.
Definition: directionalPressureGradientExplicitSource.C:499
Foam::fv::directionalPressureGradientExplicitSource::pDarcyForchheimer
Definition: directionalPressureGradientExplicitSource.H:120
interpolationTable.H
Foam::fv::directionalPressureGradientExplicitSource::pConstant
Definition: directionalPressureGradientExplicitSource.H:119
rho
rho
Definition: readInitialConditions.H:88
cellSetOption.H
Foam::Field< vector >
Foam::fv::directionalPressureGradientExplicitSource::TypeName
TypeName("directionalPressureGradientExplicitSource")
Runtime type information.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::directionalPressureGradientExplicitSource::pressureDropModel
pressureDropModel
Modes of pressure drop.
Definition: directionalPressureGradientExplicitSource.H:116
Foam::fv::directionalPressureGradientExplicitSource
Creates an explicit pressure gradient source in such a way to deflect the flow towards an specific di...
Definition: directionalPressureGradientExplicitSource.H:107
fv
labelList fv(nPoints)
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
U
U
Definition: pEqn.H:72
Foam::fv::directionalPressureGradientExplicitSource::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldI)
Add explicit contribution to momentum equation.
Definition: directionalPressureGradientExplicitSource.C:462
Foam::Vector< scalar >
fvOption.H
Foam::List< label >
Foam::fv::option::mesh
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:36
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
Foam::fv::directionalPressureGradientExplicitSource::writeData
virtual void writeData(Ostream &os) const
Write the source properties.
Definition: directionalPressureGradientExplicitSource.C:533
Foam::interpolationTable< scalar >
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::fv::directionalPressureGradientExplicitSource::correct
virtual void correct(volVectorField &U)
Correct the pressure gradient.
Definition: directionalPressureGradientExplicitSource.C:257
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::fv::directionalPressureGradientExplicitSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: directionalPressureGradientExplicitSource.C:542
autoPtr.H