Access cell face center / cell vertices
I'm back again with one question :)
If I'm inside a cell loop like
I need to control weather I'm inside a moving region that I've defined from dictionary...
Searching deeper in the huge list of files I found a
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?
00074 void Foam::primitiveMesh::makeFaceCentresAndAreas
00076 const pointField& p,
00077 vectorField& fCtrs,
00078 vectorField& fAreas
00079 ) const
00081 const faceList& fs = faces();
00083 forAll (fs, facei)
00085 const labelList& f = fs[facei];
00086 label nPoints = f.size();
00088 // If the face is a triangle, do a direct calculation for efficiency
00089 // and to avoid round-off error-related problems
00090 if (nPoints == 3)
00092 fCtrs[facei] = (1.0/3.0)*(p[f] + p[f] + p[f]);
00093 fAreas[facei] = 0.5*((p[f] - p[f])^(p[f] - p[f]));
00097 vector sumN = vector::zero;
00098 scalar sumA = 0.0;
00099 vector sumAc = vector::zero;
00101 point fCentre = p[f];
00102 for (label pi = 1; pi < nPoints; pi++)
00104 fCentre += p[f[pi]];
00107 fCentre /= nPoints;
00109 for (label pi = 0; pi < nPoints; pi++)
00111 const point& nextPoint = p[f[(pi + 1) % nPoints]];
00113 vector c = p[f[pi]] + nextPoint + fCentre;
00114 vector n = (nextPoint - p[f[pi]])^(fCentre - p[f[pi]]);
00115 scalar a = mag(n);
00117 sumN += n;
00118 sumA += a;
00119 sumAc += a*c;
00122 fCtrs[facei] = (1.0/3.0)*sumAc/(sumA + VSMALL);
00123 fAreas[facei] = 0.5*sumN;
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...
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.
Did anyone find a solution to this?
Is it possible to list vertices along a patch, like faceCells() gets cell numbers?
You can use meshPoints():
|All times are GMT -4. The time now is 09:10.|