|
[Sponsors] |
Exporting Face Normal of a patch and some other values |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 25, 2012, 13:32 |
Exporting Face Normal of a patch and some other values
|
#1 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 16 |
Dear all,
I want to do a post processing process of a patch (wall) where I need: - Face center coordinate - Normal to Face vector - Face area - Other data like density 1) I have tried first with a sampling but I cannot find a field "name" to get the face properties. Is it possible to get such a thing ? Here I put a "mesh.Sf()" as example of what I want. Code:
interpolationScheme cellPointFace; surfaceFormat raw; setFormat raw; surfaces ( wallTest { type patch; patches (wall); interpolate true; triangulate false; } ); fields ( rho U mesh.Sf() ); Code:
label wallPatch = mesh.boundaryMesh().findPatchID("wall"); rho.boundaryField()[wallPatch] // Density U.boundaryField()[wallPatch] // Velocity mesh.Sf().boundaryField()[wallPatch] // Face normal vector mesh.Cf().boundaryField()[wallPatch] // Face Center mesh.magSf().boundaryField()[wallPatch] // Face magnitude // "Export" data in the consol Info<< U.boundaryField()[wallPatch] << endl; |
|
October 26, 2012, 05:46 |
|
#2 |
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0 |
For the face centers on the patches, try something like
Code:
const fvPatchList& patches = mesh.boundary(); const surfaceVectorField& faceCenters = mesh.Cf(); scalar px; scalar py; scalar pz; forAll(patches,patchi){ label nFaces = mesh.boundaryMesh()[patchi].size(); for(int facei = 0 ; facei<nFaces, facei++){ px = faceCenters.boundaryField()[patchi][facei].x() py = faceCenters.boundaryField()[patchi][facei].x() pz = faceCenters.boundaryField()[patchi][facei].x() } } Edit: the next solution seems much more elegant Last edited by chegdan; October 26, 2012 at 06:39. |
|
October 26, 2012, 05:54 |
|
#3 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
Hi Heckmann,
The OpenFoam-formatted output can be achieved in the following way: Code:
IOField<vector> cfOut ( IOobject ( "cf", mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh.Cf().boundaryField()[ patchID ] ); cfOut.write(); Kind regards, Niels |
|
October 26, 2012, 06:38 |
|
#4 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 16 |
Thank you for yours answer
@chegdan Your function does something very similar to mesh.Cf().boundaryField()[wallPatch] but with each component separably. My question is more about how to export those data to a file in a convenient way. I don't really know how OpenFoam manage to write things on the hard drive. @ngj Your solution looks perfect ! I didn't know that we can use such direct coding into the solver. I will try your method this weekend and study the IOField. Thanks guys. (I'm still open to any other method) |
|
October 26, 2012, 06:49 |
|
#5 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
P.S. You could also add an if-statement around the above code, which looks like this
Code:
if ( runTime.write() ) { // The code above } / Niels |
|
November 9, 2012, 09:56 |
|
#6 | |
Member
Albert Tong
Join Date: Dec 2010
Location: Perth, WA, Australia
Posts: 76
Blog Entries: 1
Rep Power: 15 |
Hi Niels,
Greetings. Can you please enlighten me on how to output the pressure integration along a slice of any patch. I would like to solve the sectional force along a certain structure. Thanks in advance! Kind regards, Albert Quote:
__________________
Kind regards, Albert |
||
March 14, 2014, 07:44 |
|
#7 |
Senior Member
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 18 |
Hi All,
I am interested in such a problem. I have a patch called "airfoil" and I would like to write the normals to each face on the patch in a text file. Do you know how I can get this? Thanks a lot, Samuele |
|
May 9, 2016, 18:28 |
|
#8 |
New Member
Ishmael
Join Date: Nov 2014
Posts: 2
Rep Power: 0 |
Hi Niels, with regards to the block of code you wrote above , does it have to be in the creatFields header file for the output to be exported for post processing. Or can it still be added in the main function of the solver. I will appreciate your help
|
|
|
|