AveragedSourcePde.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 AVERAGEDSOURCEPDE_HPP_
00030 #define AVERAGEDSOURCEPDE_HPP_
00031 
00032 #include "ChasteSerialization.hpp"
00033 #include <boost/serialization/base_object.hpp>
00034 #include <boost/serialization/vector.hpp>
00035 
00036 #include "AbstractCellPopulation.hpp"
00037 #include "TetrahedralMesh.hpp"
00038 #include "AbstractLinearEllipticPde.hpp"
00039 
00044 template<unsigned DIM>
00045 class AveragedSourcePde : public AbstractLinearEllipticPde<DIM,DIM>
00046 {
00047     friend class TestCellBasedPdes;
00048 
00049 private:
00050 
00052     friend class boost::serialization::access;
00059     template<class Archive>
00060     void serialize(Archive & archive, const unsigned int version)
00061     {
00062        archive & boost::serialization::base_object<AbstractLinearEllipticPde<DIM, DIM> >(*this);
00063        archive & mCoefficient;
00064        archive & mCellDensityOnCoarseElements;
00065     }
00066 
00067 protected:
00068 
00070     AbstractCellPopulation<DIM>& mrCellPopulation;
00071 
00073     double mCoefficient;
00074 
00076     std::vector<double> mCellDensityOnCoarseElements;
00077 
00078 public:
00079 
00086     AveragedSourcePde(AbstractCellPopulation<DIM>& rCellPopulation, double coefficient=0.0);
00087 
00091     const AbstractCellPopulation<DIM>& rGetCellPopulation() const;
00092 
00096     double GetCoefficient() const;
00097 
00104     void virtual SetupSourceTerms(TetrahedralMesh<DIM,DIM>& rCoarseMesh, std::map<CellPtr, unsigned>* pCellPdeElementMap=NULL);
00105 
00115     double ComputeConstantInUSourceTerm(const ChastePoint<DIM>& rX, Element<DIM,DIM>* pElement);
00116 
00126     double ComputeLinearInUCoeffInSourceTerm(const ChastePoint<DIM>& rX, Element<DIM,DIM>* pElement);
00127 
00135     c_matrix<double,DIM,DIM> ComputeDiffusionTerm(const ChastePoint<DIM>& rX);
00136 
00142     double GetUptakeRateForElement(unsigned elementIndex);
00143 };
00144 
00145 #include "SerializationExportWrapper.hpp"
00146 EXPORT_TEMPLATE_CLASS_SAME_DIMS(AveragedSourcePde)
00147 
00148 namespace boost
00149 {
00150 namespace serialization
00151 {
00155 template<class Archive, unsigned DIM>
00156 inline void save_construct_data(
00157     Archive & ar, const AveragedSourcePde<DIM>* t, const BOOST_PFTO unsigned int file_version)
00158 {
00159     // Save data required to construct instance
00160     const AbstractCellPopulation<DIM>* p_cell_population = &(t->rGetCellPopulation());
00161     ar & p_cell_population;
00162 }
00163 
00167 template<class Archive, unsigned DIM>
00168 inline void load_construct_data(
00169     Archive & ar, AveragedSourcePde<DIM>* t, const unsigned int file_version)
00170 {
00171     // Retrieve data from archive required to construct new instance
00172     AbstractCellPopulation<DIM>* p_cell_population;
00173     ar >> p_cell_population;
00174 
00175     // Invoke inplace constructor to initialise instance
00176     ::new(t)AveragedSourcePde<DIM>(*p_cell_population);
00177 }
00178 }
00179 } // namespace ...
00180 
00181 #endif /*AVERAGEDSOURCEPDE_HPP_*/
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3