27 #include "surfaceInterpolate.H" 45 template<
class GeoField>
46 CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::DDt0Field
58 this->
timeIndex() = mesh.time().startTimeIndex();
63 template<
class GeoField>
64 CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::DDt0Field
68 const dimensioned<typename GeoField::value_type>& dimType
71 GeoField(io, mesh, dimType),
77 template<
class GeoField>
78 label CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::
79 startTimeIndex()
const 81 return startTimeIndex_;
86 template<
class GeoField>
87 GeoField& CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::
95 template<
class GeoField>
96 void CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>::
97 operator=(
const GeoField& gf)
99 GeoField::operator=(gf);
104 template<
class GeoField>
105 CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>&
106 CrankNicolsonDdtScheme<Type>::ddt0_
109 const dimensionSet& dims
112 if (!
mesh().objectRegistry::template foundObject<GeoField>(name))
114 const Time& runTime =
mesh().
time();
115 word startTimeName = runTime.
timeName(runTime.startTime().value());
120 runTime.timeIndex() == runTime.startTimeIndex()
121 || runTime.timeIndex() == runTime.startTimeIndex() + 1
128 ).typeHeaderOk<DDt0Field<GeoField>>()
133 new DDt0Field<GeoField>
151 new DDt0Field<GeoField>
162 dimensioned<typename GeoField::value_type>
173 DDt0Field<GeoField>& ddt0 =
static_cast<DDt0Field<GeoField>&
> 175 mesh().objectRegistry::template lookupObjectRef<GeoField>(
name)
183 template<
class GeoField>
184 bool CrankNicolsonDdtScheme<Type>::evaluate
186 const DDt0Field<GeoField>& ddt0
193 template<
class GeoField>
194 scalar CrankNicolsonDdtScheme<Type>::coef_
196 const DDt0Field<GeoField>& ddt0
211 template<
class GeoField>
212 scalar CrankNicolsonDdtScheme<Type>::coef0_
214 const DDt0Field<GeoField>& ddt0
229 template<
class GeoField>
232 const DDt0Field<GeoField>& ddt0
240 template<
class GeoField>
243 const DDt0Field<GeoField>& ddt0
251 template<
class GeoField>
252 tmp<GeoField> CrankNicolsonDdtScheme<Type>::offCentre_
269 const FieldField<fvPatchField, Type>&
ff 284 ocCoeff_(new Function1Types::Constant<scalar>(
"ocCoeff", 1))
304 token firstToken(is);
309 if (ocCoeff < 0 || ocCoeff > 1)
314 ) <<
"Off-centreing coefficient = " << ocCoeff
315 <<
" should be >= 0 and <= 1" 350 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
351 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
353 "ddt0(" + dt.
name() +
')',
359 "ddt(" + dt.
name() +
')',
390 -
mesh().
V00()*offCentre_(ddt0.internalField())
397 -
mesh().
V0()*offCentre_(ddt0.internalField())
412 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
413 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
415 "ddt0(" + vf.
name() +
')',
421 "ddt(" + vf.
name() +
')',
432 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
434 ddt0.primitiveFieldRef() =
440 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
443 ddt0.boundaryFieldRef() =
448 - vf.
oldTime().oldTime().boundaryField()
449 ) - offCentre_(
ff(ddt0.boundaryField()))
463 ) -
mesh().
V0()*offCentre_(ddt0()())
468 ) - offCentre_(
ff(ddt0.boundaryField()))
477 - offCentre_(ddt0());
485 rDtCoef*(vf - vf.
oldTime()) - offCentre_(ddt0())
500 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
501 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
503 "ddt0(" + rho.
name() +
',' + vf.
name() +
')',
509 "ddt(" + rho.
name() +
',' + vf.
name() +
')',
520 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
522 ddt0.primitiveFieldRef() =
524 rDtCoef0*rho.
value()*
528 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
531 ddt0.boundaryFieldRef() =
533 rDtCoef0*rho.
value()*
536 - vf.
oldTime().oldTime().boundaryField()
537 ) - offCentre_(
ff(ddt0.boundaryField()))
549 rDtCoef.value()*rho.
value()*
553 ) -
mesh().
V0()*offCentre_(ddt0.primitiveField())
555 rDtCoef.value()*rho.
value()*
558 ) - offCentre_(
ff(ddt0.boundaryField()))
566 ddt0 = rDtCoef0_(ddt0)*rho*(vf.
oldTime() - vf.
oldTime().oldTime())
567 - offCentre_(ddt0());
575 rDtCoef*rho*(vf - vf.
oldTime()) - offCentre_(ddt0())
590 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
591 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
593 "ddt0(" + rho.
name() +
',' + vf.
name() +
')',
599 "ddt(" + rho.
name() +
',' + vf.
name() +
')',
610 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
612 ddt0.primitiveFieldRef() =
619 *vf.
oldTime().oldTime().primitiveField()
620 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
623 ddt0.boundaryFieldRef() =
630 *vf.
oldTime().oldTime().boundaryField()
631 ) - offCentre_(
ff(ddt0.boundaryField()))
648 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
654 ) - offCentre_(
ff(ddt0.boundaryField()))
662 ddt0 = rDtCoef0_(ddt0)*
666 ) - offCentre_(ddt0());
691 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
692 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
694 "ddt0(" + alpha.
name() +
',' + rho.
name() +
',' + vf.
name() +
')',
700 "ddt(" + alpha.
name() +
',' + rho.
name() +
',' + vf.
name() +
')',
711 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
713 ddt0.primitiveFieldRef() =
725 *vf.
oldTime().oldTime().primitiveField()
726 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
729 ddt0.boundaryFieldRef() =
739 *vf.
oldTime().oldTime().boundaryField()
740 ) - offCentre_(
ff(ddt0.boundaryField()))
764 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
775 ) - offCentre_(
ff(ddt0.boundaryField()))
783 ddt0 = rDtCoef0_(ddt0)*
792 ) - offCentre_(ddt0());
819 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
820 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
822 "ddt0(" + vf.
name() +
')',
837 const scalar rDtCoef = rDtCoef_(ddt0).
value();
846 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
848 ddt0.primitiveFieldRef() =
855 -
mesh().
V00()*offCentre_(ddt0.primitiveField())
858 ddt0.boundaryFieldRef() =
863 - vf.
oldTime().oldTime().boundaryField()
865 - offCentre_(
ff(ddt0.boundaryField()))
871 rDtCoef*vf.
oldTime().primitiveField()
872 + offCentre_(ddt0.primitiveField())
880 - offCentre_(ddt0());
885 rDtCoef*vf.
oldTime().primitiveField()
886 + offCentre_(ddt0.primitiveField())
902 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
903 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
905 "ddt0(" + rho.
name() +
',' + vf.
name() +
')',
919 const scalar rDtCoef = rDtCoef_(ddt0).
value();
928 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
930 ddt0.primitiveFieldRef() =
932 rDtCoef0*rho.
value()*
937 -
mesh().
V00()*offCentre_(ddt0.primitiveField())
940 ddt0.boundaryFieldRef() =
942 rDtCoef0*rho.
value()*
945 - vf.
oldTime().oldTime().boundaryField()
947 - offCentre_(
ff(ddt0.boundaryField()))
954 + offCentre_(ddt0.primitiveField())
961 ddt0 = rDtCoef0_(ddt0)*rho*(vf.
oldTime() - vf.
oldTime().oldTime())
962 - offCentre_(ddt0());
968 + offCentre_(ddt0.primitiveField())
984 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
985 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
987 "ddt0(" + rho.
name() +
',' + vf.
name() +
')',
1001 const scalar rDtCoef = rDtCoef_(ddt0).
value();
1007 if (
mesh().moving())
1011 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
1013 ddt0.primitiveFieldRef() =
1018 *vf.
oldTime().primitiveField()
1020 *vf.
oldTime().oldTime().primitiveField()
1022 -
mesh().
V00()*offCentre_(ddt0.primitiveField())
1025 ddt0.boundaryFieldRef() =
1032 *vf.
oldTime().oldTime().boundaryField()
1034 - offCentre_(
ff(ddt0.boundaryField()))
1041 + offCentre_(ddt0.primitiveField())
1048 ddt0 = rDtCoef0_(ddt0)*
1052 ) - offCentre_(ddt0());
1058 + offCentre_(ddt0.primitiveField())
1066 template<
class Type>
1075 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1076 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1078 "ddt0(" + alpha.
name() +
',' + rho.
name() +
',' + vf.
name() +
')',
1092 const scalar rDtCoef = rDtCoef_(ddt0).
value();
1099 if (
mesh().moving())
1103 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
1105 ddt0.primitiveFieldRef() =
1112 *vf.
oldTime().primitiveField()
1117 *vf.
oldTime().oldTime().primitiveField()
1119 -
mesh().
V00()*offCentre_(ddt0.primitiveField())
1122 ddt0.boundaryFieldRef() =
1132 *vf.
oldTime().oldTime().boundaryField()
1134 - offCentre_(
ff(ddt0.boundaryField()))
1143 *vf.
oldTime().primitiveField()
1144 + offCentre_(ddt0.primitiveField())
1151 ddt0 = rDtCoef0_(ddt0)*
1160 ) - offCentre_(ddt0());
1168 *vf.
oldTime().primitiveField()
1169 + offCentre_(ddt0.primitiveField())
1177 template<
class Type>
1185 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1186 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1188 "ddtCorrDdt0(" + U.
name() +
')',
1192 DDt0Field<GeometricField<Type, fvsPatchField, surfaceMesh>>& dUfdt0 =
1193 ddt0_<GeometricField<Type, fvsPatchField, surfaceMesh>>
1195 "ddtCorrDdt0(" + Uf.
name() +
')',
1205 - offCentre_(ddt0());
1208 if (evaluate(dUfdt0))
1212 - offCentre_(dUfdt0());
1221 "ddtCorr(" + U.
name() +
',' + Uf.
name() +
')',
1229 (rDtCoef*Uf.
oldTime() + offCentre_(dUfdt0()))
1238 template<
class Type>
1246 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1247 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1249 "ddtCorrDdt0(" + U.
name() +
')',
1253 DDt0Field<fluxFieldType>& dphidt0 =
1254 ddt0_<fluxFieldType>
1256 "ddtCorrDdt0(" + phi.
name() +
')',
1266 - offCentre_(ddt0());
1269 if (evaluate(dphidt0))
1273 - offCentre_(dphidt0());
1282 "ddtCorr(" + U.
name() +
',' + phi.
name() +
')',
1288 (rDtCoef*phi.
oldTime() + offCentre_(dphidt0()))
1292 rDtCoef*U.
oldTime() + offCentre_(ddt0())
1300 template<
class Type>
1315 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1316 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1318 "ddtCorrDdt0(" + rho.
name() +
',' + U.
name() +
')',
1322 DDt0Field<GeometricField<Type, fvsPatchField, surfaceMesh>>& dUfdt0 =
1323 ddt0_<GeometricField<Type, fvsPatchField, surfaceMesh>>
1325 "ddtCorrDdt0(" + Uf.
name() +
')',
1341 - offCentre_(ddt0());
1344 if (evaluate(dUfdt0))
1349 - offCentre_(dUfdt0());
1367 (rDtCoef*Uf.
oldTime() + offCentre_(dUfdt0()))
1387 <<
"dimensions of Uf are not correct" 1395 template<
class Type>
1410 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1411 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1413 "ddtCorrDdt0(" + rho.
name() +
',' + U.
name() +
')',
1417 DDt0Field<fluxFieldType>& dphidt0 =
1418 ddt0_<fluxFieldType>
1420 "ddtCorrDdt0(" + phi.
name() +
')',
1436 - offCentre_(ddt0());
1439 if (evaluate(dphidt0))
1444 - offCentre_(dphidt0());
1454 + rho.
name() +
',' + U.
name() +
',' + phi.
name() +
')',
1460 (rDtCoef*phi.
oldTime() + offCentre_(dphidt0()))
1464 rDtCoef*rhoU0 + offCentre_(ddt0())
1483 <<
"dimensions of phi are not correct" 1491 template<
class Type>
1497 DDt0Field<surfaceScalarField>& meshPhi0 = ddt0_<surfaceScalarField>
1503 if (evaluate(meshPhi0))
1506 coef0_(meshPhi0)*
mesh().
phi().
oldTime() - offCentre_(meshPhi0());
1522 coef_(meshPhi0)*
mesh().
phi() - offCentre_(meshPhi0())
tmp< fluxFieldType > fvcDdtUfCorr(const GeometricField< Type, fvPatchField, volMesh > &U, const GeometricField< Type, fvsPatchField, surfaceMesh > &Uf)
const fvMesh & mesh() const
Return mesh reference.
Second-oder Crank-Nicolson implicit ddt using the current and previous time-step fields as well as th...
const surfaceVectorField & Sf() const
Return cell face area vectors.
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
dimensionedScalar deltaT0() const
Return old time step.
bool moving() const
Is mesh moving.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
scalar ocCoeff() const
Return the current off-centreing coefficient.
A token holds items read from 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.
tmp< GeometricField< typename flux< Type >::type, fvsPatchField, surfaceMesh > > ddtCorr(const GeometricField< Type, fvPatchField, volMesh > &U, const GeometricField< Type, fvsPatchField, surfaceMesh > &Uf)
void putBack(const token &)
Put back token.
const surfaceScalarField & phi() const
Return cell face motion fluxes.
const dimensionSet dimVol(dimVolume)
const DimensionedField< scalar, volMesh > & V00() const
Return old-old-time cell volumes.
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Generic GeometricField class.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Generic dimensioned Type class.
const Time & time() const
Return the top-level database.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
Abstract base class for ddt schemes.
const dimensionSet dimVolume(pow3(dimLength))
const dimensionSet & dimensions() const
Return dimensions.
ddtScheme< Type >::fluxFieldType fluxFieldType
const DimensionedField< scalar, volMesh > & V0() const
Return old-time cell volumes.
tmp< fluxFieldType > fvcDdtPhiCorr(const GeometricField< Type, fvPatchField, volMesh > &U, const fluxFieldType &phi)
Templated function that returns a constant value.
const Type & value() const
Return const reference to value.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
errorManip< error > abort(error &err)
Calculate the divergence of the given field.
void store()
Transfer ownership of this object to its registry.
tmp< fvMatrix< Type > > fvmDdt(const GeometricField< Type, fvPatchField, volMesh > &)
const word & name() const
Return const reference to name.
word name(const complex &)
Return a string representation of a complex.
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 const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
tmp< surfaceScalarField > fvcDdtPhiCoeff(const GeometricField< Type, fvPatchField, volMesh > &U, const fluxFieldType &phi, const fluxFieldType &phiCorr)
label timeIndex() const
Return current time index.
tmp< GeometricField< Type, fvPatchField, volMesh > > fvcDdt(const dimensioned< Type > &)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Mesh data needed to do the Finite Volume discretisation.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
A special matrix type and solver, designed for finite volume solutions of scalar equations.
const dimensionSet & dimensions() const
Return const reference to dimensions.
tmp< surfaceScalarField > meshPhi(const GeometricField< Type, fvPatchField, volMesh > &)
A class for managing temporary objects.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
dimensionedScalar deltaT() const
Return time step.
static autoPtr< Function1< Type > > New(const word &entryName, const dictionary &dict)
Selector.
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
const dimensionSet dimArea(sqr(dimLength))
const dimensionSet dimVelocity