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

OF23x: const labelList& cZone() and const cellZone& cZone() not working

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By floquation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 24, 2014, 01:52
Default OF23x: const labelList& cZone() and const cellZone& cZone() not working
  #1
Member
 
Join Date: Jul 2011
Posts: 54
Rep Power: 15
A_Pete is on a distinguished road
I was just trying to do a loop over all the cells in a cellZone. I am pretty sure that this worked some while ago with 2.2.x. The compiler doesn't complain, but the solver does. I have three examples below which could all be compiled, but the solver stops when he gets to the specific points that I marked. The solver doesn't have a problem getting the cellZone's idea nor getting a reference to the whole cellZoneMesh. It stops when trying to define one single cellZone though. In the 3rd example it stops when getting to the loop, which is basically the same problem for me.

Version 1:
Code:
const cellZoneMesh& czm(mesh.cellZones());    // this works
const label& zoneID(mesh.cellZones().findZoneID(faceName));    // this works

const cellZone& cZone2(czm[zoneID]);    // this doesn't work -> solver stops here
Version 2:
Code:
const cellZoneMesh& czm(mesh.cellZones());    // this works
const label& zoneID(mesh.cellZones().findZoneID(faceName));    // this works

const labelList& cZone2(czm[zoneID]);    // this doesn't work -> solver stops here
Version 3:
Code:
const cellZoneMesh& czm(mesh.cellZones());    // this works
const label& zoneID(mesh.cellZones().findZoneID(faceName));    // this works

forAll(czm[zoneID], i);    // this doesn't work -> solver stops here
I am pretty sure that it should be possible to loop over all the cells in a cellZone, since I can find these code snippets in the repository's sources as well. I am also quite confident that I used this kind of syntax in 2.2.x before.

Does anybody have an idea what I am doing wrong here?
A_Pete is offline   Reply With Quote

Old   October 24, 2014, 03:37
Default
  #2
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
I'm not an expert, but I do have 2 general suggestions in analogy with problems I faced with OF23x's cellID.

From the looks of it,
Code:
czm[zoneID]
is failing. Consequently I assume that zoneID is out of bounds.

Suggestions:
  1. Add a print statement between the working line and the failing line, displaying zoneID. I suspect that it is out of bounds (e.g., OF might return -1 if "faceName" is not recognized).
    Code:
    Sout << "[" << Pstream::myProcNo() << "] zoneID = " << zoneID<< nl;
    (Note that this prints for every processor. In case you are running parallel (are you?) and a zone is not known to that specific processor, that specific processor may return -1 and consequently crash your simulation, even though "faceName" is known to one processor.)
  2. Post your (runtime) error on the forums, such that someone might recognize it.
A_Pete likes this.
floquation is offline   Reply With Quote

Old   October 24, 2014, 04:47
Default
  #3
Member
 
Join Date: Jul 2011
Posts: 54
Rep Power: 15
A_Pete is on a distinguished road
Ah yeah that "Sout" output helped me! I was looking for the wrong zoneID! Thanks man!
A_Pete 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



All times are GMT -4. The time now is 15:32.