CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   error in calculating grad field. possible bug? (http://www.cfd-online.com/Forums/openfoam/93009-error-calculating-grad-field-possible-bug.html)

doubtsincfd October 1, 2011 23:01

error in calculating grad field. possible bug?
 
In the file write.H in laplacianFoam solver, I simply add a line

gradT.write();

recompile and run the tutorial for laplacianFoam. (the flange tutorial)

In file gradT: zeroGradient for all patches!

In files gradTx,gradTy,gradTz: non-zero values for gradTx, gradTy and gradTz on patches where zeroGradient is specified! and non zero for other patches too, though the gradT file shows zeroGradient.

Whats wrong and with whom? (me or OF)

nimasam October 2, 2011 04:26

im not sure but i think when you fixed zeroGradient at patch it will consider the patch normal gradient zero so the gradient of the patch in the other directions are non- zero

doubtsincfd October 2, 2011 13:21

what about patches with a fixedValue bc? Why does the gradient come out as zero?

nimasam October 2, 2011 14:06

as you said the value on patch is fixed so tangential gradients should be zero but normal gradient can be non zero!

hjasak October 3, 2011 06:06

Not sure what your problem is: the gradient of T at a boundary will be a vector and only a surface-normal component of this gradient is specified in the T boundary conditions. The other two components will be non-zero, due to eg. tangential component of the gradient and picked up from the cell inside of the domain next to the patch. The code that does this is:


template<class Type>
void gaussGrad<Type>::correctBoundaryConditions
(
const GeometricField<Type, fvPatchField, volMesh>& vsf,
GeometricField
<
typename outerProduct<vector, Type>::type, fvPatchField, volMesh
>& gGrad
)
{
forAll(vsf.boundaryField(), patchi)
{
if (!vsf.boundaryField()[patchi].coupled())
{
vectorField n =
vsf.mesh().Sf().boundaryField()[patchi]
/vsf.mesh().magSf().boundaryField()[patchi];

gGrad.boundaryField()[patchi] += n *
(
vsf.boundaryField()[patchi].snGrad()
- (n & gGrad.boundaryField()[patchi])
);
}
}
}

All is fine,

Hrv


All times are GMT -4. The time now is 12:18.