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

Cell area value in certain normal direction

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By blttkgl

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 14, 2017, 06:29
Default Cell area value in certain normal direction
  #1
Member
 
Join Date: Oct 2015
Location: Finland
Posts: 39
Rep Power: 10
blttkgl is on a distinguished road
Hey,

I want to get the face area of my 2d mesh for each cell. I will then take a square root of it to use it in some equation.

So far what I do is taking the volume of the cell and getting the cubic root of it, which highly depends on z direction and I don't want that:

Code:
volScalarField cellVolu
    (
    IOobject
       (
        "cellVolu",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
       ),
        mesh,
    dimensionedScalar("zero", dimVolume, 0.0)
    );
    cellVolu.ref() = mesh.V();
What I want to do is get the face area in the xy plane as a field. If a more generalized formulation involving unstructured is available I can work with that too.

Any ideas?

Bulut
blttkgl is offline   Reply With Quote

Old   April 14, 2017, 06:55
Default
  #2
Member
 
Join Date: Oct 2015
Location: Finland
Posts: 39
Rep Power: 10
blttkgl is on a distinguished road
I tried the following lines in my header file to see what they do:

Code:
forAll(mesh.magSf(), idx)
{
    Info<< "magSf of cell with index " << idx << " is " << mesh.magSf()[idx] << endl;
}
forAll(mesh.Sf(), idx)
{
    Info<< "normal of cell with index " << idx << " is " << mesh.Sf()[idx]/ mesh.magSf()[idx] << endl;
first one gave me magnitude of the faces but I dont understand how normal directions are accountant for. using mesh.Sf() directly gives surface area with the normal direction (something like (0 -1.8e-08 0) and the last one gives me the normal direction of each cell:

Code:
Sf of cell with index 9748 is (0 -1 0)
Sf of cell with index 9749 is (0 1 0)
Sf of cell with index 9750 is (1 0 0)
Sf of cell with index 9751 is (0 1 0)
Sf of cell with index 9752 is (-1 0 0)
Sf of cell with index 9753 is (0 -1 0)
Sf of cell with index 9754 is (1 0 0)
I guess is next step is somehow eliminate all the directions except for (0 0 1) (since 2d xy mesh is used) and take that scalar field to be used.

Any suggestions?

Bulut
blttkgl is offline   Reply With Quote

Old   April 14, 2017, 09:56
Default
  #3
New Member
 
Davide Fransos
Join Date: Jun 2009
Location: Torino, Italy
Posts: 4
Rep Power: 16
dfransos is on a distinguished road
Dear Bulut,

first of all: both MagSf() and Sf() methods of the class fvMesh return surfaceScalarFields. This mean that you have one value for each face of your mesh, and not cells. The "idx" index you are printing in your code refers to faces in the mesh and not cells.

Given that:
- a 2d mesh in OpenFOAM is in fact a 3d mesh with constant thickness in the third dimension;
- each face in your 2d setup corresponds to a cell in the 3d OpenFOAM mesh;
why don't you just take the cell volumes and divide them by the constant thickness?

Davide
dfransos is offline   Reply With Quote

Old   April 14, 2017, 10:00
Default
  #4
Member
 
Join Date: Oct 2015
Location: Finland
Posts: 39
Rep Power: 10
blttkgl is on a distinguished road
Hey,

Thanks for the reply. I tried that by getting the cell volumes and taking the cubic root of it because of unit consistency. Just to be clear what you suggest is:

  • Get the volume of the cell
  • Divide it by the constant thickness (Dimensioned scalar of length)
  • Get the square root of the above result


Do I understand correctly?


-Bulut
siamak 60 likes this.
blttkgl is offline   Reply With Quote

Old   April 14, 2017, 10:02
Default
  #5
New Member
 
Davide Fransos
Join Date: Jun 2009
Location: Torino, Italy
Posts: 4
Rep Power: 16
dfransos is on a distinguished road
Quote:
Originally Posted by blttkgl View Post
Hey,

Thanks for the reply. I tried that by getting the cell volumes and taking the cubic root of it because of unit consistency. Just to be clear what you suggest is:

  • Get the volume of the cell
  • Divide it by the constant thickness (Dimensioned scalar of length)
  • Get the square root of the above result


Do I understand correctly?


-Bulut
Yes, exactly.
dfransos is offline   Reply With Quote

Old   April 14, 2017, 10:03
Default
  #6
Member
 
Join Date: Oct 2015
Location: Finland
Posts: 39
Rep Power: 10
blttkgl is on a distinguished road
You're right it's that easy! Thanks
blttkgl is offline   Reply With Quote

Old   March 21, 2022, 23:08
Default
  #7
New Member
 
Prithvi
Join Date: Mar 2022
Location: Darmstadt
Posts: 6
Rep Power: 4
prinux is on a distinguished road
Hi Bulut,


Were you able to implement this successfully?
prinux is offline   Reply With Quote

Old   March 29, 2022, 17:21
Default
  #8
Member
 
Join Date: Oct 2015
Location: Finland
Posts: 39
Rep Power: 10
blttkgl is on a distinguished road
Hey,


No, it's been a while but as far as I remember I opted to just using volume instead of face are and ensuring that my third dimension is a unit dimension (in meters) so effectively volume == face area.


Hope this helps,


Bulut
blttkgl 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
How to determine the direction of cell face vectors on processor patches sebastian_vogl OpenFOAM Programming & Development 1 October 11, 2016 13:17
[OpenFOAM] Problem with cell area calculation in a slice daniel87 ParaView 5 October 24, 2015 16:18
Flow Direction: normal to boundary!!! Atit CFX 1 August 2, 2015 13:42
FvMatrix coefficients shrina OpenFOAM Running, Solving & CFD 10 October 3, 2013 14:38
Cells with t below lower limit Purushothama Siemens 2 May 31, 2010 21:58


All times are GMT -4. The time now is 23:48.