52 namespace functionObjects
82 > Foam::functionObjects::scalarTransport::diffusionTypeNames_;
88 Foam::functionObjects::scalarTransport::D()
const 90 const word Dname(
"D" + fieldName_);
92 if (diffusion_ == diffusionType::constant)
106 momentumTransportModel::typeName
109 return alphal_*turbulence.
nu() + alphat_*turbulence.
nut();
125 diffusion_(diffusionType::none),
133 mesh_.time().timeName(),
150 if (mesh_.solution().solversDict().found(fieldName_))
152 const dictionary& controls = mesh_.solution().solverDict(fieldName_);
154 if (controls.
found(
"nSubCycles"))
186 mesh_.schemes().setFluxRequired(fieldName_);
209 diffusion_ = diffusionTypeNames_.read(dict.
lookup(
"diffusion"));
213 case diffusionType::none:
216 case diffusionType::constant:
221 dict.
lookup(
"alphal") >> alphal_;
222 dict.
lookup(
"alphat") >> alphat_;
245 const word divScheme(
"div(phi," + schemesField_ +
")");
248 scalar relaxCoeff = 0.0;
249 if (mesh_.solution().relaxEquation(schemesField_))
251 relaxCoeff = mesh_.solution().equationRelaxationFactor(schemesField_);
270 for (
int i=0; i<=nCorr_; i++)
280 if (diffusion_ != diffusionType::none)
285 sEqn.relax(relaxCoeff);
289 sEqn.solve(schemesField_);
300 for (
int i=0; i<=nCorr_; i++)
307 fvModels.source(rho, s_)
310 if (diffusion_ != diffusionType::none)
315 sEqn.relax(relaxCoeff);
319 sEqn.solve(schemesField_);
327 <<
"Incompatible dimensions for phi: " << phi.
dimensions() <<
nl 338 void Foam::functionObjects::scalarTransport::subCycleMULES()
340 const dictionary& controls = mesh_.solution().solverDict(fieldName_);
357 !(++sSubCycle).end();
371 if (diffusion_ != diffusionType::none)
381 Info<< fieldName_ <<
" volume fraction = " 382 << s_.weightedAverage(mesh_.V()).value()
383 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
384 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
390 void Foam::functionObjects::scalarTransport::solveMULES()
392 const dictionary& controls = mesh_.solution().solverDict(fieldName_);
400 const bool applyPrevCorr
407 const word divScheme(
"div(phi," + schemesField_ +
")");
414 const word sScheme(mesh_.schemes().div(divScheme)[1].wordToken());
429 s_.time().timeName(),
432 gradsf/(
mag(gradsf) + deltaN_) & mesh_.Sf()
444 mesh_.schemes().ddt(
"ddt(s)")
462 <<
"Sub-cycling is not supported " 463 "with the CrankNicolson ddt scheme" 470 || mesh_.time().timeIndex() > mesh_.time().startTimeIndex() + 1
474 refCast<const fv::CrankNicolsonDdtScheme<scalar>>(ddtS)
481 <<
"Only Euler and CrankNicolson ddt schemes are supported" 497 cnCoeff*phi + (1.0 - cnCoeff)*phi.
oldTime()
520 Info<< fieldName_ <<
" volume fraction = " 521 << s_.weightedAverage(mesh_.Vsc()).value()
522 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
523 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
529 if (applyPrevCorr && tsPhiCorr0_.valid())
531 Info<<
"Applying the previous iteration compression flux" <<
endl;
542 sPhi_ += tsPhiCorr0_();
546 tsPhiCorr0_ = tsPhiUD;
549 for (
int sCorr=0; sCorr<
nCorr; sCorr++)
557 (cnCoeff*s_ + (1.0 - cnCoeff)*s_.oldTime())(),
558 mesh_.schemes().div(divScheme)
580 sPhi_ += tsPhiCorr();
584 s_ = 0.5*s_ + 0.5*s0;
585 sPhi_ += 0.5*tsPhiCorr();
604 if (applyPrevCorr && MULESCorr)
606 tsPhiCorr0_ = sPhi_ - tsPhiCorr0_;
607 tsPhiCorr0_.ref().rename(
"sPhiCorr0");
616 word(mesh_.schemes().ddt(
"ddt(s)"))
623 sPhi_ = (sPhi_ - (1.0 -
cnCoeff)*sPhi_.oldTime())/cnCoeff;
627 Info<< fieldName_ <<
"volume fraction = " 628 << s_.weightedAverage(mesh_.Vsc()).value()
629 <<
" Min(" << fieldName_ <<
") = " <<
min(s_).value()
630 <<
" Max(" << fieldName_ <<
") = " <<
max(s_).value()
Local time-step first-order Euler implicit/explicit ddt.
const dimensionSet dimViscosity
Second-oder Crank-Nicolson implicit ddt using the current and previous time-step fields as well as th...
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
virtual ~scalarTransport()
Destructor.
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
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.
T & ref() const
Return non-const reference or generate a fatal error.
Templated form of IOobject providing type information for file reading and header type checking...
static tmp< volScalarField > localRSubDeltaT(const fvMesh &mesh, const label nAlphaSubCycles)
Calculate and return the reciprocal of the local sub-cycling.
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, const Internal &, const PtrList< fvPatchField< scalar >> &)
Return a temporary field constructed from name,.
const wordHashSet compressionSchemes
Ostream & endl(Ostream &os)
Add newline and flush stream.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Calculate the matrix for the laplacian of the field.
Initialise the NamedEnum HashTable from the static list of names.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
diffusionType
Enumeration defining the type of the diffusion.
Macros for easy insertion into run-time selection tables.
Abstract base class for ddt schemes.
scalarTransport(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
virtual bool execute()
Calculate the scalarTransport.
Calculate the first temporal derivative.
const dimensionSet dimTime
const dimensionSet & dimensions() const
Return dimensions.
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, const SpType &Sp, const SuType &Su)
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
static bool enabled(const fvMesh &mesh)
Return true if LTS is enabled.
Foam::fvConstraints & fvConstraints
bool found(const Key &) const
Return true if hashedEntry is found in table.
A class representing the concept of a field of 0 used to avoid unnecessary manipulations for objects ...
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
A class for handling words, derived from string.
Calculate the face-flux of the given field.
static word groupName(Name name, const word &group)
bool isType(const Type &t)
Check the typeid.
Info<< "Reading field p\"<< endl;volScalarField p(IOobject("p", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);pressureReference pressureReference(p, simple.dict());mesh.schemes().setFluxRequired(p.name());Info<< "Reading field pa\"<< endl;volScalarField pa(IOobject("pa", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field Ua\"<< endl;volVectorField Ua(IOobject("Ua", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);# 65 "/home/ubuntu/OpenFOAM-10/applications/solvers/incompressible/adjointShapeOptimisationFoam/createFields.H" 2label paRefCell=0;scalar paRefValue=0.0;setRefCell(pa, simple.dict(), paRefCell, paRefValue);mesh.schemes().setFluxRequired(pa.name());autoPtr< viscosityModel > viscosity(viscosityModel::New(mesh))
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Calculate the matrix for the first temporal derivative.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
virtual bool read(const dictionary &)
Read the scalarTransport data.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
tmp< surfaceScalarField > phiCN(phi)
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.
Perform a subCycleTime on a field or list of fields.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);volScalarField rho(IOobject("rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), thermo.rho());volVectorField rhoU(IOobject("rhoU", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *U);volScalarField rhoE(IOobject("rhoE", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *(e+0.5 *magSqr(U)));surfaceScalarField pos(IOobject("pos", runTime.timeName(), mesh), mesh, dimensionedScalar(dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar(dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\"<< endl;autoPtr< compressible::momentumTransportModel > turbulence(compressible::momentumTransportModel::New(rho, U, phi, thermo))
SolverPerformance< Type > solve(const dictionary &)
Solve segregated or coupled returning the solution statistics.
virtual tmp< volScalarField > nut() const =0
Return the turbulence viscosity.
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
const dimensionSet dimMass
defineTypeNameAndDebug(Qdot, 0)
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.
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
Internal & ref()
Return a reference to the dimensioned internal field.
Abstract base class for turbulence models (RAS, LES and laminar).
Foam::fvModels & fvModels
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
A class representing the concept of a field of 1 used to avoid unnecessary manipulations for objects ...
Calculate the matrix for the divergence of the given field and flux.
virtual bool write()
Do nothing.
Basic second-order convection using face-gradients and Gauss' theorem.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Finite volume constraints.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
const dimensionSet dimVolume
dimensioned< scalar > mag(const dimensioned< Type > &)
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > flux() const
Return the face-flux field from the matrix.
const doubleScalar e
Elementary charge.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
A class for managing temporary objects.
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Basic first-order Euler implicit/explicit ddt using only the current and previous time-step values...
void explicitSolve(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiPsi, const SpType &Sp, const SuType &Su)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const bool MULESCorr(alphaControls.lookupOrDefault< Switch >("MULESCorr", false))
virtual wordList fields() const
Return the list of fields required.
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.
Calculate the matrix for implicit and explicit sources.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.