From cd9834b45e0eedf8ed2a8b1d93920bca710c6014 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Dec 2012 14:56:49 +0000 Subject: [PATCH 1/7] faceCorrectedSnGrad: New non-orthogonal correction scheme using point values to construct the in-plane face-gradient --- .../faceCorrectedSnGrad/faceCorrectedSnGrad.C | 167 ++++++++++++++++++ .../faceCorrectedSnGrad/faceCorrectedSnGrad.H | 157 ++++++++++++++++ .../faceCorrectedSnGrads.C | 62 +++++++ 3 files changed, 386 insertions(+) create mode 100644 src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C create mode 100644 src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H create mode 100644 src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrads.C diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C new file mode 100644 index 0000000000..6b8156aca3 --- /dev/null +++ b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "faceCorrectedSnGrad.H" +#include "volPointInterpolation.H" +#include "triangle.H" + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::fv::faceCorrectedSnGrad::~faceCorrectedSnGrad() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::tmp > +Foam::fv::faceCorrectedSnGrad::fullGradCorrection +( + const GeometricField& vf +) const +{ + const fvMesh& mesh = this->mesh(); + + GeometricField pvf + ( + volPointInterpolation::New(mesh).interpolate(vf) + ); + + // construct GeometricField + tmp > tsfCorr + ( + new GeometricField + ( + IOobject + ( + "snGradCorr("+vf.name()+')', + vf.instance(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + vf.dimensions()*mesh.nonOrthDeltaCoeffs().dimensions() + ) + ); + + Field& sfCorr = tsfCorr().internalField(); + + const pointField& points = mesh.points(); + const faceList& faces = mesh.faces(); + const vectorField& Sf = mesh.Sf().internalField(); + const vectorField& C = mesh.C().internalField(); + const scalarField& magSf = mesh.magSf().internalField(); + const labelList& owner = mesh.owner(); + const labelList& neighbour = mesh.neighbour(); + + forAll(sfCorr, facei) + { + typename outerProduct::type fgrad + ( + outerProduct::type::zero + ); + + const face& fi = faces[facei]; + + vector nf(Sf[facei]/magSf[facei]); + + for (label pi=0; pi 2) dCorr *= 2/mag(dCorr); + + sfCorr[facei] = dCorr&fgrad; + } + + tsfCorr().boundaryField() = pTraits::zero; + + return tsfCorr; +} + + +template +Foam::tmp > +Foam::fv::faceCorrectedSnGrad::correction +( + const GeometricField& vf +) const +{ + const fvMesh& mesh = this->mesh(); + + // construct GeometricField + tmp > tssf + ( + new GeometricField + ( + IOobject + ( + "snGradCorr("+vf.name()+')', + vf.instance(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + vf.dimensions()*mesh.nonOrthDeltaCoeffs().dimensions() + ) + ); + GeometricField& ssf = tssf(); + + for (direction cmpt = 0; cmpt < pTraits::nComponents; cmpt++) + { + ssf.replace + ( + cmpt, + faceCorrectedSnGrad::cmptType>(mesh) + .fullGradCorrection(vf.component(cmpt)) + ); + } + + return tssf; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H new file mode 100644 index 0000000000..a79ece3281 --- /dev/null +++ b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +Class + Foam::fv::faceCorrectedSnGrad + +Description + Simple central-difference snGrad scheme with non-orthogonal correction. + +SourceFiles + faceCorrectedSnGrad.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceCorrectedSnGrad_H +#define faceCorrectedSnGrad_H + +#include "snGradScheme.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace fv +{ + +/*---------------------------------------------------------------------------*\ + Class faceCorrectedSnGrad Declaration +\*---------------------------------------------------------------------------*/ + +template +class faceCorrectedSnGrad +: + public snGradScheme +{ + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const faceCorrectedSnGrad&); + + +public: + + //- Runtime type information + TypeName("faceCorrected"); + + + // Constructors + + //- Construct from mesh + faceCorrectedSnGrad(const fvMesh& mesh) + : + snGradScheme(mesh) + {} + + + //- Construct from mesh and data stream + faceCorrectedSnGrad(const fvMesh& mesh, Istream&) + : + snGradScheme(mesh) + {} + + + //- Destructor + virtual ~faceCorrectedSnGrad(); + + + // Member Functions + + //- Return the interpolation weighting factors for the given field + virtual tmp deltaCoeffs + ( + const GeometricField& + ) const + { + return this->mesh().nonOrthDeltaCoeffs(); + } + + //- Return true if this scheme uses an explicit correction + virtual bool corrected() const + { + return true; + } + + //- Return the explicit correction to the faceCorrectedSnGrad + // for the given field using the gradient of the field + tmp > + fullGradCorrection + ( + const GeometricField& + ) const; + + //- Return the explicit correction to the faceCorrectedSnGrad + // for the given field using the gradients of the field components + virtual tmp > + correction(const GeometricField&) const; +}; + + +// * * * * * * * * Template Member Function Specialisations * * * * * * * * // + +template<> +tmp faceCorrectedSnGrad::correction +( + const volScalarField& vsf +) const; + + +template<> +tmp faceCorrectedSnGrad::correction +( + const volVectorField& vvf +) const; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fv + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "faceCorrectedSnGrad.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrads.C b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrads.C new file mode 100644 index 0000000000..f98abfd351 --- /dev/null +++ b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrads.C @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "faceCorrectedSnGrad.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + makeSnGradScheme(faceCorrectedSnGrad) +} +} + + +template<> +Foam::tmp +Foam::fv::faceCorrectedSnGrad::correction +( + const volScalarField& vsf +) const +{ + return fullGradCorrection(vsf); +} + + +template<> +Foam::tmp +Foam::fv::faceCorrectedSnGrad::correction +( + const volVectorField& vvf +) const +{ + return fullGradCorrection(vvf); +} + + +// ************************************************************************* // From cc2eb6a83bca8d1d2ce5af528abd5542a66ea626 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Dec 2012 14:57:20 +0000 Subject: [PATCH 2/7] Updated headers --- .../snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C | 2 +- .../snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H | 2 +- .../snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrads.C | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C index 6b8156aca3..6b04bb2efb 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H index a79ece3281..a13dd62d18 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrad.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrads.C b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrads.C index f98abfd351..ba6d83542e 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrads.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/faceCorrectedSnGrad/faceCorrectedSnGrads.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License From 6a9cfbe53b98614a876758a4ce629986830999f9 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Dec 2012 14:57:56 +0000 Subject: [PATCH 3/7] fvMesh: added delta() function which returns the face-delta surface field --- src/finiteVolume/fvMesh/fvMesh.H | 3 ++ src/finiteVolume/fvMesh/fvMeshGeometry.C | 47 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 97c1b0db58..7cb9d97a00 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -312,6 +312,9 @@ public: //- Return face centres as surfaceVectorField const surfaceVectorField& Cf() const; + //- Return face deltas as surfaceVectorField + tmp delta() const; + // Edit diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index 5abdb45d11..ddd395a722 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -372,6 +372,53 @@ const surfaceVectorField& fvMesh::Cf() const } +tmp fvMesh::delta() const +{ + if (debug) + { + Info<< "void fvMesh::delta() : " + << "calculating face deltas" + << endl; + } + + tmp tdelta + ( + new surfaceVectorField + ( + IOobject + ( + "delta", + pointsInstance(), + meshSubDir, + *this, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + *this, + dimLength + ) + ); + surfaceVectorField& delta = tdelta(); + + const volVectorField& C = this->C(); + const labelUList& owner = this->owner(); + const labelUList& neighbour = this->neighbour(); + + forAll(owner, facei) + { + delta[facei] = C[neighbour[facei]] - C[owner[facei]]; + } + + forAll(delta.boundaryField(), patchi) + { + delta.boundaryField()[patchi] = boundary()[patchi].delta(); + } + + return tdelta; +} + + const surfaceScalarField& fvMesh::phi() const { if (!phiPtr_) From ee6f15b7a97583329fbb57f013d8a7a3138d87de Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Dec 2012 15:00:45 +0000 Subject: [PATCH 4/7] kOmegaSST: F3 is now optional on a switch "F3", default: false --- .../compressible/RAS/kOmegaSST/kOmegaSST.C | 27 +++++++++++++++++-- .../compressible/RAS/kOmegaSST/kOmegaSST.H | 6 ++++- .../incompressible/RAS/kOmegaSST/kOmegaSST.C | 27 +++++++++++++++++-- .../incompressible/RAS/kOmegaSST/kOmegaSST.H | 7 ++++- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C index ddde795545..321c07443b 100644 --- a/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C @@ -97,6 +97,19 @@ tmp kOmegaSST::F3() const } +tmp kOmegaSST::F23() const +{ + tmp f23(F2()); + + if (F3_) + { + f23() *= F3(); + } + + return f23; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // kOmegaSST::kOmegaSST @@ -228,6 +241,15 @@ kOmegaSST::kOmegaSST 10.0 ) ), + F3_ + ( + Switch::lookupOrAddToDict + ( + "F3", + coeffDict_, + false + ) + ), y_(mesh_), @@ -289,7 +311,7 @@ kOmegaSST::kOmegaSST / max ( a1_*omega_, - b1_*F2()*F3()*sqrt(2.0)*mag(symm(fvc::grad(U_))) + b1_*F23()*sqrt(2.0)*mag(symm(fvc::grad(U_))) ) ); mut_.correctBoundaryConditions(); @@ -370,6 +392,7 @@ bool kOmegaSST::read() a1_.readIfPresent(coeffDict()); b1_.readIfPresent(coeffDict()); c1_.readIfPresent(coeffDict()); + F3_.readIfPresent("F3", coeffDict()); return true; } @@ -470,7 +493,7 @@ void kOmegaSST::correct() // Re-calculate viscosity - mut_ = a1_*rho_*k_/max(a1_*omega_, b1_*F2()*F3()*sqrt(S2)); + mut_ = a1_*rho_*k_/max(a1_*omega_, b1_*F23()*sqrt(S2)); mut_.correctBoundaryConditions(); // Re-calculate thermal diffusivity diff --git a/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.H b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.H index 6cc40f6b68..222242a74c 100644 --- a/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.H +++ b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.H @@ -38,7 +38,7 @@ Description Nov. 2001 \endverbatim - with the addition of the F3 term for rough walls from + with the addition of the optional F3 term for rough walls from \verbatim Hellsten, A. "Some Improvements in Menter’s k-omega-SST turbulence model" @@ -80,6 +80,7 @@ Description a1 0.31; b1 1.0; c1 10.0; + F3 no; } \endverbatim @@ -138,6 +139,8 @@ protected: dimensionedScalar b1_; dimensionedScalar c1_; + Switch F3_; + //- Wall distance // Note: different to wall distance in parent RASModel @@ -156,6 +159,7 @@ protected: tmp F1(const volScalarField& CDkOmega) const; tmp F2() const; tmp F3() const; + tmp F23() const; tmp blend ( diff --git a/src/turbulenceModels/incompressible/RAS/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/incompressible/RAS/kOmegaSST/kOmegaSST.C index cff0d48146..290a4c73a8 100644 --- a/src/turbulenceModels/incompressible/RAS/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/incompressible/RAS/kOmegaSST/kOmegaSST.C @@ -98,6 +98,19 @@ tmp kOmegaSST::F3() const } +tmp kOmegaSST::F23() const +{ + tmp f23(F2()); + + if (F3_) + { + f23() *= F3(); + } + + return f23; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // kOmegaSST::kOmegaSST @@ -219,6 +232,15 @@ kOmegaSST::kOmegaSST 10.0 ) ), + F3_ + ( + Switch::lookupOrAddToDict + ( + "F3", + coeffDict_, + false + ) + ), y_(mesh_), @@ -268,7 +290,7 @@ kOmegaSST::kOmegaSST / max ( a1_*omega_, - b1_*F2()*F3()*sqrt(2.0)*mag(symm(fvc::grad(U_))) + b1_*F23()*sqrt(2.0)*mag(symm(fvc::grad(U_))) ) ); nut_.correctBoundaryConditions(); @@ -362,6 +384,7 @@ bool kOmegaSST::read() a1_.readIfPresent(coeffDict()); b1_.readIfPresent(coeffDict()); c1_.readIfPresent(coeffDict()); + F3_.readIfPresent("F3", coeffDict()); return true; } @@ -439,7 +462,7 @@ void kOmegaSST::correct() // Re-calculate viscosity - nut_ = a1_*k_/max(a1_*omega_, b1_*F2()*F3()*sqrt(S2)); + nut_ = a1_*k_/max(a1_*omega_, b1_*F23()*sqrt(S2)); nut_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/incompressible/RAS/kOmegaSST/kOmegaSST.H b/src/turbulenceModels/incompressible/RAS/kOmegaSST/kOmegaSST.H index 88feb733bc..07d16d2732 100644 --- a/src/turbulenceModels/incompressible/RAS/kOmegaSST/kOmegaSST.H +++ b/src/turbulenceModels/incompressible/RAS/kOmegaSST/kOmegaSST.H @@ -36,7 +36,7 @@ Description Nov. 2001. \endverbatim - with the addition of the F3 term for rough walls from + with the addition of the optional F3 term for rough walls from \verbatim Hellsten, A. "Some Improvements in Menter’s k-omega-SST turbulence model" @@ -77,6 +77,7 @@ Description a1 0.31; b1 1.0; c1 10.0; + F3 no; } \endverbatim @@ -132,6 +133,9 @@ protected: dimensionedScalar b1_; dimensionedScalar c1_; + Switch F3_; + + //- Wall distance field // Note: different to wall distance in parent RASModel wallDist y_; @@ -148,6 +152,7 @@ protected: tmp F1(const volScalarField& CDkOmega) const; tmp F2() const; tmp F3() const; + tmp F23() const; tmp blend ( From fe3feaf9e52f676fe8f29dc5c4b74e664ebacdf7 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Dec 2012 15:01:28 +0000 Subject: [PATCH 5/7] Added faceCorrectedSnGrad --- src/finiteVolume/Make/files | 1 + 1 file changed, 1 insertion(+) diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index b982734e8b..5e097730fd 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -342,6 +342,7 @@ $(limitedGradSchemes)/cellMDLimitedGrad/cellMDLimitedGrads.C snGradSchemes = finiteVolume/snGradSchemes $(snGradSchemes)/snGradScheme/snGradSchemes.C $(snGradSchemes)/correctedSnGrad/correctedSnGrads.C +$(snGradSchemes)/faceCorrectedSnGrad/faceCorrectedSnGrads.C $(snGradSchemes)/limitedSnGrad/limitedSnGrads.C $(snGradSchemes)/uncorrectedSnGrad/uncorrectedSnGrads.C $(snGradSchemes)/orthogonalSnGrad/orthogonalSnGrads.C From e3e62b9ef888116c81a7634f3f612f1e6aa52011 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Dec 2012 15:03:45 +0000 Subject: [PATCH 6/7] Thermo: Add support for instantiating more than one thermo package in an application --- .../basic/basicThermo/basicThermo.C | 12 ++-- .../basic/basicThermo/basicThermo.H | 16 +++-- .../basic/heThermo/heThermo.C | 64 ++++++++++++++++++- .../basic/heThermo/heThermo.H | 8 +++ .../basic/psiThermo/psiThermo.C | 4 +- .../basic/rhoThermo/rhoThermo.C | 12 ++-- .../basic/rhoThermo/rhoThermos.C | 25 ++++++++ .../solidThermo/solidThermo/solidThermo.C | 4 +- 8 files changed, 123 insertions(+), 22 deletions(-) diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index 84e30e31a4..e2fc874b5e 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -112,7 +112,7 @@ Foam::basicThermo::basicThermo ( IOobject ( - phasePropertyName("alpha"), + phasePropertyName("thermo:alpha"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -167,7 +167,7 @@ Foam::basicThermo::basicThermo ( IOobject ( - phasePropertyName("alpha"), + phasePropertyName("thermo:alpha"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -237,7 +237,7 @@ const Foam::basicThermo& Foam::basicThermo::lookupThermo void Foam::basicThermo::validate ( - const word& app, + const string& app, const word& a ) const { @@ -252,7 +252,7 @@ void Foam::basicThermo::validate void Foam::basicThermo::validate ( - const word& app, + const string& app, const word& a, const word& b ) const @@ -275,7 +275,7 @@ void Foam::basicThermo::validate void Foam::basicThermo::validate ( - const word& app, + const string& app, const word& a, const word& b, const word& c @@ -301,7 +301,7 @@ void Foam::basicThermo::validate void Foam::basicThermo::validate ( - const word& app, + const string& app, const word& a, const word& b, const word& c, diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.H b/src/thermophysicalModels/basic/basicThermo/basicThermo.H index 659b6f35ca..e652c30ee6 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.H +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.H @@ -185,7 +185,7 @@ public: // with energy forms supported by the application void validate ( - const word& app, + const string& app, const word& ) const; @@ -193,7 +193,7 @@ public: // with energy forms supported by the application void validate ( - const word& app, + const string& app, const word&, const word& ) const; @@ -202,7 +202,7 @@ public: // with energy forms supported by the application void validate ( - const word& app, + const string& app, const word&, const word&, const word& @@ -212,7 +212,7 @@ public: // with energy forms supported by the application void validate ( - const word& app, + const string& app, const word&, const word&, const word&, @@ -263,6 +263,14 @@ public: //- Enthalpy/Internal energy [J/kg] virtual const volScalarField& he() const = 0; + //- Enthalpy/Internal energy + // for given pressure and temperature [J/kg] + virtual tmp he + ( + const volScalarField& p, + const volScalarField& T + ) const = 0; + //- Enthalpy/Internal energy for cell-set [J/kg] virtual tmp he ( diff --git a/src/thermophysicalModels/basic/heThermo/heThermo.C b/src/thermophysicalModels/basic/heThermo/heThermo.C index 8efaf0f5d5..29634e2769 100644 --- a/src/thermophysicalModels/basic/heThermo/heThermo.C +++ b/src/thermophysicalModels/basic/heThermo/heThermo.C @@ -174,7 +174,10 @@ Foam::heThermo::heThermo ( IOobject ( - BasicThermo::phasePropertyName(MixtureType::thermoType::heName()), + BasicThermo::phasePropertyName + ( + MixtureType::thermoType::heName() + ), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -205,7 +208,10 @@ Foam::heThermo::heThermo ( IOobject ( - BasicThermo::phasePropertyName(MixtureType::thermoType::heName()), + BasicThermo::phasePropertyName + ( + MixtureType::thermoType::heName() + ), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -230,6 +236,60 @@ Foam::heThermo::~heThermo() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +Foam::tmp Foam::heThermo::he +( + const volScalarField& p, + const volScalarField& T +) const +{ + const fvMesh& mesh = this->T_.mesh(); + + tmp the + ( + new volScalarField + ( + IOobject + ( + "he", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + he_.dimensions() + ) + ); + + volScalarField& he = the(); + scalarField& heCells = he.internalField(); + const scalarField& pCells = p.internalField(); + const scalarField& TCells = T.internalField(); + + forAll(heCells, celli) + { + heCells[celli] = + this->cellMixture(celli).HE(pCells[celli], TCells[celli]); + } + + forAll(he.boundaryField(), patchi) + { + scalarField& hep = he.boundaryField()[patchi]; + const scalarField& pp = p.boundaryField()[patchi]; + const scalarField& Tp = T.boundaryField()[patchi]; + + forAll(hep, facei) + { + hep[facei] = + this->patchFaceMixture(patchi, facei).HE(pp[facei], Tp[facei]); + } + } + + return the; +} + + template Foam::tmp Foam::heThermo::he ( diff --git a/src/thermophysicalModels/basic/heThermo/heThermo.H b/src/thermophysicalModels/basic/heThermo/heThermo.H index ef9919a99c..f77d017e13 100644 --- a/src/thermophysicalModels/basic/heThermo/heThermo.H +++ b/src/thermophysicalModels/basic/heThermo/heThermo.H @@ -161,6 +161,14 @@ public: // Fields derived from thermodynamic state variables + //- Enthalpy/Internal energy + // for given pressure and temperature [J/kg] + virtual tmp he + ( + const volScalarField& p, + const volScalarField& T + ) const; + //- Enthalpy/Internal energy for cell-set [J/kg] virtual tmp he ( diff --git a/src/thermophysicalModels/basic/psiThermo/psiThermo.C b/src/thermophysicalModels/basic/psiThermo/psiThermo.C index fd4bc962c9..dd69890313 100644 --- a/src/thermophysicalModels/basic/psiThermo/psiThermo.C +++ b/src/thermophysicalModels/basic/psiThermo/psiThermo.C @@ -44,7 +44,7 @@ Foam::psiThermo::psiThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("psi"), + phasePropertyName("thermo:psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -58,7 +58,7 @@ Foam::psiThermo::psiThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("mu"), + phasePropertyName("thermo:mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, diff --git a/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C b/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C index 4aa7835cac..d34186eea9 100644 --- a/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C +++ b/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C @@ -43,7 +43,7 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("rhoThermo"), + phasePropertyName("thermo:rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -57,7 +57,7 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("psi"), + phasePropertyName("thermo:psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -71,7 +71,7 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("mu"), + phasePropertyName("thermo:mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -95,7 +95,7 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("rhoThermo"), + phasePropertyName("thermo:rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -109,7 +109,7 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("psi"), + phasePropertyName("thermo:psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -123,7 +123,7 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("mu"), + phasePropertyName("thermo:mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, diff --git a/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C b/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C index fcfc3437dd..beaa43b735 100644 --- a/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C +++ b/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C @@ -30,6 +30,7 @@ License #include "perfectGas.H" #include "incompressiblePerfectGas.H" #include "rhoConst.H" +#include "perfectFluid.H" #include "hConstThermo.H" #include "janafThermo.H" #include "sensibleEnthalpy.H" @@ -101,6 +102,18 @@ makeThermo specie ); +makeThermo +( + rhoThermo, + heRhoThermo, + pureMixture, + constTransport, + sensibleEnthalpy, + hConstThermo, + perfectFluid, + specie +); + makeThermo ( rhoThermo, @@ -200,6 +213,18 @@ makeThermo specie ); +makeThermo +( + rhoThermo, + heRhoThermo, + pureMixture, + constTransport, + sensibleInternalEnergy, + hConstThermo, + perfectFluid, + specie +); + makeThermo ( rhoThermo, diff --git a/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.C b/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.C index 102414e3fb..2e12bcf213 100644 --- a/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.C +++ b/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.C @@ -50,7 +50,7 @@ Foam::solidThermo::solidThermo ( IOobject ( - "rhoThermo", + phasePropertyName("thermo:rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -74,7 +74,7 @@ Foam::solidThermo::solidThermo ( IOobject ( - "rhoThermo", + phasePropertyName("thermo:rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, From 6c1aa06d164688d53f9b74fbda73b8e2fe73a84b Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Dec 2012 15:05:19 +0000 Subject: [PATCH 7/7] perfectFluid: New EoS for gases and liquids which behaves as a perfect gas for a gas and an offset perfect gas for a liquid --- .../perfectFluid/perfectFluid.C | 76 ++++++ .../perfectFluid/perfectFluid.H | 223 ++++++++++++++++++ .../perfectFluid/perfectFluidI.H | 220 +++++++++++++++++ 3 files changed, 519 insertions(+) create mode 100644 src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.C create mode 100644 src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.H create mode 100644 src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluidI.H diff --git a/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.C b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.C new file mode 100644 index 0000000000..844f293e2d --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.C @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "perfectFluid.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::perfectFluid::perfectFluid(Istream& is) +: + Specie(is), + rho0_(readScalar(is)) +{ + is.check("perfectFluid::perfectFluid(Istream& is)"); +} + + +template +Foam::perfectFluid::perfectFluid(const dictionary& dict) +: + Specie(dict), + rho0_(readScalar(dict.subDict("equationOfState").lookup("rho0"))) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::perfectFluid::write(Ostream& os) const +{ + Specie::write(os); + + dictionary dict("equationOfState"); + dict.add("rho0", rho0_); + + os << indent << dict.dictName() << dict; +} + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<<(Ostream& os, const perfectFluid& pf) +{ + os << static_cast(pf) + << token::SPACE << pf.rho0_; + + os.check("Ostream& operator<<(Ostream&, const perfectFluid&)"); + return os; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.H b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.H new file mode 100644 index 0000000000..76cf80c4a8 --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluid.H @@ -0,0 +1,223 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +Class + Foam::perfectFluid + +Description + Perfect gas equation of state. + +SourceFiles + perfectFluidI.H + perfectFluid.C + +\*---------------------------------------------------------------------------*/ + +#ifndef perfectFluid_H +#define perfectFluid_H + +#include "autoPtr.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +template class perfectFluid; + +template +inline perfectFluid operator+ +( + const perfectFluid&, + const perfectFluid& +); + +template +inline perfectFluid operator- +( + const perfectFluid&, + const perfectFluid& +); + +template +inline perfectFluid operator* +( + const scalar, + const perfectFluid& +); + +template +inline perfectFluid operator== +( + const perfectFluid&, + const perfectFluid& +); + +template +Ostream& operator<< +( + Ostream&, + const perfectFluid& +); + + +/*---------------------------------------------------------------------------*\ + Class perfectFluid Declaration +\*---------------------------------------------------------------------------*/ + +template +class perfectFluid +: + public Specie +{ + // Private data + + //- The reference density + scalar rho0_; + +public: + + // Constructors + + //- Construct from components + inline perfectFluid(const Specie& sp, const scalar rho0); + + //- Construct from Istream + perfectFluid(Istream&); + + //- Construct from dictionary + perfectFluid(const dictionary& dict); + + //- Construct as named copy + inline perfectFluid(const word& name, const perfectFluid&); + + //- Construct and return a clone + inline autoPtr clone() const; + + // Selector from Istream + inline static autoPtr New(Istream& is); + + // Selector from dictionary + inline static autoPtr New(const dictionary& dict); + + + // Member functions + + //- Return the instantiated type name + static word typeName() + { + return "perfectFluid<" + word(Specie::typeName_()) + '>'; + } + + + // Fundamental properties + + //- Is the equation of state is incompressible i.e. rho != f(p) + static const bool incompressible = false; + + //- Is the equation of state is isochoric i.e. rho = const + static const bool isochoric = false; + + //- Return density [kg/m^3] + inline scalar rho(scalar p, scalar T) const; + + //- Return compressibility rho/p [s^2/m^2] + inline scalar psi(scalar p, scalar T) const; + + //- Return compression factor [] + inline scalar Z(scalar p, scalar T) const; + + //- Return (cp - cv) [J/(kmol K] + inline scalar cpMcv(scalar p, scalar T) const; + + + // IO + + //- Write to Ostream + void write(Ostream& os) const; + + + // Member operators + + inline void operator+=(const perfectFluid&); + inline void operator-=(const perfectFluid&); + + inline void operator*=(const scalar); + + + // Friend operators + + friend perfectFluid operator+ + ( + const perfectFluid&, + const perfectFluid& + ); + + friend perfectFluid operator- + ( + const perfectFluid&, + const perfectFluid& + ); + + friend perfectFluid operator* + ( + const scalar s, + const perfectFluid& + ); + + friend perfectFluid operator== + ( + const perfectFluid&, + const perfectFluid& + ); + + + // Ostream Operator + + friend Ostream& operator<< + ( + Ostream&, + const perfectFluid& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "perfectFluidI.H" + +#ifdef NoRepository +# include "perfectFluid.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluidI.H b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluidI.H new file mode 100644 index 0000000000..21fc092fe2 --- /dev/null +++ b/src/thermophysicalModels/specie/equationOfState/perfectFluid/perfectFluidI.H @@ -0,0 +1,220 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "perfectFluid.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +inline Foam::perfectFluid::perfectFluid +( + const Specie& sp, + const scalar rho0 +) +: + Specie(sp), + rho0_(rho0) +{} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::perfectFluid::perfectFluid +( + const word& name, + const perfectFluid& pf +) +: + Specie(name, pf), + rho0_(pf.rho0_) +{} + + +template +inline Foam::autoPtr > +Foam::perfectFluid::clone() const +{ + return autoPtr >(new perfectFluid(*this)); +} + + +template +inline Foam::autoPtr > +Foam::perfectFluid::New(Istream& is) +{ + return autoPtr >(new perfectFluid(is)); +} + + +template +inline Foam::autoPtr > +Foam::perfectFluid::New +( + const dictionary& dict +) +{ + return autoPtr >(new perfectFluid(dict)); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::scalar Foam::perfectFluid::rho(scalar p, scalar T) const +{ + return rho0_ + p/(this->R()*T); +} + + +template +inline Foam::scalar Foam::perfectFluid::psi(scalar, scalar T) const +{ + return 1.0/(this->R()*T); +} + + +template +inline Foam::scalar Foam::perfectFluid::Z(scalar, scalar) const +{ + return 1.0; +} + + +template +inline Foam::scalar Foam::perfectFluid::cpMcv(scalar, scalar) const +{ + return this->RR; +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +inline void Foam::perfectFluid::operator+= +( + const perfectFluid& pf +) +{ + scalar molr1 = this->nMoles(); + + Specie::operator+=(pf); + + molr1 /= this->nMoles(); + scalar molr2 = pf.nMoles()/this->nMoles(); + + rho0_ = molr1*rho0_ + molr2*pf.rho0_; +} + + +template +inline void Foam::perfectFluid::operator-= +( + const perfectFluid& pf +) +{ + scalar molr1 = this->nMoles(); + + Specie::operator-=(pf); + + molr1 /= this->nMoles(); + scalar molr2 = pf.nMoles()/this->nMoles(); + + rho0_ = molr1*rho0_ - molr2*pf.rho0_; +} + + +template +inline void Foam::perfectFluid::operator*=(const scalar s) +{ + Specie::operator*=(s); +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template +inline Foam::perfectFluid Foam::operator+ +( + const perfectFluid& pf1, + const perfectFluid& pf2 +) +{ + scalar nMoles = pf1.nMoles() + pf2.nMoles(); + scalar molr1 = pf1.nMoles()/nMoles; + scalar molr2 = pf2.nMoles()/nMoles; + + return rhoConst + ( + static_cast(pf1) + + static_cast(pf2), + molr1*pf1.rho0_ + molr2*pf2.rho0_ + ); +} + + +template +inline Foam::perfectFluid Foam::operator- +( + const perfectFluid& pf1, + const perfectFluid& pf2 +) +{ + scalar nMoles = pf1.nMoles() + pf2.nMoles(); + scalar molr1 = pf1.nMoles()/nMoles; + scalar molr2 = pf2.nMoles()/nMoles; + + return rhoConst + ( + static_cast(pf1) + - static_cast(pf2), + molr1*pf1.rho0_ - molr2*pf2.rho0_ + ); +} + + +template +inline Foam::perfectFluid Foam::operator* +( + const scalar s, + const perfectFluid& pf +) +{ + return perfectFluid(s*static_cast(pf), pf.rho0_); +} + + +template +inline Foam::perfectFluid Foam::operator== +( + const perfectFluid& pf1, + const perfectFluid& pf2 +) +{ + return pf2 - pf1; +} + + +// ************************************************************************* //