speciesSorptionFvPatchScalarField.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) 2022 OpenCFD Ltd.
9  Copyright (C) 2026 Keysight Technologies
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::speciesSorptionFvPatchScalarField
29 
30 Group
31  grpGenericBoundaryConditions
32 
33 Description
34  This boundary condition provides a first-order zero-gradient
35  condition for a given scalar field to model time-dependent
36  adsorption-desorption processes. Desorption can be disabled.
37 
38  \f[
39  \frac{d c}{d t} = k_{ads} (c_{eq} - c_{abs})
40  \f]
41 
42  where
43  \vartable
44  c_{eq} | Equilibrium concentration
45  c_{abs} | Absorbed at wall
46  k_{ads} | Adsorption rate constant [1/s]
47  \endvartable
48 
49  \f[
50  c_{eq} = c_{max} \frac{k_l \, c_{int}}{1 + k_l \, c_{int}}
51  \f]
52 
53  where
54  \vartable
55  c_{max} | Maximum concentration
56  k_l | Langmuir constant
57  c_{int} | Local cell value concentration
58  \endvartable
59 
60 Usage
61  Example of the boundary condition specification:
62  \verbatim
63  <patchName>
64  {
65  // Mandatory entries
66  type speciesSorption;
67  equilibriumModel <word>;
68  kinematicModel <word>;
69  kabs <scalar>;
70  kl <scalar>;
71  max <scalar>;
72  thickness <PatchFunction1<scalar>>;
73  rhoS <scalar>;
74 
75  // Optional entries
76  allowDesorption <bool>;
77  dfldp <scalarField>;
78  mass <scalarField>;
79  pName <word>;
80 
81  // Inherited entries
82  ...
83  }
84  \endverbatim
85 
86  where the entries mean:
87  \table
88  Property | Description | Type | Reqd | Deflt
89  type | Type name: speciesSorption | word | yes | -
90  equilibriumModel | Equilibrium model | word | yes | -
91  kinematicModel | Kinematic model | word | yes | -
92  kabs | Adsorption rate constant [1/s] | scalar | yes | -
93  kl | Langmuir constant [1/Pa] | scalar | yes | -
94  max | Maximum concentation at wall [mol/kg] | scalar | yes | -
95  thickness| Solid thickness along the patch <!--
96  --> | PatchFunction1<scalar> | yes | -
97  rhoS | Solid density | scalar | yes | -
98  allowDesorption | Allow desorption from the solid | bool | no | true
99  dfldp | Source on cells next to patch | scalarField | no | Zero
100  mass | Absorbed mass per kg of absorbent [mol/kg] <!--
101  --> | scalarField | no | Zero
102  pName | Name of operand pressure field | word | no | p
103  \endtable
104 
105  Options for the \c equilibriumModel entry:
106  \verbatim
107  Langmuir | Langmuir model
108  \endverbatim
109 
110  Options for the \c kinematicModel entry:
111  \verbatim
112  PseudoFirstOrder | Pseudo first-order model
113  \endverbatim
114 
115  The inherited entries are elaborated in:
116  - \link zeroGradientFvPatchFields.H \endlink
117  - \link PatchFunction1.H \endlink
118 
119 SourceFiles
120  speciesSorptionFvPatchScalarField.C
121 
122 \*---------------------------------------------------------------------------*/
123 
124 #ifndef Foam_speciesSorptionFvPatchScalarField_H
125 #define Foam_speciesSorptionFvPatchScalarField_H
126 
127 #include "boundarySourcePatch.H"
129 #include "PatchFunction1.H"
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 namespace Foam
134 {
135 
136 /*---------------------------------------------------------------------------*\
137  Class speciesSorptionFvPatchScalarField Declaration
138 \*---------------------------------------------------------------------------*/
139 
140 class speciesSorptionFvPatchScalarField
141 :
142  public zeroGradientFvPatchField<scalar>,
143  public boundarySourcePatch
144 {
145  typedef speciesSorptionFvPatchScalarField this_bctype;
146  typedef zeroGradientFvPatchField<scalar> parent_bctype;
147 
148 public:
149 
150  // Public Enumeration
151 
152  //- Options for the equilibrum model
153  enum equilibriumModelType : char
154  {
155  LANGMUIR = 0
156  };
157 
158  //- Options for the kinematic model
159  enum kineticModelType : char
160  {
161  PseudoFirstOrder = 0
162  };
163 
164  //- Names for equilibriumModelType
165  static const Enum<equilibriumModelType> equilibriumModelTypeNames;
166 
167  //- Names for kineticModelType
168  static const Enum<kineticModelType> kinematicModelTypeNames;
169 
170 
171 private:
172 
173  // Private Data
174 
175  //- Equilibrium model
176  enum equilibriumModelType equilibriumModel_;
177 
178  //- Kinematic model
179  enum kineticModelType kinematicModel_;
180 
181  //- Flag to allow desorption from the solid
182  bool allowDesorption_;
183 
184  //- Solid thickness along the patch
185  autoPtr<PatchFunction1<scalar>> thicknessPtr_;
186 
187  //- Adsorption rate constant [1/sec]
188  scalar kabs_;
189 
190  //- Langmuir adsorption constant [1/Pa]
191  scalar kl_;
192 
193  //- Maximum density on patch [mol/kg]
194  scalar max_;
195 
196  //- Solid density
197  scalar rhoS_;
198 
199  //- Name of operand pressure field
200  word pName_;
201 
202  //- Source on cells next to patch [mol/kg/sec]
203  scalarField dfldp_;
204 
205  //- Absorbed mass per kg of absorbent [mol/kg]
206  scalarField mass_;
207 
208 
209  // Private Member Functions
210 
211  //- Calculate the mole fraction fields
212  tmp<scalarField> calcMoleFractions() const;
213 
214  //- Lookup (or create) field for output
215  volScalarField& field(const word&, const dimensionSet&) const;
216 
217 
218 public:
219 
220  //- Runtime type information
221  TypeName("speciesSorption");
222 
223 
224  // Constructors
225 
226  //- Construct from patch and internal field
228  (
229  const fvPatch&,
230  const DimensionedField<scalar, volMesh>&
231  );
232 
233  //- Construct from patch, internal field and dictionary
235  (
236  const fvPatch&,
237  const DimensionedField<scalar, volMesh>&,
238  const dictionary&
239  );
240 
241  //- Construct by mapping onto a new patch
243  (
244  const this_bctype&,
245  const fvPatch&,
247  const fvPatchFieldMapper&
248  );
249 
250  //- Construct as copy setting internal field reference
252  (
253  const this_bctype&,
255  );
257  //- No copy without an internal field
259  (
260  const this_bctype&
261  ) = delete;
262 
263  //- Clone with an internal field reference
265  (
267  ) const
268  {
269  return fvPatchField<scalar>::Clone(*this, iF);
270  }
271 
273  // Member Functions
274 
275  // Mapping
276 
277  //- Map (and resize as needed) from self given a mapping object
278  virtual void autoMap
279  (
280  const fvPatchFieldMapper&
281  );
282 
283  //- Reverse map the given fvPatchField onto this fvPatchField
284  virtual void rmap
285  (
286  const fvPatchScalarField&,
287  const labelList&
288  );
289 
290 
291  // Evaluation
292 
293  //- Source of cells next to the patch
294  virtual tmp<scalarField> patchSource() const;
295 
296  //- Access to mass
297  tmp<scalarField> mass() const;
298 
299  //- Update the coefficients associated with the patch field
300  virtual void updateCoeffs();
301 
302 
303  // I-O
304 
305  //- Write
306  virtual void write(Ostream&) const;
307 
308 
309  // Member Operators
310 
311  //- Inherit assignment
313 };
314 
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 } // End namespace Foam
319 
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321 
322 #endif
323 
324 // ************************************************************************* //
TypeName("speciesSorption")
Runtime type information.
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
friend Ostream & operator(Ostream &, const fvPatchField< scalar > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
speciesSorptionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
This boundary condition provides a first-order zero-gradient condition for a given scalar field to mo...
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:72
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:635
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A FieldMapper for finite-volume patch fields.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
static const Enum< equilibriumModelType > equilibriumModelTypeNames
Names for equilibriumModelType.
tmp< scalarField > mass() const
Access to mass.
static const Enum< kineticModelType > kinematicModelTypeNames
Names for kineticModelType.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual tmp< scalarField > patchSource() const
Source of cells next to the patch.
Namespace for OpenFOAM.
virtual tmp< fvPatchField< scalar > > clone() const
No clone without an internal field reference.
Definition: fvPatchField.H:610