Chaste Release::3.1
|
00001 /* 00002 00003 Copyright (c) 2005-2012, University of Oxford. 00004 All rights reserved. 00005 00006 University of Oxford means the Chancellor, Masters and Scholars of the 00007 University of Oxford, having an administrative office at Wellington 00008 Square, Oxford OX1 2JD, UK. 00009 00010 This file is part of Chaste. 00011 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions are met: 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright notice, 00017 this list of conditions and the following disclaimer in the documentation 00018 and/or other materials provided with the distribution. 00019 * Neither the name of the University of Oxford nor the names of its 00020 contributors may be used to endorse or promote products derived from this 00021 software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 */ 00035 00036 #include "CryptSimulation1d.hpp" 00037 #include "WntConcentration.hpp" 00038 #include "SmartPointers.hpp" 00039 00040 CryptSimulation1d::CryptSimulation1d(AbstractCellPopulation<1>& rCellPopulation, 00041 bool deleteCellPopulationInDestructor, 00042 bool initialiseCells) 00043 : OffLatticeSimulation<1>(rCellPopulation, 00044 deleteCellPopulationInDestructor, 00045 initialiseCells) 00046 { 00047 mpStaticCastCellPopulation = static_cast<MeshBasedCellPopulation<1>*>(&mrCellPopulation); 00048 00049 if (!mDeleteCellPopulationInDestructor) 00050 { 00051 // Pass a CryptSimulationBoundaryCondition object into mBoundaryConditions 00052 MAKE_PTR_ARGS(CryptSimulationBoundaryCondition<1>, p_bc, (&rCellPopulation)); 00053 AddCellPopulationBoundaryCondition(p_bc); 00054 } 00055 } 00056 00057 CryptSimulation1d::~CryptSimulation1d() 00058 { 00059 } 00060 00061 c_vector<double, 1> CryptSimulation1d::CalculateCellDivisionVector(CellPtr pParentCell) 00062 { 00063 // Location of parent and daughter cells 00064 c_vector<double, 1> parent_coords = mpStaticCastCellPopulation->GetLocationOfCellCentre(pParentCell); 00065 c_vector<double, 1> daughter_coords; 00066 00067 // Get separation parameter 00068 double separation = mpStaticCastCellPopulation->GetMeinekeDivisionSeparation(); 00069 00070 // Make a random direction vector of the required length 00071 c_vector<double, 1> random_vector; 00072 00073 /* 00074 * Pick a random direction and move the parent cell backwards by 0.5*separation 00075 * in that direction and return the position of the daughter cell 0.5*separation 00076 * forwards in that direction. 00077 */ 00078 00079 double random_direction = -1.0 + 2.0*(RandomNumberGenerator::Instance()->ranf() < 0.5); 00080 random_vector(0) = 0.5*separation*random_direction; 00081 c_vector<double, 1> proposed_new_parent_coords = parent_coords - random_vector; 00082 c_vector<double, 1> proposed_new_daughter_coords = parent_coords + random_vector; 00083 00084 if ( (proposed_new_parent_coords(0) >= 0.0) 00085 && (proposed_new_daughter_coords(0) >= 0.0)) 00086 { 00087 // We are not too close to the bottom of the cell population, so move parent 00088 parent_coords = proposed_new_parent_coords; 00089 daughter_coords = proposed_new_daughter_coords; 00090 } 00091 else 00092 { 00093 proposed_new_daughter_coords = parent_coords + 2.0*random_vector; 00094 while (proposed_new_daughter_coords(0) < 0.0) 00095 { 00096 double random_direction = -1.0 + 2.0*(RandomNumberGenerator::Instance()->ranf() < 0.5); 00097 random_vector(0) = 0.5*separation*random_direction; 00098 proposed_new_daughter_coords = parent_coords + random_vector; 00099 } 00100 daughter_coords = proposed_new_daughter_coords; 00101 } 00102 00103 assert(daughter_coords(0) >= 0.0); // to make sure dividing cells stay in the cell population 00104 assert(parent_coords(0) >= 0.0); // to make sure dividing cells stay in the cell population 00105 00106 // Set the parent to use this location 00107 ChastePoint<1> parent_coords_point(parent_coords); 00108 00109 unsigned node_index = mpStaticCastCellPopulation->GetLocationIndexUsingCell(pParentCell); 00110 mrCellPopulation.SetNode(node_index, parent_coords_point); 00111 00112 return daughter_coords; 00113 } 00114 00115 void CryptSimulation1d::OutputSimulationParameters(out_stream& rParamsFile) 00116 { 00117 // No parameters to output 00118 00119 // Call method on direct parent class 00120 OffLatticeSimulation<1>::OutputSimulationParameters(rParamsFile); 00121 } 00122 00123 // Serialization for Boost >= 1.36 00124 #include "SerializationExportWrapperForCpp.hpp" 00125 CHASTE_CLASS_EXPORT(CryptSimulation1d)