powerLaw.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) 2012-2017 OpenFOAM Foundation
9  Copyright (C) 2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::porosityModels::powerLaw
29 
30 Description
31  Power law porosity model, given by:
32 
33  \f[
34  S = - \rho C_0 |U|^{(C_1 - 1)} U
35  \f]
36 
37  where
38  \vartable
39  C_0 | model linear coefficient
40  C_1 | model exponent coefficient
41  \endvartable
42 
43 SourceFiles
44  powerLaw.C
45  powerLawTemplates.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef Foam_porosityModels_powerLaw_H
50 #define Foam_porosityModels_powerLaw_H
51 
52 #include "porosityModel.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 namespace porosityModels
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class powerLaw Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class powerLaw
66 :
67  public porosityModel
68 {
69  // Private Data
70 
71  //- C0 coefficient
72  scalar C0_;
73 
74  //- C1 coefficient
75  scalar C1_;
76 
77  //- Name of density field
78  word rhoName_;
79 
80 
81  // Private Member Functions
82 
83  //- Apply resistance
84  template<class RhoFieldType>
85  void apply
86  (
87  scalarField& Udiag,
88  const scalarField& V,
89  const RhoFieldType& rho,
90  const vectorField& U
91  ) const;
92 
93  //- Apply resistance
94  template<class RhoFieldType>
95  void apply
96  (
97  tensorField& AU,
98  const RhoFieldType& rho,
99  const vectorField& U
100  ) const;
101 
102  //- No copy construct
103  powerLaw(const powerLaw&) = delete;
104 
105  //- No copy assignment
106  void operator=(const powerLaw&) = delete;
107 
108 
109 public:
110 
111  //- Runtime type information
112  TypeName("powerLaw");
113 
114  //- Constructor
115  powerLaw
116  (
117  const word& name,
118  const word& modelType,
119  const fvMesh& mesh,
120  const dictionary& dict,
121  const wordRe& cellZoneName
122  );
123 
124  //- Destructor
125  virtual ~powerLaw() = default;
126 
127 
128  // Member Functions
129 
130  //- Transform the model data wrt mesh changes
131  virtual void calcTransformModelData();
132 
133  //- Calculate the porosity force
134  virtual void calcForce
135  (
136  const volVectorField& U,
137  const volScalarField& rho,
138  const volScalarField& mu,
140  ) const;
141 
142  //- Add resistance
143  virtual void correct(fvVectorMatrix& UEqn) const;
144 
145  //- Add resistance
146  virtual void correct
147  (
149  const volScalarField& rho,
150  const volScalarField& mu
151  ) const;
152 
153  //- Add resistance
154  virtual void correct
155  (
156  const fvVectorMatrix& UEqn,
157  volTensorField& AU
158  ) const;
159 
160 
161  // I-O
162 
163  //- Write
164  bool writeData(Ostream& os) const;
165 };
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace porosityModels
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #ifdef NoRepository
175  #include "powerLawTemplates.C"
176 #endif
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #endif
181 
182 // ************************************************************************* //
const dictionary & dict() const
Return dictionary used for model construction.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu)
Return the force over the cell zone(s)
TypeName("powerLaw")
Runtime type information.
virtual ~powerLaw()=default
Destructor.
virtual void calcTransformModelData()
Transform the model data wrt mesh changes.
Definition: powerLaw.C:59
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
Power law porosity model, given by:
Definition: powerLaw.H:68
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:64
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual void calcForce(const volVectorField &U, const volScalarField &rho, const volScalarField &mu, vectorField &force) const
Calculate the porosity force.
Definition: powerLaw.C:66
OBJstream os(runTime.globalPath()/outputName)
virtual void correct(fvVectorMatrix &UEqn) const
Add resistance.
Definition: powerLaw.C:83
bool writeData(Ostream &os) const
Write.
Definition: powerLaw.C:146
const dimensionedScalar mu
Atomic mass unit.
U
Definition: pEqn.H:72
const word & name() const
Return const access to the porosity model name.
fvVectorMatrix & UEqn
Definition: UEqn.H:13
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Namespace for OpenFOAM.