jouleHeatingSource.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) 2016-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::fv::jouleHeatingSource
28 
29 Group
30  grpFvOptionsSources
31 
32 Description
33  Evolves an electrical potential equation
34 
35  \f[
36  \grad \left( \sigma \grad V \right)
37  \f]
38 
39  where \f$ V \f$ is electrical potential
40  and \f$\sigma\f$ is the electrical current.
41 
42  To provide a Joule heating contribution according to:
43 
44  Differential form of Joule heating - power per unit volume:
45 
46  \f[
47  \frac{d(P)}{d(V)} = J \cdot E
48  \f]
49 
50  where \f$ J \f$ is the current density and \f$ E \f$ the electric field.
51  If no magnetic field is present:
52 
53  \f[
54  J = \sigma E
55  \f]
56 
57  The electric field given by
58 
59  \f[
60  E = \grad V
61  \f]
62 
63  Therefore:
64 
65  \f[
66  \frac{d(P)}{d(V)} = J \cdot E
67  = (sigma E) \cdot E
68  = (sigma \grad V) \cdot \grad V
69  \f]
70 
71 Usage
72  Minimal example by using \c constant/fvOptions:
73  \verbatim
74  jouleHeatingSource1
75  {
76  // Mandatory entries (unmodifiable)
77  type jouleHeatingSource;
78 
79  // Mandatory entries (runtime modifiable)
80  anisotropicElectricalConductivity true;
81 
82  // Optional entries (runtime modifiable)
83  T <Tname>;
84 
85  // Conditional mandatory entries (runtime modifiable)
86 
87  // when anisotropicElectricalConductivity=true
88  coordinateSystem
89  {
90  origin (0 0 0);
91  e1 (1 0 0);
92  e3 (0 0 1);
93  }
94 
95  // Conditional optional entries (runtime modifiable)
96 
97  // when anisotropicElectricalConductivity=false
98  // Specify the conductivity as a function of temperature
99  // If not supplied, this will be read from the time directory
100  sigma table
101  (
102  (273 1e5)
103  (1000 1e5)
104  );
105 
106  // when anisotropicElectricalConductivity=true
107  sigma (31900 63800 127600);
108  //sigma table
109  //(
110  // (0 (0 0 0))
111  // (1000 (127600 127600 127600))
112  //);
113 
114  // Mandatory/Optional (inherited) entries
115  ...
116  }
117  \endverbatim
118 
119  where the entries mean:
120  \table
121  Property | Description | Type | Reqd | Dflt
122  type | Type name: jouleHeatingSource | word | yes | -
123  anisotropicElectricalConductivity | Flag to indicate that <!--
124  --> if the electrical conductivity is anisotropic <!--
125  --> | bool | yes | -
126  T | Name of operand temperature field | word | no | T
127  sigma | Electrical conductivity as a function of temperature <!--
128  --> | table | no | -
129  coordinateSystem | User-specified coordinate system | coordSystem | no | -
130  \endtable
131 
132  The inherited entries are elaborated in:
133  - \link fvOption.H \endlink
134 
135 Note
136  - \c anisotropicElectricalConductivity=true enables
137  anisotropic (vectorial) electrical conductivity.
138  - \c anisotropicElectricalConductivity=false enables
139  isotropic (scalar) electrical conductivity.
140  - The electrical conductivity can be specified using either:
141  - If the \c sigma entry is present the electrical conductivity is specified
142  as a function of temperature using a \c Function1 type.
143  - If not present the \c sigma field will be read from file.
144  - If the \c anisotropicElectricalConductivity flag is set to \c true,
145  \c sigma should be specified as a vector quantity.
146 
147 See also
148  - Foam::Function1
149  - Foam::coordSystem
150 
151 SourceFiles
152  jouleHeatingSource.C
153  jouleHeatingSourceTemplates.C
154 
155 \*---------------------------------------------------------------------------*/
156 
157 #ifndef fv_jouleHeatingSource_H
158 #define fv_jouleHeatingSource_H
159 
160 #include "fvOption.H"
161 #include "Function1.H"
162 #include "coordinateSystem.H"
163 #include "volFields.H"
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 namespace Foam
168 {
169 namespace fv
170 {
171 
172 /*---------------------------------------------------------------------------*\
173  Class jouleHeatingSource Declaration
174 \*---------------------------------------------------------------------------*/
175 
176 class jouleHeatingSource
177 :
178  public fv::option
179 {
180  // Private Data
181 
182  //- Name of temperature field
183  word TName_;
184 
185  //- Electrical potential field / [V]
186  volScalarField V_;
187 
188  //- Flag to indicate that the electrical conductivity is anisotropic
189  bool anisotropicElectricalConductivity_;
190 
191  //- Electrical conductivity as a scalar function of temperature
192  autoPtr<Function1<scalar>> scalarSigmaVsTPtr_;
193 
194  //- Electrical conductivity as a vector function of temperature
195  autoPtr<Function1<vector>> vectorSigmaVsTPtr_;
196 
197  //- Coordinate system - used for vectorial electrical conductivity
198  autoPtr<coordinateSystem> csysPtr_;
199 
200  //- Current time index (used for updating)
201  label curTimeIndex_;
202 
203 
204  // Private Member Functions
205 
206  //- Transform the anisotropic electrical conductivity into global system
207  tmp<volSymmTensorField> transformSigma
208  (
209  const volVectorField& sigmaLocal
210  ) const;
211 
212  //- Initialise the electrical conductivity field
213  template<class Type>
214  void initialiseSigma
215  (
216  const dictionary& dict,
217  autoPtr<Function1<Type>>& sigmaVsTPtr
218  );
219 
220  //- Update the electrical conductivity field
221  template<class Type>
223  updateSigma(const autoPtr<Function1<Type>>& sigmaVsTPtr) const;
224 
225 
226 public:
227 
228  //- Runtime type information
229  TypeName("jouleHeatingSource");
230 
231 
232  // Constructors
233 
234  //- Construct from explicit source name and mesh
236  (
237  const word& sourceName,
238  const word& modelType,
239  const dictionary& dict,
240  const fvMesh& mesh
241  );
242 
243  //- No copy construct
244  jouleHeatingSource(const jouleHeatingSource&) = delete;
245 
246  //- No copy assignment
247  void operator=(const jouleHeatingSource&) = delete;
248 
249 
250  //- Destructor
251  virtual ~jouleHeatingSource() = default;
252 
253 
254  // Member Functions
255 
256  // Evaluation
257 
258  //- Add explicit contribution to compressible momentum equation
259  virtual void addSup
260  (
261  const volScalarField& rho,
262  fvMatrix<scalar>& eqn,
263  const label fieldi
264  );
265 
266 
267  // IO
268 
269  //- Read source dictionary
270  virtual bool read(const dictionary& dict);
271 };
272 
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 } // End namespace fv
277 } // End namespace Foam
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 #ifdef NoRepository
282  #include "jouleHeatingSourceTemplates.C"
283 #endif
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 #endif
288 
289 // ************************************************************************* //
TypeName("jouleHeatingSource")
Runtime type information.
virtual bool read(const dictionary &dict)
Read source dictionary.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
dictionary dict
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:30
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
jouleHeatingSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Generic GeometricField class.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:76
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:72
virtual void addSup(const volScalarField &rho, fvMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to compressible momentum equation.
A class for handling words, derived from Foam::string.
Definition: word.H:63
labelList fv(nPoints)
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
void operator=(const jouleHeatingSource &)=delete
No copy assignment.
Evolves an electrical potential equation.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Namespace for OpenFOAM.
virtual ~jouleHeatingSource()=default
Destructor.