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
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 electrical conductivity field
183  static const word sigmaName;
184 
185  //- Name of temperature field
186  word TName_;
187 
188  //- Electrical potential field / [V]
189  volScalarField V_;
190 
191  //- Flag to indicate that the electrical conductivity is anisotropic
192  bool anisotropicElectricalConductivity_;
193 
194  //- Electrical conductivity as a scalar function of temperature
195  autoPtr<Function1<scalar>> scalarSigmaVsTPtr_;
196 
197  //- Electrical conductivity as a vector function of temperature
198  autoPtr<Function1<vector>> vectorSigmaVsTPtr_;
199 
200  //- Coordinate system - used for vectorial electrical conductivity
201  autoPtr<coordinateSystem> csysPtr_;
202 
203  //- Current time index (used for updating)
204  label curTimeIndex_;
205 
206 
207  // Private Member Functions
208 
209  //- Transform the anisotropic electrical conductivity into global system
210  tmp<volSymmTensorField> transformSigma
211  (
212  const volVectorField& sigmaLocal
213  ) const;
214 
215  //- Initialise the electrical conductivity field
216  template<class Type>
217  void initialiseSigma
218  (
219  const dictionary& dict,
220  autoPtr<Function1<Type>>& sigmaVsTPtr
221  );
222 
223  //- Update the electrical conductivity field
224  template<class Type>
226  updateSigma(const autoPtr<Function1<Type>>& sigmaVsTPtr) const;
227 
228 
229 public:
230 
231  //- Runtime type information
232  TypeName("jouleHeatingSource");
233 
234 
235  // Constructors
236 
237  //- Construct from explicit source name and mesh
239  (
240  const word& sourceName,
241  const word& modelType,
242  const dictionary& dict,
243  const fvMesh& mesh
244  );
245 
246  //- No copy construct
247  jouleHeatingSource(const jouleHeatingSource&) = delete;
248 
249  //- No copy assignment
250  void operator=(const jouleHeatingSource&) = delete;
251 
252 
253  //- Destructor
254  virtual ~jouleHeatingSource() = default;
255 
256 
257  // Member Functions
258 
259  // Evaluation
260 
261  //- Add explicit contribution to compressible momentum equation
262  virtual void addSup
263  (
264  const volScalarField& rho,
265  fvMatrix<scalar>& eqn,
266  const label fieldi
267  );
268 
269 
270  // IO
271 
272  //- Read source dictionary
273  virtual bool read(const dictionary& dict);
274 };
275 
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 } // End namespace fv
280 } // End namespace Foam
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 #ifdef NoRepository
285  #include "jouleHeatingSourceTemplates.C"
286 #endif
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 #endif
291 
292 // ************************************************************************* //
volFields.H
Foam::fv::jouleHeatingSource::~jouleHeatingSource
virtual ~jouleHeatingSource()=default
Destructor.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Function1.H
Foam::fv::jouleHeatingSource::operator=
void operator=(const jouleHeatingSource &)=delete
No copy assignment.
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: propellerInfo.H:291
Foam::fv::jouleHeatingSource
Evolves an electrical potential equation.
Definition: jouleHeatingSource.H:217
Foam::fv::option
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:126
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:148
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:123
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:62
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::option::mesh
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:37
Foam::fv::jouleHeatingSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: jouleHeatingSource.C:204
fvOption.H
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::fv::jouleHeatingSource::TypeName
TypeName("jouleHeatingSource")
Runtime type information.
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::fv::jouleHeatingSource::jouleHeatingSource
jouleHeatingSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Definition: jouleHeatingSource.C:105