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

Finding list of cells according to a condition

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 18, 2009, 23:48
Default 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
alberto will become famous soon enoughalberto will become famous soon enough
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.
alberto is offline   Reply With Quote

Old   December 19, 2009, 21:23
Default
  #2
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
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();
Hope this helps...
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   December 20, 2009, 03:49
Default
  #3
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36
alberto will become famous soon enoughalberto will become famous soon enough
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.
alberto is offline   Reply With Quote

Old   January 19, 2010, 05:07
Default
  #4
aot
New Member
 
Andreas Otto
Join Date: Sep 2009
Posts: 12
Rep Power: 16
aot is on a distinguished road
Quote:
Originally Posted by alberto View Post
Thanks :-)
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!
aot is offline   Reply With Quote

Old   March 24, 2010, 16:55
Default
  #5
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36
alberto will become famous soon enoughalberto will become famous soon enough
Quote:
Originally Posted by aot View Post
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!
Yes, it does not work as expected also in my case. I used flags.

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.
alberto 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
[snappyHexMesh] SnappyHexMesh for internal Flow vishwa OpenFOAM Meshing & Mesh Conversion 24 June 27, 2016 08:54
HELPInstallation on RedHat90 booosix OpenFOAM Installation 8 July 17, 2007 06:40
Finding adjacent cells by UDFs Ertan Taskin FLUENT 0 May 5, 2005 12:02
Finding out boundary cells in a domain Abbas FLUENT 4 October 13, 2003 04:56
New List of Free CFD Codes Bert Laney Main CFD Forum 5 September 15, 1999 15:24


All times are GMT -4. The time now is 09:45.