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 Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 13, 2020, 08:49
Default coded FO, cellzone and new volScalarField: problem with mpirun
  #1
New Member
 
Pietro Tavazzi
Join Date: Aug 2019
Location: Milan, Italy
Posts: 7
Rep Power: 3
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, 9 views)

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

Old   March 13, 2020, 11:33
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 1,001
Rep Power: 27
olesen will become famous soon enougholesen will become famous soon enough
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, 11:47
Default
  #3
New Member
 
Pietro Tavazzi
Join Date: Aug 2019
Location: Milan, Italy
Posts: 7
Rep Power: 3
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

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



All times are GMT -4. The time now is 19:55.