|
[Sponsors] |
April 19, 2012, 12:42 |
Distance between cell center and given patch
|
#1 |
Member
Join Date: Sep 2011
Posts: 45
Rep Power: 14 |
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: San Francisco, CA USA
Posts: 323
Rep Power: 17 |
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: 14 |
Quote:
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: San Francisco, CA USA
Posts: 323
Rep Power: 17 |
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: 14 |
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: 14 |
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: 403
Rep Power: 25 |
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. |
|
|
|