
[Sponsors] 
July 19, 2011, 06:10 
Access cell face center / cell vertices

#1 
New Member
Lorenzo A. Ricciardi
Join Date: Mar 2011
Posts: 27
Rep Power: 7 
Hi all,
I'm back again with one question If I'm inside a cell loop like Code:
for (label i = 0; i < iMesh.C().size(); i ++) { ... } I need to control weather I'm inside a moving region that I've defined from dictionary... 

July 19, 2011, 07:05 

#2 
New Member
Lorenzo A. Ricciardi
Join Date: Mar 2011
Posts: 27
Rep Power: 7 
Searching deeper in the huge list of files I found a
Code:
Foam::label Foam::primitiveMesh::findCell(const point& location) const 

July 19, 2011, 09:50 

#3 
New Member
Lorenzo A. Ricciardi
Join Date: Mar 2011
Posts: 27
Rep Power: 7 
Sadly it's not a good solution.
I really need to cycle through all the cells and gain access to it's vertices or to it's face centers, any help? 

July 19, 2011, 15:25 

#4 
Senior Member
Pablo
Join Date: Mar 2009
Posts: 102
Rep Power: 9 
Look this;
00074 void Foam:rimitiveMesh::makeFaceCentresAndAreas 00075 ( 00076 const pointField& p, 00077 vectorField& fCtrs, 00078 vectorField& fAreas 00079 ) const 00080 { 00081 const faceList& fs = faces(); 00082 00083 forAll (fs, facei) 00084 { 00085 const labelList& f = fs[facei]; 00086 label nPoints = f.size(); 00087 00088 // If the face is a triangle, do a direct calculation for efficiency 00089 // and to avoid roundoff errorrelated problems 00090 if (nPoints == 3) 00091 { 00092 fCtrs[facei] = (1.0/3.0)*(p[f[0]] + p[f[1]] + p[f[2]]); 00093 fAreas[facei] = 0.5*((p[f[1]]  p[f[0]])^(p[f[2]]  p[f[0]])); 00094 } 00095 else 00096 { 00097 vector sumN = vector::zero; 00098 scalar sumA = 0.0; 00099 vector sumAc = vector::zero; 00100 00101 point fCentre = p[f[0]]; 00102 for (label pi = 1; pi < nPoints; pi++) 00103 { 00104 fCentre += p[f[pi]]; 00105 } 00106 00107 fCentre /= nPoints; 00108 00109 for (label pi = 0; pi < nPoints; pi++) 00110 { 00111 const point& nextPoint = p[f[(pi + 1) % nPoints]]; 00112 00113 vector c = p[f[pi]] + nextPoint + fCentre; 00114 vector n = (nextPoint  p[f[pi]])^(fCentre  p[f[pi]]); 00115 scalar a = mag(n); 00116 00117 sumN += n; 00118 sumA += a; 00119 sumAc += a*c; 00120 } 00121 00122 fCtrs[facei] = (1.0/3.0)*sumAc/(sumA + VSMALL); 00123 fAreas[facei] = 0.5*sumN; 00124 } 00125 } 00126 } 00127 

July 20, 2011, 06:42 

#5 
New Member
Lorenzo A. Ricciardi
Join Date: Mar 2011
Posts: 27
Rep Power: 7 
Hi Pablo
thanks for your reply. I had already seen the function you're suggesting, but is not what i'm looking for: i'd like to access from a fvMesh.C()[i] (center of cell) to the label of the cell itself to gain direct access to its vertices or the centers of it's faces, without having to pass entire pointFields and receiving vectFields... findCell does what I need, but it searches on the entire domain to find a cell which contains a generic point, I was hoping to find a much simpler (and faster!) solution... 

July 21, 2011, 10:39 

#6 
Member
Claudio
Join Date: Mar 2010
Posts: 57
Rep Power: 8 
Dear All,
I would like to know if there is a C++ script (also a piece of code, or the post of the needed code lines would be appreciated) that can allow me to store in a file the coordinates of cell centres along with the areas of each cells, for every patch (or the one user specified) of my mesh. In fact, I need these informations for post processing purposes. I thank You in advance. Yours Sincerely. Claudio 

May 29, 2014, 16:46 
Did anyone find a solution to this?

#7 
Member
Eric Bryant
Join Date: Sep 2013
Location: Texas
Posts: 44
Rep Power: 5 
Is it possible to list vertices along a patch, like faceCells() gets cell numbers?


May 31, 2014, 02:31 

#8 
Senior Member
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 200
Blog Entries: 1
Rep Power: 10 
Hi,
You can use meshPoints(): Code:
const fvBoundaryMesh& patches = mesh.boundary(); const polyPatch& pp = patches[patchI].patch(); labelList meshPoints(pp.meshPoints()); //label of vertices forAll(meshPoints, i) { label pointI = meshPoints[i]; //Write what you want to do } Fumiya
__________________


Tags 
cell vertices, face cells 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
FATAL ERROR: face 6 in patch 2 does not have neighbour cell face: 4(8 9 21 20)  robingilbert  OpenFOAM Native Meshers: blockMesh  18  July 15, 2016 18:58 
Import problem  ARC  Open Source Meshers: Gmsh, Netgen, CGNS, ...  0  February 27, 2010 11:56 
interpolation from cell center to vertices  Zhang  Main CFD Forum  3  August 22, 2003 07:31 
calculate cell volume, center...?  Paul  Main CFD Forum  5  June 21, 2003 12:55 
About Cell Center  Harry  FLUENT  0  December 3, 2000 05:33 