54 namespace functionObjects
82 Foam::functionObjects::scalarTransport::D()
const
84 const word Dname(
"D" + fieldName_);
119 fieldName_(
dict.lookupOrDefault<
word>(
"field",
"s")),
148 if (controls.
found(
"nSubCycles"))
173 phiName_ =
dict.lookupOrDefault<
word>(
"phi",
"phi");
174 rhoName_ =
dict.lookupOrDefault<
word>(
"rho",
"rho");
175 schemesField_ =
dict.lookupOrDefault<
word>(
"schemesField", fieldName_);
176 solverField_ =
dict.lookupOrDefault<
word>(
"solverField", fieldName_);
178 diffusivity_ = diffusivityTypeNames_.read(
dict.lookup(
"diffusivity"));
185 case diffusivityType::constant:
186 dict.lookup(
"D") >> D_;
190 dict.lookup(
"alphal") >> alphal_;
191 dict.lookup(
"alphat") >> alphat_;
212 const word divScheme(
"div(phi," + schemesField_ +
")");
215 mesh_.solution().solverDict(solverField_)
216 .lookupOrDefaultBackwardsCompatible<
label>
218 {
"nCorrectors",
"nCorr"},
223 scalar relaxCoeff = 0.0;
224 if (mesh_.solution().relaxEquation(solverField_))
226 relaxCoeff = mesh_.solution().equationRelaxationFactor(solverField_);
245 for (
int i=0; i<=nCorr; i++)
264 "laplacian(" +
D.
name() +
"," + schemesField_ +
")"
268 sEqn.
relax(relaxCoeff);
272 sEqn.
solve(solverField_);
283 for (
int i=0; i<=nCorr; i++)
302 "laplacian(" +
D.
name() +
"," + schemesField_ +
")"
306 sEqn.
relax(relaxCoeff);
310 sEqn.
solve(solverField_);
318 <<
"Incompatible dimensions for phi: " << phi.
dimensions() <<
nl
329 void Foam::functionObjects::scalarTransport::subCycleMULES()
331 const dictionary& controls = mesh_.solution().solverDict(fieldName_);
348 !(++sSubCycle).end();
373 "laplacian(" +
D.
name() +
"," + schemesField_ +
")"
377 sEqn.solve(controls.
subDict(
"diffusivity"));
379 Info<< fieldName_ <<
" volume fraction = "
380 << s_.weightedAverage(mesh_.V()).value()
381 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
382 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
388 void Foam::functionObjects::scalarTransport::solveMULES()
390 const dictionary& controls = mesh_.solution().solverDict(fieldName_);
394 {
"nCorrectors",
"nCorr"},
398 const bool MULESCorr(controls.lookupOrDefault<Switch>(
"MULESCorr",
false));
400 const MULES::control MULEScontrols(
mesh().solution().solverDict(s_.name()));
405 const bool applyPrevCorr
407 controls.lookupOrDefault<Switch>(
"applyPrevCorr",
false)
412 const word divScheme(
"div(phi," + schemesField_ +
")");
426 phi.dimensions()*s_.dimensions(),
430 const word sScheme(mesh_.schemes().div(divScheme)[1].wordToken());
434 tmp<surfaceScalarField> nHatf;
448 gradsf/(
mag(gradsf) + deltaN_) & mesh_.Sf()
455 tmp<fv::ddtScheme<scalar>> tddtS
460 mesh_.schemes().ddt(
"ddt(s)")
463 const fv::ddtScheme<scalar>& ddtS = tddtS();
467 isType<fv::EulerDdtScheme<scalar>>(ddtS)
468 ||
isType<fv::localEulerDdtScheme<scalar>>(ddtS)
473 else if (
isType<fv::CrankNicolsonDdtScheme<scalar>>(ddtS))
476 refCast<const fv::CrankNicolsonDdtScheme<scalar>>(ddtS)
482 <<
"Only Euler and CrankNicolson ddt schemes are supported"
488 scalar cnCoeff = 1.0/(1.0 + ocCoeff);
490 tmp<surfaceScalarField> tphiCN(phi);
498 cnCoeff*phi + (1.0 - cnCoeff)*phi.oldTime()
504 tmp<surfaceScalarField> tphiCN1(phi);
505 tmp<surfaceScalarField> tsPhiCN0;
521 max(cnCoeff, 1.0 - 1.0/
max(Co, scalar(2))),
529 tsPhiCN0 = fv::gaussConvectionScheme<scalar>
533 upwind<scalar>(mesh_, phiCN0)
536 tphiCN1 = cnBDCoeff*phi;
543 ? fv::localEulerDdtScheme<scalar>(mesh_).fvmDdt(s_)
544 : fv::EulerDdtScheme<scalar>(mesh_).fvmDdt(s_)
546 + fv::gaussConvectionScheme<scalar>
550 upwind<scalar>(mesh_, tphiCN1)
551 ).fvmDiv(tphiCN1, s_)
554 if (tsPhiCN0.valid())
561 Info<< fieldName_ <<
" volume fraction = "
562 << s_.weightedAverage(mesh_.Vsc()).value()
563 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
564 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
567 tmp<surfaceScalarField> tsPhiUD(sEqn.flux());
569 if (tsPhiCN0.valid())
571 tsPhiUD.ref() += tsPhiCN0;
576 if (applyPrevCorr && tsPhiCorr0_.valid())
578 Info<<
"Applying the previous iteration compression flux" <<
endl;
590 sPhi += tsPhiCorr0_();
594 tsPhiCorr0_ = tsPhiUD;
597 for (
int sCorr=0; sCorr<nCorr; sCorr++)
600 tmp<surfaceScalarField> tsPhiUn
605 (cnCoeff*s_ + (1.0 - cnCoeff)*s_.oldTime())(),
606 mesh_.schemes().div(divScheme)
612 tmp<surfaceScalarField> tsPhiCorr(tsPhiUn() - sPhi);
633 s_ = 0.5*s_ + 0.5*s0;
634 sPhi += 0.5*tsPhiCorr();
654 if (applyPrevCorr && MULESCorr)
656 tsPhiCorr0_ = sPhi - tsPhiCorr0_;
657 tsPhiCorr0_.ref().rename(
"sPhiCorr0");
664 Info<< fieldName_ <<
"volume fraction = "
665 << s_.weightedAverage(mesh_.Vsc()).value()
666 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
667 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.
Macros for easy insertion into run-time selection tables.
static fvModels & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
const dimensionSet & dimensions() const
Return dimensions.
static const char *const typeName
Generic GeometricField class.
DimensionedField< Type, GeoMesh, PrimitiveField > Internal
Type of the internal field from which this GeometricField is derived.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
bool found(const Key &) const
Return true if hashedEntry is found in table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Initialise the NamedEnum HashTable from the static list of names.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
T lookupOrDefault(const word &, const T &) const
Find and return a T, if not found return the given default.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
T lookupOrDefaultBackwardsCompatible(const wordList &, const T &) const
Find and return a T, trying a list of keywords in sequence,.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
const word & name() const
Return const reference to name.
Abstract base-class for Time/database functionObjects.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const fvMesh & mesh_
Reference to the fvMesh.
virtual bool read(const dictionary &)
Read optional controls.
Evolves a passive scalar transport equation.
static const NamedEnum< diffusivityType, 3 > diffusivityTypeNames_
Diffusivity type names.
virtual ~scalarTransport()
Destructor.
virtual wordList fields() const
Return the list of fields required.
diffusivityType
Enumeration defining the type of the diffusivity.
virtual bool execute()
Calculate the scalarTransport.
virtual bool write()
Write the updated scalar field.
virtual bool read(const dictionary &)
Read the scalarTransport data.
scalarTransport(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Finite volume constraints.
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
void relax(const scalar alpha)
Relax matrix (for steady-state solution).
SolverPerformance< Type > solve(const dictionary &)
Solve segregated or coupled returning the solution statistics.
const fvSchemes & schemes() const
Return the fvSchemes.
const fvSolution & solution() const
Return the fvSolution.
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
void setFluxRequired(const word &name) const
static tmp< ddtScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return a pointer to a new ddtScheme created on freestore.
static tmp< volScalarField > localRSubDeltaT(const fvMesh &mesh, const label nAlphaSubCycles)
Calculate and return the reciprocal of the local sub-cycling.
static bool enabled(const fvMesh &mesh)
Return true if LTS is enabled.
static const word & calculatedType()
Return the type of the calculated for of fvsPatchField.
const Type & lookupType(const word &group=word::null) const
Lookup and return the object of the given Type.
const dictionary & solversDict() const
Return the solver controls dictionary.
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Perform a subCycleTime on a field or list of fields.
A class for managing temporary objects.
A class for handling words, derived from string.
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Calculate the first temporal derivative.
Calculate the face-flux of the given field.
Calculate the matrix for the first temporal derivative.
Calculate the matrix for the divergence of the given field and flux.
Calculate the matrix for the laplacian of the field.
Calculate the matrix for implicit and explicit sources.
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, const SpType &Sp)
void explicitSolve(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &psiPhi, const SpType &Sp, const SuType &Su)
compressibleMomentumTransportModel momentumTransportModel
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
addToRunTimeSelectionTable(functionObject, fvModel, dictionary)
tmp< SurfaceField< typename innerProduct< vector, Type >::type > > flux(const VolField< Type > &vf)
Return the face-flux field obtained from the given volVectorField.
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< VolField< Type > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
tmp< VolInternalField< Type > > surfaceSum(const SurfaceField< Type > &ssf)
tmp< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const VolField< Type > &vf, const word &name)
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
static const coefficient D("D", dimTemperature, 257.14)
errorManipArg< error, int > exit(error &err, const int errNo=1)
const dimensionSet & dimKinematicViscosity
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 dimensionSet & dimMass
Ostream & endl(Ostream &os)
Add newline and flush stream.
fvMatrix< scalar > fvScalarMatrix
const dimensionSet & dimLength
dimensioned< Type > average(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
bool isType(const Type &t)
Check the typeid.
SurfaceField< scalar > surfaceScalarField
const dimensionSet & dimVolume
const dimensionSet & dimTime
const wordHashSet compressionSchemes
VolField< scalar > volScalarField
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
SurfaceField< vector > surfaceVectorField
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Info<< "Reading field U\n"<< endl;volVectorField U(IOobject("U", runTime.name(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Creating face flux\n"<< endl;surfaceScalarField phi(IOobject("phi", runTime.name(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedScalar(mesh.Sf().dimensions() *U.dimensions(), 0));autoPtr< viscosityModel > viscosity(viscosityModel::New(mesh))
autoPtr< incompressible::momentumTransportModel > turbulence(incompressible::momentumTransportModel::New(U, phi, viscosity))