CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Distance between cell center and given patch

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 19, 2012, 12:42
Default Distance between cell center and given patch
  #1
Member
 
Join Date: Sep 2011
Posts: 45
Rep Power: 5
ic3wall is on a distinguished road
Hello,

I'm currently modifying a turbulence model and I'm looking for a way to calculate the distance between a cell center in my domain and the bottom patch. I need the vertical distance, not necessarily the shortest path.

It's probably a trivial question, but I can't find how to do it ..

Thanks
ic3wall is offline   Reply With Quote

Old   April 19, 2012, 14:43
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 279
Rep Power: 9
kmooney is on a distinguished road
This will return a scalar field for each patch face. The value returned is one over the perpendicular distance between the cell center and the boundary face, that is (1/deltaX). You can check out the code at fvPatch.C/H


scalarField DnA = mesh.boundary()[myPatchID].deltaCoeffs();

I know its not exactly what you're looking for but it might be a start.

Cheers!
kmooney is offline   Reply With Quote

Old   April 19, 2012, 14:55
Default
  #3
Member
 
Join Date: Sep 2011
Posts: 45
Rep Power: 5
ic3wall is on a distinguished road
Quote:
Originally Posted by kmooney View Post
This will return a scalar field for each patch face. The value returned is one over the perpendicular distance between the cell center and the boundary face, that is (1/deltaX). You can check out the code at fvPatch.C/H


scalarField DnA = mesh.boundary()[myPatchID].deltaCoeffs();

I know its not exactly what you're looking for but it might be a start.

Cheers!
Thank you for your contribution but as mentionned, I don't necessarily need the perpendicular distance (shortest path), I need the adress of the cell with the same X and Y, but the min(Z) coords of my domain, which correspond the cell on the lower patch. I hope the description is clear ..

So far I have this:

const volVectorField& cellCentres = mesh_.C(); //Coords of cellCentres of all cells
label patchID=mesh_.boundaryMesh().findPatchID("lowerBou ndary");
const vectorField& patchFaceCenters=mesh_.Cf().boundaryField()[patchID]; //Coords of cellCentres faces at lowerBoundary

[This statement will be in a loop over celli]
mesh_.findCell(point(mesh_.C()[celli].component(0),mesh_.C()[celli].component(1),0));

Instead of the 0 in the last statement for the z-coord, I would need something like min(Z)..
ic3wall is offline   Reply With Quote

Old   April 19, 2012, 15:08
Default
  #4
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 279
Rep Power: 9
kmooney is on a distinguished road
The findCell function will return a -1 label if you leave the mesh. You could take small steps towards the boundary (by changing the z value) until it returns a -1. Then the last non -1 hit was likely to be the boundary cell. I can only guess that this could get pretty expensive however.
kmooney is offline   Reply With Quote

Old   April 19, 2012, 15:13
Default
  #5
Member
 
Join Date: Sep 2011
Posts: 45
Rep Power: 5
ic3wall is on a distinguished road
yeah, I thought about that too, but as you said it becomes computationnally demanding ..

Is there a kind of min() function that can be used with findCell ?

Or is it possible to find all cells with (X,Y,*), and then keep the one with min(Z) ?
ic3wall is offline   Reply With Quote

Old   April 20, 2012, 09:45
Default
  #6
Member
 
Join Date: Sep 2011
Posts: 45
Rep Power: 5
ic3wall is on a distinguished road
I just realized that my question would be more appropriate in the Programming and Development Section, it would be appreciated if a moderator could move it.
ic3wall is offline   Reply With Quote

Old   April 20, 2012, 11:21
Default
  #7
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 386
Rep Power: 15
deepsterblue will become famous soon enough
I think the cellDist functions in ($FOAM_SRC)/meshTools/cellDist is what you're looking for. Cell-distance calculations are integral to several turbulence models, so I would imagine the infrastructure is already in there...

Hope this helps.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:09.