Cylindrical2dMesh.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 #ifndef CYLINDRICAL2DMESH_HPP_
00029 #define CYLINDRICAL2DMESH_HPP_
00030
00031 #include "ChasteSerialization.hpp"
00032 #include <boost/serialization/base_object.hpp>
00033
00034 #include <cmath>
00035 #include <map>
00036
00037 #include "MutableMesh.hpp"
00038 #include "TrianglesMeshWriter.hpp"
00039
00048 class Cylindrical2dMesh : public MutableMesh<2,2>
00049 {
00050 friend class TestCylindrical2dMesh;
00051 private:
00052
00054 double mWidth;
00055
00057 double mTop;
00058
00060 double mBottom;
00061
00063 std::vector<unsigned> mLeftOriginals;
00064
00066 std::vector<unsigned> mLeftImages;
00067
00069 std::map<unsigned, unsigned> mImageToLeftOriginalNodeMap;
00070
00072 std::vector<unsigned> mRightOriginals;
00073
00075 std::vector<unsigned> mRightImages;
00076
00078 std::map<unsigned, unsigned> mImageToRightOriginalNodeMap;
00079
00081 std::set<unsigned> mLeftPeriodicBoundaryElementIndices;
00082
00084 std::set<unsigned> mRightPeriodicBoundaryElementIndices;
00085
00087 std::vector<unsigned > mTopHaloNodes;
00088
00090 std::vector<unsigned > mBottomHaloNodes;
00091
00098 void UpdateTopAndBottom();
00099
00108 void CreateHaloNodes();
00109
00116 void CreateMirrorNodes();
00117
00130 void ReconstructCylindricalMesh();
00131
00138 void DeleteHaloNodes();
00139
00150 void CorrectNonPeriodicMesh();
00151
00162 void GenerateVectorsOfElementsStraddlingPeriodicBoundaries();
00163
00170 unsigned GetCorrespondingNodeIndex(unsigned nodeIndex);
00171
00180 void UseTheseElementsToDecideMeshing(std::set<unsigned>& rMainSideElements);
00181
00183 friend class boost::serialization::access;
00194 template<class Archive>
00195 void serialize(Archive & archive, const unsigned int version)
00196 {
00197 archive & mWidth;
00198 archive & mTop;
00199 archive & mBottom;
00200
00201 archive & boost::serialization::base_object<MutableMesh<2,2> >(*this);
00202 }
00203
00204 public:
00205
00211 Cylindrical2dMesh(double width);
00212
00220 Cylindrical2dMesh(double width, std::vector<Node<2> *> nodes);
00221
00225 ~Cylindrical2dMesh();
00226
00237 void ReMesh(NodeMap &map);
00238
00247 c_vector<double, 2> GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2);
00248
00262 void SetNode(unsigned index, ChastePoint<2> point, bool concreteMove);
00263
00269 double GetWidth(const unsigned& rDimension) const;
00270
00280 unsigned AddNode(Node<2>* pNewNode);
00281
00282 };
00283
00284
00285 namespace boost
00286 {
00287 namespace serialization
00288 {
00292 template<class Archive>
00293 inline void save_construct_data(
00294 Archive & ar, const Cylindrical2dMesh * t, const BOOST_PFTO unsigned int file_version)
00295 {
00296
00297 const double width = t->GetWidth(0);
00298 ar << width;
00299 }
00300
00304 template<class Archive>
00305 inline void load_construct_data(
00306 Archive & ar, Cylindrical2dMesh * t, const unsigned int file_version)
00307 {
00308
00309 double width;
00310 ar >> width;
00311
00312
00313 ::new(t)Cylindrical2dMesh(width);
00314 }
00315 }
00316 }
00317
00318 #include "SerializationExportWrapper.hpp"
00319 CHASTE_CLASS_EXPORT(Cylindrical2dMesh)
00320
00321 #endif