electrostaticDepositionFvPatchScalarField.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) 2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::electrostaticDepositionFvPatchScalarField
28
29Group
30 grpGenericBoundaryConditions
31
32Description
33 The \c electrostaticDeposition is a boundary condition to
34 calculate electric potential (\c V) on a given boundary
35 based on film thickness (\c h) and film resistance (\c R) fields
36 which are updated based on a given patch-normal current density
37 field (\c jn), Coulombic efficiency and film resistivity.
38
39 \f[
40 j_n = - \sigma \nabla^\perp_p V = - \sigma (\vec{n}\cdot(\nabla V)_p)
41 \f]
42
43 \f[
44 \frac{dh}{dt} = C_{eff} (j_n - j_{min})
45 \f]
46
47 \f[
48 \frac{dR}{dt} = \rho \frac{dh}{dt} = \rho C_{eff} (j_n - j_{min})
49 \f]
50
51 \f[
52 V_{film}^n = V_{film}^o + j_n R_\Delta
53 \f]
54
55 \f[
56 V_{body} = j_n R_{body}
57 \f]
58
59 \f[
60 V_p^n = V_i + V_{body} + V_{film}^n
61 \f]
62
63 where
64 \vartable
65 j_n | Patch-normal current density [A/m^2]
66 V_p^n | Electric potential on film-fluid interface [volt = kg m^2/(A s^3)]
67 V_p^o | Previous time-step electric potential on the interface [volt]
68 V_{film} | Electric potential due to film resistance [volt]
69 V_{body} | Electric potential due to body resistance [volt]
70 V_i | Initial electric potential [volt]
71 R_\Delta| Film resistance (finite increment) [ohm m^2 = kg m^4/(A^2 s^3)]
72 R_{body} | Body resistance [ohm m^2 = kg m^4/(A^2 s^3)]
73 \rho | Isotropic film resistivity [ohm m = kg m^3/(A^2 s^3)]
74 h | Film thickness [m]
75 C_{eff} | Volumetric Coulombic efficiency [m^3/(A s)]
76 j_{min} | Minimum current density for deposition onset [A/m^2]
77 \sigma | Isotropic conductivity of mixture [S/m = A^2 s^3/(kg m^3)]
78 \vec{n} | Patch-normal unit vector [-]
79 \endvartable
80
81Usage
82 Example of the boundary condition specification:
83 \verbatim
84 <patchName>
85 {
86 // Mandatory entries
87 type electrostaticDeposition;
88 h <scalarField>;
89 CoulombicEfficiency <PatchFunction1>;
90 resistivity <PatchFunction1>;
91
92 // Conditional mandatory entries
93
94 // Option-1: single-phase
95 sigma <scalar>;
96
97 // Option-2: multiphase
98 phases
99 {
100 alpha.air
101 {
102 sigma <scalar>;
103 }
104 alpha.water
105 {
106 sigma <scalar>;
107 }
108 alpha.mercury
109 {
110 sigma <scalar>;
111 }
112 ...
113 }
114
115 // Optional entries
116 jMin <scalar>;
117 qMin <scalar>;
118 Rbody <scalar>;
119 Vi <scalar>;
120 Vanode <scalar>;
121 qCumulative <scalarField>;
122
123 // Inherited entries
124 ...
125 }
126 \endverbatim
127
128 where the entries mean:
129 \table
130 Property | Description | Type | Reqd | Deflt
131 type | Type name: electrostaticDeposition | word | yes | -
132 h | Film thickness | scalarField | yes | -
133 CoulombicEfficiency | Coulombic efficiency <!--
134 --> | PatchFunction1<scalar> | yes | -
135 resistivity | Isotropic film resistivity <!--
136 --> | PatchFunction1<scalar> | yes | -
137 sigma | Isotropic electrical conductivity of phase | scalar | yes | -
138 jMin | Minimum current density for deposition onset | scalar | no | 0
139 qMin | Minimum accumulative specific charge for deposition onset <!--
140 --> | scalar | no | 0
141 Rbody | Resistance due to main body and/or <!--
142 --> pretreatment layers | scalar | no | 0
143 Vi | Initial electric potential | scalar | no | 0
144 Vanode | Anode electric potential | scalar | no | GREAT
145 qCumulative | Accumulative specific charge [A s/m^2] <!--
146 --> | scalarField | no | 0
147 \endtable
148
149 The inherited entries are elaborated in:
150 - \link fixedValueFvPatchFields.H \endlink
151 - \link PatchFunction1.H \endlink
152
153Note
154 - Depletion or abrasion of material due to negative current is not allowed.
155 - When accumulative specific charge (\c qCumulative) is less than minimum
156 accumulative specific charge (\c qMin), no deposition occurs.
157 - Boundary-condition updates are not allowed during outer corrections
158 to prevent spurious accumulation of film thickness.
159 - \c resistivity, \c jMin, \c qMin and \c Rbody are always non-negative.
160
161SourceFiles
162 electrostaticDepositionFvPatchScalarField.C
163
164\*---------------------------------------------------------------------------*/
165
166#ifndef electrostaticDepositionFvPatchScalarField_H
167#define electrostaticDepositionFvPatchScalarField_H
168
170#include "Enum.H"
171#include "PatchFunction1.H"
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175namespace Foam
176{
177
178/*---------------------------------------------------------------------------*\
179 Class electrostaticDepositionFvPatchScalarField Declaration
180\*---------------------------------------------------------------------------*/
181
182class electrostaticDepositionFvPatchScalarField
183:
184 public fixedValueFvPatchScalarField
185{
186 // Private Data
187
188 //- Film thickness
189 scalarField h_;
190
191 //- Accumulative specific charge
192 scalarField qcum_;
193
194 //- Electric potential due to film resistance
195 scalarField Vfilm_;
196
197 //- Coulombic efficiency
198 autoPtr<PatchFunction1<scalar>> Ceffptr_;
199
200 //- Isotropic film resistivity
201 autoPtr<PatchFunction1<scalar>> rptr_;
202
203 //- Minimum current density for the deposition onset
204 scalar jMin_;
205
206 //- Minimum accumulative specific charge for the deposition onset
207 scalar qMin_;
208
209 //- Resistance due to main body and/or pretreatment layers
210 scalar Rbody_;
211
212 //- Initial electric potential
213 scalar Vi_;
214
215 //- Anode electric potential
216 scalar Vanode_;
217
218 // Isotropic electrical conductivitiy properties
219
220 //- Dictionary of phase data
221 dictionary phasesDict_;
222
223 //- List of phase names
224 wordList phaseNames_;
225
226 //- Unallocated list of phase fields
227 UPtrList<volScalarField> phases_;
228
229 //- List of isotropic electrical conductivity of phases
230 PtrList<dimensionedScalar> sigmas_;
231
232 //- Isotropic electrical conductivity of a single phase
233 dimensionedScalar sigma_;
234
235 //- Time index - used to prevent film accumulation during outer iters
236 label timei_;
237
238 //- Master patch ID
239 mutable label master_;
240
241
242 // Private Member Functions
243
244 //- Return non-const access to an electrostaticDeposition patch
246 (
247 const label patchi
248 ) const;
249
250 //- Return non-const access to the master patch ID
251 label& master() noexcept
252 {
253 return master_;
254 }
255
256 //- Set master patch ID
257 void setMaster() const;
258
259 //- Round scalars of a given scalar field to dcml points decimal
260 void round(scalarField& fld, const scalar dcml=1e8) const;
261
262 //- Write film thickness field to facilitate postprocessing
263 void writeFilmFields() const;
264
265
266public:
267
268 //- Runtime type information
269 TypeName("electrostaticDeposition");
270
271
272 // Constructors
273
274 //- Construct from patch and internal field
276 (
277 const fvPatch&,
278 const DimensionedField<scalar, volMesh>&
279 );
280
281 //- Construct from patch, internal field and dictionary
283 (
284 const fvPatch&,
285 const DimensionedField<scalar, volMesh>&,
286 const dictionary&
287 );
288
289 //- Construct by mapping given
290 //- electrostaticDepositionFvPatchScalarField onto a new patch
292 (
293 const electrostaticDepositionFvPatchScalarField&,
294 const fvPatch&,
295 const DimensionedField<scalar, volMesh>&,
296 const fvPatchFieldMapper&
297 );
298
299 //- Construct as copy
301 (
302 const electrostaticDepositionFvPatchScalarField&
303 );
304
305 //- Construct and return a clone
306 virtual tmp<fvPatchScalarField> clone() const
307 {
308 return tmp<fvPatchScalarField>
309 (
311 );
312 }
313
314 //- Construct as copy setting internal field reference
316 (
317 const electrostaticDepositionFvPatchScalarField&,
318 const DimensionedField<scalar, volMesh>&
319 );
320
321 //- Construct and return a clone setting internal field reference
323 (
325 ) const
326 {
328 (
330 );
331 }
332
333
334 // Member Functions
335
336 // Access
337
338 //- Return const access to film thickness patch field
339 const scalarField& h() const noexcept
340 {
341 return h_;
342 }
343
344
345 // Mapping
346
347 //- Map (and resize as needed) from self given a mapping object
348 virtual void autoMap
349 (
350 const fvPatchFieldMapper&
351 );
352
353 //- Reverse map the given fvPatchField onto this fvPatchField
354 virtual void rmap
355 (
356 const fvPatchScalarField&,
357 const labelList&
358 );
359
360
361 // Evaluation
362
363 //- Return the isotropic electrical conductivity field of mixture
364 tmp<scalarField> sigma() const;
365
366 //- Update the coefficients associated with the patch field
367 virtual void updateCoeffs();
368
369
370 // I-O
371
372 //- Write
373 virtual void write(Ostream&) const;
374};
375
376
377// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378
379} // End namespace Foam
380
381// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
382
383#endif
384
385// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
The electrostaticDeposition is a boundary condition to calculate electric potential (V) on a given bo...
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual tmp< fvPatchScalarField > clone(const DimensionedField< scalar, volMesh > &iF) const
Construct and return a clone setting internal field reference.
TypeName("electrostaticDeposition")
Runtime type information.
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
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.
const scalarField & h() const noexcept
Return const access to film thickness patch field.
electrostaticDepositionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
tmp< scalarField > sigma() const
Return the isotropic electrical conductivity field of mixture.
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
A class for managing temporary objects.
Definition: tmp.H:65
Namespace for OpenFOAM.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
List< word > wordList
A List of words.
Definition: fileName.H:63
List< label > labelList
A List of labels.
Definition: List.H:66
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const direction noexcept
Definition: Scalar.H:223
fvPatchField< scalar > fvPatchScalarField
runTime write()
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73