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 00037 #ifndef BIDOMAINPROBLEM_HPP_ 00038 #define BIDOMAINPROBLEM_HPP_ 00039 00040 #include "ChasteSerialization.hpp" 00041 #include <boost/serialization/base_object.hpp> 00042 00043 #include <vector> 00044 #include <boost/shared_ptr.hpp> 00045 #include <boost/serialization/shared_ptr.hpp> 00046 00047 #include "AbstractCardiacProblem.hpp" 00048 #include "AbstractCardiacTissue.hpp" 00049 #include "AbstractBidomainSolver.hpp" 00050 #include "AbstractCardiacCellFactory.hpp" 00051 #include "Electrodes.hpp" 00052 #include "BidomainTissue.hpp" 00053 #include "HeartRegionCodes.hpp" 00054 #include "DistributedTetrahedralMesh.hpp" 00055 00064 template<unsigned DIM> 00065 class BidomainProblem : public AbstractCardiacProblem<DIM,DIM, 2> 00066 { 00068 friend class boost::serialization::access; 00069 00070 // #1082 00071 friend class TestPCTwoLevelsBlockDiagonal; 00072 00079 template<class Archive> 00080 void save(Archive & archive, const unsigned int version) const 00081 { 00082 archive & boost::serialization::base_object<AbstractCardiacProblem<DIM, DIM, 2> >(*this); 00083 archive & mpBidomainTissue; 00084 //archive & mExtracelluarColumnId; // Created by InitialiseWriter, called from Solve 00085 archive & mRowForAverageOfPhiZeroed; 00086 archive & mHasBath; 00087 archive & mpElectrodes; 00088 } 00089 00096 template<class Archive> 00097 void load(Archive & archive, const unsigned int version) 00098 { 00099 archive & boost::serialization::base_object<AbstractCardiacProblem<DIM, DIM, 2> >(*this); 00100 archive & mpBidomainTissue; 00101 //archive & mExtracelluarColumnId; // Created by InitialiseWriter, called from Solve 00102 archive & mRowForAverageOfPhiZeroed; 00103 archive & mHasBath; 00104 archive & mpElectrodes; 00105 00106 if (mHasBath) 00107 { 00108 // We only save element annotations, so annotate bath nodes from these 00109 AnalyseMeshForBath(); 00110 } 00111 } 00112 BOOST_SERIALIZATION_SPLIT_MEMBER() 00113 00114 friend class TestBidomainWithBathProblem; 00115 friend class TestCardiacSimulationArchiver; 00116 00117 protected: 00119 BidomainTissue<DIM>* mpBidomainTissue; 00120 00122 std::vector<unsigned> mFixedExtracellularPotentialNodes; 00124 unsigned mExtracelluarColumnId; 00129 unsigned mRowForAverageOfPhiZeroed; 00130 00132 bool mHasBath; 00133 00135 boost::shared_ptr<Electrodes<DIM> > mpElectrodes; 00136 00141 Vec CreateInitialCondition(); 00142 00147 void AnalyseMeshForBath(); 00148 00154 AbstractBidomainSolver<DIM,DIM>* mpSolver; 00155 00157 virtual AbstractCardiacTissue<DIM> *CreateCardiacTissue(); 00158 00160 virtual AbstractDynamicLinearPdeSolver<DIM,DIM,2>* CreateSolver(); 00161 00162 public: 00172 BidomainProblem(AbstractCardiacCellFactory<DIM>* pCellFactory, bool hasBath=false); 00173 00177 BidomainProblem(); 00178 00189 void SetFixedExtracellularPotentialNodes(std::vector<unsigned> nodes); 00190 00198 void SetNodeForAverageOfPhiZeroed(unsigned node); 00199 00203 BidomainTissue<DIM>* GetBidomainTissue(); 00204 00209 void WriteInfo(double time); 00210 00216 virtual void DefineWriterColumns(bool extending); 00217 00225 virtual void WriteOneStep(double time, Vec voltageVec); 00226 00231 void PreSolveChecks(); 00232 00233 00234 00242 void AtBeginningOfTimestep(double time); 00243 00251 void OnEndOfTimestep(double time); 00252 00260 void SetUpAdditionalStoppingTimes(std::vector<double>& rAdditionalStoppingTimes); 00261 00279 template<class Archive> 00280 void LoadExtraArchiveForBidomain(Archive & archive, unsigned version); 00281 00285 bool GetHasBath(); 00286 00291 void SetElectrodes(); 00292 }; 00293 00294 #include "SerializationExportWrapper.hpp" // Must be last 00295 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BidomainProblem) 00296 00297 00298 template<unsigned DIM> 00299 template<class Archive> 00300 void BidomainProblem<DIM>::LoadExtraArchiveForBidomain(Archive & archive, unsigned version) 00301 { 00302 // Not all bidomain problems have electrodes... 00303 if (mpElectrodes) 00304 { 00305 // Electrodes will always have a BCC object by this point 00306 assert(mpElectrodes->GetBoundaryConditionsContainer()); 00307 // We might need to get some of the boundary conditions from this archive, but it might be 00308 // the case that the problem's BCC is the same object as the Electrodes' (if they are turned 00309 // on) in which case we need to do 'nothing'. 00310 boost::shared_ptr<BoundaryConditionsContainer<DIM, DIM, 2> > p_bcc; 00311 archive >> p_bcc; 00312 if (mpElectrodes->GetBoundaryConditionsContainer() != this->mpBoundaryConditionsContainer) 00313 { 00314 // The BCs will only actually be different if using a distributed tetrahedral mesh 00315 DistributedTetrahedralMesh<DIM,DIM>* p_dist_mesh = dynamic_cast<DistributedTetrahedralMesh<DIM,DIM>*>(this->mpMesh); 00316 if (p_dist_mesh) 00317 { 00318 mpElectrodes->GetBoundaryConditionsContainer()->MergeFromArchive(archive, this->mpMesh); 00319 } 00320 else 00321 { 00322 // Load into the temporary container, which will get thrown away shortly 00323 p_bcc->LoadFromArchive(archive, this->mpMesh); 00325 } 00326 } 00327 } 00328 } 00329 00330 #endif /*BIDOMAINPROBLEM_HPP_*/