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

Access to cellid in cellSet

Register Blogs Community New Posts Updated Threads Search

Like Tree9Likes
  • 2 Post By Tobi
  • 3 Post By yehaixuan
  • 4 Post By chengyu

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2015, 10:49
Default Access to cellid in cellSet
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hello all,

If I read a cellSet like:
Code:
cellSet foobar(mesh, nameOfSet);
it will read the cellSet in constant/polyMesh/sets/nameOfSet.
I did not figure it out how to get access to the values of the cellSet (cellId 's)?

Any suggestion would be appreciated.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   August 15, 2015, 12:07
Default
  #2
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12
ssss is on a distinguished road
As cellSet is a topoSet child class class maybe you can have a look in the way they use iterators and labels in topoSet, for example in the functions:

Foam::topoSet::invert
Foam::topoSet::updateLabels

Sorry that I cannot help you more, as my C++ knowledge is pretty basic
ssss is offline   Reply With Quote

Old   August 15, 2015, 14:27
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Thanks for the replay.
I also checked topoSet in doxygen but I did not find any function. There has to be a way
Foam is so awesome but I do not know the classes very well.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   August 15, 2015, 14:43
Default
  #4
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Solved!

As always soooo easy. I wanted to have access only to the cellSet cells in some postProcessing. Due to the fact that cellSet is inherit by a hash table.
Therefore I get it with that:
Code:
cellSet test(mesh, nameOfSet);

forAll(mesh.C(), id)
{
    if  (test[id])
    {
           //- Only get the cells which are included in the cellSet 
    }
}
ssss and daamec like this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 13, 2016, 11:24
Default
  #5
New Member
 
Haixuan Ye
Join Date: May 2012
Location: Ann Arbor, MI, USA
Posts: 4
Rep Power: 13
yehaixuan is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Solved!

As always soooo easy. I wanted to have access only to the cellSet cells in some postProcessing. Due to the fact that cellSet is inherit by a hash table.
Therefore I get it with that:
Code:
cellSet test(mesh, nameOfSet);

forAll(mesh.C(), id)
{
    if  (test[id])
    {
           //- Only get the cells which are included in the cellSet 
    }
}
Just for completeness. Your solution will loop all the cells. In my opinion, it may not be efficient when the cellSet is only a small portion of the mesh.

I suggest to use test.toc() to access the contents of the table directly.

Code:
test.toc()
Tobi, daamec and fly_light like this.
yehaixuan is offline   Reply With Quote

Old   April 16, 2017, 21:05
Default Use the native access method provided by OpenFOAM
  #6
New Member
 
Yu Cheng
Join Date: Aug 2014
Posts: 15
Rep Power: 11
chengyu is on a distinguished road
Hey guys,
I am also looking for the access method to cellSet, after digging into the code, I found a native way provided by OpenFOAM in the file fvOption.C, see the lines (147-148) and lines (236-240). For convenience, I paste the code here
Code:
 
           cellSet selectedCells(mesh_, cellSetName_);
           cells_ = selectedCells.toc();
Code:
        V_ = 0.0;
        forAll(cells_, i)
        {
            V_ += mesh_.V()[cells_[i]];
        }
Sun, Michael@UW, mikulo and 1 others like this.
chengyu 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
[DesignModeler] DesignModeler Scripting: How to get Full Command Access ANT ANSYS Meshing & Geometry 53 February 16, 2020 15:13
[snappyHexMesh] MultiRegion(Snappy): how to define new zones Cartuns11 OpenFOAM Meshing & Mesh Conversion 6 May 3, 2019 12:02
irregular model simulation with chtMultiregionFoam lg88 OpenFOAM 59 July 28, 2016 11:44
Creating a cellSet fom yPlus buffi OpenFOAM Post-Processing 0 December 17, 2012 04:19
Online libraries - with access to Journals momentum_waves Main CFD Forum 2 December 12, 2007 10:08


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