Cylindrical2dMesh.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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 #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 
00093     bool mMismatchedBoundaryElements;
00094 
00101     void UpdateTopAndBottom();
00102 
00111     void CreateHaloNodes();
00112 
00119     void CreateMirrorNodes();
00120 
00133     void ReconstructCylindricalMesh();
00134 
00141     void DeleteHaloNodes();
00142 
00153     void CorrectNonPeriodicMesh();
00154 
00165     void GenerateVectorsOfElementsStraddlingPeriodicBoundaries();
00166 
00174     unsigned GetCorrespondingNodeIndex(unsigned nodeIndex);
00175 
00186     void UseTheseElementsToDecideMeshing(std::set<unsigned>& rMainSideElements);
00187 
00189     friend class boost::serialization::access;
00201     template<class Archive>
00202     void serialize(Archive & archive, const unsigned int version)
00203     {
00204         archive & boost::serialization::base_object<MutableMesh<2,2> >(*this);
00205         archive & mWidth;
00206         archive & mTop;
00207         archive & mBottom;
00208     }
00209 
00210 public:
00211 
00217     Cylindrical2dMesh(double width);
00218 
00226     Cylindrical2dMesh(double width, std::vector<Node<2>*> nodes);
00227 
00231     ~Cylindrical2dMesh();
00232 
00243     void ReMesh(NodeMap& rMap);
00244 
00255     c_vector<double, 2> GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2);
00256 
00267     void SetNode(unsigned index, ChastePoint<2> point, bool concreteMove);
00268 
00278     double GetWidth(const unsigned& rDimension) const;
00279 
00286     unsigned AddNode(Node<2>* pNewNode);
00287 
00291     bool GetInstanceOfMismatchedBoundaryNodes();
00292 };
00293 
00294 namespace boost
00295 {
00296 namespace serialization
00297 {
00301 template<class Archive>
00302 inline void save_construct_data(
00303     Archive & ar, const Cylindrical2dMesh * t, const BOOST_PFTO unsigned int file_version)
00304 {
00305     // Save data required to construct instance
00306     const double width = t->GetWidth(0);
00307     ar & width;
00308 }
00309 
00313 template<class Archive>
00314 inline void load_construct_data(
00315     Archive & ar, Cylindrical2dMesh * t, const unsigned int file_version)
00316 {
00317     // Retrieve data from archive required to construct new instance
00318     double width;
00319     ar & width;
00320 
00321     // Invoke inplace constructor to initialise instance
00322     ::new(t)Cylindrical2dMesh(width);
00323 }
00324 }
00325 } // namespace ...
00326 
00327 #include "SerializationExportWrapper.hpp"
00328 CHASTE_CLASS_EXPORT(Cylindrical2dMesh)
00329 
00330 #endif /*CYLINDRICAL2DMESH_HPP_*/
Generated on Thu Dec 22 13:00:04 2011 for Chaste by  doxygen 1.6.3