CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

face centroid values using mesh.Cf() giving wrong output

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By hjasak

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 24, 2017, 12:21
Default face centroid values using mesh.Cf() giving wrong output
  #1
Member
 
Phanindra
Join Date: Jan 2013
Posts: 39
Rep Power: 13
phani45 is on a distinguished road
Hi foamers,

I tried to print out the face centroid values on a plane with fixed X value and lying on Y-axis.
I used the code snippet:

{


label patchID=mesh.boundaryMesh().findPatchID("left_wall ");

const labelList& own = mesh.faceOwner();


forAll(mesh.boundaryMesh()[patchID].faceCells(),cellf)
{

Info<<mesh.Cf()[own[cellf]]<<endl;
}

}

I'm used 10 cells in Y-direction . The length in Y-Direction is 1.0 starting from origin.

I'm getting following output:
(0.05 0.1 0.05)
(0.05 0.1 0.05)
(0.025 0.2 0.05)
(0.025 0.2 0.05)
(0.1 0.1 0.05)
(0.1 0.1 0.05)
(0.075 0.2 0.05)
(0.075 0.2 0.05)
(0.15 0.1 0.05)
(0.15 0.1 0.05)

I don't see the X value being same (which it is supposed to be 0.0) neither the Y -value varying from 0 to 1 as 0,0.1,0.2 etc....

Can anyone of you tell me where I went wrong ?

Regards,
Phanindra
phani45 is offline   Reply With Quote

Old   September 25, 2017, 04:28
Default
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33
hjasak will become famous soon enough
Think about it. Cf is a surfaceVector Field, meaning that it is defined on FACES. You are asking the patch for CELLS that are next to the patch faces:

const labelList& own = mesh.faceOwner();

and then addressing owner (which gives you a CELL index) into a list which is defined in FACES.

Enough said.
Zhiheng Wang likes this.
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   September 25, 2017, 07:59
Default Hi
  #3
Member
 
Phanindra
Join Date: Jan 2013
Posts: 39
Rep Power: 13
phani45 is on a distinguished road
I was trying with many alternatives but couldn't find one. Can you tell me how to solve this problem please.
phani45 is offline   Reply With Quote

Old   February 29, 2024, 08:13
Arrow
  #4
New Member
 
Thushadh Wijesekere
Join Date: Jan 2024
Location: Lund, Sweden
Posts: 1
Rep Power: 0
theDoomGuy is on a distinguished road
It should be like this for someone who has run into the same problem:

Code:
const surfaceVectorField Cfs = mesh.cf();

forAll(Cfs, faceI)
{
    vector Cf = Cfs[faceI];
    Info << "centroid of face " << faceI << " = " << Cf << nl << endl;
}
This works for me. I am also a beginner so any type of criticism (constructive) is welcome. The above code provides the centroid of internal faces but, I assume you could modify the code for extracting information on the baoundary cells.

Last edited by theDoomGuy; February 29, 2024 at 08:17. Reason: The code works only for internal faces.
theDoomGuy is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
udf error srihari FLUENT 1 October 31, 2016 14:18
gmsh2ToFoam sarajags_89 OpenFOAM 0 November 24, 2009 22:50
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 07:36
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 14:00
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 04:15


All times are GMT -4. The time now is 14:36.