Distance between cell center and given patch

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

 April 19, 2012, 12:42 Distance between cell center and given patch #1 Member   Join Date: Sep 2011 Posts: 45 Rep Power: 8 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

 April 19, 2012, 14:43 #2 Senior Member     Kyle Mooney Join Date: Jul 2009 Location: Amherst, MA USA - San Diego, CA USA Posts: 321 Rep Power: 11 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!

April 19, 2012, 14:55
#3
Member

Join Date: Sep 2011
Posts: 45
Rep Power: 8
Quote:
 Originally Posted by kmooney 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)..

 April 19, 2012, 15:08 #4 Senior Member     Kyle Mooney Join Date: Jul 2009 Location: Amherst, MA USA - San Diego, CA USA Posts: 321 Rep Power: 11 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.

 April 19, 2012, 15:13 #5 Member   Join Date: Sep 2011 Posts: 45 Rep Power: 8 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) ?

 April 20, 2012, 09:45 #6 Member   Join Date: Sep 2011 Posts: 45 Rep Power: 8 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.

 April 20, 2012, 11:21 #7 Senior Member   Sandeep Menon Join Date: Mar 2009 Location: Amherst, MA Posts: 396 Rep Power: 17 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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

All times are GMT -4. The time now is 05:57.