![]() |
Looping over a volScalarField in a parallel run
Dear all,
I'd like to do some on-the-run monitoring of my computation where I am interested in a temperature front. Actually, of all the cells in my domain where the temperature exceeds 1000 K, I'd like to determine the one which has the highest x-coordinate. My code looks like this: Code:
label maxindex=0;Regards, Florian |
ooo, a well formulated problem with a simple answer, my favourite :)
you cant use the index cause it only makes sense on the own processor. I would do it like this. Code:
scalar xMax = -1.0e+10; |
Thank you Niklas,
the reduce command should read Code:
reduce(xMax, maxOp<scalar>());A more tricky problem: I also want to know the y and z coordinate of the location, where the highest x coordinate is (not the maximum y and z coordinate). So a separate reduce on the scalars won't work. Code:
scalar xMax = -1.0e+10;Thanks, Florian |
That was a bit trickier...
I dont know if there's such an operation already implemented, but I would transfer the location vector for each coordinate to the main processor and do the comparison there. Here's a piece of code that generates a random vector on each processor and sends it to the 0-processor, it should be straightforward to apply it to your case. You might wanna put it inside an if(Pstream:: parRun()) if you want it to work for both serial and parallell runs. (edit:: actually its not necessary) Code:
Random rnd(0); |
Thank you, it seems to work fine!
|
| All times are GMT -4. The time now is 01:40. |