benk |
December 9, 2010 10:53 |
Accessing value at the corner of a mesh
Hi, I'm trying to get the value at the corner of a 2D mesh. I can easily get the values along the boundary by doing something like:
Code:
label topWall = 2DMesh.boundaryMesh().findPatchID("topWall");
fixedGradientFvPatchScalarField& bufferC = refCast<fixedGradientFvPatchScalarField>(C2D.boundaryField()[topWall]);
scalarField& valC = bufferC;
forAll (valCsPositive, i)
{
cBoundary[i] = C2D.boundaryField()[topWall][i];
}
But this doesn't include the values at the corners. How can I get these?
I've tried something like this which I found from http://www.cfd-online.com/Forums/ope...iven-cell.html:
Code:
vector probePoint(x,y,z); //these are the coordinates of the value I need
label probeCell = mesh.findCell(probePoint); // this is the nearest cell to the point that I need
const cell& c = mesh.cells()[probeCell]; // a cell is a list of faces
forAll (c, i)
{
// This gives you the patch ID for a face. If the face is internal, you get -1
label patchID = mesh.boundaryMesh().whichPatch(c[i]);
if (patchID > -1)
{
label faceID = mesh.boundaryMesh()[patchID].whichFace(c[i]);
Info << "values=" << field.boundaryField()[patchID][faceID] << endl;
}
}
But this will only give me the values at the patches of the specified cell (not the corner) and moreover, it gives me a segmentation fault during runtime after spitting out the values at the patches.
|