OffLatticeSimulation.hpp

00001 /*
00002 
00003 Copyright (c) 2005-2015, 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 #ifndef OFFLATTICESIMULATION_HPP_
00037 #define OFFLATTICESIMULATION_HPP_
00038 
00039 #include "AbstractCellBasedSimulation.hpp"
00040 #include "AbstractForce.hpp"
00041 #include "AbstractCellPopulationBoundaryCondition.hpp"
00042 
00043 #include "ChasteSerialization.hpp"
00044 #include <boost/serialization/base_object.hpp>
00045 #include <boost/serialization/set.hpp>
00046 #include <boost/serialization/vector.hpp>
00047 
00068 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM=ELEMENT_DIM>
00069 class OffLatticeSimulation : public AbstractCellBasedSimulation<ELEMENT_DIM,SPACE_DIM>
00070 {
00071 private:
00072 
00074     friend class boost::serialization::access;
00075     friend class TestOffLatticeSimulationWithNodeBasedCellPopulation;
00076 
00083     template<class Archive>
00084     void serialize(Archive & archive, const unsigned int version)
00085     {
00086         archive & boost::serialization::base_object<AbstractCellBasedSimulation<ELEMENT_DIM,SPACE_DIM> >(*this);
00087         archive & mForceCollection;
00088         archive & mBoundaryConditions;
00089     }
00090 
00091 protected:
00092 
00094     std::vector<boost::shared_ptr<AbstractForce<ELEMENT_DIM, SPACE_DIM> > > mForceCollection;
00095 
00097     std::vector<boost::shared_ptr<AbstractCellPopulationBoundaryCondition<ELEMENT_DIM,SPACE_DIM> > > mBoundaryConditions;
00098 
00104     virtual void UpdateCellLocationsAndTopology();
00105 
00112     virtual void UpdateNodePositions();
00113 
00117     virtual void SetupSolve();
00118 
00136     virtual c_vector<double, SPACE_DIM> CalculateCellDivisionVector(CellPtr pParentCell);
00137 
00141     virtual void WriteVisualizerSetupFile();
00142 
00143 public:
00144 
00154     OffLatticeSimulation(AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>& rCellPopulation,
00155                          bool deleteCellPopulationInDestructor=false,
00156                          bool initialiseCells=true);
00157 
00163     void AddForce(boost::shared_ptr<AbstractForce<ELEMENT_DIM,SPACE_DIM> > pForce);
00164 
00168     void RemoveAllForces();
00169 
00175     void AddCellPopulationBoundaryCondition(boost::shared_ptr<AbstractCellPopulationBoundaryCondition<ELEMENT_DIM,SPACE_DIM> >  pBoundaryCondition);
00176 
00180     void RemoveAllCellPopulationBoundaryConditions();
00181 
00188     void OutputAdditionalSimulationSetup(out_stream& rParamsFile);
00189 
00198     virtual void OutputSimulationParameters(out_stream& rParamsFile);
00199 };
00200 
00201 // Serialization for Boost >= 1.36
00202 #include "SerializationExportWrapper.hpp"
00203 EXPORT_TEMPLATE_CLASS_ALL_DIMS(OffLatticeSimulation)
00204 
00205 namespace boost
00206 {
00207 namespace serialization
00208 {
00212 template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00213 inline void save_construct_data(
00214     Archive & ar, const OffLatticeSimulation<ELEMENT_DIM,SPACE_DIM> * t, const BOOST_PFTO unsigned int file_version)
00215 {
00216     // Save data required to construct instance
00217     const AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>* p_cell_population = &(t->rGetCellPopulation());
00218     ar & p_cell_population;
00219 }
00220 
00224 template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00225 inline void load_construct_data(
00226     Archive & ar, OffLatticeSimulation<ELEMENT_DIM,SPACE_DIM> * t, const unsigned int file_version)
00227 {
00228     // Retrieve data from archive required to construct new instance
00229     AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>* p_cell_population;
00230     ar >> p_cell_population;
00231 
00232     // Invoke inplace constructor to initialise instance, last two variables set extra
00233     // member variables to be deleted as they are loaded from archive and to not initialise sells.
00234     ::new(t)OffLatticeSimulation<ELEMENT_DIM,SPACE_DIM>(*p_cell_population, true, false);
00235 }
00236 }
00237 } // namespace
00238 
00239 #endif /*OFFLATTICESIMULATION_HPP_*/

Generated by  doxygen 1.6.2