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>
99 GeoField::operator=(gf);
104 template<
class GeoField>
105 typename CrankNicolsonDdtScheme<Type>::template DDt0Field<GeoField>&
106 CrankNicolsonDdtScheme<Type>::ddt0_
112 if (!
mesh().objectRegistry::template foundObject<GeoField>(name))
128 ).typeHeaderOk<DDt0Field<GeoField>>()
133 new DDt0Field<GeoField>
151 new DDt0Field<GeoField>
173 DDt0Field<GeoField>& ddt0 =
static_cast<DDt0Field<GeoField>&
> 175 mesh().objectRegistry::template lookupObjectRef<GeoField>(
name)
183 template<
class GeoField>
186 const DDt0Field<GeoField>& ddt0
193 template<
class GeoField>
196 const DDt0Field<GeoField>& ddt0
211 template<
class GeoField>
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>
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());
1372 (rDtCoef*Uf.
oldTime() + offCentre_(dUfdt0()))
1387 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1388 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1390 "ddtCorrDdt0(" + U.
name() +
')',
1394 DDt0Field<GeometricField<Type, fvsPatchField, surfaceMesh>>& dUfdt0 =
1395 ddt0_<GeometricField<Type, fvsPatchField, surfaceMesh>>
1397 "ddtCorrDdt0(" + Uf.
name() +
')',
1407 - offCentre_(ddt0());
1410 if (evaluate(dUfdt0))
1414 - offCentre_(dUfdt0());
1423 "ddtCorr(" + U.
name() +
',' + Uf.
name() +
')',
1436 (rDtCoef*Uf.
oldTime() + offCentre_(dUfdt0()))
1439 rDtCoef*U.
oldTime() + offCentre_(ddt0())
1449 <<
"dimensions of Uf are not correct" 1457 template<
class Type>
1472 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1473 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1475 "ddtCorrDdt0(" + rho.
name() +
',' + U.
name() +
')',
1479 DDt0Field<fluxFieldType>& dphidt0 =
1480 ddt0_<fluxFieldType>
1482 "ddtCorrDdt0(" + phi.
name() +
')',
1498 - offCentre_(ddt0());
1501 if (evaluate(dphidt0))
1506 - offCentre_(dphidt0());
1516 + rho.
name() +
',' + U.
name() +
',' + phi.
name() +
')',
1522 (rDtCoef*phi.
oldTime() + offCentre_(dphidt0()))
1526 rDtCoef*rhoU0 + offCentre_(ddt0())
1540 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1541 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1543 "ddtCorrDdt0(" + U.
name() +
')',
1547 DDt0Field<fluxFieldType>& dphidt0 =
1548 ddt0_<fluxFieldType>
1550 "ddtCorrDdt0(" + phi.
name() +
')',
1560 - offCentre_(ddt0());
1563 if (evaluate(dphidt0))
1567 - offCentre_(dphidt0());
1576 "ddtCorr(" + U.
name() +
',' + phi.
name() +
')',
1582 (rDtCoef*phi.
oldTime() + offCentre_(dphidt0()))
1586 rDtCoef*U.
oldTime() + offCentre_(ddt0())
1595 <<
"dimensions of phi are not correct" 1603 template<
class Type>
1609 DDt0Field<surfaceScalarField>& meshPhi0 = ddt0_<surfaceScalarField>
1615 if (evaluate(meshPhi0))
1618 coef0_(meshPhi0)*
mesh().
phi().
oldTime() - offCentre_(meshPhi0());
1624 coef_(meshPhi0)*
mesh().
phi() - offCentre_(meshPhi0())
virtual 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)
virtual dimensionedScalar startTime() const
Return start time.
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.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Abstract base class for ddt schemes.
static tmp< GeometricField< scalar, fvsPatchField, surfaceMesh > > New(const word &name, const Mesh &, const dimensionSet &, const word &patchFieldType=fvsPatchField< scalar >::calculatedType())
Return a temporary field constructed from name, mesh, dimensionSet.
const dimensionSet dimVolume(pow3(dimLength))
const dimensionSet & dimensions() const
Return dimensions.
Dimension set for the base types.
ddtScheme< Type >::fluxFieldType fluxFieldType
const DimensionedField< scalar, volMesh > & V0() const
Return old-time cell volumes.
A class for handling words, derived from string.
virtual 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.
virtual 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.
virtual tmp< surfaceScalarField > fvcDdtPhiCoeff(const GeometricField< Type, fvPatchField, volMesh > &U, const fluxFieldType &phi, const fluxFieldType &phiCorr)
label timeIndex() const
Return current time index.
virtual tmp< GeometricField< Type, fvPatchField, volMesh > > fvcDdt(const dimensioned< Type > &)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
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.
CrankNicolsonDdtScheme(const fvMesh &mesh)
Construct from mesh.
virtual tmp< surfaceScalarField > meshPhi(const GeometricField< Type, fvPatchField, volMesh > &)
void operator=(const CrankNicolsonDdtScheme &)=delete
Disallow default bitwise assignment.
A class for managing temporary objects.
virtual label startTimeIndex() const
Return start time index.
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