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 
00036 #include "MutableMesh.hpp"
00037 #include "TrianglesMeshWriter.hpp"
00038 
00039 #include <boost/serialization/export.hpp>// at end of includes
00040 
00049 class Cylindrical2dMesh : public MutableMesh<2,2>
00050 {
00051     friend class TestCylindrical2dMesh;
00052 private:
00053 
00055     double mWidth;
00056 
00058     double mTop;
00059 
00061     double mBottom;
00062 
00064     std::vector<unsigned> mLeftOriginals;
00065 
00067     std::vector<unsigned> mLeftImages;
00068 
00070     std::map<unsigned, unsigned> mImageToLeftOriginalNodeMap;
00071 
00073     std::vector<unsigned> mRightOriginals;
00074 
00076     std::vector<unsigned> mRightImages;
00077 
00079     std::map<unsigned, unsigned> mImageToRightOriginalNodeMap;
00080 
00082     std::set<unsigned> mLeftPeriodicBoundaryElementIndices;
00083 
00085     std::set<unsigned> mRightPeriodicBoundaryElementIndices;
00086 
00088     std::vector<unsigned > mTopHaloNodes;
00089 
00091     std::vector<unsigned > mBottomHaloNodes;
00092 
00099     void UpdateTopAndBottom();
00100 
00109     void CreateHaloNodes();
00110 
00117     void CreateMirrorNodes();
00118 
00131     void ReconstructCylindricalMesh();
00132 
00139     void DeleteHaloNodes();
00140 
00151     void CorrectNonPeriodicMesh();
00152 
00163     void GenerateVectorsOfElementsStraddlingPeriodicBoundaries();
00164 
00171     unsigned GetCorrespondingNodeIndex(unsigned nodeIndex);
00172 
00181     void UseTheseElementsToDecideMeshing(std::set<unsigned> mainSideElements);
00182 
00191     bool IsThisIndexInList(const unsigned& rNodeIndex, const std::vector<unsigned>& rListOfNodes);
00192 
00194     friend class boost::serialization::access;
00205     template<class Archive>
00206     void serialize(Archive & archive, const unsigned int version)
00207     {
00208         archive & boost::serialization::base_object<MutableMesh<2,2> >(*this);
00209         archive & mWidth;
00210         archive & mTop;
00211         archive & mBottom;
00212     }
00213 
00214 public:
00215 
00221     Cylindrical2dMesh(double width);
00222 
00230     Cylindrical2dMesh(double width, std::vector<Node<2> *> nodes);
00231 
00235     ~Cylindrical2dMesh()
00236     {
00237     }
00238 
00249     void ReMesh(NodeMap &map);
00250 
00259     c_vector<double, 2> GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2);
00260 
00274     void SetNode(unsigned index, ChastePoint<2> point, bool concreteMove);
00275 
00281     double GetWidth(const unsigned& rDimension) const;
00282 
00292     unsigned AddNode(Node<2> *pNewNode);
00293 
00294 };
00295 
00296 
00297 namespace boost
00298 {
00299 namespace serialization
00300 {
00304 template<class Archive>
00305 inline void save_construct_data(
00306     Archive & ar, const Cylindrical2dMesh * t, const BOOST_PFTO unsigned int file_version)
00307 {
00308     // Save data required to construct instance
00309     const double width = t->GetWidth(0);
00310     ar << width;
00311 }
00312 
00316 template<class Archive>
00317 inline void load_construct_data(
00318     Archive & ar, Cylindrical2dMesh * t, const unsigned int file_version)
00319 {
00320     // Retrieve data from archive required to construct new instance
00321     double width;
00322     ar >> width;
00323 
00324     // Invoke inplace constructor to initialise instance
00325     ::new(t)Cylindrical2dMesh(width);
00326 }
00327 }
00328 } // namespace ...
00329 
00330 BOOST_CLASS_EXPORT(Cylindrical2dMesh)
00331 
00332 #endif /*CYLINDRICAL2DMESH_HPP_*/

Generated on Wed Mar 18 12:51:49 2009 for Chaste by  doxygen 1.5.5