localEulerDdtScheme.C
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) 2011-2018 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
27 
28 #include "localEulerDdtScheme.H"
29 #include "surfaceInterpolate.H"
30 #include "fvMatrices.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace fv
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 template<class Type>
45 const volScalarField& localEulerDdtScheme<Type>::localRDeltaT() const
46 {
48 }
49 
50 
51 template<class Type>
52 const surfaceScalarField& localEulerDdtScheme<Type>::localRDeltaTf() const
53 {
55 }
56 
57 
58 template<class Type>
59 tmp<GeometricField<Type, fvPatchField, volMesh>>
61 (
62  const dimensioned<Type>& dt
63 )
64 {
65  IOobject ddtIOobject
66  (
67  "ddt(" + dt.name() + ')',
68  mesh().time().timeName(),
69  mesh()
70  );
71 
73  (
74  ddtIOobject,
75  mesh(),
78  );
79 }
80 
81 
82 template<class Type>
85 (
87 )
88 {
89  const volScalarField& rDeltaT = localRDeltaT();
90 
91  IOobject ddtIOobject
92  (
93  "ddt(" + vf.name() + ')',
94  mesh().time().timeName(),
95  mesh()
96  );
97 
99  (
101  (
102  ddtIOobject,
103  rDeltaT*(vf - vf.oldTime())
104  )
105  );
106 }
107 
108 
109 template<class Type>
112 (
113  const dimensionedScalar& rho,
115 )
116 {
117  const volScalarField& rDeltaT = localRDeltaT();
118 
119  IOobject ddtIOobject
120  (
121  "ddt(" + rho.name() + ',' + vf.name() + ')',
122  mesh().time().timeName(),
123  mesh()
124  );
125 
127  (
129  (
130  ddtIOobject,
131  rDeltaT*rho*(vf - vf.oldTime())
132  )
133  );
134 }
135 
136 
137 template<class Type>
140 (
141  const volScalarField& rho,
143 )
144 {
145  const volScalarField& rDeltaT = localRDeltaT();
146 
147  IOobject ddtIOobject
148  (
149  "ddt(" + rho.name() + ',' + vf.name() + ')',
150  mesh().time().timeName(),
151  mesh()
152  );
153 
155  (
157  (
158  ddtIOobject,
159  rDeltaT*(rho*vf - rho.oldTime()*vf.oldTime())
160  )
161  );
162 }
163 
164 
165 template<class Type>
168 (
169  const volScalarField& alpha,
170  const volScalarField& rho,
172 )
173 {
174  const volScalarField& rDeltaT = localRDeltaT();
175 
176  IOobject ddtIOobject
177  (
178  "ddt("+alpha.name()+','+rho.name()+','+vf.name()+')',
179  mesh().time().timeName(),
180  mesh()
181  );
182 
184  (
186  (
187  ddtIOobject,
188  rDeltaT
189  *(
190  alpha*rho*vf
191  - alpha.oldTime()*rho.oldTime()*vf.oldTime()
192  )
193  )
194  );
195 }
196 
197 
198 template<class Type>
201 (
203 )
204 {
205  const surfaceScalarField& rDeltaT = localRDeltaTf();
206 
207  IOobject ddtIOobject
208  (
209  "ddt("+sf.name()+')',
210  mesh().time().timeName(),
211  mesh()
212  );
213 
215  (
217  (
218  ddtIOobject,
219  rDeltaT*(sf - sf.oldTime())
220  )
221  );
222 }
223 
224 
225 template<class Type>
228 (
230 )
231 {
232  tmp<fvMatrix<Type>> tfvm
233  (
234  new fvMatrix<Type>
235  (
236  vf,
237  vf.dimensions()*dimVol/dimTime
238  )
239  );
240 
241  fvMatrix<Type>& fvm = tfvm.ref();
242 
243  const scalarField& rDeltaT = localRDeltaT();
244 
245  fvm.diag() = rDeltaT*mesh().Vsc();
246  fvm.source() = rDeltaT*vf.oldTime().primitiveField()*mesh().Vsc();
247 
248  return tfvm;
249 }
250 
251 
252 template<class Type>
255 (
256  const dimensionedScalar& rho,
258 )
259 {
260  tmp<fvMatrix<Type>> tfvm
261  (
262  new fvMatrix<Type>
263  (
264  vf,
265  rho.dimensions()*vf.dimensions()*dimVol/dimTime
266  )
267  );
268  fvMatrix<Type>& fvm = tfvm.ref();
269 
270  const scalarField& rDeltaT = localRDeltaT();
271 
272  fvm.diag() = rDeltaT*rho.value()*mesh().Vsc();
273 
274  fvm.source() =
275  rDeltaT*rho.value()*vf.oldTime().primitiveField()*mesh().Vsc();
276 
277  return tfvm;
278 }
279 
280 
281 template<class Type>
284 (
285  const volScalarField& rho,
287 )
288 {
289  tmp<fvMatrix<Type>> tfvm
290  (
291  new fvMatrix<Type>
292  (
293  vf,
294  rho.dimensions()*vf.dimensions()*dimVol/dimTime
295  )
296  );
297  fvMatrix<Type>& fvm = tfvm.ref();
298 
299  const scalarField& rDeltaT = localRDeltaT();
300 
301  fvm.diag() = rDeltaT*rho.primitiveField()*mesh().Vsc();
302 
303  fvm.source() = rDeltaT
304  *rho.oldTime().primitiveField()
305  *vf.oldTime().primitiveField()*mesh().Vsc();
306 
307  return tfvm;
308 }
309 
310 
311 template<class Type>
314 (
315  const volScalarField& alpha,
316  const volScalarField& rho,
318 )
319 {
320  tmp<fvMatrix<Type>> tfvm
321  (
322  new fvMatrix<Type>
323  (
324  vf,
325  alpha.dimensions()*rho.dimensions()*vf.dimensions()*dimVol/dimTime
326  )
327  );
328  fvMatrix<Type>& fvm = tfvm.ref();
329 
330  const scalarField& rDeltaT = localRDeltaT();
331 
332  fvm.diag() =
333  rDeltaT*alpha.primitiveField()*rho.primitiveField()*mesh().Vsc();
334 
335  fvm.source() = rDeltaT
336  *alpha.oldTime().primitiveField()
337  *rho.oldTime().primitiveField()
338  *vf.oldTime().primitiveField()*mesh().Vsc();
339 
340  return tfvm;
341 }
342 
343 
344 template<class Type>
347 (
350 )
351 {
352  const surfaceScalarField rDeltaT(fvc::interpolate(localRDeltaT()));
353 
354  fluxFieldType phiUf0(mesh().Sf() & Uf.oldTime());
355  fluxFieldType phiCorr
356  (
357  phiUf0 - fvc::dotInterpolate(mesh().Sf(), U.oldTime())
358  );
359 
360  return tmp<fluxFieldType>
361  (
362  new fluxFieldType
363  (
364  IOobject
365  (
366  "ddtCorr(" + U.name() + ',' + Uf.name() + ')',
367  mesh().time().timeName(),
368  mesh()
369  ),
370  this->fvcDdtPhiCoeff(U.oldTime(), phiUf0, phiCorr)
371  *rDeltaT*phiCorr
372  )
373  );
374 }
375 
376 
377 template<class Type>
380 (
382  const fluxFieldType& phi
383 )
384 {
385  const surfaceScalarField rDeltaT(fvc::interpolate(localRDeltaT()));
386 
387  fluxFieldType phiCorr
388  (
389  phi.oldTime() - fvc::dotInterpolate(mesh().Sf(), U.oldTime())
390  );
391 
392  return tmp<fluxFieldType>
393  (
394  new fluxFieldType
395  (
396  IOobject
397  (
398  "ddtCorr(" + U.name() + ',' + phi.name() + ')',
399  mesh().time().timeName(),
400  mesh()
401  ),
402  this->fvcDdtPhiCoeff(U.oldTime(), phi.oldTime(), phiCorr)
403  *rDeltaT*phiCorr
404  )
405  );
406 }
407 
408 
409 template<class Type>
412 (
413  const volScalarField& rho,
416 )
417 {
418  const surfaceScalarField rDeltaT(fvc::interpolate(localRDeltaT()));
419 
420  if
421  (
422  U.dimensions() == dimVelocity
423  && Uf.dimensions() == dimDensity*dimVelocity
424  )
425  {
427  (
428  rho.oldTime()*U.oldTime()
429  );
430 
431  fluxFieldType phiUf0(mesh().Sf() & Uf.oldTime());
432  fluxFieldType phiCorr(phiUf0 - fvc::dotInterpolate(mesh().Sf(), rhoU0));
433 
434  return tmp<fluxFieldType>
435  (
436  new fluxFieldType
437  (
438  IOobject
439  (
440  "ddtCorr("
441  + rho.name() + ',' + U.name() + ',' + Uf.name() + ')',
442  mesh().time().timeName(),
443  mesh()
444  ),
445  this->fvcDdtPhiCoeff(rhoU0, phiUf0, phiCorr, rho.oldTime())
446  *rDeltaT*phiCorr
447  )
448  );
449  }
450  else if
451  (
452  U.dimensions() == dimDensity*dimVelocity
453  && Uf.dimensions() == dimDensity*dimVelocity
454  )
455  {
456  fluxFieldType phiUf0(mesh().Sf() & Uf.oldTime());
457  fluxFieldType phiCorr
458  (
459  phiUf0 - fvc::dotInterpolate(mesh().Sf(), U.oldTime())
460  );
461 
462  return tmp<fluxFieldType>
463  (
464  new fluxFieldType
465  (
466  IOobject
467  (
468  "ddtCorr("
469  + rho.name() + ',' + U.name() + ',' + Uf.name() + ')',
470  mesh().time().timeName(),
471  mesh()
472  ),
473  this->fvcDdtPhiCoeff
474  (
475  U.oldTime(),
476  phiUf0,
477  phiCorr,
478  rho.oldTime()
479  )*rDeltaT*phiCorr
480  )
481  );
482  }
483  else
484  {
486  << "dimensions of Uf are not correct"
487  << abort(FatalError);
488 
489  return fluxFieldType::null();
490  }
491 }
492 
493 
494 template<class Type>
497 (
498  const volScalarField& rho,
500  const fluxFieldType& phi
501 )
502 {
503  const surfaceScalarField rDeltaT(fvc::interpolate(localRDeltaT()));
504 
505  if
506  (
507  U.dimensions() == dimVelocity
508  && phi.dimensions() == rho.dimensions()*dimVelocity*dimArea
509  )
510  {
512  (
513  rho.oldTime()*U.oldTime()
514  );
515 
516  fluxFieldType phiCorr
517  (
518  phi.oldTime() - fvc::dotInterpolate(mesh().Sf(), rhoU0)
519  );
520 
521  return tmp<fluxFieldType>
522  (
523  new fluxFieldType
524  (
525  IOobject
526  (
527  "ddtCorr("
528  + rho.name() + ',' + U.name() + ',' + phi.name() + ')',
529  mesh().time().timeName(),
530  mesh()
531  ),
532  this->fvcDdtPhiCoeff
533  (
534  rhoU0,
535  phi.oldTime(),
536  phiCorr,
537  rho.oldTime()
538  )*rDeltaT*phiCorr
539  )
540  );
541  }
542  else if
543  (
544  U.dimensions() == rho.dimensions()*dimVelocity
545  && phi.dimensions() == rho.dimensions()*dimVelocity*dimArea
546  )
547  {
548  fluxFieldType phiCorr
549  (
550  phi.oldTime() - fvc::dotInterpolate(mesh().Sf(), U.oldTime())
551  );
552 
553  return tmp<fluxFieldType>
554  (
555  new fluxFieldType
556  (
557  IOobject
558  (
559  "ddtCorr("
560  + rho.name() + ',' + U.name() + ',' + phi.name() + ')',
561  mesh().time().timeName(),
562  mesh()
563  ),
564  this->fvcDdtPhiCoeff
565  (
566  U.oldTime(),
567  phi.oldTime(),
568  phiCorr,
569  rho.oldTime()
570  )*rDeltaT*phiCorr
571  )
572  );
573  }
574  else
575  {
577  << "dimensions of phi are not correct"
578  << abort(FatalError);
579 
580  return fluxFieldType::null();
581  }
582 }
583 
584 
585 template<class Type>
587 (
589 )
590 {
591  tmp<surfaceScalarField> tmeshPhi
592  (
594  (
595  IOobject
596  (
597  "meshPhi",
598  mesh().time().timeName(),
599  mesh(),
602  false
603  ),
604  mesh(),
606  )
607  );
608 
609  tmeshPhi.ref().setOriented();
610 
611  return tmeshPhi;
612 }
613 
614 
615 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
616 
617 } // End namespace fv
618 
619 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
620 
621 } // End namespace Foam
622 
623 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::fv::localEulerDdt::localRDeltaT
static const volScalarField & localRDeltaT(const fvMesh &mesh)
Return the reciprocal of the local time-step.
Definition: localEulerDdt.C:48
Foam::fv::localEulerDdtScheme::fvcDdtUfCorr
tmp< fluxFieldType > fvcDdtUfCorr(const GeometricField< Type, fvPatchField, volMesh > &U, const GeometricField< Type, fvsPatchField, surfaceMesh > &Uf)
Definition: localEulerDdtScheme.C:347
Foam::fvc::dotInterpolate
static tmp< GeometricField< typename innerProduct< vector, Type >::type, fvsPatchField, surfaceMesh > > dotInterpolate(const surfaceVectorField &Sf, const GeometricField< Type, fvPatchField, volMesh > &tvf)
Interpolate field onto faces.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::dimVelocity
const dimensionSet dimVelocity
Foam::dimDensity
const dimensionSet dimDensity
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::GeometricField::primitiveField
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Definition: GeometricFieldI.H:53
Uf
autoPtr< surfaceVectorField > Uf
Definition: createUfIfPresent.H:33
Foam::GeometricField::oldTime
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
Definition: GeometricField.C:850
Foam::fv::localEulerDdt::localRDeltaTf
static const surfaceScalarField & localRDeltaTf(const fvMesh &mesh)
Return the reciprocal of the local face time-step.
Definition: localEulerDdt.C:60
Foam::dimensioned::name
const word & name() const
Return const reference to name.
Definition: dimensionedType.C:406
rho
rho
Definition: readInitialConditions.H:88
Foam::fv::localEulerDdtScheme::fvcDdt
tmp< GeometricField< Type, fvPatchField, volMesh > > fvcDdt(const dimensioned< Type > &)
Definition: localEulerDdtScheme.C:61
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
localEulerDdtScheme.H
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
Foam::Field< scalar >
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:42
Foam::calculatedFvPatchField
This boundary condition is not designed to be evaluated; it is assmued that the value is assigned via...
Definition: calculatedFvPatchField.H:66
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::localEulerDdtScheme::meshPhi
tmp< surfaceScalarField > meshPhi(const GeometricField< Type, fvPatchField, volMesh > &)
Definition: localEulerDdtScheme.C:587
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::fvc::interpolate
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
fv
labelList fv(nPoints)
Foam::fv::localEulerDdtScheme::fvmDdt
tmp< fvMatrix< Type > > fvmDdt(const GeometricField< Type, fvPatchField, volMesh > &)
Definition: localEulerDdtScheme.C:228
U
U
Definition: pEqn.H:72
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
Foam::fvMatrix::source
Field< Type > & source()
Definition: fvMatrix.H:445
Foam::fv::localEulerDdtScheme::fvcDdtPhiCorr
tmp< fluxFieldType > fvcDdtPhiCorr(const GeometricField< Type, fvPatchField, volMesh > &U, const fluxFieldType &phi)
Definition: localEulerDdtScheme.C:380
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::dimVol
const dimensionSet dimVol(dimVolume)
Older spelling for dimVolume.
Definition: dimensionSets.H:64
Foam::dimensioned::dimensions
const dimensionSet & dimensions() const
Return const reference to dimensions.
Definition: dimensionedType.C:420
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:60
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188