CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Extract patch coordinates (https://www.cfd-online.com/Forums/openfoam-solving/109815-extract-patch-coordinates.html)

batta31 November 27, 2012 09:42

Extract patch coordinates
 
Hi guys I've got a simple question about the mesh:

I would like to extract the point coordinates of a patch and save them on a file. Is it possible?

Any help is really appreciated

Thanks in advance
Simone

batta31 November 28, 2012 05:38

Hi it's me again!

I found how to solve my problem by myself. Besides I write my solution, just in case someone wants to have a look; hope it can help :)



pointField meshPoints(mesh.points());

word patchName = "foil";
label patchID = mesh.boundary().findPatchID(patchName);
const polyPatch& patchFound = mesh.boundaryMesh()[patchID];
labelList labelPatchFound( patchFound.meshPoints() );
std::ofstream naca_x;
std::ofstream naca_y;
naca_x_top.open("naca_x.txt");
naca_y_top.open("naca_y.txt");

forAll(labelPatchFound , label)
{
vector coord = meshPoints[labelPatchFound[label]];
naca_x << coordTop[0];
naca_x << "\n";
naca_y << coordTop[1];
naca_y << "\n";
}

naca_x.close();
naca_y.close();

Divyaprakash May 9, 2016 13:43

:O :o Thanks for your code. :)


All times are GMT -4. The time now is 20:31.