Distance between cell center and given patch
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 |
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! |
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).. |
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.
|
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) ? |
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.
|
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. |
All times are GMT -4. The time now is 01:12. |