MaxwellStefan.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) 2021-2026 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::MaxwellStefan
26 
27 Description
28  Base class for multi-component Maxwell Stefan generalised Fick's law
29  diffusion coefficients based temperature gradient heat flux model with
30  optional Soret thermal diffusion of species.
31 
32  The binary mass diffusion coefficients are specified as Function2<scalar>s
33  of pressure and temperature but independent of composition.
34 
35  The heat flux source is implemented as an implicit energy correction to the
36  temperature gradient based flux source. At convergence the energy
37  correction is 0.
38 
39  References:
40  \verbatim
41  Taylor, R., & Krishna, R. (1993).
42  Multicomponent mass transfer (Vol. 2).
43  John Wiley & Sons.
44 
45  Merk, H. J. (1959).
46  The macroscopic equations for simultaneous heat and mass transfer
47  in isotropic, continuous and closed systems.
48  Applied Scientific Research,
49  Section A, 8(1), 73-99.
50  \endverbatim
51 
52 SourceFiles
53  MaxwellStefan.C
54 
55 \*---------------------------------------------------------------------------*/
56 
57 #ifndef MaxwellStefan_H
58 #define MaxwellStefan_H
59 
60 #include "MeshObjects.H"
61 #include "Function2.H"
62 #include "LUscalarMatrix.H"
63 #include "fvMatricesFwd.H"
64 #include "volFieldsFwd.H"
65 #include "surfaceFieldsFwd.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 // Forward declaration of classes
73 class fvMesh;
74 
75 /*---------------------------------------------------------------------------*\
76  Class MaxwellStefan Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 template<class BasicThermophysicalTransportModel>
80 class MaxwellStefan
81 :
82  public BasicThermophysicalTransportModel,
83  public TopoChangeableMeshObject<fvMesh>
84 {
85  // Private data
86 
87  // Model coefficients
88 
89  //- Array of specie binary mass diffusion coefficient functions
90  // [m^2/s]
92 
93  //- List of specie Soret thermal diffusion coefficient
94  // functions [kg/m/s]
95  PtrList<Function2<scalar>> DTFuncs_;
96 
97  //- Generalised Fick's law diffusion coefficients field list.
98  // This is the diagonal of the mass diffusion coefficient matrix
99  mutable PtrList<volScalarField> Dii_;
100 
101  //- List of fields of the explicit part of the mass diffusion flux
102  // of the species
103  mutable PtrList<surfaceScalarField> jexp_;
104 
105  //- ...
106  mutable PtrList<volScalarField> Di_;
107 
108 
109  // Workspace for diffusion coefficient transformation
110 
111  //- Molecular weights of the species
112  mutable scalarField W;
113 
114  //- List of mass-fraction field pointers
115  // for the internal mesh or a patch
116  mutable List<const scalarField*> YPtrs;
117 
118  //- Matrix of mass diffusion coefficient field pointers
119  // for the internal mesh or a patch
120  mutable SquareMatrix<scalarField*> DijPtrs;
121 
122  //- Mass-fractions at a cell or face
123  mutable scalarField Y;
124 
125  //- Mole-fractions at a cell or face
126  mutable scalarField X;
127 
128  //- Binary mass diffusion coefficient matrix at a cell or face
129  mutable scalarSquareMatrix DD;
130 
131  //- Matrix form of the coefficients in the Maxwell-Stefan equation
132  // at a cell or face
133  mutable LUscalarMatrix A;
134 
135  //- Matrix of composition coefficients at a cell or face
136  // used to transform the binary mass diffusion coefficients into
137  // the generalised Fick's law diffusion coefficients
138  mutable scalarSquareMatrix B;
139 
140  //- Inverse of A
141  mutable scalarSquareMatrix invA;
142 
143  //- Matrix of the generalised Fick's law diffusion coefficients
144  // at a cell or face
145  mutable scalarSquareMatrix D_;
146 
147 
148  // Private Member Functions
149 
150  //- Transform the Binary mass diffusion coefficient matrix DD into the
151  // matrix of the generalised Fick's law diffusion coefficients D
152  void transformDiffusionCoefficient() const;
153 
154  //- Calls transformDiffusionCoefficient() for each cell and patch face
155  // and maps the resulting D into DijPtrs
156  void transformDiffusionCoefficientFields() const;
157 
158  //- Calls transformDiffusionCoefficientFields() for the internal mesh
159  // and each patch and maps the resulting DijPtrs into Dii_ and Dij
160  void transform(List<PtrList<volScalarField>>& Dij) const;
161 
162  //- Update Dii_
163  void updateDii() const;
164 
165  //- Update Dii_ if not yet constructed and return
166  const PtrList<volScalarField>& Dii() const;
167 
168  //- Update jexp_ if not yet constructed and return
169  const PtrList<surfaceScalarField>& jexp() const;
170 
171  //- Update Di if not yet constructed and return
172  const PtrList<volScalarField>& Di() const;
173 
174 
175 public:
176 
177  typedef typename BasicThermophysicalTransportModel::alphaField
178  alphaField;
179 
180  typedef typename
183 
184  typedef typename BasicThermophysicalTransportModel::thermoModel
185  thermoModel;
186 
187 
188  // Constructors
189 
190  //- Construct from a momentum transport model and a thermo model
192  (
193  const word& type,
194  const momentumTransportModel& momentumTransport,
195  const thermoModel& thermo
196  );
197 
198 
199  //- Destructor
200  virtual ~MaxwellStefan()
201  {}
202 
203 
204  // Member Functions
205 
206  //- Read thermophysicalTransport dictionary
207  virtual bool read();
208 
209  //- Mass diffusivity
210  // for a given specie mass-fraction [kg/m/s]
211  virtual tmp<volScalarField> D(const volScalarField& Yi) const;
212 
213  //- Mass diffusivity
214  // for a given specie mass-fraction for patch [kg/m/s]
215  virtual tmp<scalarField> D
216  (
217  const volScalarField& Yi,
218  const label patchi
219  ) const;
220 
221  //- Effective mass diffusion coefficient
222  // for a given specie mass-fraction [kg/m/s]
223  virtual tmp<volScalarField> DEff(const volScalarField& Yi) const;
224 
225  //- Effective mass diffusion coefficient
226  // for a given specie mass-fraction for patch [kg/m/s]
227  virtual tmp<scalarField> DEff
228  (
229  const volScalarField& Yi,
230  const label patchi
231  ) const;
232 
233  //- Return the heat flux [W/m^2]
234  virtual tmp<surfaceScalarField> q() const;
235 
236  //- Return the patch heat flux [W/m^2]
237  virtual tmp<scalarField> q(const label patchi) const;
238 
239  //- Return the source term for the energy equation
240  virtual tmp<fvScalarMatrix> divq(volScalarField& he) const;
241 
242  //- Return the specie flux for the given specie mass-fraction [kg/m^2/s]
243  virtual tmp<surfaceScalarField> j(const volScalarField& Yi) const;
244 
245  //- Return the specie flux
246  // for the given specie mass-fraction for patch [kg/m^2/s]
247  virtual tmp<scalarField> j
248  (
249  const volScalarField& Yi,
250  const label patchi
251  ) const;
252 
253  //- Return the source term for the given specie mass-fraction equation
254  virtual tmp<fvScalarMatrix> divj(volScalarField& Yi) const;
255 
256  //- Update the diffusion coefficients and flux corrections
257  virtual void predict();
258 
259 
260  // Mesh changes
261 
262  //- Update for mesh motion
263  virtual bool movePoints();
264 
265  //- Update topology using the given map
266  virtual void topoChange(const polyTopoChangeMap& map);
267 
268  //- Update from another mesh using the given map
269  virtual void mapMesh(const polyMeshMap& map);
270 
271  //- Redistribute or update using the given distribution map
272  virtual void distribute(const polyDistributionMap& map);
273 };
274 
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 } // End namespace Foam
279 
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 
282 #ifdef NoRepository
283  #include "MaxwellStefan.C"
284 #endif
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************************************************************* //
Generic GeometricField class.
Class to perform the LU decomposition on a symmetric matrix.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
Base class for multi-component Maxwell Stefan generalised Fick's law diffusion coefficients based tem...
Definition: MaxwellStefan.H:83
virtual bool movePoints()
Update for mesh motion.
virtual tmp< volScalarField > DEff(const volScalarField &Yi) const
Effective mass diffusion coefficient.
BasicThermophysicalTransportModel::alphaField alphaField
virtual tmp< fvScalarMatrix > divq(volScalarField &he) const
Return the source term for the energy equation.
virtual tmp< fvScalarMatrix > divj(volScalarField &Yi) const
Return the source term for the given specie mass-fraction equation.
virtual void predict()
Update the diffusion coefficients and flux corrections.
virtual void mapMesh(const polyMeshMap &map)
Update from another mesh using the given map.
virtual tmp< surfaceScalarField > j(const volScalarField &Yi) const
Return the specie flux for the given specie mass-fraction [kg/m^2/s].
virtual ~MaxwellStefan()
Destructor.
virtual tmp< surfaceScalarField > q() const
Return the heat flux [W/m^2].
virtual void distribute(const polyDistributionMap &map)
Redistribute or update using the given distribution map.
MaxwellStefan(const word &type, const momentumTransportModel &momentumTransport, const thermoModel &thermo)
Construct from a momentum transport model and a thermo model.
BasicThermophysicalTransportModel::thermoModel thermoModel
virtual tmp< volScalarField > D(const volScalarField &Yi) const
Mass diffusivity.
BasicThermophysicalTransportModel::momentumTransportModel momentumTransportModel
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
virtual bool read()
Read thermophysicalTransport dictionary.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A templated 2D square matrix of objects of <T>, where the n x n matrix dimension is known and used fo...
Definition: SquareMatrix.H:61
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
Forward declarations of fvMatrix specialisations.
label patchi
compressibleMomentumTransportModel momentumTransportModel
Namespace for OpenFOAM.
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
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
fluidMulticomponentThermo & thermo
Definition: createFields.H:15