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

Finding list of cells according to a condition

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   December 19, 2009, 00: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,894
Rep Power: 26
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   December 19, 2009, 22:23
Default
  #2
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 386
Rep Power: 15
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, 04:49
Default
  #3
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   January 19, 2010, 06:07
Default
  #4
aot
New Member
 
Andreas Otto
Join Date: Sep 2009
Posts: 10
Rep Power: 7
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, 17:55
Default
  #5
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SnappyHexMesh for internal Flow vishwa OpenFOAM Native Meshers: snappyHexMesh and Others 23 August 6, 2014 03:50
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 13:43.