diff --git a/etc/caseDicts/postProcessing/scalarTransport/scalarTransport b/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport similarity index 78% rename from etc/caseDicts/postProcessing/scalarTransport/scalarTransport rename to etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport index c1204f7e731512539f1f34bbf1891fad6aa65fbc..7a6d7e06b4c26e60f59de053fc0df189996b1522 100644 --- a/etc/caseDicts/postProcessing/scalarTransport/scalarTransport +++ b/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport @@ -6,12 +6,14 @@ | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ -T +scalarTransport { - #includeEtc "caseDicts/postProcessing/scalarTransport/scalarTransport.cfg" + type scalarTransport; + libs ("libsolverFunctionObjects.so"); - userDT true; - DT 1e-09; + field s; + schemesField s; + D 1e-09; } // ************************************************************************* // diff --git a/etc/caseDicts/postProcessing/scalarTransport/scalarTransport.cfg b/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport.cfg similarity index 76% rename from etc/caseDicts/postProcessing/scalarTransport/scalarTransport.cfg rename to etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport.cfg index f56519f3f9650ea14f247bbadb1570349a29d511..5574f2a6ddf657b953a1f48bb84fff045fee5a97 100644 --- a/etc/caseDicts/postProcessing/scalarTransport/scalarTransport.cfg +++ b/etc/caseDicts/postProcessing/solvers/scalarTransport/scalarTransport.cfg @@ -7,16 +7,6 @@ \*---------------------------------------------------------------------------*/ type scalarTransport; -libs ("libutilityFunctionObjects.so"); - -writeControl timeStep; -writeInterval 1; - -write true; -log false; - -resetOnStartUp false; -autoSchemes true; -fvOptions {}; +libs ("libsolverFunctionObjects.so"); // ************************************************************************* // diff --git a/etc/caseDicts/postProcessing/scalarTransport/T b/etc/caseDicts/solvers/scalarTransport/T similarity index 100% rename from etc/caseDicts/postProcessing/scalarTransport/T rename to etc/caseDicts/solvers/scalarTransport/T diff --git a/etc/caseDicts/postProcessing/scalarTransport/scalarTransportDict b/etc/caseDicts/solvers/scalarTransport/scalarTransportDict similarity index 91% rename from etc/caseDicts/postProcessing/scalarTransport/scalarTransportDict rename to etc/caseDicts/solvers/scalarTransport/scalarTransportDict index 32b4bf14032ab4bc8379fd86047de19daabc5b55..ca6b08b6c7aeb491715080895a7b521b4506e57f 100644 --- a/etc/caseDicts/postProcessing/scalarTransport/scalarTransportDict +++ b/etc/caseDicts/solvers/scalarTransport/scalarTransportDict @@ -20,6 +20,6 @@ writeInterval 1e-2; // transportProperties settings DT DT [ 0 2 -1 0 0 0 0 ] 1e-9; -#includeEtc "caseDicts/postProcessing/scalarTransport/scalarTransportDict.cfg" +#includeEtc "caseDicts/solvers/scalarTransport/scalarTransportDict.cfg" // ************************************************************************* // diff --git a/etc/caseDicts/postProcessing/scalarTransport/scalarTransportDict.cfg b/etc/caseDicts/solvers/scalarTransport/scalarTransportDict.cfg similarity index 100% rename from etc/caseDicts/postProcessing/scalarTransport/scalarTransportDict.cfg rename to etc/caseDicts/solvers/scalarTransport/scalarTransportDict.cfg diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.C b/src/functionObjects/solvers/scalarTransport/scalarTransport.C index 1ff8599d33701fa482dc41b425b2fe1afe876e01..00e6d81a705408ad96a6374a1cfc0c263302e802 100644 --- a/src/functionObjects/solvers/scalarTransport/scalarTransport.C +++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.C @@ -25,13 +25,8 @@ License #include "scalarTransport.H" #include "surfaceFields.H" -#include "dictionary.H" -#include "fixedValueFvPatchFields.H" -#include "zeroGradientFvPatchFields.H" -#include "fvScalarMatrix.H" #include "fvmDdt.H" #include "fvmDiv.H" -#include "fvcDiv.H" #include "fvmLaplacian.H" #include "fvmSup.H" #include "turbulentTransportModel.H" @@ -58,30 +53,7 @@ namespace functionObjects // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::wordList Foam::functionObjects::scalarTransport::boundaryTypes() const -{ - const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_); - - wordList bTypes(U.boundaryField().size()); - - forAll(bTypes, patchi) - { - const fvPatchField<vector>& pf = U.boundaryField()[patchi]; - if (isA<fixedValueFvPatchVectorField>(pf)) - { - bTypes[patchi] = fixedValueFvPatchScalarField::typeName; - } - else - { - bTypes[patchi] = zeroGradientFvPatchScalarField::typeName; - } - } - - return bTypes; -} - - -Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::DT +Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::D ( const surfaceScalarField& phi ) const @@ -89,7 +61,9 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::DT typedef incompressible::turbulenceModel icoModel; typedef compressible::turbulenceModel cmpModel; - if (userDT_) + word Dname("D" + s_.name()); + + if (constantD_) { return tmp<volScalarField> ( @@ -97,14 +71,14 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::DT ( IOobject ( - "DT", + Dname, mesh_.time().timeName(), mesh_.time(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh_, - dimensionedScalar("DT", phi.dimensions()/dimLength, DT_) + dimensionedScalar(Dname, phi.dimensions()/dimLength, D_) ) ); } @@ -134,14 +108,14 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::DT ( IOobject ( - "DT", + Dname, mesh_.time().timeName(), mesh_.time(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh_, - dimensionedScalar("DT", phi.dimensions()/dimLength, 0.0) + dimensionedScalar(Dname, phi.dimensions()/dimLength, 0.0) ) ); } @@ -158,30 +132,24 @@ Foam::functionObjects::scalarTransport::scalarTransport ) : fvMeshFunctionObject(name, runTime, dict), - DT_(0.0), + fieldName_(dict.lookupOrDefault<word>("field", "s")), + D_(0), nCorr_(0), fvOptions_(mesh_), - T_ + s_ ( IOobject ( - name, + fieldName_, mesh_.time().timeName(), mesh_, - IOobject::READ_IF_PRESENT, + IOobject::MUST_READ, IOobject::AUTO_WRITE ), - mesh_, - dimensionedScalar("zero", dimless, 0.0), - boundaryTypes() + mesh_ ) { read(dict); - - if (resetOnStartUp_) - { - T_ == dimensionedScalar("zero", dimless, 0.0); - } } @@ -198,22 +166,21 @@ bool Foam::functionObjects::scalarTransport::read(const dictionary& dict) fvMeshFunctionObject::read(dict); phiName_ = dict.lookupOrDefault<word>("phi", "phi"); - UName_ = dict.lookupOrDefault<word>("U", "U"); rhoName_ = dict.lookupOrDefault<word>("rho", "rho"); + schemesField_ = dict.lookupOrDefault<word>("schemesField", fieldName_); - userDT_ = false; - if (dict.readIfPresent("DT", DT_)) + constantD_ = false; + if (dict.readIfPresent("D", D_)) { - userDT_ = true; + constantD_ = true; } - dict.lookup("resetOnStartUp") >> resetOnStartUp_; - dict.readIfPresent("nCorr", nCorr_); - dict.lookup("autoSchemes") >> autoSchemes_; - - fvOptions_.reset(dict.subDict("fvOptions")); + if (dict.found("fvOptions")) + { + fvOptions_.reset(dict.subDict("fvOptions")); + } return true; } @@ -226,24 +193,17 @@ bool Foam::functionObjects::scalarTransport::execute(const bool postProcess) const surfaceScalarField& phi = mesh_.lookupObject<surfaceScalarField>(phiName_); - // calculate the diffusivity - volScalarField DT(this->DT(phi)); - - // set schemes - word schemeVar = T_.name(); - if (autoSchemes_) - { - schemeVar = UName_; - } + // Calculate the diffusivity + volScalarField D(this->D(phi)); - word divScheme("div(phi," + schemeVar + ")"); - word laplacianScheme("laplacian(" + DT.name() + "," + schemeVar + ")"); + word divScheme("div(phi," + schemesField_ + ")"); + word laplacianScheme("laplacian(" + D.name() + "," + schemesField_ + ")"); - // set under-relaxation coeff + // Set under-relaxation coeff scalar relaxCoeff = 0.0; - if (mesh_.relaxEquation(schemeVar)) + if (mesh_.relaxEquation(schemesField_)) { - relaxCoeff = mesh_.equationRelaxationFactor(schemeVar); + relaxCoeff = mesh_.equationRelaxationFactor(schemesField_); } if (phi.dimensions() == dimMass/dimTime) @@ -251,44 +211,42 @@ bool Foam::functionObjects::scalarTransport::execute(const bool postProcess) const volScalarField& rho = mesh_.lookupObject<volScalarField>(rhoName_); - // solve for (label i = 0; i <= nCorr_; i++) { - fvScalarMatrix TEqn + fvScalarMatrix sEqn ( - fvm::ddt(rho, T_) - + fvm::div(phi, T_, divScheme) - - fvm::laplacian(DT, T_, laplacianScheme) + fvm::ddt(rho, s_) + + fvm::div(phi, s_, divScheme) + - fvm::laplacian(D, s_, laplacianScheme) == - fvOptions_(rho, T_) + fvOptions_(rho, s_) ); - TEqn.relax(relaxCoeff); + sEqn.relax(relaxCoeff); - fvOptions_.constrain(TEqn); + fvOptions_.constrain(sEqn); - TEqn.solve(mesh_.solverDict(schemeVar)); + sEqn.solve(mesh_.solverDict(schemesField_)); } } else if (phi.dimensions() == dimVolume/dimTime) { - // solve for (label i = 0; i <= nCorr_; i++) { - fvScalarMatrix TEqn + fvScalarMatrix sEqn ( - fvm::ddt(T_) - + fvm::div(phi, T_, divScheme) - - fvm::laplacian(DT, T_, laplacianScheme) + fvm::ddt(s_) + + fvm::div(phi, s_, divScheme) + - fvm::laplacian(D, s_, laplacianScheme) == - fvOptions_(T_) + fvOptions_(s_) ); - TEqn.relax(relaxCoeff); + sEqn.relax(relaxCoeff); - fvOptions_.constrain(TEqn); + fvOptions_.constrain(sEqn); - TEqn.solve(mesh_.solverDict(schemeVar)); + sEqn.solve(mesh_.solverDict(schemesField_)); } } else diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.H b/src/functionObjects/solvers/scalarTransport/scalarTransport.H index 1208388ffeacdd1396a4d7444b5ab8f5dc81120c..4e2720a078f219f86344259bdbafc2309fe14aa5 100644 --- a/src/functionObjects/solvers/scalarTransport/scalarTransport.H +++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.H @@ -28,16 +28,13 @@ Group grpSolversFunctionObjects Description - This function object evolves a passive scalar transport equation. The - field in ininitially zero, to which sources are added. The field name - is assigned the name of the function object. Boundary conditions are - automatically applied, based on the velocity boundary conditions. + This function object evolves a passive scalar transport equation. - - the field can be zeroed on start-up using the resetOnStartUp flag - - to employ the same numerical schemes as the flow velocity, use the - autoSchemes flag - - the diffusivity can be set manually using the DT entry, or retrieved - from the turbulence model (if applicable) + - To specify the field name set the 'field' entry + - To employ the same numerical schemes as another field set + the 'schemesField' entry, + - The diffusivity can be set manually using the 'D' entry, or retrieved + from the turbulence model (if applicable). SeeAlso Foam::functionObjects::fvMeshFunctionObject @@ -52,7 +49,6 @@ SourceFiles #include "fvMeshFunctionObject.H" #include "volFields.H" -#include "surfaceFieldsFwd.H" #include "fvOptionList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,44 +68,38 @@ class scalarTransport { // Private data + //- Name of field to process + word fieldName_; + //- Name of flux field (optional) word phiName_; - //- Name of velocity field (optional) - word UName_; - //- Name of density field (optional) word rhoName_; //- Diffusion coefficient (optional) - scalar DT_; + scalar D_; - //- Flag to indicate whether user DT_ is used - bool userDT_; - - //- Flag to reset scalar field on start-up - bool resetOnStartUp_; + //- Flag to indicate whether a constant, uniform D_ is specified + bool constantD_; //- Number of corrector iterations (optional) label nCorr_; - //- Flag to employ schemes for velocity for scalar transport - bool autoSchemes_; + //- Name of field whose schemes are used (optional) + word schemesField_; //- Run-time selectable finite volume options, e.g. sources, constraints fv::optionList fvOptions_; //- The scalar field - volScalarField T_; + volScalarField s_; // Private Member Functions - //- Return the boundary types for the scalar field - wordList boundaryTypes() const; - //- Return the diffusivity field - tmp<volScalarField> DT(const surfaceScalarField& phi) const; + tmp<volScalarField> D(const surfaceScalarField& phi) const; //- Disallow default bitwise copy construct scalarTransport(const scalarTransport&); diff --git a/tutorials/incompressible/pisoFoam/les/pitzDaily/0/s b/tutorials/incompressible/pisoFoam/les/pitzDaily/0/s new file mode 100644 index 0000000000000000000000000000000000000000..be72c6e32e92dbfec2fed86d25e8206c476f11ae --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/pitzDaily/0/s @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object s; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform 1; + } + + outlet + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + upperWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/pitzDaily/system/controlDict b/tutorials/incompressible/pisoFoam/les/pitzDaily/system/controlDict index 3a1c3f17f72ce8d7bd721b07469b40f6f092a4b0..d780a34b1d7a3f37c51e4a64dcb318b263d7936f 100644 --- a/tutorials/incompressible/pisoFoam/les/pitzDaily/system/controlDict +++ b/tutorials/incompressible/pisoFoam/les/pitzDaily/system/controlDict @@ -128,6 +128,8 @@ functions } ); } + + #includeFunc scalarTransport } // ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/pitzDaily/system/fvSchemes b/tutorials/incompressible/pisoFoam/les/pitzDaily/system/fvSchemes index f017d958dec094735ba18412fa9bed0d0b5988e4..ecf92258c88f4efdec13e91c49f5be23c9dda8bf 100644 --- a/tutorials/incompressible/pisoFoam/les/pitzDaily/system/fvSchemes +++ b/tutorials/incompressible/pisoFoam/les/pitzDaily/system/fvSchemes @@ -30,6 +30,7 @@ divSchemes default none; div(phi,U) Gauss LUST grad(U); div(phi,k) Gauss limitedLinear 1; + div(phi,s) bounded Gauss limitedLinear 1; div((nuEff*dev2(T(grad(U))))) Gauss linear; } diff --git a/tutorials/incompressible/pisoFoam/les/pitzDaily/system/fvSolution b/tutorials/incompressible/pisoFoam/les/pitzDaily/system/fvSolution index 1ae8d1c803f5e6df9b573a885f1127d8e295a2d0..c2e8633caef03588c2fb1d36541a82ab9f672879 100644 --- a/tutorials/incompressible/pisoFoam/les/pitzDaily/system/fvSolution +++ b/tutorials/incompressible/pisoFoam/les/pitzDaily/system/fvSolution @@ -39,7 +39,7 @@ solvers relTol 0; } - "(U|k|B|nuTilda)" + "(U|k|B|nuTilda|s)" { solver smoothSolver; smoother GaussSeidel;