not register correction vector

This commit is contained in:
mattijs
2009-08-25 13:42:58 +01:00
parent 91b0fcba61
commit cc9c4fd32a

View File

@ -38,93 +38,96 @@ Foam::linearUpwindV<Type>::correction
const GeometricField<Type, fvPatchField, volMesh>& vf const GeometricField<Type, fvPatchField, volMesh>& vf
) const ) const
{ {
const fvMesh& mesh = this->mesh(); const fvMesh& mesh = this->mesh();
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
( (
new GeometricField<Type, fvsPatchField, surfaceMesh> new GeometricField<Type, fvsPatchField, surfaceMesh>
( (
IOobject IOobject
( (
vf.name(), "linearUpwindV::correction(" + vf.name() + ')',
mesh.time().timeName(), mesh.time().timeName(),
mesh mesh,
), IOobject::NO_READ,
mesh, IOobject::NO_WRITE,
dimensioned<Type> false
( ),
vf.name(), mesh,
vf.dimensions(), dimensioned<Type>
pTraits<Type>::zero (
) vf.name(),
) vf.dimensions(),
); pTraits<Type>::zero
)
)
);
GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr(); GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();
const surfaceScalarField& faceFlux = this->faceFlux_; const surfaceScalarField& faceFlux = this->faceFlux_;
const surfaceScalarField& w = mesh.weights(); const surfaceScalarField& w = mesh.weights();
const labelList& own = mesh.owner(); const labelList& own = mesh.owner();
const labelList& nei = mesh.neighbour(); const labelList& nei = mesh.neighbour();
const vectorField& C = mesh.C(); const vectorField& C = mesh.C();
const vectorField& Cf = mesh.Cf(); const vectorField& Cf = mesh.Cf();
GeometricField GeometricField
<typename outerProduct<vector, Type>::type, fvPatchField, volMesh> <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
gradVf = gradScheme_().grad(vf); gradVf = gradScheme_().grad(vf);
forAll(faceFlux, facei) forAll(faceFlux, facei)
{ {
vector maxCorr; vector maxCorr;
if (faceFlux[facei] > 0.0) if (faceFlux[facei] > 0.0)
{ {
maxCorr = maxCorr =
(1.0 - w[facei]) (1.0 - w[facei])
*(vf[nei[facei]] - vf[own[facei]]); *(vf[nei[facei]] - vf[own[facei]]);
sfCorr[facei] = sfCorr[facei] =
(Cf[facei] - C[own[facei]]) & gradVf[own[facei]]; (Cf[facei] - C[own[facei]]) & gradVf[own[facei]];
} }
else else
{ {
maxCorr = maxCorr =
w[facei]*(vf[own[facei]] - vf[nei[facei]]); w[facei]*(vf[own[facei]] - vf[nei[facei]]);
sfCorr[facei] = sfCorr[facei] =
(Cf[facei] - C[nei[facei]]) & gradVf[nei[facei]]; (Cf[facei] - C[nei[facei]]) & gradVf[nei[facei]];
} }
scalar sfCorrs = magSqr(sfCorr[facei]); scalar sfCorrs = magSqr(sfCorr[facei]);
scalar maxCorrs = sfCorr[facei] & maxCorr; scalar maxCorrs = sfCorr[facei] & maxCorr;
if (sfCorrs > 0) if (sfCorrs > 0)
{ {
if (maxCorrs < 0) if (maxCorrs < 0)
{ {
sfCorr[facei] = vector::zero; sfCorr[facei] = vector::zero;
} }
else if (sfCorrs > maxCorrs) else if (sfCorrs > maxCorrs)
{ {
sfCorr[facei] *= maxCorrs/(sfCorrs + VSMALL); sfCorr[facei] *= maxCorrs/(sfCorrs + VSMALL);
} }
} }
else if (sfCorrs < 0) else if (sfCorrs < 0)
{ {
if (maxCorrs > 0) if (maxCorrs > 0)
{ {
sfCorr[facei] = vector::zero; sfCorr[facei] = vector::zero;
} }
else if (sfCorrs < maxCorrs) else if (sfCorrs < maxCorrs)
{ {
sfCorr[facei] *= maxCorrs/(sfCorrs - VSMALL); sfCorr[facei] *= maxCorrs/(sfCorrs - VSMALL);
} }
} }
} }
return tsfCorr; return tsfCorr;
} }