diff --git a/etc/caseDicts/postProcessing/fields/age b/etc/caseDicts/postProcessing/fields/age new file mode 100644 index 0000000000000000000000000000000000000000..ade50c8543052b707684accd954d625eedb3a4fb --- /dev/null +++ b/etc/caseDicts/postProcessing/fields/age @@ -0,0 +1,18 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Version: v1912 + \\ / A nd | Website: www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Solves a transport equation to determine the time taken for a particle to + convect from an inlet to an input location in the flow. +\*---------------------------------------------------------------------------*/ + +type age; +libs (fieldFunctionObjects); + +nCorr 10; + +// ************************************************************************* // \ No newline at end of file diff --git a/etc/caseDicts/postProcessing/fields/log b/etc/caseDicts/postProcessing/fields/log new file mode 100644 index 0000000000000000000000000000000000000000..f8c0ff79c36bdfe8e80d883a64e5641849bf1da9 --- /dev/null +++ b/etc/caseDicts/postProcessing/fields/log @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Version: v1912 + \\ / A nd | Website: www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Calculates the natural logarithm of the input scalar field +\*---------------------------------------------------------------------------*/ + +type log; +libs (fieldFunctionObjects); + +field <fieldName>; + +executeControl writeTime; +writeControl writeTime; + +// ************************************************************************* // \ No newline at end of file diff --git a/etc/caseDicts/postProcessing/fields/shearStress b/etc/caseDicts/postProcessing/fields/shearStress new file mode 100644 index 0000000000000000000000000000000000000000..2665bfbe2516b6c512d0221637551b9cf8353e29 --- /dev/null +++ b/etc/caseDicts/postProcessing/fields/shearStress @@ -0,0 +1,18 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Version: v1912 + \\ / A nd | Website: www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Computes the shear stress, outputting the data as a volSymmTensorField. +\*---------------------------------------------------------------------------*/ + +type shearStress; +libs (fieldFunctionObjects); + +executeControl writeTime; +writeControl writeTime; + +// ************************************************************************* // \ No newline at end of file diff --git a/etc/caseDicts/postProcessing/fields/totalEnthalpy b/etc/caseDicts/postProcessing/fields/totalEnthalpy new file mode 100644 index 0000000000000000000000000000000000000000..330d6d131537d9e93e770e4975186be8479de732 --- /dev/null +++ b/etc/caseDicts/postProcessing/fields/totalEnthalpy @@ -0,0 +1,19 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Calculates and writes the total enthalpy (ha + K) as the volScalarField Ha + +\*---------------------------------------------------------------------------*/ + +type totalEnthalpy; +libs ("libfieldFunctionObjects.so"); + +executeControl writeTime; +writeControl writeTime; + +// ************************************************************************* // diff --git a/src/functionObjects/field/Make/files b/src/functionObjects/field/Make/files index 649176d1f43f1d8f2e7d80b8f98cdccf9ccbb4cb..be2cb65926b913a354ef30c822a706720de3eb8b 100644 --- a/src/functionObjects/field/Make/files +++ b/src/functionObjects/field/Make/files @@ -1,9 +1,8 @@ AMIWeights/AMIWeights.C - +age/age.C columnAverage/columnAverage.C - +comfort/comfort.C continuityError/continuityError.C - derivedFields/derivedFields.C fieldAverage/fieldAverage.C @@ -79,6 +78,10 @@ pressure/pressure.C MachNo/MachNo.C Curle/Curle.C reference/reference.C +log/log.C +scale/scale.C +shearStress/shearStress.C +totalEnthalpy/totalEnthalpy.C fieldsExpression/fieldsExpression.C add/add.C diff --git a/src/functionObjects/field/age/age.C b/src/functionObjects/field/age/age.C new file mode 100644 index 0000000000000000000000000000000000000000..d048f8b976141bdce2f362bb7bd41c577c7e50b9 --- /dev/null +++ b/src/functionObjects/field/age/age.C @@ -0,0 +1,265 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2018-2020 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "age.H" +#include "fvmDiv.H" +#include "fvmLaplacian.H" +#include "turbulenceModel.H" +#include "inletOutletFvPatchField.H" +#include "wallFvPatch.H" +#include "zeroGradientFvPatchField.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(age, 0); + addToRunTimeSelectionTable(functionObject, age, dictionary); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::wordList Foam::functionObjects::age::patchTypes() const +{ + wordList result + ( + mesh_.boundary().size(), + inletOutletFvPatchField<scalar>::typeName + ); + + forAll(mesh_.boundary(), patchi) + { + if (isA<wallFvPatch>(mesh_.boundary()[patchi])) + { + result[patchi] = zeroGradientFvPatchField<scalar>::typeName; + } + } + + return result; +} + + +bool Foam::functionObjects::age::converged +( + const label nCorr, + const scalar initialResidual +) const +{ + if (initialResidual < tolerance_) + { + Info<< "Field " << typeName + << " converged in " << nCorr << " correctors\n" << endl; + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::age::age +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + diffusion_(false), + nCorr_(5), + phiName_("phi"), + rhoName_("rho"), + schemesField_(), + tolerance_(1e-5) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::age::read(const dictionary& dict) +{ + diffusion_ = dict.getOrDefault<Switch>("diffusion", false); + nCorr_ = dict.getCheckOrDefault<label>("nCorr", 5, labelMinMax::ge(1)); + phiName_ = dict.getOrDefault<word>("phi", "phi"); + rhoName_ = dict.getOrDefault<word>("rho", "rho"); + schemesField_ = dict.getOrDefault<word>("schemesField", typeName); + tolerance_ = + dict.getCheckOrDefault<scalar> + ( + "tolerance", + 1e-5, + scalarMinMax::ge(SMALL) + ); + + return true; +} + + +bool Foam::functionObjects::age::execute() +{ + tmp<volScalarField> tage + ( + new volScalarField + ( + IOobject + ( + typeName, + mesh_.time().timeName(), + mesh_, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE, + false + ), + mesh_, + dimensionedScalar(dimTime, 0), + patchTypes() + ) + ); + volScalarField& age = tage.ref(); + + const word divScheme("div(phi," + schemesField_ + ")"); + + // Set under-relaxation coeff + scalar relaxCoeff = 0.0; + if (mesh_.relaxEquation(schemesField_)) + { + relaxCoeff = mesh_.equationRelaxationFactor(schemesField_); + } + + // This only works because the null constructed inletValue for an + // inletOutletFvPatchField is zero. If we needed any other value we would + // have to loop over the inletOutlet patches and explicitly set the + // inletValues. We would need to change the interface of inletOutlet in + // order to do this. + + const surfaceScalarField& phi = + mesh_.lookupObject<surfaceScalarField>(phiName_); + + if (phi.dimensions() == dimMass/dimTime) + { + const volScalarField& rho = + mesh_.lookupObject<volScalarField>(rhoName_); + + tmp<volScalarField> tmuEff; + word laplacianScheme; + + if (diffusion_) + { + tmuEff = + mesh_.lookupObject<turbulenceModel> + ( + turbulenceModel::typeName + ).muEff(); + + laplacianScheme = + "laplacian(" + tmuEff().name() + ',' + schemesField_ + ")"; + } + + for (label i = 0; i <= nCorr_; ++i) + { + fvScalarMatrix ageEqn + ( + fvm::div(phi, age, divScheme) == rho + ); + + if (diffusion_) + { + ageEqn -= fvm::laplacian(tmuEff(), age, laplacianScheme); + } + + ageEqn.relax(relaxCoeff); + + if (converged(i, ageEqn.solve(schemesField_).initialResidual())) + { + break; + }; + } + } + else + { + tmp<volScalarField> tnuEff; + word laplacianScheme; + + if (diffusion_) + { + tnuEff = + mesh_.lookupObject<turbulenceModel> + ( + turbulenceModel::typeName + ).nuEff(); + + laplacianScheme = + "laplacian(" + tnuEff().name() + ',' + schemesField_ + ")"; + } + + for (label i = 0; i <= nCorr_; ++i) + { + fvScalarMatrix ageEqn + ( + fvm::div(phi, age, divScheme) == dimensionedScalar(1) + ); + + if (diffusion_) + { + ageEqn -= fvm::laplacian(tnuEff(), age, laplacianScheme); + } + + ageEqn.relax(relaxCoeff); + + if (converged(i, ageEqn.solve(schemesField_).initialResidual())) + { + break; + } + } + } + + Info<< "Min/max age:" << min(age).value() + << ' ' << max(age).value() << endl; + + return store(tage); +} + + +bool Foam::functionObjects::age::write() +{ + return writeObject(typeName); +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/age/age.H b/src/functionObjects/field/age/age.H new file mode 100644 index 0000000000000000000000000000000000000000..71070329dd3bfc69e90a6210130f7eaa32464203 --- /dev/null +++ b/src/functionObjects/field/age/age.H @@ -0,0 +1,221 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2018-2019 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::age + +Group + grpFieldFunctionObjects + +Description + Computes the age of fluid in the domain in time units, i.e. the time taken + for a fluid particle to travel from an inlet to an input location. + + Solves the following equation for incompressible flows: + \f[ + \div (\phi t) = 1 + \f] + + where: + \vartable + t | Age [s] + \phi | Volumetric flux [m^3/s] + \endvartable + + \table + Operand | Type | Location + input | - | - + output file | PENDING | PEND + output field | - | - + \endtable + +Note + Boundary conditions are generated automatically as zeroGradient on all + walls and inletOutlet everywhere else. + +Usage + Minimal example by using \c system/controlDict.functions: + \verbatim + age1 + { + // Mandatory entries (unmodifiable) + type age; + libs (fieldFunctionObjects); + + // Optional entries (runtime modifiable) + schemesField k; + nCorr 5; + tolerance 1e-5; + diffusion false; + phi phi; + rho rho; + + // Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + type | Type name: age | word | yes | - + libs | Library name: fieldFunctionObjects | word | yes | - + schemesField | Name of the field from which schemes are taken <!-- + --> | word | no | age + nCorr | The maximum number of correctors that determines how <!-- + --> many times the solution is repeated to iterate away any <!-- + --> non-linearities due the choice of scheme | label | no | 5 + tolerance | Solver residual control | scalar | no | 1e-5 + diffusion | Flag to turn on/off the diffusion term | bool | no | false + phi | Name of the flux field | word | no | phi + rho | Name of the density field | word | no | rho + \endtable + + The inherited entries are elaborated in: + - \link functionObject.H \endlink + + Minimal example by using the \c postProcess utility: + \verbatim + postProcess -func age -fields "(phi)" + \endverbatim + +Note + - \b Requirement: Requires a solver set in \c fvSolution and + a \c div(phi\,age) in \c fvSchemes to be specified. + - \b Warning: If the divergence scheme is set to \c upwind, + no corrections will be necessary. + +See also + - Foam::functionObject + - Foam::functionObjects::fvMeshFunctionObject + - ExtendedCodeGuide::functionObjects::field::age + +SourceFiles + age.C + +\*---------------------------------------------------------------------------*/ + +#ifndef age_H +#define age_H + +#include "fvMeshFunctionObject.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class age Declaration +\*---------------------------------------------------------------------------*/ + +class age +: + public fvMeshFunctionObject +{ + // Private Data + + //- Flag to turn on/off the diffusion term + Switch diffusion_; + + //- Number of corrections + label nCorr_; + + //- Name of the flux field + word phiName_; + + //- Name of the density field + word rhoName_; + + //- Name of field from which schemes are taken + word schemesField_; + + //- Convergence tolerance + scalar tolerance_; + + + // Private Member Functions + + //- The list of patch types for the age field + wordList patchTypes() const; + + //- Check convergence + bool converged(const label nCorr, const scalar initialResidual) const; + + +public: + + //- Runtime type information + TypeName("age"); + + + // Constructors + + //- Construct from Time and dictionary + age + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- No copy construct + age(const age&) = delete; + + //- No copy assignment + void operator=(const age&) = delete; + + + //- Destructor + virtual ~age() = default; + + + // Member Functions + + //- Read the data + virtual bool read(const dictionary&); + + //- Execute + virtual bool execute(); + + //- Write + virtual bool write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/functionObjects/field/comfort/comfort.C b/src/functionObjects/field/comfort/comfort.C new file mode 100644 index 0000000000000000000000000000000000000000..c647e1c6311006618bf60d48fd820817f0774b6c --- /dev/null +++ b/src/functionObjects/field/comfort/comfort.C @@ -0,0 +1,429 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "comfort.H" +#include "wallFvPatch.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(comfort, 0); + addToRunTimeSelectionTable(functionObject, comfort, dictionary); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::tmp<Foam::volScalarField> Foam::functionObjects::comfort::magU() const +{ + tmp<volScalarField> tmagU = mag(lookupObject<volVectorField>("U")); + + // Switch to use the averaged velocity field in the domain. + // Consistent with EN ISO 7730 but does not make physical sense + if (meanVelocity_) + { + tmagU.ref() = tmagU->weightedAverage(mesh_.V()); + } + + return tmagU; +} + + +Foam::dimensionedScalar Foam::functionObjects::comfort::Trad() const +{ + dimensionedScalar Trad(Trad_); + + // The mean radiation is calculated by the mean wall temperatures + // which are summed and divided by the area | only walls are taken into + // account. This approach might be correct for a squared room but will + // defintely be inconsistent for complex room geometries. The norm does + // not provide any information about the calculation of this quantity. + if (!TradSet_) + { + const volScalarField::Boundary& TBf = + lookupObject<volScalarField>("T").boundaryField(); + + scalar areaIntegral = 0; + scalar TareaIntegral = 0; + + forAll(TBf, patchi) + { + const fvPatchScalarField& pT = TBf[patchi]; + const fvPatch& pTBf = TBf[patchi].patch(); + const scalarField& pSf = pTBf.magSf(); + + if (isType<wallFvPatch>(pTBf)) + { + areaIntegral += gSum(pSf); + TareaIntegral += gSum(pSf*pT); + } + } + + Trad.value() = TareaIntegral/areaIntegral; + } + + // Bounds based on EN ISO 7730 + if ((Trad.value() < 283.15) || (Trad.value() > 313.15)) + { + WarningInFunction + << "The calculated mean wall radiation temperature is out of the\n" + << "bounds specified in EN ISO 7730:2006\n" + << "Valid range is 10 degC < T < 40 degC\n" + << "The actual value is: " << Trad - 273.15 << nl << endl; + } + + return Trad; +} + + +Foam::tmp<Foam::volScalarField> Foam::functionObjects::comfort::pSat() const +{ + static const dimensionedScalar kPaToPa(dimPressure, 1000); + static const dimensionedScalar A(dimless, 16.6563); + static const dimensionedScalar B(dimTemperature, 4030.183); + static const dimensionedScalar C(dimTemperature, -38.15); + + tmp<volScalarField> tpSat(volScalarField::New("pSat", mesh_, pSat_)); + + // Calculate the saturation pressure if no user input is given + if (pSat_.value() == 0) + { + const volScalarField& T = lookupObject<volScalarField>("T"); + + // Equation based on ISO 7730:2006 + tpSat = kPaToPa*exp(A - B/(T + C)); + } + + return tpSat; +} + + +Foam::tmp<Foam::volScalarField> Foam::functionObjects::comfort::Tcloth +( + volScalarField& hc, + const dimensionedScalar& metabolicRateSI, + const dimensionedScalar& extWorkSI, + const volScalarField& T, + const dimensionedScalar& Trad +) +{ + const dimensionedScalar factor1(dimTemperature, 308.85); + + const dimensionedScalar factor2 + ( + dimTemperature/metabolicRateSI.dimensions(), + 0.028 + ); + + const dimensionedScalar factor3 + ( + dimMass/pow3(dimTime)/pow4(dimTemperature) + 3.96e-8 + ); + + // Heat transfer coefficient based on forced convection [W/m^2/K] + const volScalarField hcForced + ( + dimensionedScalar(hc.dimensions()/sqrt(dimVelocity), 12.1) + *sqrt(magU()) + ); + + // Tcl [K] (surface cloth temperature) + tmp<volScalarField> tTcl + ( + volScalarField::New + ( + "Tcl", + T.mesh(), + dimTemperature + ) + ); + + volScalarField& Tcl = tTcl.ref(); + + // Initial guess + Tcl = T; + + label i = 0; + + Tcl.storePrevIter(); + + // Iterative solving of equation (2) + do + { + Tcl = (Tcl + Tcl.prevIter())/2; + Tcl.storePrevIter(); + + // Heat transfer coefficient based on natural convection + volScalarField hcNatural + ( + dimensionedScalar(hc.dimensions()/pow025(dimTemperature), 2.38) + *pow025(mag(Tcl - T)) + ); + + // Set heat transfer coefficient based on equation (3) + hc = + pos(hcForced - hcNatural)*hcForced + + neg0(hcForced - hcNatural)*hcNatural; + + // Calculate surface temperature based on equation (2) + Tcl = + factor1 + - factor2*(metabolicRateSI - extWorkSI) + - Icl_*factor3*fcl_*(pow4(Tcl) - pow4(Trad)) + - Icl_*fcl_*hc*(Tcl - T); + + } while (!converged(Tcl) && i++ < maxClothIter_); + + if (i == maxClothIter_) + { + WarningInFunction + << "The surface cloth temperature " + << "did not converge within " << i << " iterations" + << endl; + } + + return tTcl; +} + + +bool Foam::functionObjects::comfort::converged +( + const volScalarField& phi +) const +{ + return + max(mag(phi.primitiveField() - phi.prevIter().primitiveField())) + < tolerance_; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::comfort::comfort +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + TradSet_(false), + meanVelocity_(false), + maxClothIter_(100), + tolerance_(1e-4), + clothing_("clothing", dimless, 0.0), + metabolicRate_("metabolicRate", dimMass/pow3(dimTime), 0.8), + extWork_("extWork", dimMass/pow3(dimTime), 0.0), + Trad_("Trad", dimTemperature, 0.0), + relHumidity_("relHumidity", dimless, 0.5), + pSat_("pSat", dimPressure, 0.0), + Icl_("Icl", pow3(dimTime)*dimTemperature/dimMass, 0.0), + fcl_("fcl", dimless, 0.0) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::comfort::read(const dictionary& dict) +{ + meanVelocity_ = dict.getOrDefault<Switch>("meanVelocity", false); + maxClothIter_ = + dict.getCheckOrDefault("maxClothIter", 100, labelMinMax::ge(0)); + tolerance_ = dict.getCheckOrDefault("tolerance", 1e-4, scalarMinMax::ge(0)); + clothing_.readIfPresent(dict); + metabolicRate_.readIfPresent(dict); + extWork_.readIfPresent(dict); + pSat_.readIfPresent(dict); + + // Read relative humidity if provided and convert from % to fraction + if (dict.found(relHumidity_.name())) + { + relHumidity_.read(dict); + relHumidity_ /= 100; + } + + // Read radiation temperature if provided + if (dict.found(Trad_.name())) + { + TradSet_ = true; + Trad_.read(dict); + } + else + { + TradSet_ = false; + } + + Icl_ = dimensionedScalar(Icl_.dimensions(), 0.155)*clothing_; + + fcl_.value() = + Icl_.value() <= 0.078 + ? 1.0 + 1.290*Icl_.value() + : 1.05 + 0.645*Icl_.value(); + + return true; +} + + +bool Foam::functionObjects::comfort::execute() +{ + const dimensionedScalar Trad(this->Trad()); + const volScalarField pSat(this->pSat()); + + const dimensionedScalar metabolicRateSI(58.15*metabolicRate_); + const dimensionedScalar extWorkSI(58.15*extWork_); + + const volScalarField& T = lookupObject<volScalarField>("T"); + + // Heat transfer coefficient [W/m^2/K] + // This field is updated in Tcloth() + volScalarField hc + ( + IOobject + ( + "hc", + mesh_.time().timeName(), + mesh_ + ), + mesh_, + dimensionedScalar(dimMass/pow3(dimTime)/dimTemperature, 0) + ); + + // Calculate the surface temperature of the cloth by an iterative + // process using equation (2) from DIN EN ISO 7730 [degC] + const volScalarField Tcloth + ( + this->Tcloth + ( + hc, + metabolicRateSI, + extWorkSI, + T, + Trad + ) + ); + + // Calculate the PMV quantity + const dimensionedScalar factor1(pow3(dimTime)/dimMass, 0.303); + const dimensionedScalar factor2 + ( + dimless/metabolicRateSI.dimensions(), + -0.036 + ); + const dimensionedScalar factor3(factor1.dimensions(), 0.028); + const dimensionedScalar factor4(dimLength/dimTime, 3.05e-3); + const dimensionedScalar factor5(dimPressure, 5733); + const dimensionedScalar factor6(dimTime/dimLength, 6.99); + const dimensionedScalar factor8(metabolicRateSI.dimensions(), 58.15); + const dimensionedScalar factor9(dimless/dimPressure, 1.7e-5); + const dimensionedScalar factor10(dimPressure, 5867); + const dimensionedScalar factor11(dimless/dimTemperature, 0.0014); + const dimensionedScalar factor12(dimTemperature, 307.15); + const dimensionedScalar factor13 + ( + dimMass/pow3(dimTime)/pow4(dimTemperature) + 3.96e-8 + ); + + const scalar factor7 + ( + // Special treatment of Term4 + // if metaRate - extWork < factor8, set to zero + (metabolicRateSI - extWorkSI).value() < factor8.value() ? 0 : 0.42 + ); + + Info<< "Calculating the predicted mean vote (PMV)\n"; + + // Equation (1) + tmp<volScalarField> PMV + ( + volScalarField::New + ( + "PMV", + + // Term1: Thermal sensation transfer coefficient + (factor1*exp(factor2*metabolicRateSI) + factor3) + *( + (metabolicRateSI - extWorkSI) + + // Term2: Heat loss difference through skin + - factor4 + *( + factor5 + - factor6*(metabolicRateSI - extWorkSI) + - pSat*relHumidity_ + ) + + // Term3: Heat loss through sweating + - factor7*(metabolicRateSI - extWorkSI - factor8) + + // Term4: Heat loss through latent respiration + - factor9*metabolicRateSI*(factor10 - pSat*relHumidity_) + + // Term5: Heat loss through dry respiration + - factor11*metabolicRateSI*(factor12 - T) + + // Term6: Heat loss through radiation + - factor13*fcl_*(pow4(Tcloth) - pow4(Trad)) + + // Term7: Heat loss through convection + - fcl_*hc*(Tcloth - T) + ) + ) + ); + + Info<< "Calculating the predicted percentage of dissatisfaction (PPD)\n"; + + // Equation (5) in EN ISO + tmp<volScalarField> PPD + ( + volScalarField::New + ( + "PPD", + 100 - 95*exp(-0.03353*pow4(PMV()) - 0.21790*sqr(PMV())) + ) + ); + + return store(PMV) && store(PPD); +} + + +bool Foam::functionObjects::comfort::write() +{ + return writeObject("PMV") && writeObject("PPD"); +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/comfort/comfort.H b/src/functionObjects/field/comfort/comfort.H new file mode 100644 index 0000000000000000000000000000000000000000..a35f547877c9dd23ca8328ea912096291026a6df --- /dev/null +++ b/src/functionObjects/field/comfort/comfort.H @@ -0,0 +1,256 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::comfort + +Group + grpFieldFunctionObjects + +Description + Computes the thermal comfort indicators, i.e. the predicted mean vote (PMV) + and predicted percentage of dissatisfaction (PPD) based on + DIN ISO EN 7730:2005. + + The values of the \c PMV mean: + \table + Predicted Mean Vote (PMV) | Evaluation + + 3 | hot + + 2 | warm + + 1 | slightly warm + + 0 | neutral + - 1 | slightly cool + - 2 | cool + - 3 | cold + \endtable + + \table + Operand | Type | Location + input | - | - + output file | PENDING | PENDING + output field | PENDING | PENDING + \endtable + +Usage + Minimal example by using \c system/controlDict.functions: + \verbatim + comfort1 + { + // Mandatory entries (unmodifiable) + type comfort; + libs (fieldFunctionObjects); + + // Optional entries (runtime modifiable) + clothing 0.0; + metabolicRate 0.8; + extWork 0.0; + Trad 0.0; + relHumidity 0.5; + pSat 0.0; + tolerance 1e-4; + maxClothIter 100; + meanVelocity false; + + // Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + type | Type name: comfort | word | yes | - + libs | Library name: fieldFunctionObjects | word | yes | - + clothing | The insulation value of the cloth [-] | scalar | no | 0.0 + metabolicRate | The metabolic rate [kg/s^3] | scalar | no | 0.8 + extWork | The external work [kg/s^3] | scalar | no | 0.0 + Trad | Mean radiation temperature [K] | scalar | no | 0.0 + relHumidity | Relative humidity of the air [%] | scalar | no | 0.5 + pSat | Saturation pressure of water [Pa] | scalar | no | 0.0 + tolerance | Tolerance criteria for iterative process to find Tcl <!-- + --> | scalar | no | 1e-4 + maxClothIter | Maximum number of correctors for cloth temperature <!-- + --> | label | no | 100 + meanVelocity | Flag to use volume weighted velocity field or a <!-- + --> constant mean velocity for calculation in the whole <!-- + --> domain | bool | no | false + \endtable + + The inherited entries are elaborated in: + - \link functionObject.H \endlink + + Usage by the \c postProcess utility is not available. + +See also + - Foam::functionObject + - Foam::functionObjects::fvMeshFunctionObject + - ExtendedCodeGuide::functionObjects::field::comfort + +SourceFiles + comfort.C + +\*---------------------------------------------------------------------------*/ + +#ifndef comfort_H +#define comfort_H + +#include "fvMeshFunctionObject.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class comfort Declaration +\*---------------------------------------------------------------------------*/ + +class comfort +: + public fvMeshFunctionObject +{ + // Private Data + + //- Flag to set to true if the radiation temperature (Trad) is provided + Switch TradSet_; + + //- Flag to use volume weighted velocity field for calculation + Switch meanVelocity_; + + //- Maximum number of correctors for cloth temperature + label maxClothIter_; + + //- Tolerance criteria for iterative process to find Tcl + scalar tolerance_; + + //- The insulation value of the cloth + dimensionedScalar clothing_; + + //- Metabolic rate + dimensionedScalar metabolicRate_; + + //- External work + dimensionedScalar extWork_; + + //- Mean radiation temperature + dimensionedScalar Trad_; + + //- Relative humidity + dimensionedScalar relHumidity_; + + //- Saturation pressure of water + dimensionedScalar pSat_; + + //- Thermal insulation of clothing [W/m^2/K] + dimensionedScalar Icl_; + + //- Prefactor of cloth area [-] + dimensionedScalar fcl_; + + + // Private Member Functions + + //- Calculate the magnitude of the velocity [m/s] + tmp<volScalarField> magU() const; + + //- Calculate the radiation temperature in the domain using a simple + //- approach [K] + dimensionedScalar Trad() const; + + //- Calculate the saturation pressure based on 7730:2006 + // Possible options: adding different calculation methods such as + // the formulation based on Magnus or others [Pa] + tmp<volScalarField> pSat() const; + + //- Calculate and return the surface temperature of the cloth [K] + //- and the heat transfer coefficient hc [W/m^2/K] + tmp<volScalarField> Tcloth + ( + volScalarField& hc, + const dimensionedScalar& metabolicRateSI, + const dimensionedScalar& extWorkSI, + const volScalarField& TdegC, + const dimensionedScalar& Trad + ); + + //- Return true if the cloth temperature iteration has converged + bool converged(const volScalarField&) const; + + +public: + + //- Runtime type information + TypeName("comfort"); + + + // Constructors + + //- Construct from Time and dictionary + comfort + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- No copy construct + comfort(const comfort&) = delete; + + //- No copy assignment + void operator=(const comfort&) = delete; + + + //- Destructor + virtual ~comfort() = default; + + + // Member Functions + + //- Read the data needed for the comfort calculation + virtual bool read(const dictionary&); + + //- Calculate the predicted mean vote (PMV) + //- and predicted percentage dissatisfaction (PPD) fields + virtual bool execute(); + + //- Write the PPD and PMV fields + virtual bool write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/functionObjects/field/log/log.C b/src/functionObjects/field/log/log.C new file mode 100644 index 0000000000000000000000000000000000000000..5793104f7e5dea8a78b1cac906652f3b7ce2b688 --- /dev/null +++ b/src/functionObjects/field/log/log.C @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2018-2019 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------ +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "log.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(log, 0); + addToRunTimeSelectionTable(functionObject, log, dictionary); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::log::calc() +{ + if (foundObject<volScalarField>(fieldName_)) + { + const volScalarField& x = lookupObject<volScalarField>(fieldName_); + + // Cache the current debug setting for dimensionSet + const bool dimensionSetDebug = dimensionSet::debug; + + // Switch-off dimension checking if requested + if (!checkDimensions_) + { + dimensionSet::debug = 0; + } + + bool stored = store + ( + resultName_, + Foam::log(max(x, clipValue_)) + ); + + // Reinstate dimension checking + if (!checkDimensions_) + { + dimensionSet::debug = dimensionSetDebug; + } + + return stored; + } + else + { + return false; + } + + return true; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::log::log +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, typeName), + checkDimensions_(true), + clipValue_(SMALL) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::log::read(const dictionary& dict) +{ + checkDimensions_ = dict.getOrDefault<Switch>("checkDimensions", true); + + clipValue_ = + dict.getCheckOrDefault<scalar>("clip", SMALL, scalarMinMax::ge(SMALL)); + + return true; +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/log/log.H b/src/functionObjects/field/log/log.H new file mode 100644 index 0000000000000000000000000000000000000000..0a6ff24d28391021cf864c115e6c44036f0226c4 --- /dev/null +++ b/src/functionObjects/field/log/log.H @@ -0,0 +1,177 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2018-2019 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::log + +Group + grpFieldFunctionObjects + +Description + Computes the natural logarithm of an input scalar field. + + Performs \f$ln(max(x, a))\f$ where \f$x\f$ is the field and \f$a\f$ a + clip, equals to \c SMALL by default, to prevent zero or negative \f$x\f$, + hence the domain error in the natural logarithm. + + Dimension checking can optionally be suspended if \f$x\f$ is dimensioned. + + \table + Operand | Type | Location + input | - | - + output file | PENDING | PENDING + output field | PENDING | PENDING + \endtable + +Usage + Minimal example by using \c system/controlDict.functions: + \verbatim + log1 + { + // Mandatory entries (unmodifiable) + type log; + libs (fieldFunctionObjects); + + // Mandatory (inherited) entry (runtime modifiable) + field <inpField>; + + // Optional entries (runtime modifiable) + clip 1e-3; + checkDimensions false; + + // Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + type | Type name: log | word | yes | - + libs | Library name: fieldFunctionObjects | word | yes | - + field | Name of the operand field | word | yes | - + clip | Value to lower clip the operand to prevent zero or <!-- + --> negative values | scalar | no | SMALL + checkDimensions | Flag to check dimensions of the operand <!-- + --> | bool | no | true + \endtable + + The inherited entries are elaborated in: + - \link functionObject.H \endlink + - \link fieldExpression.H \endlink + + Usage by the \c postProcess utility is not available. + +See also + - Foam::functionObject + - Foam::functionObjects::fieldExpression + - Foam::functionObjects::fvMeshFunctionObject + - ExtendedCodeGuide::functionObjects::field::log + +SourceFiles + log.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_log_H +#define functionObjects_log_H + +#include "fieldExpression.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class log Declaration +\*---------------------------------------------------------------------------*/ + +class log +: + public fieldExpression +{ + // Private Data + + //- Flag to check dimensions of the operand + Switch checkDimensions_; + + //- Value to clip the operand to prevent zero or negative values + scalar clipValue_; + + + // Private Member Functions + + //- Calculate the log field and return true if successful + virtual bool calc(); + + +public: + + //- Runtime type information + TypeName("log"); + + + // Constructors + + //- Construct from Time and dictionary + log + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- No copy construct + log(const log&) = delete; + + //- No copy assignment + void operator=(const log&) = delete; + + + //- Destructor + virtual ~log() = default; + + + // Member Functions + + //- Read the randomise data + virtual bool read(const dictionary&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/functionObjects/field/scale/scale.C b/src/functionObjects/field/scale/scale.C new file mode 100644 index 0000000000000000000000000000000000000000..286ace47dd918cabac94e1a77cd3a9914d2901ea --- /dev/null +++ b/src/functionObjects/field/scale/scale.C @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2018-2019 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "scale.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(scale, 0); + addToRunTimeSelectionTable(functionObject, scale, dictionary); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::scale::calc() +{ + bool processed = false; + + processed = processed || calcScale<scalar>(); + processed = processed || calcScale<vector>(); + processed = processed || calcScale<sphericalTensor>(); + processed = processed || calcScale<symmTensor>(); + processed = processed || calcScale<tensor>(); + + return processed; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::scale::scale +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, typeName), + scale_(0) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::scale::read(const dictionary& dict) +{ + dict.lookup("scale") >> scale_; + + return true; +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/scale/scale.H b/src/functionObjects/field/scale/scale.H new file mode 100644 index 0000000000000000000000000000000000000000..52a7a593e7e88e1e9bec595c02de986d007bdc6b --- /dev/null +++ b/src/functionObjects/field/scale/scale.H @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2018-2019 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::scale + +Group + grpFieldFunctionObjects + +Description + Multiplies an input field elementwise by an input scaling factor. + + \table + Operand | Type | Location + input | - | - + output file | PENDING | PENDING + output field | PENDING | PENDING + \endtable + +Usage + Minimal example by using \c system/controlDict.functions: + \verbatim + scale1 + { + // Mandatory entries (unmodifiable) + type scale; + libs (fieldFunctionObjects); + scale 1.0; + + // Mandatory (inherited) entry (runtime modifiable) + field <inpField>; + + // Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + type | Type name: log | word | yes | - + libs | Library name: fieldFunctionObjects | word | yes | - + field | Name of the operand field | word | yes | - + scale | Scaling factor | scalar | yes | - + \endtable + + The inherited entries are elaborated in: + - \link functionObject.H \endlink + - \link fieldExpression.H \endlink + + Usage by the \c postProcess utility is not available. + +See also + - Foam::functionObject + - Foam::functionObjects::fvMeshFunctionObject + - ExtendedCodeGuide::functionObjects::field::scale + +SourceFiles + scale.C + scaleTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_scale_H +#define functionObjects_scale_H + +#include "fieldExpression.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class scale Declaration +\*---------------------------------------------------------------------------*/ + +class scale +: + public fieldExpression +{ + // Private Data + + //- Scale factor + scalar scale_; + + + // Private Member Functions + + //- Calculate the scale of the field and register the result + template<class Type> + bool calcScale(); + + //- Calculate the scale of the field and return true if successful + virtual bool calc(); + + +public: + + //- Runtime type information + TypeName("scale"); + + + // Constructors + + //- Construct from Time and dictionary + scale + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- No copy construct + scale(const scale&) = delete; + + //- No copy assignment + void operator=(const scale&) = delete; + + + //- Destructor + virtual ~scale() = default; + + + // Member Functions + + //- Read the randomise data + virtual bool read(const dictionary&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "scaleTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/functionObjects/field/scale/scaleTemplates.C b/src/functionObjects/field/scale/scaleTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..de8f5d78f7670c3e6f3b8e50ed8e2fac7306bea3 --- /dev/null +++ b/src/functionObjects/field/scale/scaleTemplates.C @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2018 OpenFOAM Foundation +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +bool Foam::functionObjects::scale::calcScale() +{ + typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; + typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; + + if (foundObject<VolFieldType>(fieldName_)) + { + return store + ( + resultName_, + scale_*lookupObject<VolFieldType>(fieldName_) + ); + } + else if (foundObject<SurfaceFieldType>(fieldName_)) + { + return store + ( + resultName_, + scale_*lookupObject<SurfaceFieldType>(fieldName_) + ); + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/shearStress/shearStress.C b/src/functionObjects/field/shearStress/shearStress.C new file mode 100644 index 0000000000000000000000000000000000000000..d6f77640d72a91776e600b4ef8c39651c499e8f3 --- /dev/null +++ b/src/functionObjects/field/shearStress/shearStress.C @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "shearStress.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "turbulentTransportModel.H" +#include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(shearStress, 0); + addToRunTimeSelectionTable(functionObject, shearStress, dictionary); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::shearStress::shearStress +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + writeLocalObjects(obr_, false), + phaseName_(word::null) +{ + read(dict); + resetLocalObjectName(IOobject::groupName(type(), phaseName_)); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::shearStress::read +( + const dictionary& dict +) +{ + fvMeshFunctionObject::read(dict); + writeLocalObjects::read(dict); + + phaseName_ = dict.getOrDefault<word>("phase", word::null); + + return true; +} + + +bool Foam::functionObjects::shearStress::execute() +{ + const word fieldName(IOobject::groupName(type(), phaseName_)); + + typedef compressible::turbulenceModel cmpModel; + typedef incompressible::turbulenceModel icoModel; + + if (mesh_.foundObject<cmpModel>(turbulenceModel::propertiesName)) + { + const cmpModel& model = + mesh_.lookupObject<cmpModel>(turbulenceModel::propertiesName); + + return store(fieldName, model.devRhoReff()); + } + else if (mesh_.foundObject<icoModel>(turbulenceModel::propertiesName)) + { + const icoModel& model = + mesh_.lookupObject<icoModel>(turbulenceModel::propertiesName); + + return store(fieldName, model.devReff()); + } + else + { + FatalErrorInFunction + << "Unable to find turbulence model in the " + << "database" << exit(FatalError); + + return false; + } +} + + +bool Foam::functionObjects::shearStress::write() +{ + return writeLocalObjects::write(); +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/src/functionObjects/field/shearStress/shearStress.H b/src/functionObjects/field/shearStress/shearStress.H new file mode 100644 index 0000000000000000000000000000000000000000..e62b08adbbc6193a5f19593a812ba3936cacbcbf --- /dev/null +++ b/src/functionObjects/field/shearStress/shearStress.H @@ -0,0 +1,163 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::shearStress + +Group + grpFieldFunctionObjects + +Description + Computes the shear-stress as a \c volSymmTensorField. + + \table + Operand | Type | Location + input | - | - + output file | PENDING | PENDING + output field | PENDING | PENDING + \endtable + +Usage + Minimal example by using \c system/controlDict.functions: + \verbatim + shearStress1 + { + // Mandatory entries (unmodifiable) + type shearStress; + libs (fieldFunctionObjects); + + // Optional entries (runtime modifiable) + phase ""; + + // Optional (inherited) entries + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + type | Type name: log | word | yes | - + libs | Library name: fieldFunctionObjects | word | yes | - + phase | Name of the phase | word | no | "" + \endtable + + The inherited entries are elaborated in: + - \link functionObject.H \endlink + - \link fieldExpression.H \endlink + + Minimal example by using the \c postProcess utility: + \verbatim + postProcess -func shearStress + \endverbatim + +See also + - Foam::functionObject + - Foam::functionObjects::fieldExpression + - Foam::functionObjects::fvMeshFunctionObject + - ExtendedCodeGuide::functionObjects::field::shearStress + +SourceFiles + shearStress.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_shearStress_H +#define functionObjects_shearStress_H + +#include "fieldExpression.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class shearStress Declaration +\*---------------------------------------------------------------------------*/ + +class shearStress +: + public fvMeshFunctionObject +{ + // Private Data + + //- Name of the phase + word phaseName_; + + +public: + + //- Runtime type information + TypeName("shearStress"); + + + // Constructors + + //- Construct from Time and dictionary + shearStress + ( + const word& name, + const Time& runTime, + const dictionary& + ); + + //- No copy construct + shearStress(const shearStress&) = delete; + + //- No copy assignment + void operator=(const shearStress&) = delete; + + + //- Destructor + virtual ~shearStress() = delete; + + + // Member Functions + + //- Read the data + virtual bool read(const dictionary&); + + //- Calculate the shearStress field + virtual bool execute(); + + //- Do nothing + virtual bool write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/functionObjects/field/totalEnthalpy/totalEnthalpy.C b/src/functionObjects/field/totalEnthalpy/totalEnthalpy.C new file mode 100644 index 0000000000000000000000000000000000000000..33de3c9ad00c83a4735afa770692bdb0f6201e63 --- /dev/null +++ b/src/functionObjects/field/totalEnthalpy/totalEnthalpy.C @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "totalEnthalpy.H" +#include "fluidThermo.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(totalEnthalpy, 0); + addToRunTimeSelectionTable(functionObject, totalEnthalpy, dictionary); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::totalEnthalpy::totalEnthalpy +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + writeLocalObjects(obr_, false), + phaseName_(word::null) +{ + read(dict); + resetLocalObjectName(IOobject::groupName("Ha", phaseName_)); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::totalEnthalpy::~totalEnthalpy() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::totalEnthalpy::read +( + const dictionary& dict +) +{ + fvMeshFunctionObject::read(dict); + writeLocalObjects::read(dict); + + phaseName_ = dict.lookupOrDefault<word>("phase", word::null); + + return true; +} + + +bool Foam::functionObjects::totalEnthalpy::execute() +{ + const word fieldName(IOobject::groupName("Ha", phaseName_)); + + const word thermoName + ( + IOobject::groupName(fluidThermo::dictName, phaseName_) + ); + + if (mesh_.foundObject<fluidThermo>(thermoName)) + { + const fluidThermo& thermo = mesh_.lookupObject<fluidThermo>(thermoName); + const volVectorField& U = mesh_.lookupObject<volVectorField> + ( + IOobject::groupName("U", phaseName_) + ); + + return store(fieldName, thermo.ha() + 0.5*magSqr(U)); + } + else + { + FatalErrorInFunction + << "Unable to find fluidThermo " << thermoName + << " in the database" + << exit(FatalError); + + return false; + } +} + + +bool Foam::functionObjects::totalEnthalpy::write() +{ + return writeLocalObjects::write(); +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/totalEnthalpy/totalEnthalpy.H b/src/functionObjects/field/totalEnthalpy/totalEnthalpy.H new file mode 100644 index 0000000000000000000000000000000000000000..c5e2d1c634c11080529cda55aceacdc7afc34fb1 --- /dev/null +++ b/src/functionObjects/field/totalEnthalpy/totalEnthalpy.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::functionObjects::totalEnthalpy + +Description + Calculates and writes the total enthalpy (ha + K) as the volScalarField + 'Ha'. + +See also + Foam::functionObjects::fvMeshFunctionObject + Foam::functionObjects::writeLocalObjects + +SourceFiles + totalEnthalpy.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_totalEnthalpy_H +#define functionObjects_totalEnthalpy_H + +#include "fieldExpression.H" +#include "writeLocalObjects.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class totalEnthalpy Declaration +\*---------------------------------------------------------------------------*/ + +class totalEnthalpy +: + public fvMeshFunctionObject, + public writeLocalObjects +{ + // Private Data + + //- The name of the phase + word phaseName_; + + +public: + + //- Runtime type information + TypeName("totalEnthalpy"); + + + // Constructors + + //- Construct from Time and dictionary + totalEnthalpy + ( + const word& name, + const Time& runTime, + const dictionary& + ); + + + //- Destructor + virtual ~totalEnthalpy(); + + + // Member Functions + + //- Read the data + virtual bool read(const dictionary&); + + //- Calculate the totalEnthalpy field + virtual bool execute(); + + //- Do nothing + virtual bool write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/U b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/U new file mode 100644 index 0000000000000000000000000000000000000000..3075fd2d8ddfdebc4648cad785be609db8ea6c61 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/U @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + walls + { + type noSlip; + } + + inlet + { + type fixedValue; + value uniform (0.2 0 0); + } + + outlet + { + type pressureInletOutletVelocity; + value $internalField; + } +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/alphat b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/alphat new file mode 100644 index 0000000000000000000000000000000000000000..93bd28aee5a19180163d45bd07a01e552dc95bb1 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/alphat @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alphat; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + walls + { + type compressible::alphatJayatillekeWallFunction; + Prt 0.85; + value $internalField; + } + + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/epsilon b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/epsilon new file mode 100644 index 0000000000000000000000000000000000000000..e48c84f7ce5c8e8f52fe09a30e802a667c3f8e9b --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/epsilon @@ -0,0 +1,45 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +internalField uniform 0.23; + +boundaryField +{ + walls + { + type epsilonWallFunction; + value $internalField; + } + + inlet + { + type turbulentMixingLengthDissipationRateInlet; + mixingLength 0.0168; + value $internalField; + } + + outlet + { + type inletOutlet; + inletValue $internalField; + } +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/k b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/k new file mode 100644 index 0000000000000000000000000000000000000000..f560ce00756a1667993b40dab806d6ce6e7f59b4 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/k @@ -0,0 +1,45 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 8e-2; + +boundaryField +{ + walls + { + type kqRWallFunction; + value $internalField; + } + + inlet + { + type turbulentIntensityKineticEnergyInlet; + intensity 0.14; + value $internalField; + } + + outlet + { + type inletOutlet; + inletValue $internalField; + } +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/nut b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/nut new file mode 100644 index 0000000000000000000000000000000000000000..de31198bf063a7e865ec63493c915e6df85447ed --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/nut @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + walls + { + type nutkWallFunction; + value $internalField; + } + + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/p b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/p new file mode 100644 index 0000000000000000000000000000000000000000..b73abe3f307a6091aa6c0b05e4ecdc6d03a54072 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/p @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 1e5; + +boundaryField +{ + walls + { + type calculated; + value $internalField; + } + + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } +} + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/p_rgh b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..9ee00e9dbddd34d07a5e571f3de032090178ab1b --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/0.orig/p_rgh @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 1e5; + +boundaryField +{ + walls + { + type fixedFluxPressure; + value $internalField; + } + + outlet + { + type prghPressure; + p $internalField; + value $internalField; + } + + inlet + { + type fixedFluxPressure; + value $internalField; + } +} + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/Allclean b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..fb1f3847301c377e02e12439ba58cbf303af3ef9 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/Allclean @@ -0,0 +1,8 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions +#------------------------------------------------------------------------------ + +cleanCase0 + +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/Allrun b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..9c994f5eb9bb7f918637f12fe48f01621bfa97ec --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/Allrun @@ -0,0 +1,16 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +restore0Dir + +runApplication blockMesh + +runApplication topoSet + +runApplication createPatch -overwrite + +runApplication $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/constant/g b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..422ba618ea9f6096f42836ea2bfd4c781e3d1490 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 0 -9.81); + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/constant/thermophysicalProperties b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/constant/thermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..6ab143359646816b5445837da878e1749e9bccb7 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/constant/thermophysicalProperties @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture pureMixture; + transport const; + thermo eConst; + equationOfState Boussinesq; + specie specie; + energy sensibleInternalEnergy; +} + +mixture +{ + specie + { + molWeight 28.9; + } + equationOfState + { + rho0 1; + T0 300; + beta 3e-03; + } + thermodynamics + { + Cv 712; + Hf 0; + } + transport + { + mu 1e-05; + Pr 0.7; + } +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/constant/turbulenceProperties b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..9222c0615d2d0acc158398b56ca5468b46972196 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/constant/turbulenceProperties @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType RAS; + +RAS +{ + RASModel kEpsilon; + + turbulence on; + + printCoeffs on; +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/blockMeshDict b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..fcad996b0fc8a47ae6dbcc561e566b55ef97e1b6 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/blockMeshDict @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (0 0 0) + (0 0 1.6) + (0 3 1.6) + (0 3 0) + + (4 0 0) + (4 0 1.6) + (4 3 1.6) + (4 3 0) +); + +blocks +( + hex (0 3 2 1 4 7 6 5) (40 20 60) simpleGrading (1 1 1) +); + +defaultPatch +{ + name walls; + type wall; +} + +boundary +(); + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/controlDict b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..023934fc5e2da0c7a8dba744d252a0c57780f620 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/controlDict @@ -0,0 +1,76 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application buoyantSimpleFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 3000; + +deltaT 1; + +writeControl timeStep; + +writeInterval 100; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +functions +{ + age + { + libs ("libfieldFunctionObjects.so"); + type age; + + diffusion on; + + writeControl writeTime; + executeControl writeTime; + } + + comfort + { + libs ("libfieldFunctionObjects.so"); + type comfort; + + clothing 0.5; + metabolicRate 1.2; + extWork 0; + relHumidity 60; + + writeControl writeTime; + executeControl writeTime; + } +} + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/createPatchDict b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/createPatchDict new file mode 100644 index 0000000000000000000000000000000000000000..df1c7c7f059ceb1caad3df219fba9bea7859112d --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/createPatchDict @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object createPatchDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +pointSync false; + +writeCyclicMatch false; + +patches +( + { + name inlet; + + patchInfo + { + type patch; + } + + constructFrom set; + set inlet; + } + { + name outlet; + + patchInfo + { + type patch; + } + + constructFrom set; + set outlet; + } +); + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/fvSchemes b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..626ee371b94a76f33be253c5e21afb31bfe6a6c0 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/fvSchemes @@ -0,0 +1,61 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) bounded Gauss upwind; + div(phi,e) bounded Gauss upwind; + + div(phi,k) bounded Gauss upwind; + div(phi,epsilon) bounded Gauss upwind; + + div(phi,Ekp) bounded Gauss linear; + + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; + + div(phi,age) bounded Gauss upwind; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/fvSolution b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..6f19a1779bc79af58c96a08a78423594504ec1f6 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/fvSolution @@ -0,0 +1,74 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p_rgh + { + solver PCG; + preconditioner DIC; + tolerance 1e-8; + relTol 0.01; + } + + "(U|e|k|epsilon)" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-7; + relTol 0.1; + } + + age + { + $U; + relTol 0.001; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; + + residualControl + { + p_rgh 1e-2; + U 1e-4; + e 1e-2; + + "(k|epsilon|omega)" 1e-3; + } +} + +relaxationFactors +{ + fields + { + p_rgh 0.7; + } + + equations + { + U 0.2; + e 0.1; + "(k|epsilon|R)" 0.7; + age 1; + } +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/topoSetDict b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/topoSetDict new file mode 100644 index 0000000000000000000000000000000000000000..7353ae4623745ade550a8d267befcf72970a12d3 --- /dev/null +++ b/tutorials/heatTransfer/buoyantSimpleFoam/comfortHotRoom/system/topoSetDict @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object topoSetDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +actions +( + { + name inlet; + type faceSet; + action new; + source boxToFace; + sourceInfo + { + box (-0.001 0.25 1.1)(0.001 0.75 1.3); + } + } + { + name outlet; + type faceSet; + action new; + source boxToFace; + sourceInfo + { + box (1.75 2.999 0.3)(2.25 3.001 0.5); + } + } +); + +// ************************************************************************* // \ No newline at end of file