1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Foam::fv::EulerLocalDdtScheme
31 \*---------------------------------------------------------------------------*/
33 #include "EulerLocalDdtScheme.H"
34 #include "surfaceInterpolate.H"
36 #include "fvMatrices.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 tmp<GeometricField<Type, fvPatchField, volMesh> >
52 EulerLocalDdtScheme<Type>::fvcDdt
54 const dimensioned<Type>& dt
57 const objectRegistry& registry = this->mesh();
59 // get access to the scalar beta[i]
60 const scalarField& beta =
61 registry.lookupObject<scalarField>(deltaTName_);
63 volScalarField rDeltaT =
64 1.0/(beta[0]*registry.lookupObject<volScalarField>(deltaTauName_));
69 mesh().time().timeName(),
75 tmp<GeometricField<Type, fvPatchField, volMesh> > tdtdt
77 new GeometricField<Type, fvPatchField, volMesh>
84 dt.dimensions()/dimTime,
90 tdtdt().internalField() =
91 rDeltaT.internalField()*dt.value()*(1.0 - mesh().V0()/mesh().V());
97 return tmp<GeometricField<Type, fvPatchField, volMesh> >
99 new GeometricField<Type, fvPatchField, volMesh>
106 dt.dimensions()/dimTime,
109 calculatedFvPatchField<Type>::typeName
117 tmp<GeometricField<Type, fvPatchField, volMesh> >
118 EulerLocalDdtScheme<Type>::fvcDdt
120 const GeometricField<Type, fvPatchField, volMesh>& vf
123 const objectRegistry& registry = this->mesh();
125 // get access to the scalar beta[i]
126 const scalarField& beta =
127 registry.lookupObject<scalarField>(deltaTName_);
129 volScalarField rDeltaT =
130 1.0/(beta[0]*registry.lookupObject<volScalarField>(deltaTauName_));
134 "ddt("+vf.name()+')',
135 mesh().time().timeName(),
141 return tmp<GeometricField<Type, fvPatchField, volMesh> >
143 new GeometricField<Type, fvPatchField, volMesh>
147 rDeltaT.dimensions()*vf.dimensions(),
148 rDeltaT.internalField()*
151 - vf.oldTime().internalField()*mesh().V0()/mesh().V()
153 rDeltaT.boundaryField()*
155 vf.boundaryField() - vf.oldTime().boundaryField()
162 return tmp<GeometricField<Type, fvPatchField, volMesh> >
164 new GeometricField<Type, fvPatchField, volMesh>
167 rDeltaT*(vf - vf.oldTime())
175 tmp<GeometricField<Type, fvPatchField, volMesh> >
176 EulerLocalDdtScheme<Type>::fvcDdt
178 const dimensionedScalar& rho,
179 const GeometricField<Type, fvPatchField, volMesh>& vf
182 const objectRegistry& registry = this->mesh();
184 // get access to the scalar beta[i]
185 const scalarField& beta =
186 registry.lookupObject<scalarField>(deltaTName_);
188 volScalarField rDeltaT =
189 1.0/(beta[0]*registry.lookupObject<volScalarField>(deltaTauName_));
193 "ddt("+rho.name()+','+vf.name()+')',
194 mesh().time().timeName(),
200 return tmp<GeometricField<Type, fvPatchField, volMesh> >
202 new GeometricField<Type, fvPatchField, volMesh>
206 rDeltaT.dimensions()*rho.dimensions()*vf.dimensions(),
207 rDeltaT.internalField()*rho.value()*
210 - vf.oldTime().internalField()*mesh().V0()/mesh().V()
212 rDeltaT.boundaryField()*rho.value()*
214 vf.boundaryField() - vf.oldTime().boundaryField()
221 return tmp<GeometricField<Type, fvPatchField, volMesh> >
223 new GeometricField<Type, fvPatchField, volMesh>
226 rDeltaT*rho*(vf - vf.oldTime())
234 tmp<GeometricField<Type, fvPatchField, volMesh> >
235 EulerLocalDdtScheme<Type>::fvcDdt
237 const volScalarField& rho,
238 const GeometricField<Type, fvPatchField, volMesh>& vf
241 const objectRegistry& registry = this->mesh();
243 // get access to the scalar beta[i]
244 const scalarField& beta =
245 registry.lookupObject<scalarField>(deltaTName_);
247 volScalarField rDeltaT =
248 1.0/(beta[0]*registry.lookupObject<volScalarField>(deltaTauName_));
252 "ddt("+rho.name()+','+vf.name()+')',
253 mesh().time().timeName(),
259 return tmp<GeometricField<Type, fvPatchField, volMesh> >
261 new GeometricField<Type, fvPatchField, volMesh>
265 rDeltaT.dimensions()*rho.dimensions()*vf.dimensions(),
266 rDeltaT.internalField()*
268 rho.internalField()*vf.internalField()
269 - rho.oldTime().internalField()
270 *vf.oldTime().internalField()*mesh().V0()/mesh().V()
272 rDeltaT.boundaryField()*
274 rho.boundaryField()*vf.boundaryField()
275 - rho.oldTime().boundaryField()
276 *vf.oldTime().boundaryField()
283 return tmp<GeometricField<Type, fvPatchField, volMesh> >
285 new GeometricField<Type, fvPatchField, volMesh>
288 rDeltaT*(rho*vf - rho.oldTime()*vf.oldTime())
297 EulerLocalDdtScheme<Type>::fvmDdt
299 GeometricField<Type, fvPatchField, volMesh>& vf
302 const objectRegistry& registry = this->mesh();
304 // get access to the scalar beta[i]
305 const scalarField& beta =
306 registry.lookupObject<scalarField>(deltaTName_);
308 tmp<fvMatrix<Type> > tfvm
313 vf.dimensions()*dimVol/dimTime
317 fvMatrix<Type>& fvm = tfvm();
319 scalarField rDeltaT =
320 1.0/(beta[0]*registry.lookupObject<volScalarField>
325 fvm.diag() = rDeltaT*mesh().V();
329 fvm.source() = rDeltaT*vf.oldTime().internalField()*mesh().V0();
333 fvm.source() = rDeltaT*vf.oldTime().internalField()*mesh().V();
342 EulerLocalDdtScheme<Type>::fvmDdt
344 const dimensionedScalar& rho,
345 GeometricField<Type, fvPatchField, volMesh>& vf
348 const objectRegistry& registry = this->mesh();
350 // get access to the scalar beta[i]
351 const scalarField& beta =
352 registry.lookupObject<scalarField>(deltaTName_);
354 tmp<fvMatrix<Type> > tfvm
359 rho.dimensions()*vf.dimensions()*dimVol/dimTime
362 fvMatrix<Type>& fvm = tfvm();
364 scalarField rDeltaT =
365 1.0/(beta[0]*registry.lookupObject<volScalarField>(deltaTauName_).internalField());
367 fvm.diag() = rDeltaT*rho.value()*mesh().V();
371 fvm.source() = rDeltaT
372 *rho.value()*vf.oldTime().internalField()*mesh().V0();
376 fvm.source() = rDeltaT
377 *rho.value()*vf.oldTime().internalField()*mesh().V();
386 EulerLocalDdtScheme<Type>::fvmDdt
388 const volScalarField& rho,
389 GeometricField<Type, fvPatchField, volMesh>& vf
392 const objectRegistry& registry = this->mesh();
394 // get access to the scalar beta[i]
395 const scalarField& beta =
396 registry.lookupObject<scalarField>(deltaTName_);
398 tmp<fvMatrix<Type> > tfvm
403 rho.dimensions()*vf.dimensions()*dimVol/dimTime
406 fvMatrix<Type>& fvm = tfvm();
408 scalarField rDeltaT =
409 1.0/(beta[0]*registry.lookupObject<volScalarField>
414 fvm.diag() = rDeltaT*rho.internalField()*mesh().V();
418 fvm.source() = rDeltaT
419 *rho.oldTime().internalField()
420 *vf.oldTime().internalField()*mesh().V0();
424 fvm.source() = rDeltaT
425 *rho.oldTime().internalField()
426 *vf.oldTime().internalField()*mesh().V();
434 tmp<typename EulerLocalDdtScheme<Type>::fluxFieldType>
435 EulerLocalDdtScheme<Type>::fvcDdtPhiCorr
437 const volScalarField& rA,
438 const GeometricField<Type, fvPatchField, volMesh>& U,
439 const fluxFieldType& phi
444 "ddtPhiCorr(" + rA.name() + ',' + U.name() + ',' + phi.name() + ')',
445 mesh().time().timeName(),
451 return tmp<fluxFieldType>
457 dimensioned<typename flux<Type>::type>
460 rA.dimensions()*phi.dimensions()/dimTime,
461 pTraits<typename flux<Type>::type>::zero
468 const objectRegistry& registry = this->mesh();
470 // get access to the scalar beta[i]
471 const scalarField& beta =
472 registry.lookupObject<scalarField>(deltaTName_);
474 volScalarField rDeltaT =
475 1.0/(beta[0]*registry.lookupObject<volScalarField>(deltaTauName_));
477 return tmp<fluxFieldType>
482 this->fvcDdtPhiCoeff(U.oldTime(), phi.oldTime())*
484 fvc::interpolate(rDeltaT*rA)*phi.oldTime()
485 - (fvc::interpolate(rDeltaT*rA*U.oldTime()) & mesh().Sf())
494 tmp<typename EulerLocalDdtScheme<Type>::fluxFieldType>
495 EulerLocalDdtScheme<Type>::fvcDdtPhiCorr
497 const volScalarField& rA,
498 const volScalarField& rho,
499 const GeometricField<Type, fvPatchField, volMesh>& U,
500 const fluxFieldType& phi
506 + rA.name() + ',' + rho.name() + ',' + U.name() + ',' + phi.name() + ')',
507 mesh().time().timeName(),
513 return tmp<fluxFieldType>
519 dimensioned<typename flux<Type>::type>
522 rA.dimensions()*phi.dimensions()/dimTime,
523 pTraits<typename flux<Type>::type>::zero
530 const objectRegistry& registry = this->mesh();
532 // get access to the scalar beta[i]
533 const scalarField& beta =
534 registry.lookupObject<scalarField>(deltaTName_);
536 volScalarField rDeltaT =
537 1.0/(beta[0]*registry.lookupObject<volScalarField>(deltaTauName_));
541 U.dimensions() == dimVelocity
542 && phi.dimensions() == dimVelocity*dimArea
545 return tmp<fluxFieldType>
550 this->fvcDdtPhiCoeff(U.oldTime(), phi.oldTime())*
554 rDeltaT*rA*rho.oldTime()
556 - (fvc::interpolate(rDeltaT*rA*rho.oldTime()*U.oldTime())
564 U.dimensions() == dimVelocity
565 && phi.dimensions() == dimDensity*dimVelocity*dimArea
568 return tmp<fluxFieldType>
576 phi.oldTime()/fvc::interpolate(rho.oldTime())
579 fvc::interpolate(rDeltaT*rA*rho.oldTime())
580 *phi.oldTime()/fvc::interpolate(rho.oldTime())
584 rDeltaT*rA*rho.oldTime()*U.oldTime()
593 U.dimensions() == dimDensity*dimVelocity
594 && phi.dimensions() == dimDensity*dimVelocity*dimArea
597 return tmp<fluxFieldType>
602 this->fvcDdtPhiCoeff(rho.oldTime(), U.oldTime(), phi.oldTime())*
604 fvc::interpolate(rDeltaT*rA)*phi.oldTime()
606 fvc::interpolate(rDeltaT*rA*U.oldTime())
617 "EulerLocalDdtScheme<Type>::fvcDdtPhiCorr"
618 ) << "dimensions of phi are not correct"
619 << abort(FatalError);
621 return fluxFieldType::null();
628 tmp<surfaceScalarField> EulerLocalDdtScheme<Type>::meshPhi
630 const GeometricField<Type, fvPatchField, volMesh>&
633 return tmp<surfaceScalarField>
635 new surfaceScalarField
640 mesh().time().timeName(),
644 dimensionedScalar("0", dimVolume/dimTime, 0.0)
650 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
652 } // End namespace fv
654 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
656 } // End namespace Foam
658 // ************************************************************************* //