SphereGeometryBoundaryCondition.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #ifndef SPHEREGEOMETRYBOUNDARYCONDITION_HPP_
00030 #define SPHEREGEOMETRYBOUNDARYCONDITION_HPP_
00031 
00032 #include "AbstractCellPopulationBoundaryCondition.hpp"
00033 
00034 #include "ChasteSerialization.hpp"
00035 #include <boost/serialization/base_object.hpp>
00036 #include <boost/serialization/vector.hpp>
00037 
00044 template<unsigned DIM>
00045 class SphereGeometryBoundaryCondition : public AbstractCellPopulationBoundaryCondition<DIM>
00046 {
00047 private:
00048 
00050     c_vector<double, DIM> mCentreOfSphere;
00051 
00053     double mRadiusOfSphere;
00054 
00056     double mMaximumDistance;
00057 
00059     friend class boost::serialization::access;
00066     template<class Archive>
00067     void serialize(Archive & archive, const unsigned int version)
00068     {
00069         archive & boost::serialization::base_object<AbstractCellPopulationBoundaryCondition<DIM> >(*this);
00070         archive & mMaximumDistance;
00071     }
00072 
00073 public:
00074 
00083     SphereGeometryBoundaryCondition(AbstractCellPopulation<DIM>* pCellPopulation,
00084                                     c_vector<double, DIM> centre,
00085                                     double radius,
00086                                     double distance=1e-5);
00087 
00091     const c_vector<double, DIM>& rGetCentreOfSphere() const;
00092 
00096     double GetRadiusOfSphere() const;
00097 
00105     void ImposeBoundaryCondition(const std::vector< c_vector<double, DIM> >& rOldLocations);
00106 
00114     bool VerifyBoundaryCondition();
00115 
00122     void OutputCellPopulationBoundaryConditionParameters(out_stream& rParamsFile);
00123 };
00124 
00125 #include "SerializationExportWrapper.hpp"
00126 EXPORT_TEMPLATE_CLASS_SAME_DIMS(SphereGeometryBoundaryCondition)
00127 
00128 namespace boost
00129 {
00130 namespace serialization
00131 {
00135 template<class Archive, unsigned DIM>
00136 inline void save_construct_data(
00137     Archive & ar, const SphereGeometryBoundaryCondition<DIM>* t, const BOOST_PFTO unsigned int file_version)
00138 {
00139     // Save data required to construct instance
00140     const AbstractCellPopulation<DIM>* const p_cell_population = t->GetCellPopulation();
00141     ar << p_cell_population;
00142 
00143     // Archive c_vectors one component at a time
00144     c_vector<double, DIM> point = t->rGetCentreOfSphere();
00145     for (unsigned i=0; i<DIM; i++)
00146     {
00147         ar << point[i];
00148     }
00149 
00150     // Archive other member variables
00151     double radius = t->GetRadiusOfSphere();
00152     ar << radius;
00153 }
00154 
00158 template<class Archive, unsigned DIM>
00159 inline void load_construct_data(
00160     Archive & ar, SphereGeometryBoundaryCondition<DIM>* t, const unsigned int file_version)
00161 {
00162     // Retrieve data from archive required to construct new instance
00163     AbstractCellPopulation<DIM>* p_cell_population;
00164     ar >> p_cell_population;
00165 
00166     // Retrieve c_vectors one component at a time
00167     c_vector<double, DIM> point;
00168     for (unsigned i=0; i<DIM; i++)
00169     {
00170         ar >> point[i];
00171     }
00172 
00173     // Retrieve other member variables
00174     double radius;
00175     ar >> radius;
00176 
00177     // Invoke inplace constructor to initialise instance
00178     ::new(t)SphereGeometryBoundaryCondition<DIM>(p_cell_population, point, radius);
00179 }
00180 }
00181 } // namespace ...
00182 
00183 #endif /*SPHEREGEOMETRYBOUNDARYCONDITION_HPP_*/
Generated on Thu Dec 22 13:00:04 2011 for Chaste by  doxygen 1.6.3