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