Faces of a cell
Hi all,
probably a very simple question. How can i access the faces of a particular cell? I would like to loop over all the cell and for every cell[i] over all the face. Thanks Andrea |
Hi Andrea
You can get the information as: Code:
const labelListList & cellFaces = mesh.cellFaces(); Best regards, Niels |
Hi Niels,
thanks for the answer. I need to know the values of a variable (alpha1 using interFoam) belonging to the faces of a particular cell, and then loop for all the cell. Something like that: forAll(alpha1,celli) { alpha[celli] = sum(alpha[facei]*Sf[facei])/sum(Sf[facei]) } this does not work of course. I dont know where to put the loop on the correct faces belonging to the cell[i]. many thanks for any help andrea |
Isn't fvc able to calculate what you want? I suppose fvc:div does something similar you what you want? I cannot give you the correct syntax though, but maybe someone else can help you out.
|
Hi,
basically a need to smooth alpha on every cell and i would like to do that by using alpha on the face times area divided by the total area. So i need to sum alpha on the 4 faces. The divergence is a difference between values on the faces divided by deltax and i dont know if is the same that i need. andrea |
Hi Andrea,
Take a look at src/finiteVolume/finiteVolume/fvc/fvcSurfaceIntegrate.C and what they do is very similar to what you want. I also did the smoothed alpha1, but I did not include the boundary value at all. |
Dear forumers,
I decided to post my question inside this thread, as it is also somehow connected with looping over faces in a given cell. What I try to achieve is to get the face normal vector at every face in the cell, regardless it is a boundary cell or internal. I produced the following code...: Code:
const cell& faces = mesh_.cells()[cellI]; |
Hey,
have you solved your problem? I also would like to access the face normal vectors of internal faces.... Kind Regards Anne |
Yes, I solved the problem. The solution I got was correct. I.e. the components of normal vectors for an arbitrary cell can be in general of the same sign.
The reason for this are the normal vector direction rules. In OpenFoam mesh normal vectors: - at boundary faces point out of the domain - at internal faces they point from the cell of lower global ID number to higher. Hope this helps, Best regards, kuczmas. |
Just a small note, I think
Code:
vector faceINormal = mesh_.Sf()[i] / mesh_.magSf()[i]; Code:
L |
Thank you for this hint. I will keep on trying.
Kind Regards Anne |
Dear Niels,
Could you please elaborate more on how to access the value of a surface<Type>Field given face label if the face is not internal? I manage to acess the boundary field but I can't find out how to obtain a certain value from it knowing the face label. Best regards, Thomas |
How to identify that a particular facelabel is internal or boundary?
I want to find out the face normal vectors irrespective of whether they are internal or at the boundary |
Hi,
@ashish.svm Guess, you have already tried: https://cpp.openfoam.org/v4/a02014.h...c7903e486776a8, and failed. Could you describe difficulties, which using this method? |
Quote:
|
Quote:
hi Niels, I am trying to get the cellFaces but it says FvMesh has no function defined as that. I am making a dual grid solver is that the reason why I am facing this problem. The error message shows as : error: ‘class Foam::fvMesh’ has no member named ‘cellFaces’ const labelListList& cellFaces = fluidRegions[0].cellFaces(); |
I am trying to run the same thing but I am getting unusual value for the normals at boundary. My code is:
Info<< "\nOUTPUT FOR FACE NORMAL OF COARSE MESH\n" << endl; forAll(fluidRegions[0].cells(), cellI) { const cell& faces = fluidRegions[0].cells()[cellI]; forAll( faces, i ) // loop over all faces in cellID { int k=faces[i]; vector faceINormal = fluidRegions[0].Sf()[k] / fluidRegions[0].magSf()[k] ; vector faceICenter = fluidRegions[0].Cf()[k]; Info << " k = " << k << " i = " << i << ", faceINormal = " << faceINormal << ", faceICenter = " << faceICenter << endl ; } } OUTPUT FOR FACE NORMAL OF COARSE MESH k = 0 i = 0, faceINormal = (1 0 0), faceICenter = (0.005 0.0025 0.0005) k = 1 i = 1, faceINormal = (0 1 0), faceICenter = (0.0025 0.005 0.0005) k = 6 i = 2, faceINormal = (-7.21083e+303 0 0), faceICenter = (0 0.0025 0.0005) which eventually leds to Floating Point Exception (core dumped) error. |
Quote:
Have you checked the quality of the mesh? Isn't the magSf of some cells too small, close to the machine precision? |
All times are GMT -4. The time now is 07:15. |