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

[Technical] is there any way to get cell surface area?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 21, 2022, 13:18
Default is there any way to get cell surface area?
  #1
New Member
 
Join Date: Jun 2022
Posts: 10
Rep Power: 3
AbhishekTAMU is on a distinguished road
I know that magSf() function can calculate individual face area. However, I want to know the surface area of a cell just like we can get cell volume by using mesh.V().

Does anyone know how to get the cell surface area?

Thanks in advance !
AbhishekTAMU is offline   Reply With Quote

Old   July 22, 2022, 05:43
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
I don't know where that would normally be needed, so there is no such functionality. However, writing it yourself is not actually too hard I think.


The basic algorithm would entail the following:
  • create a scalarField with size nCells, initialized to zero everywhere.
  • get a const ref to the magSf() field and face owner/face neighbour lists
  • loop over magSf field for faces 0 to nInternalFaces. Add in area contributions to owner and neighbour cells
  • loop over magSf field for faces nInternalFaces to nFaces. Add in area contributions to the owner cells.
  • Done
olesen is offline   Reply With Quote

Old   July 22, 2022, 13:35
Default
  #3
New Member
 
Join Date: Jun 2022
Posts: 10
Rep Power: 3
AbhishekTAMU is on a distinguished road
Hello olesen,

Thank you for your response !

I just want to know where I would need to write this code?

in src/OpenFOAM/meshes/primitiveMesh/ there are two files namely primitiveMeshCellCentresAndVols.C and primitiveMeshFaceCentresAndAreas.C . Do I need to write the code in one of these files or I have to create separate .C file.
AbhishekTAMU is offline   Reply With Quote

Old   July 31, 2022, 12:17
Default
  #4
New Member
 
Join Date: Jun 2022
Posts: 10
Rep Power: 3
AbhishekTAMU is on a distinguished road
Foam::tmp<Foam::scalarField> Foam::cellQuality::cellSurfaceArea() const
{
tmp<scalarField> tresult
(
new scalarField
(
mesh_.nCells(), 0.0
)
);
scalarField& result = tresult.ref();

scalar sumCellArea;
forAll(result,celli)
{
const labelList& cellFaces = mesh_.cells()[celli]; //with this line, I expect to access the faces belonging to cell under consideration.

const vectorField& areas = mesh_.faceAreas();

forAll(cellFaces,facei)
{
sumCellArea=0;
sumCellArea+=mag(areas[facei]);
}
result[celli]=sumCellArea;
}
return tresult;
}

I am trying to find cell surface area. For this, I am trying to access faces belonging to the particular cell and sum their face areas and assign the sum value to 'result' scalar Field whose size is equal to nCells.
Please let me know, if the way I have written code is correct logically.

Last edited by AbhishekTAMU; July 31, 2022 at 16:19.
AbhishekTAMU 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
Surface area of each cell for mean beam length calculation chloe612 OpenFOAM Programming & Development 0 April 14, 2021 00:12
[snappyHexMesh] snappyHexMesh generates not planar surface krzychu111 OpenFOAM Meshing & Mesh Conversion 2 April 23, 2020 16:38
[snappyHexMesh] SnappyHexMesh no layers and no decent mesh for complex geometry pizzaspinate OpenFOAM Meshing & Mesh Conversion 1 February 25, 2015 07:05
[snappyHexMesh] Problem with Sanpper, surface still Rough Zephiro88 OpenFOAM Meshing & Mesh Conversion 7 November 5, 2014 12:05
Cluster ID's not contiguous in compute-nodes domain. ??? Shogan FLUENT 1 May 28, 2014 15:03


All times are GMT -4. The time now is 19:20.