Chaste  Release::2018.1
CryptSimulation2d.cpp
1 /*
2 
3 Copyright (c) 2005-2018, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #include "CryptSimulation2d.hpp"
37 #include "CellAncestor.hpp"
38 #include "CellBetaCateninWriter.hpp"
39 #include "MeshBasedCellPopulation.hpp"
40 #include "SmartPointers.hpp"
41 #include "StemCellProliferativeType.hpp"
42 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisOne.hpp"
43 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisTwo.hpp"
44 #include "WntConcentration.hpp"
45 
47  bool deleteCellPopulationInDestructor,
48  bool initialiseCells)
49  : OffLatticeSimulation<2>(rCellPopulation,
50  deleteCellPopulationInDestructor,
51  initialiseCells),
52  mUsingMeshBasedCellPopulation(false)
53 {
54  /* Throw an exception message if not using a MeshBasedCellPopulation or a VertexBasedCellPopulation.
55  * This is to catch NodeBasedCellPopulations as AbstactOnLatticeBasedCellPopulations are caught in
56  * the OffLatticeSimulation constructor.
57  */
58  if ((dynamic_cast<VertexBasedCellPopulation<2>*>(&rCellPopulation) == nullptr)
59  && (dynamic_cast<MeshBasedCellPopulation<2>*>(&rCellPopulation) == nullptr))
60  {
61  EXCEPTION("CryptSimulation2d is to be used with MeshBasedCellPopulation or VertexBasedCellPopulation (or subclasses) only");
62  }
63 
64  if (dynamic_cast<MeshBasedCellPopulation<2>*>(&mrCellPopulation))
65  {
67 
68  MAKE_PTR(CryptCentreBasedDivisionRule<2>, p_centre_div_rule);
69  static_cast<MeshBasedCellPopulation<2>*>(&mrCellPopulation)->SetCentreBasedDivisionRule(p_centre_div_rule);
70  }
71  else // VertexBasedCellPopulation
72  {
73  MAKE_PTR(CryptVertexBasedDivisionRule<2>, p_vertex_div_rule);
74  static_cast<VertexBasedCellPopulation<2>*>(&mrCellPopulation)->SetVertexBasedDivisionRule(p_vertex_div_rule);
75  }
76 
78  {
79  // Pass a CryptSimulationBoundaryCondition object into mBoundaryConditions
80  MAKE_PTR_ARGS(CryptSimulationBoundaryCondition<2>, p_bc, (&rCellPopulation));
82  }
83 }
84 
86 {
87 }
88 
90 {
91  // First call method on base class
93 
94  /*
95  * To check if beta-catenin results will be written to file, we test if the first
96  * cell has a cell-cycle model that is a subclass of AbstractVanLeeuwen2009WntSwatCellCycleModel.
97  * In doing so, we assume that all cells in the simulation have the same cell-cycle
98  * model.
99  */
100  if (dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(this->mrCellPopulation.Begin()->GetCellCycleModel()))
101  {
102  mrCellPopulation.AddCellWriter<CellBetaCateninWriter>();
103  }
104 
105  if (dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(mrCellPopulation.Begin()->GetCellCycleModel()))
106  {
107  *mpVizSetupFile << "BetaCatenin\n";
108  }
109 }
110 
112 {
113  // The CryptSimulationBoundaryCondition object is the first element of mBoundaryConditions
114  boost::static_pointer_cast<CryptSimulationBoundaryCondition<2> >(mBoundaryConditions[0])->SetUseJiggledBottomCells(true);
115 }
116 
118 {
119  /*
120  * We use a different height threshold depending on which type of cell
121  * population we are using, a MeshBasedCellPopulationWithGhostNodes or
122  * a VertexBasedCellPopulation.
123  *
124  * \todo Make this threshold height a member variable and set it in the constructor,
125  * depending on the cell population type; this would allow us to remove mUsingMeshBasedCellPopulation
126  */
127  double threshold_height = 1.0;
129  {
130  threshold_height = 0.5;
131  }
132 
133  unsigned index = 0;
134  for (AbstractCellPopulation<2>::Iterator cell_iter = mrCellPopulation.Begin();
135  cell_iter != mrCellPopulation.End();
136  ++cell_iter)
137  {
138  if (mrCellPopulation.GetLocationOfCellCentre(*cell_iter)[1] < threshold_height)
139  {
140  MAKE_PTR_ARGS(CellAncestor, p_cell_ancestor, (index++));
141  cell_iter->SetAncestor(p_cell_ancestor);
142  }
143  }
144 }
145 
147 {
148  double width = mrCellPopulation.GetWidth(0);
149  bool use_jiggled_bottom_cells = boost::static_pointer_cast<CryptSimulationBoundaryCondition<2> >(mBoundaryConditions[0])->GetUseJiggledBottomCells();
150 
151  *rParamsFile << "\t\t<CryptCircumference>" << width << "</CryptCircumference>\n";
152  *rParamsFile << "\t\t<UseJiggledBottomCells>" << use_jiggled_bottom_cells << "</UseJiggledBottomCells>\n";
153 
154  // Call method on direct parent class
156 }
157 
158 // Serialization for Boost >= 1.36
#define EXCEPTION(message)
Definition: Exception.hpp:143
std::vector< boost::shared_ptr< AbstractCellPopulationBoundaryCondition< ELEMENT_DIM, ELEMENT_DIM > > > mBoundaryConditions
#define MAKE_PTR(TYPE, NAME)
CryptSimulation2d(AbstractCellPopulation< 2 > &rCellPopulation, bool deleteCellPopulationInDestructor=false, bool initialiseCells=true)
void OutputSimulationParameters(out_stream &rParamsFile)
#define CHASTE_CLASS_EXPORT(T)
#define MAKE_PTR_ARGS(TYPE, NAME, ARGS)
virtual void OutputSimulationParameters(out_stream &rParamsFile)
void AddCellPopulationBoundaryCondition(boost::shared_ptr< AbstractCellPopulationBoundaryCondition< ELEMENT_DIM, ELEMENT_DIM > > pBoundaryCondition)
AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM > & mrCellPopulation