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 Function1s::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() +
')',
357 const word ddtName(
"ddt(" + dt.
name() +
')');
385 -
mesh().
V00()*offCentre_(ddt0.internalField())
392 -
mesh().
V0()*offCentre_(ddt0.internalField())
407 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
408 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
410 "ddt0(" + vf.
name() +
')',
414 const word ddtName(
"ddt(" + vf.
name() +
')');
422 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
424 ddt0.primitiveFieldRef() =
430 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
433 ddt0.boundaryFieldRef() =
438 - vf.
oldTime().oldTime().boundaryField()
439 ) - offCentre_(
ff(ddt0.boundaryField()))
451 ) -
mesh().
V0()*offCentre_(ddt0()())
456 ) - offCentre_(
ff(ddt0.boundaryField()))
464 - offCentre_(ddt0());
470 rDtCoef*(vf - vf.
oldTime()) - offCentre_(ddt0())
484 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
485 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
487 "ddt0(" + rho.
name() +
',' + vf.
name() +
')',
491 const word ddtName(
"ddt(" + rho.
name() +
',' + vf.
name() +
')');
499 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
501 ddt0.primitiveFieldRef() =
503 rDtCoef0*rho.
value()*
507 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
510 ddt0.boundaryFieldRef() =
512 rDtCoef0*rho.
value()*
515 - vf.
oldTime().oldTime().boundaryField()
516 ) - offCentre_(
ff(ddt0.boundaryField()))
528 ) -
mesh().
V0()*offCentre_(ddt0())()
530 rDtCoef.value()*rho.
value()*
533 ) - offCentre_(
ff(ddt0.boundaryField()))
540 ddt0 = rDtCoef0_(ddt0)*rho*(vf.
oldTime() - vf.
oldTime().oldTime())
541 - offCentre_(ddt0());
547 rDtCoef*rho*(vf - vf.
oldTime()) - offCentre_(ddt0())
561 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
562 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
564 "ddt0(" + rho.
name() +
',' + vf.
name() +
')',
568 const word ddtName(
"ddt(" + rho.
name() +
',' + vf.
name() +
')');
576 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
578 ddt0.primitiveFieldRef() =
585 *vf.
oldTime().oldTime().primitiveField()
586 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
589 ddt0.boundaryFieldRef() =
596 *vf.
oldTime().oldTime().boundaryField()
597 ) - offCentre_(
ff(ddt0.boundaryField()))
610 ) -
mesh().
V00()*offCentre_(ddt0())()
616 ) - offCentre_(
ff(ddt0.boundaryField()))
623 ddt0 = rDtCoef0_(ddt0)*
627 ) - offCentre_(ddt0());
633 rDtCoef*(rho*vf - rho.
oldTime()*vf.
oldTime()) - offCentre_(ddt0())
648 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
649 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
651 "ddt0(" + alpha.
name() +
',' + rho.
name() +
',' + vf.
name() +
')',
657 "ddt(" + alpha.
name() +
',' + rho.
name() +
',' + vf.
name() +
')' 666 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
668 ddt0.primitiveFieldRef() =
680 *vf.
oldTime().oldTime().primitiveField()
681 ) -
mesh().
V00()*offCentre_(ddt0.primitiveField())
684 ddt0.boundaryFieldRef() =
694 *vf.
oldTime().oldTime().boundaryField()
695 ) - offCentre_(
ff(ddt0.boundaryField()))
707 ) -
mesh().
V00()*offCentre_(ddt0())()
718 ) - offCentre_(
ff(ddt0.boundaryField()))
725 ddt0 = rDtCoef0_(ddt0)*
734 ) - offCentre_(ddt0());
758 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
759 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
761 "ddt0(" + vf.
name() +
')',
776 const scalar rDtCoef = rDtCoef_(ddt0).
value();
785 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
787 ddt0.primitiveFieldRef() =
794 -
mesh().
V00()*offCentre_(ddt0.primitiveField())
797 ddt0.boundaryFieldRef() =
802 - vf.
oldTime().oldTime().boundaryField()
804 - offCentre_(
ff(ddt0.boundaryField()))
810 rDtCoef*vf.
oldTime().primitiveField()
811 + offCentre_(ddt0.primitiveField())
819 - offCentre_(ddt0());
824 rDtCoef*vf.
oldTime().primitiveField()
825 + offCentre_(ddt0.primitiveField())
841 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
842 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
844 "ddt0(" + rho.
name() +
',' + vf.
name() +
')',
858 const scalar rDtCoef = rDtCoef_(ddt0).
value();
867 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
869 ddt0.primitiveFieldRef() =
871 rDtCoef0*rho.
value()*
876 -
mesh().
V00()*offCentre_(ddt0.primitiveField())
879 ddt0.boundaryFieldRef() =
881 rDtCoef0*rho.
value()*
884 - vf.
oldTime().oldTime().boundaryField()
886 - offCentre_(
ff(ddt0.boundaryField()))
893 + offCentre_(ddt0.primitiveField())
900 ddt0 = rDtCoef0_(ddt0)*rho*(vf.
oldTime() - vf.
oldTime().oldTime())
901 - offCentre_(ddt0());
907 + offCentre_(ddt0.primitiveField())
923 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
924 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
926 "ddt0(" + rho.
name() +
',' + vf.
name() +
')',
940 const scalar rDtCoef = rDtCoef_(ddt0).
value();
950 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
952 ddt0.primitiveFieldRef() =
959 *vf.
oldTime().oldTime().primitiveField()
961 -
mesh().
V00()*offCentre_(ddt0.primitiveField())
964 ddt0.boundaryFieldRef() =
971 *vf.
oldTime().oldTime().boundaryField()
973 - offCentre_(
ff(ddt0.boundaryField()))
980 + offCentre_(ddt0.primitiveField())
987 ddt0 = rDtCoef0_(ddt0)*
991 ) - offCentre_(ddt0());
997 + offCentre_(ddt0.primitiveField())
1005 template<
class Type>
1014 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1015 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1017 "ddt0(" + alpha.
name() +
',' + rho.
name() +
',' + vf.
name() +
')',
1031 const scalar rDtCoef = rDtCoef_(ddt0).
value();
1038 if (
mesh().moving())
1042 const scalar rDtCoef0 = rDtCoef0_(ddt0).
value();
1044 ddt0.primitiveFieldRef() =
1051 *vf.
oldTime().primitiveField()
1056 *vf.
oldTime().oldTime().primitiveField()
1058 -
mesh().
V00()*offCentre_(ddt0.primitiveField())
1061 ddt0.boundaryFieldRef() =
1071 *vf.
oldTime().oldTime().boundaryField()
1073 - offCentre_(
ff(ddt0.boundaryField()))
1082 *vf.
oldTime().primitiveField()
1083 + offCentre_(ddt0.primitiveField())
1090 ddt0 = rDtCoef0_(ddt0)*
1099 ) - offCentre_(ddt0());
1107 *vf.
oldTime().primitiveField()
1108 + offCentre_(ddt0.primitiveField())
1116 template<
class Type>
1124 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1125 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1127 "ddtCorrDdt0(" + U.
name() +
')',
1131 DDt0Field<GeometricField<Type, fvsPatchField, surfaceMesh>>& dUfdt0 =
1132 ddt0_<GeometricField<Type, fvsPatchField, surfaceMesh>>
1134 "ddtCorrDdt0(" + Uf.
name() +
')',
1144 - offCentre_(ddt0());
1147 if (evaluate(dUfdt0))
1151 - offCentre_(dUfdt0());
1156 "ddtCorr(" + U.
name() +
',' + Uf.
name() +
')',
1161 (rDtCoef*Uf.
oldTime() + offCentre_(dUfdt0()))
1169 template<
class Type>
1177 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1178 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1180 "ddtCorrDdt0(" + U.
name() +
')',
1184 DDt0Field<fluxFieldType>& dphidt0 =
1185 ddt0_<fluxFieldType>
1187 "ddtCorrDdt0(" + phi.
name() +
')',
1197 - offCentre_(ddt0());
1200 if (evaluate(dphidt0))
1204 - offCentre_(dphidt0());
1209 "ddtCorr(" + U.
name() +
',' + phi.
name() +
')',
1212 (rDtCoef*phi.
oldTime() + offCentre_(dphidt0()))
1216 rDtCoef*U.
oldTime() + offCentre_(ddt0())
1223 template<
class Type>
1238 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1239 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1241 "ddtCorrDdt0(" + rho.
name() +
',' + U.
name() +
')',
1245 DDt0Field<GeometricField<Type, fvsPatchField, surfaceMesh>>& dUfdt0 =
1246 ddt0_<GeometricField<Type, fvsPatchField, surfaceMesh>>
1248 "ddtCorrDdt0(" + Uf.
name() +
')',
1264 - offCentre_(ddt0());
1267 if (evaluate(dUfdt0))
1272 - offCentre_(dUfdt0());
1277 "ddtCorr(" + rho.
name() +
',' + U.
name() +
',' + Uf.
name() +
')',
1287 (rDtCoef*Uf.
oldTime() + offCentre_(dUfdt0()))
1299 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1300 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1302 "ddtCorrDdt0(" + U.
name() +
')',
1306 DDt0Field<GeometricField<Type, fvsPatchField, surfaceMesh>>& dUfdt0 =
1307 ddt0_<GeometricField<Type, fvsPatchField, surfaceMesh>>
1309 "ddtCorrDdt0(" + Uf.
name() +
')',
1319 - offCentre_(ddt0());
1322 if (evaluate(dUfdt0))
1326 - offCentre_(dUfdt0());
1331 "ddtCorr(" + U.
name() +
',' + Uf.
name() +
')',
1341 (rDtCoef*Uf.
oldTime() + offCentre_(dUfdt0()))
1344 rDtCoef*U.
oldTime() + offCentre_(ddt0())
1353 <<
"dimensions of Uf are not correct" 1361 template<
class Type>
1376 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1377 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1379 "ddtCorrDdt0(" + rho.
name() +
',' + U.
name() +
')',
1383 DDt0Field<fluxFieldType>& dphidt0 =
1384 ddt0_<fluxFieldType>
1386 "ddtCorrDdt0(" + phi.
name() +
')',
1402 - offCentre_(ddt0());
1405 if (evaluate(dphidt0))
1410 - offCentre_(dphidt0());
1415 "ddtCorr(" + rho.
name() +
',' + U.
name() +
',' + phi.
name() +
')',
1418 (rDtCoef*phi.
oldTime() + offCentre_(dphidt0()))
1422 rDtCoef*rhoU0 + offCentre_(ddt0())
1433 DDt0Field<GeometricField<Type, fvPatchField, volMesh>>& ddt0 =
1434 ddt0_<GeometricField<Type, fvPatchField, volMesh>>
1436 "ddtCorrDdt0(" + U.
name() +
')',
1440 DDt0Field<fluxFieldType>& dphidt0 =
1441 ddt0_<fluxFieldType>
1443 "ddtCorrDdt0(" + phi.
name() +
')',
1453 - offCentre_(ddt0());
1456 if (evaluate(dphidt0))
1460 - offCentre_(dphidt0());
1465 "ddtCorr(" + U.
name() +
',' + phi.
name() +
')',
1468 (rDtCoef*phi.
oldTime() + offCentre_(dphidt0()))
1472 rDtCoef*U.
oldTime() + offCentre_(ddt0())
1480 <<
"dimensions of phi are not correct" 1488 template<
class Type>
1494 DDt0Field<surfaceScalarField>& meshPhi0 = ddt0_<surfaceScalarField>
1500 if (evaluate(meshPhi0))
1503 coef0_(meshPhi0)*
mesh().
phi().
oldTime() - offCentre_(meshPhi0());
1509 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.
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
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.
virtual dimensionedScalar startTime() const
Return start time.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &)
Return a temporary field constructed from name,.
void putBack(const token &)
Put back token.
const surfaceScalarField & phi() const
Return cell face motion fluxes.
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.
const dimensionSet dimTime
const dimensionSet & dimensions() const
Return dimensions.
Dimension set for the base types.
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)
const dimensionSet dimVol
const dimensionSet dimFlux
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 dimensionSet dimVelocity
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.
Templated function that returns a constant value.
Mesh data needed to do the Finite Volume discretisation.
A special matrix type and solver, designed for finite volume solutions of scalar equations.
const dimensionSet & dimensions() const
Return const reference to dimensions.
const dimensionSet dimVolume
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.
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
static autoPtr< Function1< Type > > New(const word &name, const dictionary &dict)
Selector.