diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/michalakGoochGrad/michalakGoochGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/michalakGoochGrad/michalakGoochGrad.H new file mode 100644 index 000000000..c77367931 --- /dev/null +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/michalakGoochGrad/michalakGoochGrad.H @@ -0,0 +1,139 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 3.2 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + Foam::fv::michalakGoochGrad + +Description + Michalak-Gooch gradient limiter applied to a runTime selected + base gradient scheme. + +SourceFiles + michalakGoochGrad.C + +\*---------------------------------------------------------------------------*/ + +#ifndef michalakGoochGrad_H +#define michalakGoochGrad_H + +#include "gradScheme.H" +#include "LimitedGrad.H" +#include "MichalakGoochLimiter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace fv +{ + +/*---------------------------------------------------------------------------*\ + Class michalakGoochGrad Declaration +\*---------------------------------------------------------------------------*/ + +template +class michalakGoochGrad +: + public fv::gradScheme, + public LimitedGrad +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + michalakGoochGrad(const michalakGoochGrad&); + + //- Disallow default bitwise assignment + void operator=(const michalakGoochGrad&); + + +public: + + //- RunTime type information + TypeName("michalakGooch"); + + + // Constructors + + //- Construct from mesh and schemeData + michalakGoochGrad(const fvMesh& mesh, Istream& schemeData) + : + gradScheme(mesh), + LimitedGrad(mesh, schemeData) + {} + + + // Member Functions + + //- Return the gradient of the given field to the gradScheme::grad + // for optional caching + virtual tmp + < + GeometricField + ::type, fvPatchField, volMesh> + > calcGrad + ( + const GeometricField& vf, + const word& name + ) const + { + return LimitedGrad::gradientField + ( + vf, + name + ); + } + + //- Return the BlockLduSystem corresponding to the implicit cell + // limited grad discretization. For block coupled systems. + virtual tmp + < + BlockLduSystem::type> + > fvmGrad + ( + const GeometricField& vf + ) const + { + return LimitedGrad::gradientMatrix + ( + vf + ); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fv + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/michalakGoochGrad/michalakGoochGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/michalakGoochGrad/michalakGoochGrads.C new file mode 100644 index 000000000..1ffd9772a --- /dev/null +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/michalakGoochGrad/michalakGoochGrads.C @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 3.2 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "michalakGoochGrad.H" +#include "fvMesh.H" +#include "volMesh.H" +#include "surfaceMesh.H" +#include "volFields.H" +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace fv +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeFvGradScheme(michalakGoochGrad) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +template<> +tmp +< + BlockLduSystem::type> +> +michalakGoochGrad::fvmGrad +( + const volVectorField& vf +) const +{ + FatalErrorIn + ( + "tmp michalakGoochGrad::fvmGrad\n" + "(\n" + " GeometricField&" + ")\n" + ) << "Implicit gradient operators with cell limiters defined only for " + << "scalar." + << abort(FatalError); + + typedef outerProduct::type GradType; + + tmp > tbs + ( + new BlockLduSystem(vf.mesh()) + ); + + return tbs; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fv + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradientLimiters/MichalakGoochLimiter.H b/src/finiteVolume/finiteVolume/gradientLimiters/MichalakGoochLimiter.H new file mode 100644 index 000000000..0ebba270f --- /dev/null +++ b/src/finiteVolume/finiteVolume/gradientLimiters/MichalakGoochLimiter.H @@ -0,0 +1,145 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 3.2 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + MichalakGoochLimiter + +Description + Michalak-Gooch limiter, AIAA-2009-954 + +Author + Hrvoje Jasak + +\*---------------------------------------------------------------------------*/ + +#ifndef MichalakGoochLimiter_H +#define MichalakGoochLimiter_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class MichalakGoochLimiter Declaration +\*---------------------------------------------------------------------------*/ + +class MichalakGoochLimiter +{ + // Private data + + //- Coefficient + const scalar k_; + + +public: + + // Constructors + + //- Construct null + MichalakGoochLimiter() + : + k_(1.5) + {} + + + // Destructor - default + + + // Member functions + + //- Set scalar limiter value + inline void limiter + ( + scalar& lim, + const scalar& cellVolume, + const scalar& deltaOneMax, + const scalar& deltaOneMin, + const scalar& extrapolate + ) + { + // If there is no span or extrapolation, do not limit. Note that + // deltaOneMax and deltaOneMin are bound by zero and min is + // negative + if + ( + deltaOneMax - deltaOneMin < SMALL + || mag(extrapolate) < SMALL + ) + { + return; + } + + scalar y; + + if (extrapolate > 0) + { + y = deltaOneMax/extrapolate; + } + else + { + y = deltaOneMin/extrapolate; + } + + if (y < k_) + { + const scalar C2 = (3 - 2*k_)/sqr(k_); + const scalar C3 = -1/(3*sqr(k_)) - 2/(3*k_)*C2; + + lim = min(lim, y + C2*sqr(y) + C3*pow3(y)); + } + } + + //- Set Type limiter + template + inline void limiter + ( + Type& lim, + const scalar& cellVolume, + const Type& deltaOneMax, + const Type& deltaOneMin, + const Type& extrapolate + ) + { + for (direction cmpt = 0; cmpt < Type::nComponents; cmpt++) + { + limiter + ( + lim.component(cmpt), + cellVolume, + deltaOneMax.component(cmpt), + deltaOneMin.component(cmpt), + extrapolate.component(cmpt) + ); + } + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +#endif + +// ************************************************************************* //