MixedDimensionMesh.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 MIXEDDIMENSIONMESH_HPP_
00030 #define MIXEDDIMENSIONMESH_HPP_
00031
00032 #include "DistributedTetrahedralMesh.hpp"
00033 #include "AbstractMeshReader.hpp"
00034
00035 #include "ChasteSerialization.hpp"
00036 #include <boost/serialization/base_object.hpp>
00037
00043 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00044 class MixedDimensionMesh : public DistributedTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>
00045 {
00046 public:
00047
00053 MixedDimensionMesh(DistributedTetrahedralMeshPartitionType::type partitioningMethod=DistributedTetrahedralMeshPartitionType::METIS_LIBRARY);
00054
00059 ~MixedDimensionMesh();
00060
00066 void ConstructFromMeshReader(AbstractMeshReader<ELEMENT_DIM,SPACE_DIM>& rMeshReader);
00067
00073 void RegisterCableElement(unsigned index);
00074
00078 unsigned GetNumCableElements() const;
00079
00083 unsigned GetNumLocalCableElements() const;
00084
00091 Element<1u, SPACE_DIM>* GetCableElement(unsigned globalElementIndex) const;
00092
00099 bool CalculateDesignatedOwnershipOfCableElement( unsigned globalElementIndex );
00100
00101
00102 private:
00104 std::vector<Element<1u, SPACE_DIM>*> mCableElements;
00106 unsigned mNumCableElements;
00108 std::map<unsigned, unsigned> mCableElementsMapping;
00109
00111 friend class boost::serialization::access;
00118 template<class Archive>
00119 void serialize(Archive & archive, const unsigned int version)
00120 {
00121 archive & boost::serialization::base_object<DistributedTetrahedralMesh<ELEMENT_DIM, SPACE_DIM> >(*this);
00122 }
00123
00124 public:
00125
00127
00129
00131 typedef typename std::vector<Element<1, SPACE_DIM> *>::const_iterator CableElementIterator;
00132
00136 CableElementIterator GetCableElementIteratorBegin() const;
00137
00142 CableElementIterator GetCableElementIteratorEnd() const;
00143
00144
00145 };
00146
00147
00148 #include "SerializationExportWrapper.hpp"
00149 EXPORT_TEMPLATE_CLASS_ALL_DIMS(MixedDimensionMesh)
00150
00151 namespace boost
00152 {
00153 namespace serialization
00154 {
00158 template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00159 inline void save_construct_data(
00160 Archive & ar, const MixedDimensionMesh<ELEMENT_DIM, SPACE_DIM> * t, const BOOST_PFTO unsigned int file_version)
00161 {
00162 unsigned num_procs = PetscTools::GetNumProcs();
00163 const DistributedTetrahedralMeshPartitionType::type partition_type = t->GetPartitionType();
00164 ar << num_procs;
00165 ar << partition_type;
00166 }
00167
00172 template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00173 inline void load_construct_data(
00174 Archive & ar, MixedDimensionMesh<ELEMENT_DIM, SPACE_DIM> * t, const unsigned int file_version)
00175 {
00176 unsigned num_procs;
00177 DistributedTetrahedralMeshPartitionType::type partition_type;
00178
00179 ar >> num_procs;
00180 ar >> partition_type;
00181
00182
00184
00185 ::new(t)MixedDimensionMesh<ELEMENT_DIM, SPACE_DIM>(DistributedTetrahedralMeshPartitionType::DUMB);
00186
00187
00188
00189
00190
00191 if (DistributedVectorFactory::CheckNumberOfProcessesOnLoad() &&
00192 num_procs != PetscTools::GetNumProcs())
00193 {
00194 EXCEPTION("This archive was written for a different number of processors");
00195 }
00196
00197 }
00198 }
00199 }
00200
00201 #endif