Bugfix: fixed memory leak for cached gradient in limited grad schemes

This commit is contained in:
Hrvoje Jasak 2016-06-04 08:47:49 +01:00
parent ca9da6ed66
commit 480cf683dd
6 changed files with 10 additions and 21 deletions

View file

@ -158,12 +158,6 @@ Foam::fv::gradScheme<Type>::grad
solution::cachePrintMessage("Recalculating", name, vsf);
tmp<GradFieldType> tgGrad = calcGrad(vsf, name);
// Note: in order for the patchNeighbourField to be
// correct on coupled boundaries,
// correctBoundaryConditions needs to be called. The call
// shall be moved into the library fvc operators
tgGrad().correctBoundaryConditions();
solution::cachePrintMessage("Storing", name, vsf);
regIOobject::store(tgGrad.ptr());
GradFieldType& gGrad = const_cast<GradFieldType&>

View file

@ -100,7 +100,7 @@ tmp<volVectorField> cellLimitedGrad<scalar>::calcGrad
{
const fvMesh& mesh = vsf.mesh();
tmp<volVectorField> tGrad = basicGradScheme_().grad(vsf);
tmp<volVectorField> tGrad = basicGradScheme_().calcGrad(vsf, name);
if (k_ < SMALL)
{
@ -253,7 +253,7 @@ tmp<volTensorField> cellLimitedGrad<vector>::calcGrad
{
const fvMesh& mesh = vsf.mesh();
tmp<volTensorField> tGrad = basicGradScheme_().grad(vsf);
tmp<volTensorField> tGrad = basicGradScheme_().calcGrad(vsf, name);
if (k_ < SMALL)
{
@ -428,6 +428,7 @@ tmp<BlockLduSystem<vector, vector> > cellLimitedGrad<scalar>::fvmGrad
// Calculate current gradient for explicit limiting
// In fvm::grad the current gradient may be cached
// Using cached gradient? Check. HJ, 4/Jun/2016
tmp<volVectorField> tGrad = basicGradScheme_().grad(vsf);
const volVectorField& g = tGrad();

View file

@ -387,6 +387,7 @@ tmp<BlockLduSystem<vector, vector> > faceLimitedGrad<scalar>::fvmGrad
BlockLduSystem<vector, vector>& bs = tbs();
// Calculate current gradient for explicit limiting
// Using cached gradient? Check. HJ, 4/Jun/2016
tmp<volVectorField> tGrad = basicGradScheme_().grad(vsf);
const volVectorField& g = tGrad();

View file

@ -57,7 +57,7 @@ tmp<volVectorField> faceMDLimitedGrad<scalar>::calcGrad
{
const fvMesh& mesh = vsf.mesh();
tmp<volVectorField> tGrad = basicGradScheme_().grad(vsf, name);
tmp<volVectorField> tGrad = basicGradScheme_().calcGrad(vsf, name);
if (k_ < SMALL)
{
@ -196,7 +196,7 @@ tmp<volTensorField> faceMDLimitedGrad<vector>::calcGrad
{
const fvMesh& mesh = vvf.mesh();
tmp<volTensorField> tGrad = basicGradScheme_().grad(vvf, name);
tmp<volTensorField> tGrad = basicGradScheme_().calcGrad(vvf, name);
if (k_ < SMALL)
{

View file

@ -232,7 +232,7 @@ LimitedGrad<Type, GradientLimiter>::gradientField
) const
{
// Get base gradient
tmp<GeoGradFieldType> tGrad = basicGradScheme_().grad(vf, name);
tmp<GeoGradFieldType> tGrad = basicGradScheme_().calcGrad(vf, name);
GeoGradFieldType& gradVf = tGrad();
// Apply the limiter
@ -263,6 +263,7 @@ LimitedGrad<Type, GradientLimiter>::gradientMatrix
GradMatrixType& bs = tbs();
// Calculate limiter. Using explicit gradient
// Using cached gradient? Check. HJ, 4/Jun/2016
GeoFieldType limitField
(
this->limiter

View file

@ -30,6 +30,7 @@ Description
#include "volFields.H"
#include "surfaceFields.H"
#include "linear.H"
#include "surfaceInterpolate.H"
#include "fvcGrad.H"
#include "gaussGrad.H"
@ -61,17 +62,8 @@ Foam::fv::correctedSnGrad<Type>::fullGradCorrection
{
const fvMesh& mesh = this->mesh();
// construct GeometricField<Type, fvsPatchField, surfaceMesh>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tssf =
mesh.correctionVectors()
& linear<typename outerProduct<vector, Type>::type>(mesh).interpolate
(
gradScheme<Type>::New
(
mesh,
mesh.schemesDict().gradScheme("grad(" + vf.name() + ')')
)().grad(vf, "grad(" + vf.name() + ')')
);
mesh.correctionVectors() & fvc::interpolate(fvc::grad(vf));
tssf().rename("snGradCorr(" + vf.name() + ')');
return tssf;