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 Tree10Likes
  • 2 Post By Tobi
  • 3 Post By yehaixuan
  • 5 Post By chengyu

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2015, 11:49
Default Access to cellid in cellSet
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
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, 13:07
Default
  #2
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 13
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, 15:27
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
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, 15:43
Default
  #4
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
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, 12:24
Default
  #5
New Member
 
Haixuan Ye
Join Date: May 2012
Location: Ann Arbor, MI, USA
Posts: 4
Rep Power: 14
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, 22:05
Default Use the native access method provided by OpenFOAM
  #6
New Member
 
Yu Cheng
Join Date: Aug 2014
Posts: 15
Rep Power: 12
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, ruloz, Michael@UW and 2 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 16:13
[snappyHexMesh] MultiRegion(Snappy): how to define new zones Cartuns11 OpenFOAM Meshing & Mesh Conversion 6 May 3, 2019 13:02
irregular model simulation with chtMultiregionFoam lg88 OpenFOAM 59 July 28, 2016 12:44
Creating a cellSet fom yPlus buffi OpenFOAM Post-Processing 0 December 17, 2012 05:19
Online libraries - with access to Journals momentum_waves Main CFD Forum 2 December 12, 2007 11:08


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