AbstractCardiacPde.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
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 #ifndef ABSTRACTCARDIACPDE_HPP_
00029 #define ABSTRACTCARDIACPDE_HPP_
00030 
00031 #include <vector>
00032 #include <climits> // Work around a boost bug - see #1024.
00033 #include <boost/serialization/access.hpp>
00034 #include <boost/serialization/is_abstract.hpp>
00035 #include <boost/serialization/base_object.hpp>
00036 #include <boost/shared_ptr.hpp>
00037 #include <boost/serialization/shared_ptr.hpp>
00038 #include <boost/serialization/vector.hpp>
00039 
00040 #include <boost/numeric/ublas/matrix.hpp>
00041 
00042 #include "AbstractCardiacCell.hpp"
00043 #include "AbstractCardiacCellFactory.hpp"
00044 #include "AbstractConductivityTensors.hpp"
00045 
00046 #include "ReplicatableVector.hpp"
00047 #include "HeartConfig.hpp"
00048 #include "ArchiveLocationInfo.hpp"
00049 
00050 // Needs to be included last
00051 #include "TemplatedExport.hpp"
00052 
00053 
00055 // IMPORTANT NOTE: the inheritance of AbstractPde has to be 'virtual'
00056 // ie "class AbstractCardiacPde : public virtual AbstractPde"
00057 // because AbstractPde will be the top class in a 'dreaded diamond':
00058 //      A
00059 //     / \     A = AbstractPde, B = AbstractCardiac, C = AbstractLinearParabolic (etc)
00060 //    B   C    D = MonodomainPde
00061 //     \ /
00062 //      D
00063 //
00064 // B and C must use virtual inheritence of A in order for D to only contain 1 instance
00065 // of the member variables in A
00066 
00076 template <unsigned ELEM_DIM, unsigned SPACE_DIM = ELEM_DIM>
00077 class AbstractCardiacPde
00078 {
00079 private:
00080 
00082     friend class boost::serialization::access;
00089     template<class Archive>
00090     void serialize(Archive & archive, const unsigned int version)
00091     {
00092         //Archive vector factory?  Do we have one available?  (If not - do it in the test to guard against errors)
00093 
00094         //Archive cells using handler.GetProcessUniqueFilePath("") and ArchiveLocationInfo
00095 
00097 
00098         archive & mpDistributedVectorFactory;
00099     }
00100 
00101 protected:
00102 
00104     AbstractConductivityTensors<SPACE_DIM> *mpIntracellularConductivityTensors;
00105 
00107     std::vector< AbstractCardiacCell* > mCellsDistributed;
00108 
00113     ReplicatableVector mIionicCacheReplicated;
00114     
00119     ReplicatableVector mIntracellularStimulusCacheReplicated;
00120 
00127     const unsigned mStride;
00128 
00130     HeartConfig* mpConfig;
00131 
00141     bool mDoCacheReplication;
00142     
00148     bool mDoOneCacheReplication;
00149 
00155     DistributedVectorFactory* mpDistributedVectorFactory;
00156     
00160     bool mpFactoryWasUnarchived;
00161 public:
00171     AbstractCardiacPde(AbstractCardiacCellFactory<ELEM_DIM,SPACE_DIM>* pCellFactory,
00172                        const unsigned stride=1);
00173 
00180     AbstractCardiacPde(std::vector<AbstractCardiacCell*> & rCellsDistributed,
00181                        const unsigned stride = 1);
00182 
00184     virtual ~AbstractCardiacPde();
00185 
00192     void SetCacheReplication(bool doCacheReplication);
00193 
00197     const c_matrix<double, SPACE_DIM, SPACE_DIM>& rGetIntracellularConductivityTensor(unsigned elementIndex);
00198 
00207     AbstractCardiacCell* GetCardiacCell( unsigned globalIndex );
00208 
00223     virtual void SolveCellSystems(Vec existingSolution, double time, double nextTime);
00224 
00226     ReplicatableVector& rGetIionicCacheReplicated();
00227 
00229     ReplicatableVector& rGetIntracellularStimulusCacheReplicated();
00230 
00231 
00239     void UpdateCaches(unsigned globalIndex, unsigned localIndex, double nextTime);
00240 
00244     void ReplicateCaches();
00245 
00249     const std::vector<AbstractCardiacCell*>& GetCellsDistributed() const;
00250 
00251 };
00252 
00253 // Declare identifier for the serializer
00254 EXPORT_ABSTRACT_TEMPLATE_CLASS_ALL_DIMS(AbstractCardiacPde);
00255 
00256 #endif /*ABSTRACTCARDIACPDE_HPP_*/
00257 

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5