void TestConstruct2dParallelPopulation() throw (Exception)
    {
        NodesOnlyMesh<2> mesh;
        mesh.SetMaximumInteractionDistance(0.5);

        std::vector<CellPtr> cells;

        ParallelCellsGenerator<StochasticDurationGenerationBasedCellCycleModel, 2> generator;
        c_vector<double, 4> bounding_box = generator.GetArchiveBoundingBox("cell_based/test/data/TestParallelConstruction/Population2d.dat");

        TS_ASSERT_DELTA(bounding_box[0], 0.0, 1e-4);
        TS_ASSERT_DELTA(bounding_box[1], 1.0, 1e-4);
        TS_ASSERT_DELTA(bounding_box[2], 0.0, 1e-4);
        TS_ASSERT_DELTA(bounding_box[3], 1.0, 1e-4);

        generator.GenerateParallelCells("cell_based/test/data/TestParallelConstruction/Population2d.dat", cells, mesh, CellPropertyRegistry::Instance()->Get<TransitCellProliferativeType>());

        unsigned num_nodes = mesh.GetNumNodes();
        unsigned total_nodes;

        MPI_Allreduce(&num_nodes, &total_nodes, 1, MPI_UNSIGNED, MPI_SUM, PetscTools::GetWorld());
        TS_ASSERT_EQUALS(total_nodes, 4u);

        unsigned num_cells = cells.size();
        unsigned total_cells;

        MPI_Allreduce(&num_cells, &total_cells, 1, MPI_UNSIGNED, MPI_SUM, PetscTools::GetWorld());
        TS_ASSERT_EQUALS(total_cells, 4u);

        for (unsigned i=0; i<cells.size(); i++)
        {
            TS_ASSERT(cells[i]->GetCellProliferativeType()->IsType<TransitCellProliferativeType>());
        }
    }
    void TestConstruct1dParallelPopulation() throw (Exception)
    {
        NodesOnlyMesh<1> mesh;
        mesh.SetMaximumInteractionDistance(0.5);

        std::vector<CellPtr> cells;

        ParallelCellsGenerator<FixedDurationGenerationBasedCellCycleModel, 1> generator;
        c_vector<double, 2> bounding_box = generator.GetArchiveBoundingBox("cell_based/test/data/TestParallelConstruction/Population1d.dat");

        TS_ASSERT_DELTA(bounding_box[0], 0.0, 1e-4);
        TS_ASSERT_DELTA(bounding_box[1], 1.0, 1e-4);

        // Check an assertion which tests whether the space dimensions of the mesh and archive file are consistent.
        TS_ASSERT_THROWS_THIS(generator.GetArchiveBoundingBox("cell_based/test/data/TestParallelConstruction/Population2d.dat"), "Space dimension of ParallelCellsGenerator and archive file do not match");

        generator.GenerateParallelCells("cell_based/test/data/TestParallelConstruction/Population1d.dat", cells, mesh, CellPropertyRegistry::Instance()->Get<DifferentiatedCellProliferativeType>());

        unsigned num_nodes = mesh.GetNumNodes();
        unsigned total_nodes;

        MPI_Allreduce(&num_nodes, &total_nodes, 1, MPI_UNSIGNED, MPI_SUM, PetscTools::GetWorld());
        TS_ASSERT_EQUALS(total_nodes, 2u);

        unsigned num_cells = cells.size();
        unsigned total_cells;

        MPI_Allreduce(&num_cells, &total_cells, 1, MPI_UNSIGNED, MPI_SUM, PetscTools::GetWorld());
        TS_ASSERT_EQUALS(total_cells, 2u);

        for (unsigned i=0; i<cells.size(); i++)
        {
            TS_ASSERT(cells[i]->GetCellProliferativeType()->IsType<DifferentiatedCellProliferativeType>());
        }
    }