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 #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 00082 template<class Archive> 00083 void serialize(Archive & archive, const unsigned int version) 00084 { 00085 archive & boost::serialization::base_object<AbstractCellBasedSimulation<ELEMENT_DIM,SPACE_DIM> >(*this); 00086 archive & mForceCollection; 00087 archive & mBoundaryConditions; 00088 archive & mOutputNodeVelocities; 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 00100 bool mOutputNodeVelocities; 00101 00103 out_stream mpNodeVelocitiesFile; 00104 00110 virtual void UpdateCellLocationsAndTopology(); 00111 00119 virtual void UpdateNodePositions(const std::vector< c_vector<double, SPACE_DIM> >& rNodeForces); 00120 00124 virtual void SetupSolve(); 00125 00129 virtual void UpdateAtEndOfSolve(); 00130 00147 virtual c_vector<double, SPACE_DIM> CalculateCellDivisionVector(CellPtr pParentCell); 00148 00152 virtual void WriteVisualizerSetupFile(); 00153 00154 public: 00155 00165 OffLatticeSimulation(AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>& rCellPopulation, 00166 bool deleteCellPopulationInDestructor=false, 00167 bool initialiseCells=true); 00168 00174 void AddForce(boost::shared_ptr<AbstractForce<ELEMENT_DIM,SPACE_DIM> > pForce); 00175 00179 void RemoveAllForces(); 00180 00186 void AddCellPopulationBoundaryCondition(boost::shared_ptr<AbstractCellPopulationBoundaryCondition<ELEMENT_DIM,SPACE_DIM> > pBoundaryCondition); 00187 00191 void RemoveAllCellPopulationBoundaryConditions(); 00192 00196 bool GetOutputNodeVelocities(); 00197 00203 void SetOutputNodeVelocities(bool outputNodeVelocities); 00204 00211 void OutputAdditionalSimulationSetup(out_stream& rParamsFile); 00212 00221 virtual void OutputSimulationParameters(out_stream& rParamsFile); 00222 }; 00223 00224 // Serialization for Boost >= 1.36 00225 #include "SerializationExportWrapper.hpp" 00226 EXPORT_TEMPLATE_CLASS_ALL_DIMS(OffLatticeSimulation) 00227 00228 namespace boost 00229 { 00230 namespace serialization 00231 { 00235 template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM> 00236 inline void save_construct_data( 00237 Archive & ar, const OffLatticeSimulation<ELEMENT_DIM,SPACE_DIM> * t, const BOOST_PFTO unsigned int file_version) 00238 { 00239 // Save data required to construct instance 00240 const AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>* p_cell_population = &(t->rGetCellPopulation()); 00241 ar & p_cell_population; 00242 } 00243 00247 template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM> 00248 inline void load_construct_data( 00249 Archive & ar, OffLatticeSimulation<ELEMENT_DIM,SPACE_DIM> * t, const unsigned int file_version) 00250 { 00251 // Retrieve data from archive required to construct new instance 00252 AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>* p_cell_population; 00253 ar >> p_cell_population; 00254 00255 // Invoke inplace constructor to initialise instance, last two variables set extra 00256 // member variables to be deleted as they are loaded from archive and to not initialise sells. 00257 ::new(t)OffLatticeSimulation<ELEMENT_DIM,SPACE_DIM>(*p_cell_population, true, false); 00258 } 00259 } 00260 } // namespace 00261 00262 #endif /*OFFLATTICESIMULATION_HPP_*/