CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

error in calculating grad field. possible bug?

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 1, 2011, 23:01
Default error in calculating grad field. possible bug?
  #1
Senior Member
 
Join Date: Nov 2009
Location: Michigan
Posts: 135
Rep Power: 16
doubtsincfd is on a distinguished road
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)
doubtsincfd is offline   Reply With Quote

Old   October 2, 2011, 04:26
Default
  #2
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
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
nimasam is offline   Reply With Quote

Old   October 2, 2011, 13:21
Default
  #3
Senior Member
 
Join Date: Nov 2009
Location: Michigan
Posts: 135
Rep Power: 16
doubtsincfd is on a distinguished road
what about patches with a fixedValue bc? Why does the gradient come out as zero?
doubtsincfd is offline   Reply With Quote

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

Old   October 3, 2011, 06:06
Default
  #5
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33
hjasak will become famous soon enough
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
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problems after decomposing for running alessio.nz OpenFOAM 7 March 5, 2021 04:49
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51
Problems calculating field gh with interFoam cricke OpenFOAM Running, Solving & CFD 0 December 10, 2007 07:17
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 17:27


All times are GMT -4. The time now is 03:24.