VasiliBaranov/packing-generation

Crash in ColumnMajorIndexingProvider::ApplyPeriodicity

Closed this issue · 0 comments

Dear Dr Vasili,
I was able to build your great program and running with the genration.conf and diameters.txt but the program is crashing in the following function (division by zero).

diameters.txt
--------Generation.conf ----------
Particles count: 360
Packing size: 12.032 2.352 2.395
Generation start: 1
Seed: 250
Steps to write: 30
Boundaries mode: 1
Contraction rate: 1.328910e-005

  1. boundaries mode: 1 - bulk; 2 - ellipse (inscribed in XYZ box, Z is length of an ellipse); 3 - rectangle
  2. generationMode = 1 (Poisson, R) or 2 (Poisson in cells, S)

int ColumnMajorIndexingProvider::ApplyPeriodicity(int coordinate, Axis::Type dimension) const
{
if (coordinate >= 0 && coordinate < systemSize[dimension])
{
return coordinate;
}

    if (!geometryParameters->IsPeriodicByAxis(dimension))
    {
        return ILinearIndexingProvider::UnavailableNodeIndex;
    }

    //let coordinate be -11, size in the dimension = 10
    if (coordinate < 0)
    {
        coordinate = - coordinate; //coordinate = 11
        if (systemSize[dimension] != 0)
			coordinate %= systemSize[dimension]; //vishy error by zero error
        if (coordinate != 0)
        {
            coordinate = systemSize[dimension] - coordinate; //coordinate = 9
        }
    }
    else
    {
        coordinate %= systemSize[dimension];
    }

    return coordinate;
}

}

Actually I am trying to use your program to solve the container packing problem:
Given the L B W of a container how many spheres (of different diameters) would fit in.
The input I am using are particle number=360 and with diameters.txt. I expect the program to report 360 packing not possible but less number (lets say 200) possible with these diameters that is the optimal.

Looking forward to your reply.
Best Regards,
Vishy