|
[Sponsors] |
Finding list of cells according to a condition |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 19, 2009, 00:48 |
Finding list of cells according to a condition
|
#1 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Hello,
I need to find the labelList of cells that respect a certain condition in my simulation, in order to use it in setValues to exclude the equations of those cells from the matrix. Is there any easy way to do this, excluding looping and checking? Thanks in advance.
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
December 19, 2009, 22:23 |
|
#2 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
I usually use a labelHashSet to do this. You'll still have to loop through all cells to test for the condition, but when you do, add the cell index to the hashSet. At the end of the loop, you can use the toc() method in HashSet to obtain a labelList of cell indices.
Code:
labelHashSet conditionCells; forAll(mesh.cells(), cellI) { if (condition) { conditionCells.insert(cellI); } } labelList cellLabels = conditionCells.toc(); |
|
December 20, 2009, 04:49 |
|
#3 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Thanks :-)
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
January 19, 2010, 06:07 |
|
#4 |
New Member
Andreas Otto
Join Date: Sep 2009
Posts: 12
Rep Power: 17 |
Hi Alberto,
how do you now use your labellist with setValues? I tried it as it was shown in http://http://www.cfd-online.com/Forums/openfoam-solving/59266-how-force-fixed-value-variable-one-cell-2.html#post196058 but it didn't work. Thanks in advance! |
|
March 24, 2010, 17:55 |
|
#5 | |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Quote:
Best,
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] SnappyHexMesh for internal Flow | vishwa | OpenFOAM Meshing & Mesh Conversion | 24 | June 27, 2016 09:54 |
HELPInstallation on RedHat90 | booosix | OpenFOAM Installation | 8 | July 17, 2007 07:40 |
Finding adjacent cells by UDFs | Ertan Taskin | FLUENT | 0 | May 5, 2005 13:02 |
Finding out boundary cells in a domain | Abbas | FLUENT | 4 | October 13, 2003 05:56 |
New List of Free CFD Codes | Bert Laney | Main CFD Forum | 5 | September 15, 1999 16:24 |