diff --git a/applications/solvers/incompressible/oodles/oodles.C b/applications/solvers/incompressible/oodles/oodles.C index 8c51065db1d06490ed8fba17107553c52f0b2be0..0714bf851566d59b556d1fa8350f59128e333046 100644 --- a/applications/solvers/incompressible/oodles/oodles.C +++ b/applications/solvers/incompressible/oodles/oodles.C @@ -34,9 +34,6 @@ Description #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" #include "incompressible/transportModel/transportModel.H" #include "incompressible/LESModel/LESModel.H" -#include "IFstream.H" -#include "OFstream.H" -#include "Random.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 25137c58c7d4199eb7579f5b6fc59114db7b231c..923e4c50e60b14f7b95c7daad7b1ab04a90e98aa 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -251,6 +251,8 @@ $(snGradSchemes)/snGradScheme/snGradSchemes.C $(snGradSchemes)/correctedSnGrad/correctedSnGrads.C $(snGradSchemes)/limitedSnGrad/limitedSnGrads.C $(snGradSchemes)/uncorrectedSnGrad/uncorrectedSnGrads.C +$(snGradSchemes)/quadraticFitSnGrad/quadraticFitSnGradData.C +$(snGradSchemes)/quadraticFitSnGrad/quadraticFitSnGrads.C convectionSchemes = finiteVolume/convectionSchemes $(convectionSchemes)/convectionScheme/convectionSchemes.C diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrad.H new file mode 100644 index 0000000000000000000000000000000000000000..b74c3d2f205fca1510bb2eb5cbd03fa94f55840d --- /dev/null +++ b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrad.H @@ -0,0 +1,161 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + quadraticFitSnGrad + +Description + Simple central-difference snGrad scheme with quadratic fit correction from + a larger stencil. + +SourceFiles + quadraticFitSnGrad.C + +\*---------------------------------------------------------------------------*/ + +#ifndef quadraticFitSnGrad_H +#define quadraticFitSnGrad_H + +#include "snGradScheme.H" +#include "quadraticFitSnGradData.H" +#include "extendedStencil.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace fv +{ + +/*---------------------------------------------------------------------------*\ + Class quadraticFitSnGrad Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class quadraticFitSnGrad +: + public snGradScheme<Type> +{ + // Private Data + //- weights for central stencil + const scalar centralWeight_; + + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const quadraticFitSnGrad&); + + +public: + + //- Runtime type information + TypeName("quadraticFit"); + + + // Constructors + + //- Construct from mesh and scheme data + quadraticFitSnGrad + ( + const fvMesh& mesh, + const scalar centralWeight + ) + : + snGradScheme<Type>(mesh), + centralWeight_(centralWeight) + {} + + + //- Construct from mesh and data stream + quadraticFitSnGrad(const fvMesh& mesh, Istream& is) + : + snGradScheme<Type>(mesh), + centralWeight_(readScalar(is)) + {} + + + // Destructor + + virtual ~quadraticFitSnGrad() {} + + + // Member Functions + + //- Return the interpolation weighting factors for the given field + virtual tmp<surfaceScalarField> deltaCoeffs + ( + const GeometricField<Type, fvPatchField, volMesh>& + ) const + { + return this->mesh().deltaCoeffs(); + } + + //- Return true if this scheme uses an explicit correction + virtual bool corrected() const + { + return true; + } + + //- Return the explicit correction to the quadraticFitSnGrad + // for the given field + virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > + correction(const GeometricField<Type, fvPatchField, volMesh>& vf) const + { + const fvMesh& mesh = this->mesh(); + + const quadraticFitSnGradData& qfd = quadraticFitSnGradData::New + ( + mesh, + centralWeight_ + ); + + const extendedStencil& stencil = qfd.stencil(); + const List<scalarList>& f = qfd.fit(); + + tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > sft + = stencil.weightedSum(vf, f); + + sft().dimensions() /= dimLength; + + return sft; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fv + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C new file mode 100644 index 0000000000000000000000000000000000000000..133f1e79332a307bb6cf73a57a9cdc30077a732f --- /dev/null +++ b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C @@ -0,0 +1,325 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "quadraticFitSnGradData.H" +#include "surfaceFields.H" +#include "volFields.H" +#include "SVD.H" +#include "syncTools.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(quadraticFitSnGradData, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::quadraticFitSnGradData::quadraticFitSnGradData +( + const fvMesh& mesh, + const scalar cWeight +) +: + MeshObject<fvMesh, quadraticFitSnGradData>(mesh), + centralWeight_(cWeight), + #ifdef SPHERICAL_GEOMETRY + dim_(2), + #else + dim_(mesh.nGeometricD()), + #endif + minSize_ + ( + dim_ == 1 ? 3 : + dim_ == 2 ? 6 : + dim_ == 3 ? 9 : 0 + ), + stencil_(mesh), + fit_(mesh.nInternalFaces()) +{ + if (debug) + { + Info << "Contructing quadraticFitSnGradData" << endl; + } + + // check input + if (centralWeight_ < 1 - SMALL) + { + FatalErrorIn("quadraticFitSnGradData::quadraticFitSnGradData") + << "centralWeight requested = " << centralWeight_ + << " should not be less than one" + << exit(FatalError); + } + + if (minSize_ == 0) + { + FatalErrorIn("quadraticFitSnGradData") + << " dimension must be 1,2 or 3, not" << dim_ << exit(FatalError); + } + + // store the polynomial size for each face to write out + surfaceScalarField snGradPolySize + ( + IOobject + ( + "quadraticFitSnGradPolySize", + "constant", + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("quadraticFitSnGradPolySize", dimless, scalar(0)) + ); + + // Get the cell/face centres in stencil order. + // Centred face stencils no good for triangles of tets. Need bigger stencils + List<List<point> > stencilPoints(stencil_.stencil().size()); + stencil_.collectData + ( + mesh.C(), + stencilPoints + ); + + // find the fit coefficients for every face in the mesh + + for(label faci = 0; faci < mesh.nInternalFaces(); faci++) + { + snGradPolySize[faci] = calcFit(stencilPoints[faci], faci); + } + + if (debug) + { + snGradPolySize.write(); + Info<< "quadraticFitSnGradData::quadraticFitSnGradData() :" + << "Finished constructing polynomialFit data" + << endl; + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::quadraticFitSnGradData::findFaceDirs +( + vector& idir, // value changed in return + vector& jdir, // value changed in return + vector& kdir, // value changed in return + const fvMesh& mesh, + const label faci +) +{ + idir = mesh.Sf()[faci]; + idir /= mag(idir); + + #ifndef SPHERICAL_GEOMETRY + if (mesh.nGeometricD() <= 2) // find the normal direcion + { + if (mesh.directions()[0] == -1) + { + kdir = vector(1, 0, 0); + } + else if (mesh.directions()[1] == -1) + { + kdir = vector(0, 1, 0); + } + else + { + kdir = vector(0, 0, 1); + } + } + else // 3D so find a direction in the place of the face + { + const face& f = mesh.faces()[faci]; + kdir = mesh.points()[f[0]] - mesh.points()[f[1]]; + } + #else + // Spherical geometry so kdir is the radial direction + kdir = mesh.Cf()[faci]; + #endif + + if (mesh.nGeometricD() == 3) + { + // Remove the idir component from kdir and normalise + kdir -= (idir & kdir)*idir; + + scalar magk = mag(kdir); + + if (magk < SMALL) + { + FatalErrorIn("findFaceDirs") << " calculated kdir = zero" + << exit(FatalError); + } + else + { + kdir /= magk; + } + } + + jdir = kdir ^ idir; +} + + +Foam::label Foam::quadraticFitSnGradData::calcFit +( + const List<point>& C, + const label faci +) +{ + vector idir(1,0,0); + vector jdir(0,1,0); + vector kdir(0,0,1); + findFaceDirs(idir, jdir, kdir, mesh(), faci); + + scalarList wts(C.size(), scalar(1)); + wts[0] = centralWeight_; + wts[1] = centralWeight_; + + point p0 = mesh().faceCentres()[faci]; + scalar scale = 0; + + // calculate the matrix of the polynomial components + scalarRectangularMatrix B(C.size(), minSize_, scalar(0)); + + for(label ip = 0; ip < C.size(); ip++) + { + const point& p = C[ip]; + + scalar px = (p - p0)&idir; + scalar py = (p - p0)&jdir; + #ifdef SPHERICAL_GEOMETRY + scalar pz = mag(p) - mag(p0); + #else + scalar pz = (p - p0)&kdir; + #endif + + if (ip == 0) scale = max(max(mag(px), mag(py)), mag(pz)); + + px /= scale; + py /= scale; + pz /= scale; + + label is = 0; + + B[ip][is++] = wts[0]*wts[ip]; + B[ip][is++] = wts[0]*wts[ip]*px; + B[ip][is++] = wts[ip]*sqr(px); + + if (dim_ >= 2) + { + B[ip][is++] = wts[ip]*py; + B[ip][is++] = wts[ip]*px*py; + B[ip][is++] = wts[ip]*sqr(py); + } + if (dim_ == 3) + { + B[ip][is++] = wts[ip]*pz; + B[ip][is++] = wts[ip]*px*pz; + //B[ip][is++] = wts[ip]*py*pz; + B[ip][is++] = wts[ip]*sqr(pz); + } + } + + // Set the fit + label stencilSize = C.size(); + fit_[faci].setSize(stencilSize); + scalarList singVals(minSize_); + label nSVDzeros = 0; + + const scalar& deltaCoeff = mesh().deltaCoeffs()[faci]; + + bool goodFit = false; + for(int iIt = 0; iIt < 10 && !goodFit; iIt++) + { + SVD svd(B, SMALL); + + scalar fit0 = wts[0]*wts[0]*svd.VSinvUt()[1][0]/scale; + scalar fit1 = wts[0]*wts[1]*svd.VSinvUt()[1][1]/scale; + + goodFit = + fit0 < 0 && fit1 > 0 + && mag(fit0 + deltaCoeff) < 0.5*deltaCoeff + && mag(fit1 - deltaCoeff) < 0.5*deltaCoeff; + + if (goodFit) + { + fit_[faci][0] = fit0; + fit_[faci][1] = fit1; + for(label i = 2; i < stencilSize; i++) + { + fit_[faci][i] = wts[0]*wts[i]*svd.VSinvUt()[1][i]/scale; + } + singVals = svd.S(); + nSVDzeros = svd.nZeros(); + } + else // (not good fit so increase weight in the centre and for linear) + { + wts[0] *= 10; + wts[1] *= 10; + + for(label i = 0; i < B.n(); i++) + { + B[i][0] *= 10; + B[i][1] *= 10; + } + + for(label j = 0; j < B.m(); j++) + { + B[0][j] *= 10; + B[1][j] *= 10; + } + } + } + + if (goodFit) + { + // remove the uncorrected snGradScheme coefficients + fit_[faci][0] += deltaCoeff; + fit_[faci][1] -= deltaCoeff; + } + else + { + Pout<< "quadratifFitSnGradData could not fit face " << faci + << " fit_[faci][0] = " << fit_[faci][0] + << " fit_[faci][1] = " << fit_[faci][1] + << " deltaCoeff = " << deltaCoeff << endl; + fit_[faci] = 0; + } + + return minSize_ - nSVDzeros; +} + +bool Foam::quadraticFitSnGradData::movePoints() +{ + notImplemented("quadraticFitSnGradData::movePoints()"); + + return true; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.H b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.H new file mode 100644 index 0000000000000000000000000000000000000000..0f5fda5ce6e7cbb82292da3ed5a5b57f4fd6f907 --- /dev/null +++ b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.H @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + quadraticFitSnGradData + +Description + Data for the quadratic fit correction snGrad scheme + +SourceFiles + quadraticFitSnGradData.C + +\*---------------------------------------------------------------------------*/ + +#ifndef quadraticFitSnGradData_H +#define quadraticFitSnGradData_H + +#include "MeshObject.H" +#include "fvMesh.H" +#include "extendedStencil.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class quadraticFitSnGradData Declaration +\*---------------------------------------------------------------------------*/ + +class quadraticFitSnGradData +: + public MeshObject<fvMesh, quadraticFitSnGradData> +{ + // Private data + + const scalar centralWeight_; + const label dim_; + + //- minimum stencil size + const label minSize_; + + //- Extended stencil addressing + extendedStencil stencil_; + + //- For each cell in the mesh store the values which multiply the + // values of the stencil to obtain the gradient for each direction + List<scalarList> fit_; + + + // Private member functions + + //- Find the normal direction and i, j and k directions for face faci + static void findFaceDirs + ( + vector& idir, // value changed in return + vector& jdir, // value changed in return + vector& kdir, // value changed in return + const fvMesh& mesh, + const label faci + ); + + label calcFit(const List<point>&, const label faci); + + +public: + + TypeName("quadraticFitSnGradData"); + + + // Constructors + + explicit quadraticFitSnGradData + ( + const fvMesh& mesh, + const scalar cWeight + ); + + + // Destructor + + virtual ~quadraticFitSnGradData() + {}; + + + // Member functions + + //- Return reference to the stencil + const extendedStencil& stencil() const + { + return stencil_; + } + + //- Return reference to fit coefficients + const List<scalarList>& fit() const { return fit_; } + + //- Delete the data when the mesh moves not implemented + virtual bool movePoints(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrads.C b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrads.C new file mode 100644 index 0000000000000000000000000000000000000000..aee4af29e3b58e3ccccd7476556c09ab0791dcb9 --- /dev/null +++ b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrads.C @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Simple central-difference snGrad scheme with quadratic fit correction from + a larger stencil. + +\*---------------------------------------------------------------------------*/ + +#include "quadraticFitSnGrad.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + makeSnGradScheme(quadraticFitSnGrad) +} +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.H b/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.H index 1d00972403ba61be4316d38f275300cd9eb190a0..ad2f4e1b0b0c98ff746733e2b247bbe8fc907ac3 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.H +++ b/src/finiteVolume/fvMesh/extendedStencil/extendedStencil.H @@ -123,9 +123,9 @@ public: List<List<T> >& stencilFld ) const; - //- Given weights interpolate vol field + //- Calculate weighted sum of vol field template<class Type> - tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > interpolate + tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > weightedSum ( const GeometricField<Type, fvPatchField, volMesh>& fld, const List<List<scalar> >& stencilWeights diff --git a/src/finiteVolume/fvMesh/extendedStencil/extendedStencilTemplates.C b/src/finiteVolume/fvMesh/extendedStencil/extendedStencilTemplates.C index a408621dc4c4fce2becbcc03eafa8ea82f2d62e5..31adb48392ac34d125b7592394ffc1b1d7f57ab6 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/extendedStencilTemplates.C +++ b/src/finiteVolume/fvMesh/extendedStencil/extendedStencilTemplates.C @@ -77,7 +77,7 @@ void Foam::extendedStencil::collectData template<class Type> Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> > -Foam::extendedStencil::interpolate +Foam::extendedStencil::weightedSum ( const GeometricField<Type, fvPatchField, volMesh>& fld, const List<List<scalar> >& stencilWeights @@ -120,7 +120,34 @@ Foam::extendedStencil::interpolate sf[faceI] += stField[i]*stWeight[i]; } } - // And what for boundaries? + + // Coupled boundaries + /* + typename GeometricField<Type, fvsPatchField, surfaceMesh>:: + GeometricBoundaryField& bSfCorr = sf.boundaryField(); + forAll(bSfCorr, patchi) + { + fvsPatchField<Type>& pSfCorr = bSfCorr[patchi]; + + if (pSfCorr.coupled()) + { + label faceI = pSfCorr.patch().patch().start(); + + forAll(pSfCorr, i) + { + const List<Type>& stField = stencilFld[faceI]; + const List<scalar>& stWeight = stencilWeights[faceI]; + + forAll(stField, j) + { + pSfCorr[i] += stField[j]*stWeight[j]; + } + + faceI++; + } + } + } + */ return tsfCorr; } diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.H index 412b454015dfcbecdea2752b4394ae4abc457dd9..9db4996862881c924150ceaf3bbc762087a955e4 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFit.H @@ -122,7 +122,7 @@ public: const extendedStencil& stencil = cfd.stencil(); const List<scalarList>& f = cfd.fit(); - return stencil.interpolate(vf, f); + return stencil.weightedSum(vf, f); } }; diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.C b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.C index 79f9107e97f61b4b9f77a364256dca9c021f3620..52cf371c70caf34814d99c9e32d2d13ff22df2e2 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/quadraticFit/quadraticFitData.C @@ -41,6 +41,8 @@ namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +static int count = 0; + Foam::quadraticFitData::quadraticFitData ( const fvMesh& mesh, @@ -114,13 +116,15 @@ Foam::quadraticFitData::quadraticFitData interpPolySize[faci] = calcFit(stencilPoints[faci], faci); } - interpPolySize.write(); + Pout<< "count = " << count << endl; if (debug) { Info<< "quadraticFitData::quadraticFitData() :" << "Finished constructing polynomialFit data" << endl; + + interpPolySize.write(); } } @@ -270,8 +274,8 @@ Foam::label Foam::quadraticFitData::calcFit //goodFit = (fit0 > 0 && fit1 > 0); goodFit = - (mag(fit0 - w[faci])/w[faci] < 0.5) - && (mag(fit1 - (1 - w[faci]))/(1 - w[faci]) < 0.5); + (mag(fit0 - w[faci])/w[faci] < 0.15) + && (mag(fit1 - (1 - w[faci]))/(1 - w[faci]) < 0.15); //scalar w0Err = fit0/w[faci]; //scalar w1Err = fit1/(1 - w[faci]); @@ -312,11 +316,21 @@ Foam::label Foam::quadraticFitData::calcFit } } - //static const scalar alpha = 1.5; - //static const scalar beta = alpha/0.5; + // static const scalar L = 0.1; + // static const scalar R = 0.2; + + // static const scalar beta = 1.0/(R - L); + // static const scalar alpha = R*beta; if (goodFit) { + if ((mag(fit_[faci][0] - w[faci])/w[faci] < 0.15) + && (mag(fit_[faci][1] - (1 - w[faci]))/(1 - w[faci]) < 0.15)) + { + count++; + //Pout<< "fit " << mag(fit_[faci][0] - w[faci])/w[faci] << " " << mag(fit_[faci][1] - (1 - w[faci]))/(1 - w[faci]) << endl; + } + // scalar limiter = // max // ( diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C index 5fe3aa163338046abc340b06ba6cb41fb0b910e9..d7b2f2b9695f700644a169cb312ca1e051517e00 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C @@ -57,6 +57,7 @@ void Foam::ReactingParcel<ParcelType>::calcCoupled // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const vector U0 = this->U_; const scalar mass0 = this->mass(); + const scalar cp0 = this->cp_; const scalar np0 = this->nParticle_; const scalar T0 = this->T_; @@ -116,11 +117,11 @@ void Foam::ReactingParcel<ParcelType>::calcCoupled T1 -= td.constProps().Ldevol() *sum(dMassMT) - /(0.5*(mass0 + mass1)*this->cp_); + /(0.5*(mass0 + mass1)*cp0); // Add retained enthalpy from surface reaction to particle and remove // from gas - T1 += dhRet/(0.5*(mass0 + mass1)*this->cp_); + T1 += dhRet/(0.5*(mass0 + mass1)*cp0); dhTrans -= dhRet; // Correct dhTrans to account for enthalpy of evolved volatiles diff --git a/src/postProcessing/Allwmake b/src/postProcessing/Allwmake index 1d889e8b76f7d90c636e8f8d7a6a1a6616925a48..e1f7cc56d8290d962530cc3667457b174a6181ea 100755 --- a/src/postProcessing/Allwmake +++ b/src/postProcessing/Allwmake @@ -7,5 +7,6 @@ wmake libso forces wmake libso fieldAverage wmake libso foamCalcFunctions wmake libso minMaxFields +wmake libso systemCall # ----------------------------------------------------------------- end-of-file diff --git a/src/postProcessing/forces/Make/options b/src/postProcessing/forces/Make/options index 929d4c25d15f82207388b9503672aea0d2bcbc6b..3ae6adad4ed07c9da403e68843a740fbfa986cd4 100644 --- a/src/postProcessing/forces/Make/options +++ b/src/postProcessing/forces/Make/options @@ -11,6 +11,7 @@ EXE_INC = \ LIB_LIBS = \ -lfiniteVolume \ -lmeshTools \ + -lsampling \ -lincompressibleTransportModels \ -lincompressibleRASModels \ -lincompressibleLESModels \ diff --git a/src/postProcessing/forces/forces/forces.C b/src/postProcessing/forces/forces/forces.C index 17254aec3d04aee759a98c0348bdfd1d23d95463..d3db7ed56915170aa112849afc3776e5fec338db 100644 --- a/src/postProcessing/forces/forces/forces.C +++ b/src/postProcessing/forces/forces/forces.C @@ -81,7 +81,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const const basicThermo& thermo = obr_.lookupObject<basicThermo>("thermophysicalProperties"); - const volVectorField& U = obr_.lookupObject<volVectorField>(Uname_); + const volVectorField& U = obr_.lookupObject<volVectorField>(UName_); return -thermo.mu()*dev(twoSymm(fvc::grad(U))); } @@ -94,7 +94,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const obr_.lookupObject<singlePhaseTransportModel> ("transportProperties"); - const volVectorField& U = obr_.lookupObject<volVectorField>(Uname_); + const volVectorField& U = obr_.lookupObject<volVectorField>(UName_); return -rhoRef_*laminarT.nu()*dev(twoSymm(fvc::grad(U))); } @@ -105,7 +105,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const dimensionedScalar nu(transportProperties.lookup("nu")); - const volVectorField& U = obr_.lookupObject<volVectorField>(Uname_); + const volVectorField& U = obr_.lookupObject<volVectorField>(UName_); return -rhoRef_*nu*dev(twoSymm(fvc::grad(U))); } @@ -149,7 +149,7 @@ Foam::forces::forces log_(false), patchSet_(), pName_(""), - Uname_(""), + UName_(""), rhoRef_(0), CofR_(vector::zero), forcesFilePtr_(NULL) @@ -190,18 +190,18 @@ void Foam::forces::read(const dictionary& dict) // Optional entries U and p pName_ = dict.lookupOrDefault<word>("pName", "p"); - Uname_ = dict.lookupOrDefault<word>("Uname", "U"); + UName_ = dict.lookupOrDefault<word>("UName", "U"); - // Check whether Uname and pName exists, if not deactivate forces + // Check whether UName and pName exists, if not deactivate forces if ( - !obr_.foundObject<volVectorField>(Uname_) + !obr_.foundObject<volVectorField>(UName_) || !obr_.foundObject<volScalarField>(pName_) ) { active_ = false; WarningIn("void forces::read(const dictionary& dict)") - << "Could not find " << Uname_ << " or " + << "Could not find " << UName_ << " or " << pName_ << " in database." << nl << " De-activating forces." << endl; @@ -299,7 +299,7 @@ void Foam::forces::write() Foam::forces::forcesMoments Foam::forces::calcForcesMoment() const { - const volVectorField& U = obr_.lookupObject<volVectorField>(Uname_); + const volVectorField& U = obr_.lookupObject<volVectorField>(UName_); const volScalarField& p = obr_.lookupObject<volScalarField>(pName_); const fvMesh& mesh = U.mesh(); diff --git a/src/postProcessing/forces/forces/forces.H b/src/postProcessing/forces/forces/forces.H index 285a0acea11d84d9176a575ec6d61ef09774a151..35b1bdf0341d41b4071b923b8e85b6db96d4858f 100644 --- a/src/postProcessing/forces/forces/forces.H +++ b/src/postProcessing/forces/forces/forces.H @@ -130,7 +130,7 @@ protected: word pName_; //- Name of velocity field - word Uname_; + word UName_; //- Reference density needed for incompressible calculations scalar rhoRef_; diff --git a/src/postProcessing/minMaxFields/Make/options b/src/postProcessing/minMaxFields/Make/options index 0954a90689826c4634362b58d14d8a3c34d37a03..5166bcc9e32f547f48a5f87c9c60d7210409967f 100644 --- a/src/postProcessing/minMaxFields/Make/options +++ b/src/postProcessing/minMaxFields/Make/options @@ -5,4 +5,5 @@ EXE_INC = \ LIB_LIBS = \ -lfiniteVolume \ - -lmeshTools + -lmeshTools \ + -lsampling diff --git a/src/postProcessing/systemCall/IOsystemCall.H b/src/postProcessing/systemCall/IOsystemCall.H new file mode 100644 index 0000000000000000000000000000000000000000..fff6e7dbdb456159fdedd0c585a755eae1fc410c --- /dev/null +++ b/src/postProcessing/systemCall/IOsystemCall.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Typedef + Foam::IOsystemCall + +Description + Instance of the generic IOOutputFilter for systemCall. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOsystemCall_H +#define IOsystemCall_H + +#include "systemCall.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter<systemCall> IOsystemCall; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/systemCall/Make/files b/src/postProcessing/systemCall/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..20bafa8dfa02102e3336118b2eeb385fff6114a5 --- /dev/null +++ b/src/postProcessing/systemCall/Make/files @@ -0,0 +1,4 @@ +systemCall.C +systemCallFunctionObject.C + +LIB = $(FOAM_LIBBIN)/libsystemCall diff --git a/src/postProcessing/systemCall/Make/options b/src/postProcessing/systemCall/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..5166bcc9e32f547f48a5f87c9c60d7210409967f --- /dev/null +++ b/src/postProcessing/systemCall/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -lsampling diff --git a/src/postProcessing/systemCall/systemCall.C b/src/postProcessing/systemCall/systemCall.C new file mode 100644 index 0000000000000000000000000000000000000000..b1756776c500a61ce8fc12d812675fdf455919f7 --- /dev/null +++ b/src/postProcessing/systemCall/systemCall.C @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "systemCall.H" +#include "dictionary.H" +#include "Time.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(systemCall, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::systemCall::systemCall +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + executeCalls_(), + writeCalls_() +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::systemCall::~systemCall() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::systemCall::read(const dictionary& dict) +{ + dict.lookup("executeCalls") >> executeCalls_; + dict.lookup("writeCalls") >> writeCalls_; +} + + +void Foam::systemCall::execute() +{ + forAll(executeCalls_, callI) + { + ::system(executeCalls_[callI].c_str()); + } +} + +void Foam::systemCall::write() +{ + forAll(writeCalls_, callI) + { + ::system(writeCalls_[callI].c_str()); + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/systemCall/systemCall.H b/src/postProcessing/systemCall/systemCall.H new file mode 100644 index 0000000000000000000000000000000000000000..1d070cd6a9951135be34c940046bbc16fb7785cc --- /dev/null +++ b/src/postProcessing/systemCall/systemCall.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::systemCall + +Description + Executes system calls, entered in the form of a string list + +SourceFiles + systemCall.C + IOsystemCall.H + +\*---------------------------------------------------------------------------*/ + +#ifndef systemCall_H +#define systemCall_H + +#include "stringList.H" +#include "pointFieldFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class systemCall Declaration +\*---------------------------------------------------------------------------*/ + +class systemCall +{ +protected: + + // Private data + + //- Name of this set of forces, + // Also used as the name of the probes directory. + word name_; + + const objectRegistry& obr_; + + //- on/off switch + bool active_; + + //- List of calls to execute - every step + stringList executeCalls_; + + //- List of calls to execute - write steps + stringList writeCalls_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + systemCall(const systemCall&); + + //- Disallow default bitwise assignment + void operator=(const systemCall&); + + +public: + + //- Runtime type information + TypeName("systemCall"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + systemCall + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + // Destructor + + virtual ~systemCall(); + + + // Member Functions + + //- Return name of the system call set + virtual const word& name() const + { + return name_; + } + + //- Read the system calls + virtual void read(const dictionary&); + + //- Execute + virtual void execute(); + + //- Write + virtual void write(); + + //- Update for changes of mesh + virtual void updateMesh(const mapPolyMesh&) + {} + + //- Update for changes of mesh + virtual void movePoints(const pointField&) + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/systemCall/systemCallFunctionObject.C b/src/postProcessing/systemCall/systemCallFunctionObject.C new file mode 100644 index 0000000000000000000000000000000000000000..6e6b2e646bb16a82e1a42f82571220e4b94f3b76 --- /dev/null +++ b/src/postProcessing/systemCall/systemCallFunctionObject.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "systemCallFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(systemCallFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + systemCallFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/systemCall/systemCallFunctionObject.H b/src/postProcessing/systemCall/systemCallFunctionObject.H new file mode 100644 index 0000000000000000000000000000000000000000..6f8b6ba63531a7695cec8048c9dc7415b45d1de9 --- /dev/null +++ b/src/postProcessing/systemCall/systemCallFunctionObject.H @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Typedef + Foam::systemCallFunctionObject + +Description + FunctionObject wrapper around systemCall to allow them to be created via + the functions list within controlDict. + +SourceFiles + systemCallFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef systemCallFunctionObject_H +#define systemCallFunctionObject_H + +#include "systemCall.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject<systemCall> + systemCallFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/LES/incompressible/Make/files b/src/turbulenceModels/LES/incompressible/Make/files index 796bbee6a0070d16a9464befb7a318d71a676899..b6c245c866bb81e3c6767c2f6fbde1823bd0c430 100644 --- a/src/turbulenceModels/LES/incompressible/Make/files +++ b/src/turbulenceModels/LES/incompressible/Make/files @@ -8,6 +8,9 @@ GenSGSStress/GenSGSStress.C laminar/laminar.C SpalartAllmaras/SpalartAllmaras.C +SpalartAllmarasDDES/SpalartAllmarasDDES.C +SpalartAllmarasIDDES/SpalartAllmarasIDDES.C +SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C oneEqEddy/oneEqEddy.C dynOneEqEddy/dynOneEqEddy.C diff --git a/src/turbulenceModels/LES/incompressible/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/LES/incompressible/SpalartAllmaras/SpalartAllmaras.C index 6dd450c312948e6a496a5c2c998dfbf13c672a3a..9d5ad49bdd2dda666fe7ad4d9e3f3b4d372fc8ab 100644 --- a/src/turbulenceModels/LES/incompressible/SpalartAllmaras/SpalartAllmaras.C +++ b/src/turbulenceModels/LES/incompressible/SpalartAllmaras/SpalartAllmaras.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,8 +42,7 @@ namespace LESModels defineTypeNameAndDebug(SpalartAllmaras, 0); addToRunTimeSelectionTable(LESModel, SpalartAllmaras, dictionary); - -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // tmp<volScalarField> SpalartAllmaras::fv1() const { @@ -55,7 +54,6 @@ tmp<volScalarField> SpalartAllmaras::fv1() const tmp<volScalarField> SpalartAllmaras::fv2() const { volScalarField chi = nuTilda_/nu(); - //return scalar(1) - chi/(scalar(1) + chi*fv1()); return 1.0/pow3(scalar(1) + chi/Cv2_); } @@ -73,18 +71,57 @@ tmp<volScalarField> SpalartAllmaras::fv3() const } -tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& Stilda) const +tmp<volScalarField> SpalartAllmaras::calcS(const volTensorField& gradU) +{ + return ::sqrt(2.0)*mag(skew(gradU)); +} + + +tmp<volScalarField> SpalartAllmaras::calcSTilda(const volTensorField& gradU) +{ + return fv3()*calcS(gradU) + fv2()*nuTilda_/sqr(kappa_*dTilda_); +} + + +tmp<volScalarField> SpalartAllmaras::r +( + const volScalarField& visc, + const volScalarField& S +) const { - volScalarField r = min + tmp<volScalarField> tr ( - nuTilda_ - /( - max(Stilda, dimensionedScalar("SMALL", Stilda.dimensions(), SMALL)) - *sqr(kappa_*dTilda_) - ), - scalar(10.0) + new volScalarField + ( + min + ( + visc + /( + max + ( + S, + dimensionedScalar("SMALL", S.dimensions(), SMALL) + ) + *sqr(kappa_*dTilda_) + + dimensionedScalar + ( + "ROOTVSMALL", + dimensionSet(0, 2 , -1, 0, 0), + ROOTVSMALL + ) + ), + scalar(10.0) + ) + ) ); - r.boundaryField() == 0.0; + + return tr; +} + + +tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& S) const +{ + volScalarField r = this->r(nuTilda_, S); volScalarField g = r + Cw2_*(pow6(r) - r); @@ -92,17 +129,26 @@ tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& Stilda) const } +void SpalartAllmaras::dTildaUpdate(const volScalarField&) +{ + if (mesh_.changing()) + { + dTilda_ = min(CDES_*delta(), wallDist(mesh_).y()); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // SpalartAllmaras::SpalartAllmaras ( const volVectorField& U, const surfaceScalarField& phi, - transportModel& transport + transportModel& transport, + const word& modelName ) : - LESModel(typeName, U, phi, transport), - + LESModel(modelName, U, phi, transport), alphaNut_ ( @@ -113,6 +159,15 @@ SpalartAllmaras::SpalartAllmaras 1.5 ) ), + kappa_ + ( + dimensioned<scalar>::lookupOrAddToDict + ( + "kappa", + *this, + 0.4187 + ) + ), Cb1_ ( dimensioned<scalar>::lookupOrAddToDict @@ -167,15 +222,6 @@ SpalartAllmaras::SpalartAllmaras 0.07 ) ), - kappa_ - ( - dimensioned<scalar>::lookupOrAddToDict - ( - "kappa", - *this, - 0.4187 - ) - ), Cw1_(Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_)), Cw2_ ( @@ -223,10 +269,7 @@ SpalartAllmaras::SpalartAllmaras ), mesh_ ) -{ - printCoeffs(); -} - +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -234,13 +277,11 @@ void SpalartAllmaras::correct(const tmp<volTensorField>& gradU) { LESModel::correct(gradU); - if (mesh_.changing()) - { - dTilda_ = min(CDES_*delta(), wallDist(mesh_).y()); - } + const volScalarField STilda = calcSTilda(gradU); - volScalarField Stilda = - fv3()*::sqrt(2.0)*mag(skew(gradU)) + fv2()*nuTilda_/sqr(kappa_*dTilda_); + const volScalarField S = calcS(gradU); + + dTildaUpdate(S); solve ( @@ -254,8 +295,8 @@ void SpalartAllmaras::correct(const tmp<volTensorField>& gradU) ) - alphaNut_*Cb2_*magSqr(fvc::grad(nuTilda_)) == - Cb1_*Stilda*nuTilda_ - - fvm::Sp(Cw1_*fw(Stilda)*nuTilda_/sqr(dTilda_), nuTilda_) + Cb1_*STilda*nuTilda_ + - fvm::Sp(Cw1_*fw(STilda)*nuTilda_/sqr(dTilda_), nuTilda_) ); bound(nuTilda_, dimensionedScalar("zero", nuTilda_.dimensions(), 0.0)); @@ -268,7 +309,7 @@ void SpalartAllmaras::correct(const tmp<volTensorField>& gradU) tmp<volScalarField> SpalartAllmaras::epsilon() const { - return 2*nuEff()*magSqr(symm(fvc::grad(U()))); + return 2.0*nuEff()*magSqr(symm(fvc::grad(U()))); } @@ -298,16 +339,16 @@ bool SpalartAllmaras::read() if (LESModel::read()) { alphaNut_.readIfPresent(coeffDict()); + kappa_.readIfPresent(*this); Cb1_.readIfPresent(coeffDict()); Cb2_.readIfPresent(coeffDict()); - Cw1_ = Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_); - Cw2_.readIfPresent(coeffDict()); - Cw3_.readIfPresent(coeffDict()); Cv1_.readIfPresent(coeffDict()); Cv2_.readIfPresent(coeffDict()); CDES_.readIfPresent(coeffDict()); ck_.readIfPresent(coeffDict()); - kappa_.readIfPresent(*this); + Cw1_ = Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_); + Cw2_.readIfPresent(coeffDict()); + Cw3_.readIfPresent(coeffDict()); return true; } diff --git a/src/turbulenceModels/LES/incompressible/SpalartAllmaras/SpalartAllmaras.H b/src/turbulenceModels/LES/incompressible/SpalartAllmaras/SpalartAllmaras.H index 523da4611c665213e53fb11d44d8781f07919055..1bcecd018ff52a25ad4a5f87f4becbe072c8ef11 100644 --- a/src/turbulenceModels/LES/incompressible/SpalartAllmaras/SpalartAllmaras.H +++ b/src/turbulenceModels/LES/incompressible/SpalartAllmaras/SpalartAllmaras.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,10 +23,10 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::incompressible::LESModels::SpalartAllmaras + Foam::LESmodels::SpalartAllmaras Description - SpalartAllmaras for incompressible flows + SpalartAllmaras DES (SA + LES) turbulence model for incompressible flows SourceFiles SpalartAllmaras.C @@ -49,43 +49,67 @@ namespace LESModels { /*---------------------------------------------------------------------------*\ - Class SpalartAllmaras Declaration + Class SpalartAllmaras Declaration \*---------------------------------------------------------------------------*/ class SpalartAllmaras : public LESModel { - // Private data + // Private member functions - dimensionedScalar alphaNut_; + // Disallow default bitwise copy construct and assignment + SpalartAllmaras(const SpalartAllmaras&); + SpalartAllmaras& operator=(const SpalartAllmaras&); - dimensionedScalar Cb1_; - dimensionedScalar Cb2_; - dimensionedScalar Cv1_; - dimensionedScalar Cv2_; - dimensionedScalar CDES_; - dimensionedScalar ck_; + +protected: + + // Protected data + + dimensionedScalar alphaNut_; dimensionedScalar kappa_; - dimensionedScalar Cw1_; - dimensionedScalar Cw2_; - dimensionedScalar Cw3_; - // Private member functions + // Model constants - tmp<volScalarField> fv1() const; - tmp<volScalarField> fv2() const; - tmp<volScalarField> fv3() const; - tmp<volScalarField> fw(const volScalarField& Stilda) const; + dimensionedScalar Cb1_; + dimensionedScalar Cb2_; + dimensionedScalar Cv1_; + dimensionedScalar Cv2_; + dimensionedScalar CDES_; + dimensionedScalar ck_; + dimensionedScalar Cw1_; + dimensionedScalar Cw2_; + dimensionedScalar Cw3_; - // Disallow default bitwise copy construct and assignment - SpalartAllmaras(const SpalartAllmaras&); - SpalartAllmaras& operator=(const SpalartAllmaras&); - volScalarField nuTilda_; - volScalarField dTilda_; - volScalarField nuSgs_; + // Fields + + volScalarField nuTilda_; + volScalarField dTilda_; + volScalarField nuSgs_; + + + // Protected member functions + + // Helper functions + + virtual tmp<volScalarField> fv1() const; + virtual tmp<volScalarField> fv2() const; + virtual tmp<volScalarField> fv3() const; + //- + virtual tmp<volScalarField> calcS(const volTensorField& gradU); + virtual tmp<volScalarField> calcSTilda(const volTensorField& gradU); + virtual tmp<volScalarField> r + ( + const volScalarField& visc, + const volScalarField& S + ) const; + virtual tmp<volScalarField> fw(const volScalarField& S) const; + + //- Length scale calculation + virtual void dTildaUpdate(const volScalarField& S); public: @@ -101,13 +125,14 @@ public: ( const volVectorField& U, const surfaceScalarField& phi, - transportModel& transport + transportModel& transport, + const word& modelName = typeName ); // Destructor - ~SpalartAllmaras() + virtual ~SpalartAllmaras() {} @@ -145,10 +170,10 @@ public: tmp<fvVectorMatrix> divDevBeff(volVectorField& U) const; //- Correct nuTilda and related properties - void correct(const tmp<volTensorField>& gradU); + virtual void correct(const tmp<volTensorField>& gradU); //- Read turbulenceProperties dictionary - bool read(); + virtual bool read(); }; diff --git a/src/turbulenceModels/LES/incompressible/SpalartAllmarasDDES/SpalartAllmarasDDES.C b/src/turbulenceModels/LES/incompressible/SpalartAllmarasDDES/SpalartAllmarasDDES.C new file mode 100644 index 0000000000000000000000000000000000000000..6f5435a2681eca7e0a7587a33d319bbad43b934e --- /dev/null +++ b/src/turbulenceModels/LES/incompressible/SpalartAllmarasDDES/SpalartAllmarasDDES.C @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "SpalartAllmarasDDES.H" +#include "addToRunTimeSelectionTable.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(SpalartAllmarasDDES, 0); +addToRunTimeSelectionTable(LESModel, SpalartAllmarasDDES, dictionary); + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp<volScalarField> SpalartAllmarasDDES::rd +( + const volScalarField& visc, + const volScalarField& S +) const +{ + volScalarField d = wallDist(mesh_).y(); + + tmp<volScalarField> trd + ( + new volScalarField + ( + min + ( + visc + /( + max + ( + S, + dimensionedScalar("SMALL", S.dimensions(), SMALL) + )*sqr(kappa_*d) + + dimensionedScalar + ( + "ROOTVSMALL", + dimensionSet(0, 2 , -1, 0, 0), + ROOTVSMALL + ) + ), scalar(10.0) + ) + ) + ); + + return trd; +} + + +tmp<volScalarField> SpalartAllmarasDDES::fd(const volScalarField& S) +{ + return 1.0 - tanh(pow3(8.0*rd(nuSgs_ + transport().nu(), S))); +} + + +void SpalartAllmarasDDES::dTildaUpdate(const volScalarField& S) +{ + dTilda_ = + wallDist(mesh_).y() + - fd(S)*max + ( + dimensionedScalar("zero", dimLength, 0.0), + wallDist(mesh_).y() - CDES_*delta() + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +SpalartAllmarasDDES::SpalartAllmarasDDES +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + SpalartAllmaras(U, phi, transport, typeName) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/LES/incompressible/SpalartAllmarasDDES/SpalartAllmarasDDES.H b/src/turbulenceModels/LES/incompressible/SpalartAllmarasDDES/SpalartAllmarasDDES.H new file mode 100644 index 0000000000000000000000000000000000000000..d905c34710d36c3804a2cd41619f616ba954220d --- /dev/null +++ b/src/turbulenceModels/LES/incompressible/SpalartAllmarasDDES/SpalartAllmarasDDES.H @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::LESmodels::SpalartAllmarasDDES + +Description + SpalartAllmaras DDES LES turbulence model for incompressible flows + + Reference: + P.R. Spalart, S. Deck, S., M.L.Shur, K.D. Squires, M.Kh Strelets, and + A. Travin. `A new version of detached-eddy simulation, resistant to + ambiguous grid densities'. Theor. Comp. Fluid Dyn., 20:181-195, 2006. + +SourceFiles + SpalartAllmarasDDES.C + +\*---------------------------------------------------------------------------*/ + +#ifndef SpalartAllmarasDDES_H +#define SpalartAllmarasDDES_H + +#include "SpalartAllmaras.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class SpalartAllmarasDDES Declaration +\*---------------------------------------------------------------------------*/ + +class SpalartAllmarasDDES +: + public SpalartAllmaras +{ + // Private member functions + + // Disallow default bitwise copy construct and assignment + SpalartAllmarasDDES(const SpalartAllmarasDDES&); + SpalartAllmarasDDES& operator=(const SpalartAllmarasDDES&); + + +protected: + + // Protected member functions + + tmp<volScalarField> fd(const volScalarField& S); + tmp<volScalarField> rd + ( + const volScalarField& visc, + const volScalarField& S + ) const; + + //- Length scale calculation + virtual void dTildaUpdate(const volScalarField& S); + + +public: + + //- Runtime type information + TypeName("SpalartAllmarasDDES"); + + + // Constructors + + //- Constructor from components + SpalartAllmarasDDES + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + //- Destructor + virtual ~SpalartAllmarasDDES() + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C b/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C new file mode 100644 index 0000000000000000000000000000000000000000..36e6a46a4ebdef8f936a2f3023c4835d8a1048d0 --- /dev/null +++ b/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "IDDESDelta.H" +#include "addToRunTimeSelectionTable.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(IDDESDelta, 0); + addToRunTimeSelectionTable(LESdelta, IDDESDelta, dictionary); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::IDDESDelta::calcDelta() +{ + const Vector<label>& directions = mesh().directions(); + label nD = (directions.nComponents + cmptSum(directions))/2; + + // - Init hwn as wall distant. + volScalarField hwn = wallDist(mesh()).y(); + + scalar deltamaxTmp = 0.; + + const cellList& cells = mesh().cells(); + + forAll(cells,cellI) + { + scalar deltaminTmp = 1.e10; + const labelList& cFaces = mesh().cells()[cellI]; + const point& centrevector = mesh().cellCentres()[cellI]; + + forAll(cFaces, cFaceI) + { + label faceI = cFaces[cFaceI]; + const point& facevector = mesh().faceCentres()[faceI]; + scalar tmp = mag(facevector-centrevector); + if (tmp > deltamaxTmp) + { + deltamaxTmp = tmp; + } + if (tmp < deltaminTmp) + { + deltaminTmp = tmp; + } + } + hwn[cellI] = 2.0*deltaminTmp; + } + + dimensionedScalar deltamax("deltamax",dimLength,2.0*deltamaxTmp); + + if (nD == 3) + { + delta_.internalField() = + deltaCoeff_ + *min(max(max(cw_*wallDist(mesh()).y(),cw_*deltamax),hwn),deltamax); + } + else if (nD == 2) + { + WarningIn("IDDESDelta::calcDelta()") + << "Case is 2D, LES is not strictly applicable\n" + << endl; + + delta_.internalField() = + deltaCoeff_ + *min(max(max(cw_*wallDist(mesh()).y(),cw_*deltamax),hwn),deltamax); + } + else + { + FatalErrorIn("IDDESDelta::calcDelta()") + << "Case is not 3D or 2D, LES is not applicable" + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::IDDESDelta::IDDESDelta +( + const word& name, + const fvMesh& mesh, + const dictionary& dd +) +: + LESdelta(name, mesh), + deltaCoeff_(readScalar(dd.subDict(type() + "Coeffs").lookup("deltaCoeff"))), + cw_(0) +{ + dd.subDict(type() + "Coeffs").readIfPresent("cw", cw_); + calcDelta(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::IDDESDelta::read(const dictionary& dd) +{ + dd.subDict(type() + "Coeffs").lookup("deltaCoeff") >> deltaCoeff_; + calcDelta(); +} + + +void Foam::IDDESDelta::correct() +{ + if (mesh_.changing()) + { + calcDelta(); + } +} + + +// ************************************************************************* // diff --git a/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.H b/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.H new file mode 100644 index 0000000000000000000000000000000000000000..a53d1127d284b0019b281dc4385469b00ab42c00 --- /dev/null +++ b/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.H @@ -0,0 +1,113 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::IDDESDelta + +Description + IDDESDelta used by the IDDES (improved low Re Spalart-Allmaras DES model) + The min and max delta are calculated using the double distance of the min or + max from the face centre to the cell centre. + +SourceFiles + IDDESDelta.C + +\*---------------------------------------------------------------------------*/ + +#ifndef IDDESDeltaDelta_H +#define IDDESDeltaDelta_H + +#include "LESdelta.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class IDDESDelta Declaration +\*---------------------------------------------------------------------------*/ + +class IDDESDelta +: + public LESdelta +{ + // Private data + + scalar deltaCoeff_; + scalar cw_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct and assignment + IDDESDelta(const IDDESDelta&); + void operator=(const IDDESDelta&); + + //- Calculate the delta values + void calcDelta(); + + +public: + + //- Runtime type information + TypeName("IDDESDelta"); + + + // Constructors + + //- Construct from name, mesh and IOdictionary + IDDESDelta + ( + const word& name, + const fvMesh& mesh, + const dictionary& + ); + + + // Destructor + + ~IDDESDelta() + {} + + + // Member Functions + + //- Read the LESdelta dictionary + void read(const dictionary&); + + // Correct values + void correct(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C b/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C new file mode 100644 index 0000000000000000000000000000000000000000..b58c9557d44a8823dec6c674f0f223c3a037a379 --- /dev/null +++ b/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C @@ -0,0 +1,214 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "SpalartAllmarasIDDES.H" +#include "addToRunTimeSelectionTable.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(SpalartAllmarasIDDES, 0); +addToRunTimeSelectionTable(LESModel, SpalartAllmarasIDDES, dictionary); + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +tmp<volScalarField> SpalartAllmarasIDDES::alpha() const +{ + return + 0.25 + - wallDist(mesh_).y() + /dimensionedScalar("hMax", dimLength, max(cmptMax(delta()))); +} + + +tmp<volScalarField> SpalartAllmarasIDDES::ft(const volScalarField& S) const +{ + return tanh(pow3(sqr(ct_)*r(nuSgs_, S))); +} + + +tmp<volScalarField> SpalartAllmarasIDDES::fl(const volScalarField& S) const +{ + return tanh(pow(sqr(cl_)*r(transport().nu(), S), 10)); +} + + +tmp<volScalarField> SpalartAllmarasIDDES::rd +( + const volScalarField& visc, + const volScalarField& S +) const +{ + volScalarField d = wallDist(mesh_).y(); + + tmp<volScalarField> trd + ( + new volScalarField + ( + min + ( + visc + /( + max + ( + S, + dimensionedScalar("SMALL", S.dimensions(), SMALL) + )*sqr(kappa_*d) + + dimensionedScalar + ( + "ROOTVSMALL", + dimensionSet(0, 2 , -1, 0, 0), + ROOTVSMALL + ) + ), scalar(10.0) + ) + ) + ); + + return trd; +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp<volScalarField> SpalartAllmarasIDDES::fd(const volScalarField& S) const +{ + return 1.0 - tanh(pow3(8.0*rd(nuSgs_+transport().nu(), S))); +} + + +void SpalartAllmarasIDDES::dTildaUpdate(const volScalarField& S) +{ + volScalarField alpha = this->alpha(); + + volScalarField expTerm = exp(sqr(alpha)); + + volScalarField fHill = + 2.0*(pos(alpha)*pow(expTerm, -11.09) + neg(alpha)*pow(expTerm, -9.0)); + + + volScalarField fStep = min(2.0*pow(expTerm, -9.0), 1.0); + volScalarField fHyb = max(1.0 - fd(S), fStep); + + volScalarField fAmp = 1.0 - max(ft(S), fl(S)); + + volScalarField fRestore = max(fHill - 1.0, 0.0)*fAmp; + + // volScalarField ft2 = IGNORING ft2 terms + + volScalarField Psi = sqrt + ( + min + ( + 100.0, + (1.0 - Cb1_/(Cw1_*sqr(kappa_)*fwStar_)*fv2())/max(SMALL, fv1()) + ) + ); + + dTilda_ = max + ( + dimensionedScalar("zero", dimLength, 0.0), + fHyb*(1.0 + fRestore*Psi)*wallDist(mesh_).y() + + (1.0 - fHyb)*CDES_*Psi*delta() + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +SpalartAllmarasIDDES::SpalartAllmarasIDDES +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + SpalartAllmaras(U, phi, transport, typeName), + + fwStar_ + ( + dimensioned<scalar>::lookupOrAddToDict + ( + "fwStar", + coeffDict(), + 0.424 + ) + ), + cl_ + ( + dimensioned<scalar>::lookupOrAddToDict + ( + "cl", + coeffDict(), + 3.55 + ) + ), + ct_ + ( + dimensioned<scalar>::lookupOrAddToDict + ( + "ct", + coeffDict(), + 1.63 + ) + ) + +{} + + +bool SpalartAllmarasIDDES::read() +{ + if (SpalartAllmaras::read()) + { + fwStar_.readIfPresent(coeffDict()); + cl_.readIfPresent(coeffDict()); + ct_.readIfPresent(coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H b/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H new file mode 100644 index 0000000000000000000000000000000000000000..d07b53672c007929893e099ce2ef8c6b7b04a428 --- /dev/null +++ b/src/turbulenceModels/LES/incompressible/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::LESmodels::SpalartAllmarasIDDES + +Description + SpalartAllmarasIDDES LES turbulence model for incompressible flows + +SourceFiles + SpalartAllmarasIDDES.C + +\*---------------------------------------------------------------------------*/ + +#ifndef SpalartAllmarasIDDES_H +#define SpalartAllmarasIDDES_H + +#include "SpalartAllmaras.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class SpalartAllmarasIDDES Declaration +\*---------------------------------------------------------------------------*/ + +class SpalartAllmarasIDDES +: + public SpalartAllmaras +{ + // Private data + + // Model constants + + dimensionedScalar fwStar_; + dimensionedScalar cl_; + dimensionedScalar ct_; + + + // Private member functions + + tmp<volScalarField> alpha() const; + tmp<volScalarField> ft(const volScalarField& S) const; + tmp<volScalarField> fl(const volScalarField& S) const; + tmp<volScalarField> rd + ( + const volScalarField& visc, + const volScalarField& S + ) const; + + // Disallow default bitwise copy construct and assignment + SpalartAllmarasIDDES(const SpalartAllmarasIDDES&); + SpalartAllmarasIDDES& operator=(const SpalartAllmarasIDDES&); + + +protected: + + // Protected member functions + + //- Delay function + tmp<volScalarField> fd(const volScalarField& S) const; + + //- Length scale calculation + virtual void dTildaUpdate(const volScalarField& S); + +public: + + //- Runtime type information + TypeName("SpalartAllmarasIDDES"); + + + // Constructors + + //- Constructor from components + SpalartAllmarasIDDES + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + //- Destructor + virtual ~SpalartAllmarasIDDES() + {} + + + // Member Functions + + //- Read turbulenceProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //