volumeFractionSource.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2019 OpenFOAM Foundation
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::volumeFractionSource
26 
27 Description
28  This option adds transport terms into the equations to account for the
29  presence of a constant volume fraction. The volume fraction is read from
30  constant/alpha.<phase>, where <phase> is given as a parameter to the
31  option. Both advective and diffusive terms are added, and the resulting
32  solution is time-accurate. The flux and velocity are treated as
33  superficial.
34 
35  This can be used to represent the effect of porous media that are caused
36  purely by the reduction in volume of the fluid phase; i.e., additional
37  blockage, and changes to transport and diffusion rates. It does not
38  represent losses or transfers with the porous media. That requires separate
39  sub-modelling.
40 
41 Usage
42  \table
43  Property | Description | Req'd? | Default
44  phase | Name of the phase associated with the volume fraction \\
45  | yes |
46  phi | Name of the flux field | no | phi
47  rho | Name of the density field | no | rho
48  U | Name of the velocity field | no | U
49  fields | Names of the fields to apply the option to \\
50  | yes |
51  \endtable
52 
53  Example specification:
54  \verbatim
55  <fvOptionName>
56  {
57  type volumeFractionSource;
58  phase solid;
59  phi phi;
60  rho rho;
61  U U;
62  fields (rho U e);
63  }
64  \endverbatim
65 
66 SourceFiles
67  volumeFractionSource.C
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef volumeFractionSource_H
72 #define volumeFractionSource_H
73 
74 #include "fvOption.H"
75 #include "surfaceFields.H"
76 #include "volFields.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 namespace fv
83 {
84 
85 /*---------------------------------------------------------------------------*\
86  Class volumeFractionSource Declaration
87 \*---------------------------------------------------------------------------*/
88 
89 class volumeFractionSource
90 :
91  public option
92 {
93  // Private Member Data
94 
95  //- The name of the phase
96  const word phaseName_;
97 
98  //- The name of the flux field
99  word phiName_;
100 
101  //- The name of the density field
102  word rhoName_;
103 
104  //- The name of the velocity field
105  word UName_;
106 
107 
108  // Private Member Functions
109 
110  //- Get the volume fraction field
111  const volScalarField& alpha() const;
112 
113  //- Get the diffusivity for a given field
114  tmp<volScalarField> D(const label) const;
115 
116  //- Add time-derivative terms to an equation
117  template <class Type>
118  void addDdtSup(fvMatrix<Type>&, const label);
119 
120  //- Add time-derivative terms to a compressible equation
121  template <class Type>
122  void addDdtSup(const volScalarField&, fvMatrix<Type>&, const label);
123 
124  //- Add time-derivative terms to a phase-compressible equation
125  template <class Type>
126  void addDdtSup
127  (
128  const volScalarField&,
129  const volScalarField&,
131  const label
132  );
133 
134  //- Add divergence terms to an equation
135  template <class Type>
136  void addDivSup(fvMatrix<Type>&, const label);
137 
138  //- Add divergence terms to the momentum equation
139  void addUDivSup(fvMatrix<vector>&, const label);
140 
141  //- Add divergence terms to the continuity equation
142  void addRhoDivSup(fvMatrix<scalar>&, const label);
143 
144  //- Add Laplacian terms to an equation
145  template <class Type, class AlphaFieldType>
146  void addLaplacianSup
147  (
148  const AlphaFieldType& alpha,
149  fvMatrix<Type>& eqn,
150  const label fieldi
151  );
152 
153 
154 public:
155 
156  //- Runtime type information
157  TypeName("volumeFractionSource");
158 
159 
160  // Constructors
161 
162  //- Construct from components
164  (
165  const word& name,
166  const word& modelType,
167  const dictionary& dict,
168  const fvMesh& mesh
169  );
170 
171  //- Disallow default bitwise copy construction
173 
174 
175  //- Destructor
176  virtual ~volumeFractionSource();
177 
178 
179  // Member Functions
180 
181  // Evaluation
182 
183  // Explicit and implicit sources
184 
185  virtual void addSup(fvMatrix<scalar>&, const label);
186 
187  virtual void addSup(fvMatrix<vector>&, const label);
188 
189  virtual void addSup(fvMatrix<symmTensor>&, const label);
190 
191  virtual void addSup(fvMatrix<sphericalTensor>&, const label);
192 
193  virtual void addSup(fvMatrix<tensor>&, const label);
194 
195 
196  // Explicit and implicit sources for compressible equations
197 
198  virtual void addSup
199  (
200  const volScalarField&,
202  const label
203  );
204 
205  virtual void addSup
206  (
207  const volScalarField&,
209  const label
210  );
211 
212  virtual void addSup
213  (
214  const volScalarField&,
216  const label
217  );
218 
219  virtual void addSup
220  (
221  const volScalarField&,
223  const label
224  );
225 
226  virtual void addSup
227  (
228  const volScalarField&,
230  const label
231  );
232 
233 
234  // Explicit and implicit sources for phase equations
235 
236  virtual void addSup
237  (
238  const volScalarField&,
239  const volScalarField&,
241  const label
242  );
243 
244  virtual void addSup
245  (
246  const volScalarField&,
247  const volScalarField&,
249  const label
250  );
251 
252  virtual void addSup
253  (
254  const volScalarField&,
255  const volScalarField&,
257  const label
258  );
259 
260  virtual void addSup
261  (
262  const volScalarField&,
263  const volScalarField&,
265  const label
266  );
267 
268  virtual void addSup
269  (
270  const volScalarField&,
271  const volScalarField&,
273  const label
274  );
275 
276 
277  // IO
278 
279  //- Read dictionary
280  virtual bool read(const dictionary& dict);
281 
282 
283  // Member Operators
284 
285  //- Disallow default bitwise assignment
286  void operator=(const volumeFractionSource&) = delete;
287 };
288 
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 } // End namespace fv
293 } // End namespace Foam
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 #endif
298 
299 // ************************************************************************* //
Foam::surfaceFields.
TypeName("volumeFractionSource")
Runtime type information.
dictionary dict
virtual ~volumeFractionSource()
Destructor.
virtual void addSup(fvMatrix< scalar > &, const 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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual bool read(const dictionary &dict)
Read dictionary.
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
void operator=(const volumeFractionSource &)=delete
Disallow default bitwise assignment.
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
This option adds transport terms into the equations to account for the presence of a constant volume ...
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
const word & name() const
Return const access to the source name.
Definition: fvOptionI.H:28
volumeFractionSource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Namespace for OpenFOAM.