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-------------------------------------------------------------------------------
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
26\*---------------------------------------------------------------------------*/
27
28#include "localEulerDdtScheme.H"
29#include "surfaceInterpolate.H"
30#include "fvMatrices.H"
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34namespace Foam
35{
36
37// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38
39namespace fv
40{
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44template<class Type>
45const volScalarField& localEulerDdtScheme<Type>::localRDeltaT() const
46{
47 return localEulerDdt::localRDeltaT(mesh());
48}
49
50
51template<class Type>
52const surfaceScalarField& localEulerDdtScheme<Type>::localRDeltaTf() const
53{
54 return localEulerDdt::localRDeltaTf(mesh());
55}
56
57
58template<class Type>
59tmp<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
82template<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
109template<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
137template<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
165template<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
198template<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
225template<class Type>
228(
230)
231{
233 (
235 (
236 vf,
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
252template<class Type>
255(
256 const dimensionedScalar& rho,
258)
259{
261 (
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
281template<class Type>
284(
285 const volScalarField& rho,
287)
288{
290 (
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
311template<class Type>
314(
315 const volScalarField& alpha,
316 const volScalarField& rho,
318)
319{
321 (
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
344template<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 (
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
377template<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 (
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
409template<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 (
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 (
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
494template<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 (
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 (
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
585template<class Type>
587(
589)
590{
592 (
594 (
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// ************************************************************************* //
surfaceScalarField & phi
const dimensionSet & dimensions() const
Return dimensions.
Generic GeometricField class.
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
This boundary condition is not designed to be evaluated; it is assmued that the value is assigned via...
Generic dimensioned Type class.
const dimensionSet & dimensions() const
Return const reference to dimensions.
const word & name() const
Return const reference to name.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:121
Field< Type > & source() noexcept
Definition: fvMatrix.H:458
tmp< GeometricField< Type, fvPatchField, volMesh > > fvcDdt(const dimensioned< Type > &)
tmp< fluxFieldType > fvcDdtUfCorr(const GeometricField< Type, fvPatchField, volMesh > &U, const GeometricField< Type, fvsPatchField, surfaceMesh > &Uf)
tmp< fvMatrix< Type > > fvmDdt(const GeometricField< Type, fvPatchField, volMesh > &)
tmp< fluxFieldType > fvcDdtPhiCorr(const GeometricField< Type, fvPatchField, volMesh > &U, const fluxFieldType &phi)
tmp< surfaceScalarField > meshPhi(const GeometricField< Type, fvPatchField, volMesh > &)
scalarField & diag()
Definition: lduMatrix.C:192
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
U
Definition: pEqn.H:72
dynamicFvMesh & mesh
autoPtr< surfaceVectorField > Uf
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
A special matrix type and solver, designed for finite volume solutions of scalar equations.
word timeName
Definition: getTimeIndex.H:3
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.
static tmp< GeometricField< typename innerProduct< vector, Type >::type, fvsPatchField, surfaceMesh > > dotInterpolate(const surfaceVectorField &Sf, const GeometricField< Type, fvPatchField, volMesh > &tvf)
Interpolate field onto faces.
Namespace for OpenFOAM.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
const dimensionSet dimVelocity
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
errorManip< error > abort(error &err)
Definition: errorManip.H:144
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
error FatalError
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:60
const dimensionSet dimDensity
const dimensionSet dimVol(dimVolume)
Older spelling for dimVolume.
Definition: dimensionSets.H:64
labelList fv(nPoints)
volScalarField & alpha