CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

coded FO, cellzone and new volScalarField: problem with mpirun

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 13, 2020, 09:49
Default coded FO, cellzone and new volScalarField: problem with mpirun
  #1
New Member
 
Pietro Tavazzi
Join Date: Aug 2019
Location: Milan, Italy
Posts: 8
Rep Power: 7
elden is on a distinguished road
Hi,
I'm trying to run a few tests before converting the following coded FO in an actual OpenFoam FO.

This FO initialises a zero volScalarField in all the grid, then it changes its values ONLY in a previously generated cellZone (by means of topoSet). Each cell value of the volScalarField is now 0 or 1. The output consists of cells number where 0 becomes 1, printed in the logfile.

I noticed differences in the output running the case with mpirun. Looking at the results in paraview it seems that there is an error in forAll cycle: the coded FO changes the values of the new volScalarField outside the defined cellzone.

I thought the problem was related to the definition of the scalar "sum" and that the answer I was looking for was associated with the use of the reduce() command, but I didn't solve it.
Attached Images
File Type: png codedFO.png (50.6 KB, 26 views)

Last edited by elden; March 13, 2020 at 09:55. Reason: missing code
elden is offline   Reply With Quote

Old   March 13, 2020, 12:33
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
An indexing error in your code.
You want something like this instead:
Code:
forAll(cz, i)
{
    const label celli = cz[i];
    ....
}
Unless you need the loop index, it is often safer and clearer to use a range-for:

Code:
for (const label celli : cz)
{
    ....
}
/mark




@Bruno - relocate to programming?
elden likes this.
olesen is offline   Reply With Quote

Old   March 13, 2020, 12:47
Default
  #3
New Member
 
Pietro Tavazzi
Join Date: Aug 2019
Location: Milan, Italy
Posts: 8
Rep Power: 7
elden is on a distinguished road
Thanks a lot.
And sorry for the silly question.
elden is offline   Reply With Quote

Reply

Tags
cellzone, coded, mpirun


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 12:15.