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-2020 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 and \f$\sigma\f$ is the
40  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 
72 Usage
73  Isotropic (scalar) electrical conductivity
74  \verbatim
75  jouleHeatingSourceCoeffs
76  {
77  anisotropicElectricalConductivity no;
78 
79  // Optionally specify the conductivity as a function of temperature
80  // Note: if not supplied, this will be read from the time directory
81  sigma table
82  (
83  (273 1e5)
84  (1000 1e5)
85  );
86  }
87  \endverbatim
88 
89  Anisotropic (vectorial) electrical conductivity
90  jouleHeatingSourceCoeffs
91  {
92  anisotropicElectricalConductivity yes;
93 
94  coordinateSystem
95  {
96  origin (0 0 0);
97  e1 (1 0 0);
98  e3 (0 0 1);
99  }
100 
101  // Optionally specify sigma as a function of temperature
102  //sigma (31900 63800 127600);
103  //
104  //sigma table
105  //(
106  // (0 (0 0 0))
107  // (1000 (127600 127600 127600))
108  //);
109  }
110 
111 
112  Where:
113  \table
114  Property | Description | Required | Default value
115  T | Name of temperature field | no | T
116  sigma | Electrical conductivity as a function of temperature |no|
117  anisotropicElectricalConductivity | Anisotropic flag | yes |
118  \endtable
119 
120  The electrical conductivity can be specified using either:
121  - If the \c sigma entry is present the electrical conductivity is specified
122  as a function of temperature using a Function1 type
123  - If not present the sigma field will be read from file
124  - If the anisotropicElectricalConductivity flag is set to 'true', sigma
125  should be specified as a vector quantity
126 
127 SourceFiles
128  jouleHeatingSource.C
129 
130 SeeAlso
131  Foam::Function1
132 
133 \*---------------------------------------------------------------------------*/
134 
135 #ifndef fv_jouleHeatingSource_H
136 #define fv_jouleHeatingSource_H
137 
138 #include "fvOption.H"
139 #include "Function1.H"
140 #include "coordinateSystem.H"
141 #include "volFields.H"
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 namespace Foam
146 {
147 namespace fv
148 {
149 
150 /*---------------------------------------------------------------------------*\
151  Class jouleHeatingSource Declaration
152 \*---------------------------------------------------------------------------*/
153 
154 class jouleHeatingSource
155 :
156  public option
157 {
158  // Private Data
159 
160  //- Name of electrical conductivity field
161  static const word sigmaName;
162 
163  //- Name of temperature field - default = "T" (optional)
164  word TName_;
165 
166  //- Electrical potential field / [V]
167  volScalarField V_;
168 
169  //- Flag to indicate that the electrical conductivity is anisotropic
170  bool anisotropicElectricalConductivity_;
171 
172  //- Electrical conductivity as a scalar function of temperature
173  autoPtr<Function1<scalar>> scalarSigmaVsTPtr_;
174 
175  //- Electrical conductivity as a vector function of temperature
176  autoPtr<Function1<vector>> vectorSigmaVsTPtr_;
177 
178  //- Coordinate system - used for vectorial electrical conductivity
179  autoPtr<coordinateSystem> csysPtr_;
180 
181  //- Current time index (used for updating)
182  label curTimeIndex_;
183 
184 
185  // Private Member Functions
186 
187  //- No copy construct
188  jouleHeatingSource(const jouleHeatingSource&) = delete;
189 
190  //- No copy assignment
191  void operator=(const jouleHeatingSource&) = delete;
192 
193  //- Transform the anisotropic electrical conductivity into global system
194  tmp<volSymmTensorField> transformSigma
195  (
196  const volVectorField& sigmaLocal
197  ) const;
198 
199  //- Initialise the electrical conductivity field
200  template<class Type>
201  void initialiseSigma
202  (
203  const dictionary& dict,
204  autoPtr<Function1<Type>>& sigmaVsTPtr
205  );
206 
207  //- Update the electrical conductivity field
208  template<class Type>
210  updateSigma(const autoPtr<Function1<Type>>& sigmaVsTPtr) const;
211 
212 
213 public:
214 
215  //- Runtime type information
216  TypeName("jouleHeatingSource");
217 
218 
219  // Constructors
220 
221  //- Construct from explicit source name and mesh
223  (
224  const word& sourceName,
225  const word& modelType,
226  const dictionary& dict,
227  const fvMesh& mesh
228  );
229 
230 
231  //- Destructor
232  virtual ~jouleHeatingSource() = default;
233 
234 
235  // Member Functions
236 
237  // Evaluate
238 
239  //- Add explicit contribution to compressible momentum equation
240  virtual void addSup
241  (
242  const volScalarField& rho,
243  fvMatrix<scalar>& eqn,
244  const label fieldi
245  );
246 
247 
248  // IO
249 
250  //- Read source dictionary
251  virtual bool read(const dictionary& dict);
252 };
253 
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 } // End namespace fv
258 } // End namespace Foam
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #ifdef NoRepository
264 #endif
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #endif
269 
270 // ************************************************************************* //
volFields.H
Foam::fv::jouleHeatingSource::~jouleHeatingSource
virtual ~jouleHeatingSource()=default
Destructor.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
jouleHeatingSourceTemplates.C
Function1.H
rho
rho
Definition: readInitialConditions.H:88
coordinateSystem.H
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:86
Foam::fv::jouleHeatingSource
Evolves an electrical potential equation.
Definition: jouleHeatingSource.H:173
Foam::fv::option
Finite volume options abstract base class. Provides a base set of controls, e.g.:
Definition: fvOption.H:69
Foam::fv::jouleHeatingSource::addSup
virtual void addSup(const volScalarField &rho, fvMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to compressible momentum equation.
Definition: jouleHeatingSource.C:155
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fv
labelList fv(nPoints)
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::fv::jouleHeatingSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: jouleHeatingSource.C:213
fvOption.H
Foam::fv::option::mesh
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:36
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
Foam::fv::jouleHeatingSource::TypeName
TypeName("jouleHeatingSource")
Runtime type information.
Foam::GeometricField< scalar, fvPatchField, volMesh >