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 
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 
00171     unsigned GetCorrespondingNodeIndex(unsigned nodeIndex);
00172 
00183     void UseTheseElementsToDecideMeshing(std::set<unsigned>& rMainSideElements);
00184 
00186     friend class boost::serialization::access;
00198     template<class Archive>
00199     void serialize(Archive & archive, const unsigned int version)
00200     {
00201         archive & boost::serialization::base_object<MutableMesh<2,2> >(*this);
00202         archive & mWidth;
00203         archive & mTop;
00204         archive & mBottom;
00205     }
00206 
00207 public:
00208 
00214     Cylindrical2dMesh(double width);
00215 
00223     Cylindrical2dMesh(double width, std::vector<Node<2>*> nodes);
00224 
00228     ~Cylindrical2dMesh();
00229 
00240     void ReMesh(NodeMap& rMap);
00241 
00252     c_vector<double, 2> GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2);
00253 
00264     void SetNode(unsigned index, ChastePoint<2> point, bool concreteMove);
00265 
00275     double GetWidth(const unsigned& rDimension) const;
00276 
00283     unsigned AddNode(Node<2>* pNewNode);
00284 };
00285 
00286 namespace boost
00287 {
00288 namespace serialization
00289 {
00293 template<class Archive>
00294 inline void save_construct_data(
00295     Archive & ar, const Cylindrical2dMesh * t, const BOOST_PFTO unsigned int file_version)
00296 {
00297     // Save data required to construct instance
00298     const double width = t->GetWidth(0);
00299     ar & width;
00300 }
00301 
00305 template<class Archive>
00306 inline void load_construct_data(
00307     Archive & ar, Cylindrical2dMesh * t, const unsigned int file_version)
00308 {
00309     // Retrieve data from archive required to construct new instance
00310     double width;
00311     ar & width;
00312 
00313     // Invoke inplace constructor to initialise instance
00314     ::new(t)Cylindrical2dMesh(width);
00315 }
00316 }
00317 } // namespace ...
00318 
00319 #include "SerializationExportWrapper.hpp"
00320 CHASTE_CLASS_EXPORT(Cylindrical2dMesh)
00321 
00322 #endif /*CYLINDRICAL2DMESH_HPP_*/

Generated on Mon Apr 18 11:35:27 2011 for Chaste by  doxygen 1.5.5