Example #1
0
void FineCoarseMeshPair<DIM>::ComputeCoarseElementsForFineElementCentroids(bool safeMode)
{
    if (mpCoarseMeshBoxCollection==NULL)
    {
        EXCEPTION("Call SetUpBoxesOnCoarseMesh() before ComputeCoarseElementsForFineElementCentroids()");
    }

    #define COVERAGE_IGNORE
    if(CommandLineArguments::Instance()->OptionExists("-mesh_pair_verbose"))
    {
        std::cout << "\nComputing coarse elements for fine element centroids\n";
    }
    #undef COVERAGE_IGNORE

    mCoarseElementsForFineElementCentroids.resize(mrFineMesh.GetNumElements());

    ResetStatisticsVariables();
    for (unsigned i=0; i<mrFineMesh.GetNumElements(); i++)
    {
        #define COVERAGE_IGNORE
        if(CommandLineArguments::Instance()->OptionExists("-mesh_pair_verbose"))
        {
            std::cout << "\t" << i << " of " << mrFineMesh.GetNumElements() << std::flush;
        }
        #undef COVERAGE_IGNORE

        c_vector<double,DIM> point_cvec = mrFineMesh.GetElement(i)->CalculateCentroid();
        ChastePoint<DIM> point(point_cvec);

        // Get the box this point is in
        unsigned box_for_this_point = mpCoarseMeshBoxCollection->CalculateContainingBox( point_cvec );

        mCoarseElementsForFineElementCentroids[i] = ComputeCoarseElementForGivenPoint(point, safeMode, box_for_this_point);
    }
}
Example #2
0
void FineCoarseMeshPair<DIM>::ComputeCoarseElementsForFineNodes(bool safeMode)
{
    if (mpCoarseMeshBoxCollection==NULL)
    {
        EXCEPTION("Call SetUpBoxesOnCoarseMesh() before ComputeCoarseElementsForFineNodes()");
    }

    #define COVERAGE_IGNORE
    if(CommandLineArguments::Instance()->OptionExists("-mesh_pair_verbose"))
    {
        std::cout << "\nComputing coarse elements for fine nodes\n";
    }
    #undef COVERAGE_IGNORE
    mCoarseElementsForFineNodes.clear();
    mCoarseElementsForFineNodes.resize(mrFineMesh.GetNumNodes(), 0.0);

    ResetStatisticsVariables();
    for (unsigned i=0; i<mCoarseElementsForFineNodes.size(); i++)
    {
        #define COVERAGE_IGNORE
        if(CommandLineArguments::Instance()->OptionExists("-mesh_pair_verbose"))
        {
            std::cout << "\t" << i << " of " << mCoarseElementsForFineNodes.size() << std::flush;
        }
        #undef COVERAGE_IGNORE

        ChastePoint<DIM> point = mrFineMesh.GetNode(i)->GetPoint();

        // Get the box this point is in
        unsigned box_for_this_point = mpCoarseMeshBoxCollection->CalculateContainingBox(mrFineMesh.GetNode(i)->rGetModifiableLocation());
        if (mpCoarseMeshBoxCollection->IsBoxOwned(box_for_this_point))
        {
            mCoarseElementsForFineNodes[i] = ComputeCoarseElementForGivenPoint(point, safeMode, box_for_this_point);
        }
    }
    ShareCoarseElementData();
}