SloughingCellKiller.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 #include "SloughingCellKiller.hpp"
00029 #include "AbstractCentreBasedCellPopulation.hpp"
00030 #include "PetscTools.hpp"
00031 
00032 template <unsigned DIM>
00033 SloughingCellKiller<DIM>::SloughingCellKiller(AbstractCellPopulation<DIM>* pCrypt, double sloughHeight, bool sloughSides, double sloughWidth)
00034     : AbstractCellKiller<DIM>(pCrypt),
00035       mSloughSides(sloughSides)
00036 {
00037     assert(sloughHeight > 0.0);
00038     mSloughHeight = sloughHeight;
00039 
00040     assert(sloughWidth > 0.0);
00041     mSloughWidth = sloughWidth;
00042 }
00043 
00044 template <unsigned DIM>
00045 bool SloughingCellKiller<DIM>::GetSloughSides() const
00046 {
00047     return mSloughSides;
00048 }
00049 
00050 template <unsigned DIM>
00051 double SloughingCellKiller<DIM>::GetSloughHeight() const
00052 {
00053     return mSloughHeight;
00054 }
00055 
00056 template <unsigned DIM>
00057 double SloughingCellKiller<DIM>::GetSloughWidth() const
00058 {
00059     return mSloughWidth;
00060 }
00061 
00062 
00063 template <unsigned DIM>
00064 void SloughingCellKiller<DIM>::TestAndLabelCellsForApoptosisOrDeath()
00065 {
00066     switch (DIM)
00067     {
00068         case 1:
00069         {
00070             for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = this->mpCellPopulation->Begin();
00071                  cell_iter != this->mpCellPopulation->End();
00072                  ++cell_iter)
00073             {
00074                 double x = this->mpCellPopulation->GetLocationOfCellCentre(*cell_iter)[0];
00075 
00076                 if (x > mSloughHeight)
00077                 {
00078                     cell_iter->Kill();
00079                 }
00080             }
00081             break;
00082         }
00083         case 2:
00084         {
00085             for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = this->mpCellPopulation->Begin();
00086                  cell_iter != this->mpCellPopulation->End();
00087                  ++cell_iter)
00088             {
00089                 c_vector<double, 2> location = this->mpCellPopulation->GetLocationOfCellCentre(*cell_iter);
00090                 double x = location[0];
00091                 double y = location[1];
00092 
00093                 if ( (y>mSloughHeight) ||  (mSloughSides && ((x<0.0) || (x>mSloughWidth))) )
00094                 {
00095                     cell_iter->Kill();
00096                 }
00097             }
00098             break;
00099         }
00100         case 3:
00101         {
00102             EXCEPTION("SloughingCellKiller is not yet implemented in 3D");
00103             break;
00104         }
00105         default:
00106             // This can't happen
00107             NEVER_REACHED;
00108     }
00109 }
00110 
00111 template<unsigned DIM>
00112 void SloughingCellKiller<DIM>::OutputCellKillerParameters(out_stream& rParamsFile)
00113 {
00114     *rParamsFile << "\t\t\t<SloughLength>" << mSloughHeight << "</SloughLength> \n";
00115     *rParamsFile << "\t\t\t<SloughSides>" << mSloughSides << "</SloughSides> \n";
00116     *rParamsFile << "\t\t\t<SloughWidth>" << mSloughWidth << "</SloughWidth> \n";
00117 
00118     // Call method on direct parent class
00119     AbstractCellKiller<DIM>::OutputCellKillerParameters(rParamsFile);
00120 }
00121 
00123 // Explicit instantiation
00125 
00126 template class SloughingCellKiller<1>;
00127 template class SloughingCellKiller<2>;
00128 template class SloughingCellKiller<3>;
00129 
00130 // Serialization for Boost >= 1.36
00131 #include "SerializationExportWrapperForCpp.hpp"
00132 EXPORT_TEMPLATE_CLASS_SAME_DIMS(SloughingCellKiller)

Generated on Mon Apr 18 11:35:28 2011 for Chaste by  doxygen 1.5.5