Exemplo n.º 1
0
void CryptProjectionForce::UpdateNode3dLocationMap(AbstractCellPopulation<2>& rCellPopulation)
{
    mNode3dLocationMap.clear();

    c_vector<double, 2> node_location_2d;
    c_vector<double, 3> node_location_3d;

    // Only consider nodes corresponding to real cells
    for (AbstractCellPopulation<2>::Iterator cell_iter = rCellPopulation.Begin();
         cell_iter != rCellPopulation.End();
         ++cell_iter)
    {
        // Get node index
        unsigned node_index = rCellPopulation.GetLocationIndexUsingCell(*cell_iter);

        // Get 3D location
        node_location_2d = rCellPopulation.GetLocationOfCellCentre(*cell_iter);

        node_location_3d[0] = node_location_2d[0];
        node_location_3d[1] = node_location_2d[1];
        node_location_3d[2] = CalculateCryptSurfaceHeightAtPoint(node_location_2d);

        // Add to map
        mNode3dLocationMap[node_index] = node_location_3d;
    }
}
    /*
     * Next, we define the {{{UpdateCellData()}}} method itself. This is a helper
     * method that computes the height (y coordinate) of each cell in the population
     * and stores this in the {{{CellData}}} property.
     */
    void UpdateCellData(AbstractCellPopulation<2,2>& rCellPopulation)
    {
        /*
         * We begin by calling {{{Update()}}} on the cell population, which ensures that
         * it is in a coherent state.
         */
        rCellPopulation.Update();

        /*
         * Next, we iterate over the cell population...
         */
        for (AbstractCellPopulation<2>::Iterator cell_iter = rCellPopulation.Begin();
             cell_iter != rCellPopulation.End();
             ++cell_iter)
        {
            /*
             * ...find its height...
             */
            double cell_height = rCellPopulation.GetLocationOfCellCentre(*cell_iter)[1];

            /*
             * ...and store this in the {{{CellData}}} item "height".
             */
            cell_iter->GetCellData()->SetItem("height", cell_height);
        }
    }
    /* The second public method overrides {{{AddForceContribution()}}}.
     * This method takes in one argument, a reference to the cell population itself.
     */
    void AddForceContribution(AbstractCellPopulation<2>& rCellPopulation)
    {
        /* Inside the method, we loop over cells, and add a vector to
         * each node associated with cells with the {{{MotileCellProperty}}}, which is proportional (with constant {{{mStrength}}}) to the negative of the position. Causing
         * cells to move inwards towards the origin. Note that this will currently only work with subclasses of {{{AbstractCentreBasedCellPopulation}}}s as
         * we associate cells with nodes in the force calculation. However, this could easily be modified to make it work for {{{VertexBasedCellPopulation}}}s.
         */
        for (AbstractCellPopulation<2>::Iterator cell_iter = rCellPopulation.Begin();
             cell_iter != rCellPopulation.End();
             ++cell_iter)
        {
            if (cell_iter->HasCellProperty<MotileCellProperty>())
            {
                unsigned node_index = rCellPopulation.GetLocationIndexUsingCell(*cell_iter);

                c_vector<double, 2> location = rCellPopulation.GetLocationOfCellCentre(*cell_iter);
                c_vector<double, 2> force = -1.0 * mStrength * location;
                rCellPopulation.GetNode(node_index)->AddAppliedForceContribution(force);
            }
        }
    }