PdeAndBoundaryConditions.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef PDEANDBOUNDARYCONDITIONS_HPP_
00030 #define PDEANDBOUNDARYCONDITIONS_HPP_
00031
00032 #include "ChasteSerialization.hpp"
00033 #include "AbstractBoundaryCondition.hpp"
00034 #include "ArchiveLocationInfo.hpp"
00035 #include "AbstractLinearEllipticPde.hpp"
00036 #include "AveragedSourcePde.hpp"
00037 #include "PetscTools.hpp"
00038 #include "FileFinder.hpp"
00039
00051 template<unsigned DIM>
00052 class PdeAndBoundaryConditions
00053 {
00054 friend class TestPdeAndBoundaryConditions;
00055
00056 private:
00057
00059 friend class boost::serialization::access;
00066 template<class Archive>
00067 void serialize(Archive & archive, const unsigned int version)
00068 {
00069
00070 archive & mpPde;
00071 archive & mpBoundaryCondition;
00072 archive & mIsNeumannBoundaryCondition;
00073 }
00074
00076 AbstractLinearEllipticPde<DIM,DIM>* mpPde;
00077
00079 AbstractBoundaryCondition<DIM>* mpBoundaryCondition;
00080
00082 bool mIsNeumannBoundaryCondition;
00083
00085 Vec mSolution;
00086
00088 bool mDeleteMemberPointersInDestructor;
00089
00090 public:
00091
00103 PdeAndBoundaryConditions(AbstractLinearEllipticPde<DIM,DIM>* pPde=NULL,
00104 AbstractBoundaryCondition<DIM>* pBoundaryCondition=NULL,
00105 bool isNeumannBoundaryCondition=true,
00106 Vec solution=NULL,
00107 bool deleteMemberPointersInDestructor=false);
00108
00112 ~PdeAndBoundaryConditions();
00113
00117 AbstractLinearEllipticPde<DIM,DIM>* GetPde();
00118
00122 AbstractBoundaryCondition<DIM>* GetBoundaryCondition() const;
00123
00127 Vec GetSolution();
00128
00132 Vec GetSolution() const;
00133
00139 void SetSolution(Vec solution);
00140
00144 bool IsNeumannBoundaryCondition();
00145
00149 bool HasAveragedSourcePde();
00150
00154 void DestroySolution();
00155
00163 void SetUpSourceTermsForAveragedSourcePde(TetrahedralMesh<DIM,DIM>* pMesh, std::map< CellPtr, unsigned >* pCellPdeElementMap=NULL);
00164 };
00165
00166 #include "SerializationExportWrapper.hpp"
00167
00168 EXPORT_TEMPLATE_CLASS_SAME_DIMS(PdeAndBoundaryConditions)
00169
00170 namespace boost
00171 {
00172 namespace serialization
00173 {
00174 template<class Archive, unsigned DIM>
00175 inline void save_construct_data(
00176 Archive & ar, const PdeAndBoundaryConditions<DIM> * t, const unsigned int file_version)
00177 {
00178 if (t->GetSolution())
00179 {
00180 std::string archive_filename = ArchiveLocationInfo::GetArchiveDirectory() + "solution.vec";
00181 PetscTools::DumpPetscObject(t->GetSolution(), archive_filename);
00182 }
00183 }
00184
00185 template<class Archive, unsigned DIM>
00186 inline void load_construct_data(
00187 Archive & ar, PdeAndBoundaryConditions<DIM> * t, const unsigned int file_version)
00188 {
00189 Vec solution = NULL;
00190
00191 std::string archive_filename = ArchiveLocationInfo::GetArchiveDirectory() + "solution.vec";
00192 FileFinder file_finder(archive_filename, RelativeTo::Absolute);
00193
00194 if (file_finder.Exists())
00195 {
00196 PetscTools::ReadPetscObject(solution, archive_filename);
00197 }
00198
00199 ::new(t)PdeAndBoundaryConditions<DIM>(NULL, NULL, false, solution, true);
00200 }
00201 }
00202 }
00203
00204 #endif