# Cell area value in certain normal direction

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 14, 2017, 06:29 Cell area value in certain normal direction #1 Member   Join Date: Oct 2015 Location: Finland Posts: 37 Rep Power: 8 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

 April 14, 2017, 06:55 #2 Member   Join Date: Oct 2015 Location: Finland Posts: 37 Rep Power: 8 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

 April 14, 2017, 09:56 #3 New Member   Davide Fransos Join Date: Jun 2009 Location: Torino, Italy Posts: 4 Rep Power: 14 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

 April 14, 2017, 10:00 #4 Member   Join Date: Oct 2015 Location: Finland Posts: 37 Rep Power: 8 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.

April 14, 2017, 10:02
#5
New Member

Davide Fransos
Join Date: Jun 2009
Location: Torino, Italy
Posts: 4
Rep Power: 14
Quote:
 Originally Posted by blttkgl 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.

 April 14, 2017, 10:03 #6 Member   Join Date: Oct 2015 Location: Finland Posts: 37 Rep Power: 8 You're right it's that easy! Thanks

 March 21, 2022, 23:08 #7 New Member   Join Date: Mar 2022 Posts: 2 Rep Power: 0 Hi Bulut, Were you able to implement this successfully?

 March 29, 2022, 17:21 #8 Member   Join Date: Oct 2015 Location: Finland Posts: 37 Rep Power: 8 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