View Issue Details

IDProjectCategoryView StatusLast Update
0001556OpenFOAM[All Projects] Bugpublic2015-03-05 17:21
ReportertniemiAssigned Tohenry 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Fixed in Version 
Summary0001556: Lagrangian PatchInjection, wrong number of injected parcels in parallel cases
DescriptionIn parallel cases a wrong number of parcels can be injected, if a patch is shared between multiple processors. This is due to a bug in the algorithm which decides the injecting processor.

The injecting processor is determined in patchInjectionBase.C in lines 168-178. The problem is that each processor computes a separate areaFraction in line 168. If the random generators are not in a same state, each processor gets a different areaFraction. This can lead to errors, because different processors can have different ideas on who's turn it is to inject the parcel.

The problem can be simply fixed by forcing a unique areaFraction to each processor. I tested a quick fix, which worked ok (placed in the beginning of the function for reduce to work):

scalar areaFraction = 0;
    
if (Pstream::master())
{
    areaFraction = rnd.position<scalar>(0, patchArea_);
}
reduce(areaFraction, sumOp<scalar>());

Also I think that the check in line 173 (areaFraction > sumTriMagSf_[i]) should have a >=, because otherwise if areaFraction == 0 no parcel will be injected. (extremely rare but possible)
TagsNo tags attached.

Activities

henry

2015-03-05 11:54

manager   ~0003961

Thanks, I will work on this later today. If you could attach your corrected patchInjectionBase.C it would help.

tniemi

2015-03-05 11:55

reporter  

patchInjectionBase.C (7,248 bytes)

tniemi

2015-03-05 11:58

reporter   ~0003962

Uploaded. My fix is very quick and dirty and probably can be done more elegantly. I'm not just very good with the Pstream/parallel syntax :)

henry

2015-03-05 15:50

manager   ~0003964

Thanks. So the proposal is to calculate the areaFraction only on the master and distribute to the slaves? I will look at a better approach than using a sum-reduction.

henry

2015-03-05 17:09

manager   ~0003966

Conceptually the scatter function is more appropriate:

    scalar areaFraction = 0;

    if (Pstream::master())
    {
        areaFraction = rnd.position<scalar>(0, patchArea_);
    }

    Pstream::scatter(areaFraction);

henry

2015-03-05 17:21

manager   ~0003967

Resolved by commit b6a9960198a8b8492cf33a5a467c38580ad698b7

Issue History

Date Modified Username Field Change
2015-03-05 11:49 tniemi New Issue
2015-03-05 11:54 henry Note Added: 0003961
2015-03-05 11:55 tniemi File Added: patchInjectionBase.C
2015-03-05 11:58 tniemi Note Added: 0003962
2015-03-05 15:50 henry Note Added: 0003964
2015-03-05 17:09 henry Note Added: 0003966
2015-03-05 17:21 henry Note Added: 0003967
2015-03-05 17:21 henry Status new => resolved
2015-03-05 17:21 henry Resolution open => fixed
2015-03-05 17:21 henry Assigned To => henry