52 namespace functionObjects
82 > Foam::functionObjects::scalarTransport::diffusivityTypeNames_;
88 Foam::functionObjects::scalarTransport::D()
const
90 const word Dname(
"D" + fieldName_);
121 fieldName_(
dict.lookupOrDefault<
word>(
"field",
"s")),
151 if (controls.
found(
"nSubCycles"))
202 phiName_ =
dict.lookupOrDefault<
word>(
"phi",
"phi");
203 rhoName_ =
dict.lookupOrDefault<
word>(
"rho",
"rho");
204 schemesField_ =
dict.lookupOrDefault<
word>(
"schemesField", fieldName_);
206 diffusivity_ = diffusivityTypeNames_.read(
dict.lookup(
"diffusivity"));
210 case diffusivityType::none:
213 case diffusivityType::constant:
214 dict.lookup(
"D") >> D_;
218 dict.lookup(
"alphal") >> alphal_;
219 dict.lookup(
"alphat") >> alphat_;
223 dict.readIfPresent(
"nCorr", nCorr_);
242 const word divScheme(
"div(phi," + schemesField_ +
")");
245 scalar relaxCoeff = 0.0;
246 if (mesh_.solution().relaxEquation(schemesField_))
248 relaxCoeff = mesh_.solution().equationRelaxationFactor(schemesField_);
267 for (
int i=0; i<=nCorr_; i++)
277 if (diffusivity_ != diffusivityType::none)
282 sEqn.
relax(relaxCoeff);
286 sEqn.
solve(schemesField_);
297 for (
int i=0; i<=nCorr_; i++)
307 if (diffusivity_ != diffusivityType::none)
312 sEqn.
relax(relaxCoeff);
316 sEqn.
solve(schemesField_);
324 <<
"Incompatible dimensions for phi: " << phi.
dimensions() <<
nl
335 void Foam::functionObjects::scalarTransport::subCycleMULES()
337 const dictionary& controls = mesh_.solution().solverDict(fieldName_);
354 !(++sSubCycle).end();
368 if (diffusivity_ != diffusivityType::none)
376 sEqn.solve(controls.
subDict(
"diffusivity"));
378 Info<< fieldName_ <<
" volume fraction = "
379 << s_.weightedAverage(mesh_.V()).value()
380 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
381 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
387 void Foam::functionObjects::scalarTransport::solveMULES()
389 const dictionary& controls = mesh_.solution().solverDict(fieldName_);
390 const label nCorr(controls.lookup<
label>(
"nCorr"));
391 const label nSubCycles(controls.lookup<
label>(
"nSubCycles"));
392 const bool MULESCorr(controls.lookupOrDefault<Switch>(
"MULESCorr",
false));
397 const bool applyPrevCorr
399 controls.lookupOrDefault<Switch>(
"applyPrevCorr",
false)
404 const word divScheme(
"div(phi," + schemesField_ +
")");
411 const word sScheme(mesh_.schemes().div(divScheme)[1].wordToken());
415 tmp<surfaceScalarField> nHatf;
429 gradsf/(
mag(gradsf) + deltaN_) & mesh_.Sf()
436 tmp<fv::ddtScheme<scalar>> tddtS
441 mesh_.schemes().ddt(
"ddt(s)")
444 const fv::ddtScheme<scalar>& ddtS = tddtS();
448 isType<fv::EulerDdtScheme<scalar>>(ddtS)
449 ||
isType<fv::localEulerDdtScheme<scalar>>(ddtS)
454 else if (
isType<fv::CrankNicolsonDdtScheme<scalar>>(ddtS))
459 <<
"Sub-cycling is not supported "
460 "with the CrankNicolson ddt scheme"
467 || time_.timeIndex() > time_.startTimeIndex() + 1
471 refCast<const fv::CrankNicolsonDdtScheme<scalar>>(ddtS)
478 <<
"Only Euler and CrankNicolson ddt schemes are supported"
484 scalar cnCoeff = 1.0/(1.0 + ocCoeff);
486 tmp<surfaceScalarField> phiCN(phi);
494 cnCoeff*phi + (1.0 - cnCoeff)*phi.oldTime()
504 ? fv::localEulerDdtScheme<scalar>(mesh_).fvmDdt(s_)
505 : fv::EulerDdtScheme<scalar>(mesh_).fvmDdt(s_)
507 + fv::gaussConvectionScheme<scalar>
511 upwind<scalar>(mesh_, phiCN)
517 Info<< fieldName_ <<
" volume fraction = "
518 << s_.weightedAverage(mesh_.Vsc()).value()
519 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
520 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
523 tmp<surfaceScalarField> tsPhiUD(sEqn.flux());
526 if (applyPrevCorr && tsPhiCorr0_.valid())
528 Info<<
"Applying the previous iteration compression flux" <<
endl;
539 sPhi_ += tsPhiCorr0_();
543 tsPhiCorr0_ = tsPhiUD;
546 for (
int sCorr=0; sCorr<nCorr; sCorr++)
549 tmp<surfaceScalarField> tsPhiUn
554 (cnCoeff*s_ + (1.0 - cnCoeff)*s_.oldTime())(),
555 mesh_.schemes().div(divScheme)
561 tmp<surfaceScalarField> tsPhiCorr(tsPhiUn() - sPhi_);
577 sPhi_ += tsPhiCorr();
581 s_ = 0.5*s_ + 0.5*s0;
582 sPhi_ += 0.5*tsPhiCorr();
603 tsPhiCorr0_ = sPhi_ - tsPhiCorr0_;
604 tsPhiCorr0_.ref().rename(
"sPhiCorr0");
613 word(mesh_.schemes().ddt(
"ddt(s)"))
614 == fv::CrankNicolsonDdtScheme<scalar>::typeName
620 sPhi_ = (sPhi_ - (1.0 - cnCoeff)*sPhi_.oldTime())/cnCoeff;
624 Info<< fieldName_ <<
"volume fraction = "
625 << s_.weightedAverage(mesh_.Vsc()).value()
626 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
627 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
static const Foam::dimensionedScalar D("D", Foam::dimTemperature, 257.14)
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.
Macros for easy insertion into run-time selection tables.
const bool MULESCorr(alphaControls.lookupOrDefault< Switch >("MULESCorr", false))
const dimensionSet & dimensions() const
Return dimensions.
Generic GeometricField class.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &, 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...
static word group(const word &name)
Return group (extension part of name)
static word groupName(Name name, const word &group)
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 keyword definitions, which are a keyword followed by any number of values (e....
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) 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.
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.
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
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.
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()
Do nothing.
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 & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
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.
Templated form of IOobject providing type information for file reading and header type checking.
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
A class for handling words, derived from string.
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
#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 explicitSolve(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiPsi, const SpType &Sp, const SuType &Su)
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, 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< 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)
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
fvMatrix< scalar > fvScalarMatrix
const dimensionSet dimKinematicViscosity
bool isType(const Type &t)
Check the typeid.
SurfaceField< scalar > surfaceScalarField
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
const dimensionSet dimTime
const dimensionSet dimVolume
const wordHashSet compressionSchemes
VolField< scalar > volScalarField
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
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))