54 namespace functionObjects
82 Foam::functionObjects::scalarTransport::D()
const
84 const word Dname(
"D" + fieldName_);
119 fieldName_(
dict.lookupOrDefault<
word>(
"field",
"s")),
149 if (controls.
found(
"nSubCycles"))
174 phiName_ =
dict.lookupOrDefault<
word>(
"phi",
"phi");
175 rhoName_ =
dict.lookupOrDefault<
word>(
"rho",
"rho");
176 schemesField_ =
dict.lookupOrDefault<
word>(
"schemesField", fieldName_);
178 diffusivity_ = diffusivityTypeNames_.read(
dict.lookup(
"diffusivity"));
182 case diffusivityType::none:
185 case diffusivityType::constant:
186 dict.lookup(
"D") >> D_;
190 dict.lookup(
"alphal") >> alphal_;
191 dict.lookup(
"alphat") >> alphat_;
195 nCorr_ =
dict.lookupOrDefaultBackwardsCompatible<
label>
197 {
"nCorrectors",
"nCorr"},
218 const word divScheme(
"div(phi," + schemesField_ +
")");
221 scalar relaxCoeff = 0.0;
222 if (mesh_.solution().relaxEquation(schemesField_))
224 relaxCoeff = mesh_.solution().equationRelaxationFactor(schemesField_);
243 for (
int i=0; i<=nCorr_; i++)
253 if (diffusivity_ != diffusivityType::none)
258 sEqn.
relax(relaxCoeff);
262 sEqn.
solve(schemesField_);
273 for (
int i=0; i<=nCorr_; i++)
283 if (diffusivity_ != diffusivityType::none)
288 sEqn.
relax(relaxCoeff);
292 sEqn.
solve(schemesField_);
300 <<
"Incompatible dimensions for phi: " << phi.
dimensions() <<
nl
311 void Foam::functionObjects::scalarTransport::subCycleMULES()
313 const dictionary& controls = mesh_.solution().solverDict(fieldName_);
330 !(++sSubCycle).end();
344 if (diffusivity_ != diffusivityType::none)
352 sEqn.solve(controls.
subDict(
"diffusivity"));
354 Info<< fieldName_ <<
" volume fraction = "
355 << s_.weightedAverage(mesh_.V()).value()
356 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
357 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
363 void Foam::functionObjects::scalarTransport::solveMULES()
365 const dictionary& controls = mesh_.solution().solverDict(fieldName_);
366 const bool MULESCorr(controls.lookupOrDefault<Switch>(
"MULESCorr",
false));
368 const MULES::control MULEScontrols(
mesh().solution().solverDict(s_.name()));
373 const bool applyPrevCorr
375 controls.lookupOrDefault<Switch>(
"applyPrevCorr",
false)
380 const word divScheme(
"div(phi," + schemesField_ +
")");
394 phi.dimensions()*s_.dimensions()
397 const word sScheme(mesh_.schemes().div(divScheme)[1].wordToken());
401 tmp<surfaceScalarField> nHatf;
415 gradsf/(
mag(gradsf) + deltaN_) & mesh_.Sf()
422 tmp<fv::ddtScheme<scalar>> tddtS
427 mesh_.schemes().ddt(
"ddt(s)")
430 const fv::ddtScheme<scalar>& ddtS = tddtS();
434 isType<fv::EulerDdtScheme<scalar>>(ddtS)
435 ||
isType<fv::localEulerDdtScheme<scalar>>(ddtS)
440 else if (
isType<fv::CrankNicolsonDdtScheme<scalar>>(ddtS))
443 refCast<const fv::CrankNicolsonDdtScheme<scalar>>(ddtS)
449 <<
"Only Euler and CrankNicolson ddt schemes are supported"
455 scalar cnCoeff = 1.0/(1.0 + ocCoeff);
457 tmp<surfaceScalarField> tphiCN(phi);
465 cnCoeff*phi + (1.0 - cnCoeff)*phi.oldTime()
471 tmp<surfaceScalarField> tphiCN1(phi);
472 tmp<surfaceScalarField> tsPhiCN0;
488 max(cnCoeff, 1.0 - 1.0/
max(Co, scalar(2))),
496 tsPhiCN0 = fv::gaussConvectionScheme<scalar>
500 upwind<scalar>(mesh_, phiCN0)
503 tphiCN1 = cnBDCoeff*phi;
510 ? fv::localEulerDdtScheme<scalar>(mesh_).fvmDdt(s_)
511 : fv::EulerDdtScheme<scalar>(mesh_).fvmDdt(s_)
513 + fv::gaussConvectionScheme<scalar>
517 upwind<scalar>(mesh_, tphiCN1)
518 ).fvmDiv(tphiCN1, s_)
521 if (tsPhiCN0.valid())
528 Info<< fieldName_ <<
" volume fraction = "
529 << s_.weightedAverage(mesh_.Vsc()).value()
530 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
531 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
534 tmp<surfaceScalarField> tsPhiUD(sEqn.flux());
536 if (tsPhiCN0.valid())
538 tsPhiUD.ref() += tsPhiCN0;
543 if (applyPrevCorr && tsPhiCorr0_.valid())
545 Info<<
"Applying the previous iteration compression flux" <<
endl;
557 sPhi += tsPhiCorr0_();
561 tsPhiCorr0_ = tsPhiUD;
564 for (
int sCorr=0; sCorr<nCorr_; sCorr++)
567 tmp<surfaceScalarField> tsPhiUn
572 (cnCoeff*s_ + (1.0 - cnCoeff)*s_.oldTime())(),
573 mesh_.schemes().div(divScheme)
579 tmp<surfaceScalarField> tsPhiCorr(tsPhiUn() - sPhi);
600 s_ = 0.5*s_ + 0.5*s0;
601 sPhi += 0.5*tsPhiCorr();
621 if (applyPrevCorr && MULESCorr)
623 tsPhiCorr0_ = sPhi - tsPhiCorr0_;
624 tsPhiCorr0_.ref().rename(
"sPhiCorr0");
631 Info<< fieldName_ <<
"volume fraction = "
632 << s_.weightedAverage(mesh_.Vsc()).value()
633 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
634 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.
Macros for easy insertion into run-time selection tables.
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.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
T lookupOrDefault(const word &, const T &, const bool writeDefault=writeOptionalEntries > 0) const
Find and return a T, if not found return the given default.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
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.
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(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, 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)
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 HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Ostream & endl(Ostream &os)
Add newline and flush stream.
fvMatrix< scalar > fvScalarMatrix
const dimensionSet dimKinematicViscosity
dimensioned< Type > average(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
bool isType(const Type &t)
Check the typeid.
SurfaceField< scalar > surfaceScalarField
const dimensionSet dimLength
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const dimensionSet dimTime
void pow(LagrangianPatchField< typename powProduct< Type, r >::type > &f, const LagrangianPatchField< Type > &f1)
const dimensionSet dimVolume
const wordHashSet compressionSchemes
VolField< scalar > volScalarField
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
const dimensionSet dimMass
SurfaceField< vector > surfaceVectorField
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))