AbstractCardiacProblem.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 
00029 
00030 #ifndef ABSTRACTCARDIACPROBLEM_HPP_
00031 #define ABSTRACTCARDIACPROBLEM_HPP_
00032 
00033 #include <string>
00034 #include <vector>
00035 
00036 #include "AbstractCardiacCellFactory.hpp"
00037 #include "AbstractCardiacPde.hpp"
00038 #include "AbstractDynamicAssemblerMixin.hpp"
00039 #include "AbstractMesh.hpp"
00040 
00041 #include "BoundaryConditionsContainer.hpp"
00042 #include "Hdf5DataReader.hpp"
00043 #include "Hdf5DataWriter.hpp"
00044 
00050 template<unsigned SPACE_DIM, unsigned PROBLEM_DIM>
00051 class AbstractCardiacProblem
00052 {
00053 friend class TestBidomainWithBathAssembler;
00054     
00055 protected:
00058     std::string mMeshFilename;
00059 
00061     std::string mNodesPerProcessorFilename;
00062 
00064     std::string  mOutputDirectory, mOutputFilenamePrefix;
00065 
00070     bool mUseMatrixBasedRhsAssembly;
00072     bool mAllocatedMemoryForMesh;
00074     bool mWriteInfo;
00076     bool mPrintOutput;
00078     bool mCallChaste2Meshalyzer;
00079 
00081     std::vector<unsigned> mNodesToOutput;
00082 
00084     unsigned mVoltageColumnId;
00086     unsigned mTimeColumnId;
00088     unsigned mNodeColumnId;
00089 
00091     AbstractCardiacPde<SPACE_DIM>* mpCardiacPde;
00092 
00094     BoundaryConditionsContainer<SPACE_DIM, SPACE_DIM, PROBLEM_DIM>* mpBoundaryConditionsContainer;
00096     BoundaryConditionsContainer<SPACE_DIM, SPACE_DIM, PROBLEM_DIM>* mpDefaultBoundaryConditionsContainer;
00098     AbstractDynamicAssemblerMixin<SPACE_DIM, SPACE_DIM, PROBLEM_DIM>* mpAssembler;
00100     AbstractCardiacCellFactory<SPACE_DIM>* mpCellFactory;
00102     AbstractMesh<SPACE_DIM,SPACE_DIM>* mpMesh;
00103 
00106     Vec mSolution; 
00107 
00113     virtual AbstractCardiacPde<SPACE_DIM>* CreateCardiacPde() =0;
00114 
00120     virtual AbstractDynamicAssemblerMixin<SPACE_DIM, SPACE_DIM, PROBLEM_DIM>* CreateAssembler() =0;
00121 
00122 public:
00123     // This (and things in MonodomainProblem) being public are hacks for
00124     // CardiacElectroMechanicsProblem to work.
00125     // ///\todo CardiacElectroMechanicsProblem should be a friend, but not sure
00126     // how to get friends to work when both friends are templated and abstract.
00127     Hdf5DataWriter* mpWriter;
00128 
00129 public:
00135     AbstractCardiacProblem(AbstractCardiacCellFactory<SPACE_DIM>* pCellFactory);
00136 
00137     virtual ~AbstractCardiacProblem();
00138 
00139     /*
00140      *  Initialise the system. Must be called before Solve()
00141      */
00142     void Initialise();
00143 
00147     void SetNodesPerProcessorFilename(const std::string& filename);
00148     
00153     void SetBoundaryConditionsContainer(BoundaryConditionsContainer<SPACE_DIM, SPACE_DIM, PROBLEM_DIM> *bcc);
00154     
00162     virtual void PreSolveChecks();
00163 
00169     virtual Vec CreateInitialCondition();
00170 
00177     void ConvertOutputToMeshalyzerFormat(bool call = true);
00178 
00180     void SetMesh(AbstractMesh<SPACE_DIM,SPACE_DIM>* pMesh);
00181 
00185     void PrintOutput(bool rPrintOutput);
00186 
00190     void SetWriteInfo(bool writeInfo = true);
00191 
00202     Vec GetSolution();
00203 
00204     AbstractMesh<SPACE_DIM,SPACE_DIM> & rGetMesh();
00205 
00206     AbstractCardiacPde<SPACE_DIM>* GetPde();
00207     
00215     void Solve();
00216     
00222     void CloseFilesAndPostProcess();
00223 
00224 
00225     virtual void WriteInfo(double time)=0;
00226 
00227     virtual void DefineWriterColumns();
00228 
00229     virtual void WriteOneStep(double time, Vec voltageVec);
00230     
00236     void InitialiseWriter();
00237     
00244     void SetOutputNodes(std::vector<unsigned> &nodesToOutput);
00245     
00246     Hdf5DataReader GetDataReader();
00247     
00251     void UseMatrixBasedRhsAssembly(bool usematrix=true);
00252     
00258     virtual void OnEndOfTimestep(double time)
00259     {}
00260     
00261 };
00262 #endif /*ABSTRACTCARDIACPROBLEM_HPP_*/

Generated on Wed Mar 18 12:51:51 2009 for Chaste by  doxygen 1.5.5