 
                 gridSpinEnergy = externalField;
 
-                for (int x = (int) i - radiusX; x <= (int) i + radiusX; x++)
-                {
-                    for (int y = (int) j - radiusY; y <= (int) j + radiusY; y++)
+                for (int x = i - radiusX; x <= i + radiusX; x++)
+                {
+                    for (int y = j - radiusY; y <= j + radiusY; y++)
                     {
-                        for (int z = (int) k - radiusZ; z <= (int) k + radiusZ; z++)
+                        for (int z = k - radiusZ; z <= k + radiusZ; z++)
                         {
                             xx = (xSize + x) % xSize;
                             yy = (ySize + y) % ySize;

    uint offsetz = gridDim.z * blockDim.z;

    float gridSize = 5.0f;

    // TODO
    float cubeSize = (gridSize / xSize) * (0.01f * percentOfCube);
    float cubeSpace = (gridSize / xSize) * (0.01f * (100 - percentOfCube));

    float lengthX = xSize * cubeSize + (xSize - 1) * cubeSpace;
    float lengthY = ySize * cubeSize + (ySize - 1) * cubeSpace;

        case DIM_2: radiusZ = 0; break;
    }

    for (int i = idx + idx * interactionRadius + iterx; i < xSize; i += gridOffsetx)
    {
        for (int j = idy + idy * interactionRadius + itery; j < ySize; j += gridOffsety)
        {
            for (int k = idz + idz * interactionRadius + iterz; k < zSize; k += gridOffsetz)
            {
                index = gridIndex(i, j, k);
                spinValue = data[index] - 1;
