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
00030
00031
00032
00033
00034
00035
00036 #ifndef PDEANDBOUNDARYCONDITIONS_HPP_
00037 #define PDEANDBOUNDARYCONDITIONS_HPP_
00038
00039 #include "ChasteSerialization.hpp"
00040 #include "AbstractBoundaryCondition.hpp"
00041 #include "ArchiveLocationInfo.hpp"
00042 #include "AbstractLinearEllipticPde.hpp"
00043 #include "AveragedSourcePde.hpp"
00044 #include "PetscTools.hpp"
00045 #include "FileFinder.hpp"
00046
00058 template<unsigned DIM>
00059 class PdeAndBoundaryConditions
00060 {
00061 friend class TestPdeAndBoundaryConditions;
00062
00063 private:
00064
00066 friend class boost::serialization::access;
00073 template<class Archive>
00074 void serialize(Archive & archive, const unsigned int version)
00075 {
00076
00077 archive & mpPde;
00078 archive & mpBoundaryCondition;
00079 archive & mIsNeumannBoundaryCondition;
00080 archive & mDependentVariableName;
00081 }
00082
00084 AbstractLinearEllipticPde<DIM,DIM>* mpPde;
00085
00087 AbstractBoundaryCondition<DIM>* mpBoundaryCondition;
00088
00090 bool mIsNeumannBoundaryCondition;
00091
00093 Vec mSolution;
00094
00096 bool mDeleteMemberPointersInDestructor;
00097
00101 std::string mDependentVariableName;
00102
00103
00104 public:
00105
00117 PdeAndBoundaryConditions(AbstractLinearEllipticPde<DIM,DIM>* pPde=NULL,
00118 AbstractBoundaryCondition<DIM>* pBoundaryCondition=NULL,
00119 bool isNeumannBoundaryCondition=true,
00120 Vec solution=NULL,
00121 bool deleteMemberPointersInDestructor=false);
00122
00126 ~PdeAndBoundaryConditions();
00127
00131 AbstractLinearEllipticPde<DIM,DIM>* GetPde();
00132
00136 AbstractBoundaryCondition<DIM>* GetBoundaryCondition() const;
00137
00141 Vec GetSolution();
00142
00146 Vec GetSolution() const;
00147
00153 void SetSolution(Vec solution);
00154
00158 bool IsNeumannBoundaryCondition();
00159
00163 bool HasAveragedSourcePde();
00164
00168 void DestroySolution();
00169
00177 void SetUpSourceTermsForAveragedSourcePde(TetrahedralMesh<DIM,DIM>* pMesh, std::map< CellPtr, unsigned >* pCellPdeElementMap=NULL);
00178
00184 void SetDependentVariableName(const std::string& rName);
00185
00191 std::string& rGetDependentVariableName();
00192 };
00193
00194 #include "SerializationExportWrapper.hpp"
00195
00196 EXPORT_TEMPLATE_CLASS_SAME_DIMS(PdeAndBoundaryConditions)
00197
00198 namespace boost
00199 {
00200 namespace serialization
00201 {
00202 template<class Archive, unsigned DIM>
00203 inline void save_construct_data(
00204 Archive & ar, const PdeAndBoundaryConditions<DIM> * t, const unsigned int file_version)
00205 {
00206 if (t->GetSolution())
00207 {
00208 std::string archive_filename = ArchiveLocationInfo::GetArchiveDirectory() + "solution.vec";
00209 PetscTools::DumpPetscObject(t->GetSolution(), archive_filename);
00210 }
00211 }
00212
00213 template<class Archive, unsigned DIM>
00214 inline void load_construct_data(
00215 Archive & ar, PdeAndBoundaryConditions<DIM> * t, const unsigned int file_version)
00216 {
00217 Vec solution = NULL;
00218
00219 std::string archive_filename = ArchiveLocationInfo::GetArchiveDirectory() + "solution.vec";
00220 FileFinder file_finder(archive_filename, RelativeTo::Absolute);
00221
00222 if (file_finder.Exists())
00223 {
00224 PetscTools::ReadPetscObject(solution, archive_filename);
00225 }
00226
00227 ::new(t)PdeAndBoundaryConditions<DIM>(NULL, NULL, false, solution, true);
00228 }
00229 }
00230 }
00231
00232 #endif