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

Faces of a cell

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 3 Post By ngj
  • 1 Post By kuczmas

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2011, 10:04
Default Faces of a cell
  #1
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16
Andrea_85 is on a distinguished road
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
Andrea_85 is offline   Reply With Quote

Old   March 14, 2011, 10:20
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Andrea

You can get the information as:

Code:
const labelListList & cellFaces = mesh.cellFaces();
Be aware that if you will access some surface<Type>Field given the faces, you need to check whether or not the face label is internal. If not, then you need to access the value of this boundary face through the boundary field.

Best regards,

Niels
rajibroy, mbookin and fly_light like this.
ngj is offline   Reply With Quote

Old   March 14, 2011, 10:44
Default
  #3
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16
Andrea_85 is on a distinguished road
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
Andrea_85 is offline   Reply With Quote

Old   March 14, 2011, 11:00
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
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.
Bernhard is offline   Reply With Quote

Old   March 14, 2011, 11:25
Default
  #5
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16
Andrea_85 is on a distinguished road
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
Andrea_85 is offline   Reply With Quote

Old   March 14, 2011, 12:35
Default
  #6
Member
 
Duong A. Hoang
Join Date: Apr 2009
Location: Delft, Netherlands
Posts: 93
Rep Power: 17
duongquaphim is on a distinguished road
Send a message via Yahoo to duongquaphim
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.
duongquaphim is offline   Reply With Quote

Old   June 8, 2011, 09:56
Default
  #7
New Member
 
Paweł Kuczyński
Join Date: Feb 2011
Location: Warsaw, Poland
Posts: 19
Rep Power: 15
kuczmas is on a distinguished road
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];

    forAll( faces, i )        // loop over all faces in cellID
    {
        vector faceINormal = mesh_.Sf()[i] / mesh_.magSf()[i] ; 
        Info << " i = " << i << ", faceINormal = " << faceINormal << endl ;
    }
...but the values of normal vectors I received are all of positive sign, all the components are of positive sign (on hexahedral mesh). I think in three normal vectors there should be at least one component of negative sign... Do you have any ideas?
__________________
Best regards
P. Kuczynski.
kuczmas is offline   Reply With Quote

Old   April 29, 2013, 11:36
Default
  #8
Senior Member
 
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 15
Anne Lincke is on a distinguished road
Hey,
have you solved your problem? I also would like to access the face normal vectors of internal faces....

Kind Regards
Anne
Anne Lincke is offline   Reply With Quote

Old   April 30, 2013, 02:23
Default
  #9
New Member
 
Paweł Kuczyński
Join Date: Feb 2011
Location: Warsaw, Poland
Posts: 19
Rep Power: 15
kuczmas is on a distinguished road
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.
babala likes this.
__________________
Best regards
P. Kuczynski.
kuczmas is offline   Reply With Quote

Old   April 30, 2013, 07:16
Default
  #10
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Just a small note, I think

Code:
vector faceINormal = mesh_.Sf()[i] / mesh_.magSf()[i];
should be
Code:
 
vector faceINormal = mesh_.Sf()[faces[i]] / mesh_.magSf()[faces[i]] ;
Cheers,

L
Lieven is offline   Reply With Quote

Old   April 30, 2013, 08:36
Default
  #11
Senior Member
 
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 15
Anne Lincke is on a distinguished road
Thank you for this hint. I will keep on trying.
Kind Regards
Anne
Anne Lincke is offline   Reply With Quote

Old   May 29, 2016, 19:25
Default
  #12
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
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
t.oliveira is offline   Reply With Quote

Old   May 12, 2017, 18:04
Default
  #13
Member
 
Ashish Kumar
Join Date: Jun 2015
Posts: 33
Rep Power: 10
ashish.svm is on a distinguished road
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
ashish.svm is offline   Reply With Quote

Old   May 13, 2017, 03:59
Default
  #14
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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?
alexeym is offline   Reply With Quote

Old   May 14, 2017, 00:57
Default
  #15
Member
 
Ashish Kumar
Join Date: Jun 2015
Posts: 33
Rep Power: 10
ashish.svm is on a distinguished road
Quote:
Originally Posted by alexeym View Post
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?
Thanks. "isInternalFace" helped.
ashish.svm is offline   Reply With Quote

Old   July 12, 2018, 01:22
Default
  #16
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
Quote:
Originally Posted by ngj View Post
Hi Andrea

You can get the information as:

Code:
const labelListList & cellFaces = mesh.cellFaces();
Be aware that if you will access some surface<Type>Field given the faces, you need to check whether or not the face label is internal. If not, then you need to access the value of this boundary face through the boundary field.

Best regards,

Niels

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();
kk415 is offline   Reply With Quote

Old   July 12, 2018, 03:16
Default
  #17
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
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.
kk415 is offline   Reply With Quote

Old   July 13, 2018, 08:20
Default
  #18
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Quote:
Originally Posted by kk415 View Post
which eventually leds to Floating Point Exception (core dumped) error.

Have you checked the quality of the mesh? Isn't the magSf of some cells too small, close to the machine precision?
t.oliveira 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
[snappyHexMesh] SnappyHexMesh - no layer added bejbro OpenFOAM Meshing & Mesh Conversion 5 February 1, 2020 20:05
DecomposePar unequal number of shared faces maka OpenFOAM Pre-Processing 6 August 12, 2010 09:01
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 19:43
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 04:15
Warning 097- AB Siemens 6 November 15, 2004 04:41


All times are GMT -4. The time now is 13:32.