|
[Sponsors] |
|
October 8, 2018, 18:35 |
How to access cellSet elements?
|
#1 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
In my code, I can add cell IDs to a cellSet
Code:
cellSet myCellSet ( IOobject ( "myCellSet", runTime.timeName(), runTime, IOobject::MUST_READ, IOobject::AUTO_WRITE ) ); myCellSet.clear(); const volVectorField& C = mesh.C(); const vector origin(0.0,0.0,0.0); forAll(C, i) { if((mag(C[i] - origin) < 0.6) && (mag(C[i] - origin) > 0.5) ) { myCellSet.insert(i); } } Code:
Info << myCellSet.sortedToc()[0] << endl; NOTE: The code works very well and the myCellSet is written to the directories (the remaining code is not shown here). In summary the question is very simple: Why the following syntax doesn't give the expected result: Code:
myCellSet[0] #s3gt_translate_tooltip_mini { display: none !important; }[/COLOR] |
|
October 10, 2018, 01:04 |
|
#2 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
Hi,
the object myCellSet is based on the class cellSet (https://cpp.openfoam.org/v6/classFoam_1_1cellSet.html). As you can see, there is no operator defined in that class that overloads/defines the operator[] operator. Additionally, you see the inherited functions (from inherited classes). While checking these functions, you can see that the operator[] is defined in the HashSet< label, Hash<label>> class. The operator will do the following: Code:
bool operator[] (const label &) const Return true if the entry exists, same as found() More... Thanks for using code-tags.
__________________
Keep foaming, Tobias Holzmann |
|
October 10, 2018, 06:22 |
|
#3 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
Thank you Tobi.
So Code:
myCellSet.sortedToc(i) |
|
October 10, 2018, 07:12 |
|
#4 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
Hi,
the function you recently added does not exist. This following would be correct Code:
myObject.sortedToc()[i] Code:
myObject.toc()[i] Code:
iterator find (const label &) Find and return an iterator set at the hashedEntry. More...
__________________
Keep foaming, Tobias Holzmann |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Access to cellid in cellSet | Tobi | OpenFOAM Programming & Development | 5 | April 16, 2017 21:05 |
Access (x y z) coordinates of cellSet | hxaxtma | OpenFOAM Programming & Development | 1 | January 21, 2016 05:40 |
Ansys SIG$ILL error | loth | ANSYS | 3 | December 24, 2015 05:31 |
How can I access to a volTensorField elements? urgent!!! | adambarfi | OpenFOAM Running, Solving & CFD | 6 | May 14, 2013 16:28 |
CFX4.3 -build analysis form | Chie Min | CFX | 5 | July 12, 2001 23:19 |