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

Iterate over nearing cells of a specified cell

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

Like Tree1Likes
  • 1 Post By ngj

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 3, 2014, 12:50
Default Iterate over nearing cells of a specified cell
  #1
ooo
Member
 
Join Date: Feb 2012
Posts: 49
Rep Power: 14
ooo is on a distinguished road
Hi FOAMers,

I've implemented a user-interpolation in OpenFOAM , but to compute the distance of the current cell to near cells, i have to iterate over all cells which can be costly.
So do you have any suggestion on how to iterate over a specified radius of a cell(or coordinate), and not over all cells. (to reduce computation cost)
What i'm doing :
Code:
forAll(U,cellI)
point[XX].x() - mesh.C()[cellI].x()
...
What i want to do:
Code:
forAll(iterate over nearing cells of point[XX].x()) 
point[XX].x() - mesh.C()[cellI].x()
...
Thank you in advance,
ooo is offline   Reply With Quote

Old   May 4, 2014, 14:26
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Good evening ooo

You should be able to construct what you want using the following methods in the mesh class:

Code:
mesh.cellCells();
mesh.pointCells();
mesh.cellPoints();
Be aware that you will need to treat the processor boundaries specially (and potentially also periodic/cyclic boundaries).

Kind regards,

Niels
ooo likes this.
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 20, 2014, 13:36
Default
  #3
ooo
Member
 
Join Date: Feb 2012
Posts: 49
Rep Power: 14
ooo is on a distinguished road
Quote:
Originally Posted by ngj View Post
Good evening ooo

You should be able to construct what you want using the following methods in the mesh class:

Code:
mesh.cellCells();
mesh.pointCells();
mesh.cellPoints();
Be aware that you will need to treat the processor boundaries specially (and potentially also periodic/cyclic boundaries).

Kind regards,

Niels
Thank you.
Having 2 cell layers (or maximum 3) is enough for me so i'm using this code.(if it works, then i continue to removing duplication by uniqueOrder...)
It gives no compilation error, but segmentation error in running.
Do you know what's the problem?
Code:
labelListList cellCells;
forAll(mesh.cells(),cellI)
        {
        labelList layer1 = mesh.cellCells()[cellI];
        cellCells[cellI].append(layer1) ;
        for(int i=0; i<layer1.size(); i++)
        {
        labelList layer2 = mesh.cellCells()[layer1[i]];
        cellCells[cellI].append(layer2);
        }
        }
ooo is offline   Reply With Quote

Old   May 20, 2014, 16:52
Default
  #4
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
You never define the size of cellCells, and afterward you to assign something to the ceellI'th array of cellCells, but it still does not have a size.

If I understand the code correct, the append works on the nested labelList, and not on the outer list.

Kind regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 20, 2014, 17:29
Default
  #5
ooo
Member
 
Join Date: Feb 2012
Posts: 49
Rep Power: 14
ooo is on a distinguished road
Thank you.
Using dynamic labelLists solved the problem.

Last edited by ooo; May 20, 2014 at 19:58.
ooo is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ICEM] Error in mesh writing helios ANSYS Meshing & Geometry 21 August 19, 2021 14:18
[snappyHexMesh] SnappyHexMesh for internal Flow vishwa OpenFOAM Meshing & Mesh Conversion 24 June 27, 2016 08:54
How to find the ghost cells in the immersed boundary methods? cyou Main CFD Forum 19 April 14, 2013 23:00
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 19:43
[Commercial meshers] Import error Gambit msh file with Cell Type 7 polyhedral cells philippose OpenFOAM Meshing & Mesh Conversion 1 June 1, 2007 02:58


All times are GMT -4. The time now is 05:13.