void UpdateRadius(CellPtr pCell){
  double MaxRad = GetMaxRadius(pCell);
  double Rad = pCell->GetCellData()->GetItem("Radius");
  if(Rad<MaxRad-0.1){
    SetRadius(pCell,Rad+=GetTimestep());
  }
};
void CellDataItemWriter<ELEMENT_DIM, SPACE_DIM>::VisitCell(CellPtr pCell, AbstractCellPopulation<ELEMENT_DIM, SPACE_DIM>* pCellPopulation)
{
    // Output the location index corresponding to this cell
    unsigned location_index = pCellPopulation->GetLocationIndexUsingCell(pCell);
    *this->mpOutStream << location_index << " ";

    // Output this cell's ID
    unsigned cell_id = pCell->GetCellId();
    *this->mpOutStream << cell_id << " ";

    // Output the position of this cell's centre
    c_vector<double, SPACE_DIM> centre_location = pCellPopulation->GetLocationOfCellCentre(pCell);
    for (unsigned i=0; i<SPACE_DIM; i++)
    {
        *this->mpOutStream << centre_location[i] << " ";
    }

    // Output this cell's level of mCellDataVariableName
    double value = pCell->GetCellData()->GetItem(mCellDataVariableName);
    *this->mpOutStream << value << " ";
}
double CellDataItemWriter<ELEMENT_DIM, SPACE_DIM>::GetCellDataForVtkOutput(CellPtr pCell, AbstractCellPopulation<ELEMENT_DIM, SPACE_DIM>* pCellPopulation)
{
    double value = pCell->GetCellData()->GetItem(mCellDataVariableName);
    return value;
}
double GetMaxRadius(CellPtr pCell){
    return pCell->GetCellData()->GetItem("MaxRadius");
};
double GetDistanceFromDTC(CellPtr pCell){
    return pCell->GetCellData()->GetItem("DistanceAwayFromDTC");
};
void SetRadius(CellPtr pCell, double radius){
      pCell->GetCellData()->SetItem("Radius",radius);
};
//Elegans Specific
void SetProliferationFlag(CellPtr pCell, double Flag){
    pCell->GetCellData()->SetItem("Proliferating",0.0);
};
void FoodDifferentialByLabelAreaModifier<DIM>::UpdateTargetAreaOfCell(
		CellPtr pCell) {
	// Get target area A of a healthy cell in S, G2 or M phase
	double cell_target_area = this->mReferenceTargetArea;
	//std::cout<<GetCellularFood()<<std::endl;

	if (!pCell->ReadyToDivide()) {
		if (pCell->HasCellProperty<ApoptoticCellProperty>()) {
			//std::cout<<"apoptotic!!"<<std::endl;
			cell_target_area = cell_target_area - 0.001 * cell_target_area;

			// Don't allow a negative target area
			if (cell_target_area < 0) {
				cell_target_area = 0;
			}
		} else {
			if (pCell->template HasCellProperty<CellLabel>()) {
				double cell_age = pCell->GetAge();
				double growth_start_time = 5;
				AbstractCellCycleModel* p_model = pCell->GetCellCycleModel();

				if (cell_age > growth_start_time) {
					if (GetCellularFood() > 1
							&& cell_target_area <= 2 * cAreaIdeal) {
						double g2_duration = p_model->GetG2Duration();
						cell_target_area *=
								(1
										+ (cell_age - growth_start_time)
										/ (g2_duration * 2));
						DecreaseCellularFood();
						DecreaseCellularFood();

						if (pCell->template HasCellProperty<ApoptoticCellProperty>()) {
							pCell->template RemoveCellProperty<ApoptoticCellProperty>();
						}

					} else {
						MAKE_PTR(ApoptoticCellProperty, apoptotic);
						pCell->AddCellProperty(apoptotic);
					}
				}
			} else {
				double cell_age = pCell->GetAge();
				double growth_start_time = 7;
				AbstractCellCycleModel* p_model = pCell->GetCellCycleModel();

				//std::cout<<"edad: "<< cell_age <<" "<< growth_start_time<<std::endl;
				// The target area of a proliferating cell increases linearly from A to 2A over the course of the G2 phase
				if (cell_age > growth_start_time
						&& cell_target_area <= 2 * cAreaIdeal && pCell->GetCellData()->GetItem("Fitness") > 0) {

					double g2_duration = p_model->GetG2Duration();
					cell_target_area *= (1
							+ ((cell_age-growth_start_time) * pCell->GetCellData()->GetItem("Fitness")
									/ (g2_duration * 1)));
				}
				IncreaseCellularFood();
			}
		}
	}

	if (cell_target_area > 2.2){
		cell_target_area = 2.2;
	}

	// Set cell data
	pCell->GetCellData()->SetItem("target area", cell_target_area);
}