# error in calculating grad field. possible bug?

 Register Blogs Members List Search Today's Posts Mark Forums Read

 October 2, 2011, 04:26 #2 Senior Member   Nima Samkhaniani Join Date: Sep 2009 Location: Tehran, Iran Posts: 1,266 Blog Entries: 1 Rep Power: 24 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

 October 2, 2011, 13:21 #3 Senior Member   Join Date: Nov 2009 Location: Michigan Posts: 135 Rep Power: 16 what about patches with a fixedValue bc? Why does the gradient come out as zero?

 October 2, 2011, 14:06 #4 Senior Member   Nima Samkhaniani Join Date: Sep 2009 Location: Tehran, Iran Posts: 1,266 Blog Entries: 1 Rep Power: 24 as you said the value on patch is fixed so tangential gradients should be zero but normal gradient can be non zero!

 October 3, 2011, 06:06 #5 Senior Member   Hrvoje Jasak Join Date: Mar 2009 Location: London, England Posts: 1,905 Rep Power: 33 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 void gaussGrad::correctBoundaryConditions ( const GeometricField& vsf, GeometricField < typename outerProduct::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 __________________ Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk