Cylindrical2dMesh.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
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 <boost/serialization/access.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 
00040 #include <boost/serialization/export.hpp>// at end of includes
00041 
00050 class Cylindrical2dMesh : public MutableMesh<2,2>
00051 {
00052     friend class TestCylindrical2dMesh;
00053 private:
00054 
00056     double mWidth;
00057 
00059     double mTop;
00060 
00062     double mBottom;
00063 
00065     std::vector<unsigned> mLeftOriginals;
00066 
00068     std::vector<unsigned> mLeftImages;
00069 
00071     std::map<unsigned, unsigned> mImageToLeftOriginalNodeMap;
00072 
00074     std::vector<unsigned> mRightOriginals;
00075 
00077     std::vector<unsigned> mRightImages;
00078 
00080     std::map<unsigned, unsigned> mImageToRightOriginalNodeMap;
00081 
00083     std::set<unsigned> mLeftPeriodicBoundaryElementIndices;
00084 
00086     std::set<unsigned> mRightPeriodicBoundaryElementIndices;
00087 
00089     std::vector<unsigned > mTopHaloNodes;
00090 
00092     std::vector<unsigned > mBottomHaloNodes;
00093 
00100     void UpdateTopAndBottom();
00101 
00110     void CreateHaloNodes();
00111 
00118     void CreateMirrorNodes();
00119 
00132     void ReconstructCylindricalMesh();
00133 
00140     void DeleteHaloNodes();
00141 
00152     void CorrectNonPeriodicMesh();
00153 
00164     void GenerateVectorsOfElementsStraddlingPeriodicBoundaries();
00165 
00172     unsigned GetCorrespondingNodeIndex(unsigned nodeIndex);
00173 
00182     void UseTheseElementsToDecideMeshing(std::set<unsigned> mainSideElements);
00183 
00192     bool IsThisIndexInList(const unsigned& rNodeIndex, const std::vector<unsigned>& rListOfNodes);
00193 
00195     friend class boost::serialization::access;
00206     template<class Archive>
00207     void serialize(Archive & archive, const unsigned int version)
00208     {
00209         archive & mWidth;
00210         archive & mTop;
00211         archive & mBottom;
00212 
00213         archive & boost::serialization::base_object<MutableMesh<2,2> >(*this);
00214     }
00215 
00216 public:
00217 
00223     Cylindrical2dMesh(double width);
00224 
00232     Cylindrical2dMesh(double width, std::vector<Node<2> *> nodes);
00233 
00237     ~Cylindrical2dMesh()
00238     {
00239     }
00240 
00251     void ReMesh(NodeMap &map);
00252 
00261     c_vector<double, 2> GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2);
00262 
00276     void SetNode(unsigned index, ChastePoint<2> point, bool concreteMove);
00277 
00283     double GetWidth(const unsigned& rDimension) const;
00284 
00294     unsigned AddNode(Node<2>* pNewNode);
00295 
00296 };
00297 
00298 
00299 namespace boost
00300 {
00301 namespace serialization
00302 {
00306 template<class Archive>
00307 inline void save_construct_data(
00308     Archive & ar, const Cylindrical2dMesh * t, const BOOST_PFTO unsigned int file_version)
00309 {
00310     // Save data required to construct instance
00311     const double width = t->GetWidth(0);
00312     ar << width;
00313 }
00314 
00318 template<class Archive>
00319 inline void load_construct_data(
00320     Archive & ar, Cylindrical2dMesh * t, const unsigned int file_version)
00321 {
00322     // Retrieve data from archive required to construct new instance
00323     double width;
00324     ar >> width;
00325 
00326     // Invoke inplace constructor to initialise instance
00327     ::new(t)Cylindrical2dMesh(width);
00328 }
00329 }
00330 } // namespace ...
00331 
00332 BOOST_CLASS_EXPORT(Cylindrical2dMesh)
00333 
00334 #endif /*CYLINDRICAL2DMESH_HPP_*/

Generated on Tue Aug 4 16:10:21 2009 for Chaste by  doxygen 1.5.5