Chaste Release::3.1
Cylindrical2dMesh.hpp
00001 /*
00002 
00003 Copyright (c) 2005-2012, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 #ifndef CYLINDRICAL2DMESH_HPP_
00036 #define CYLINDRICAL2DMESH_HPP_
00037 
00038 #include "ChasteSerialization.hpp"
00039 #include <boost/serialization/base_object.hpp>
00040 
00041 #include <cmath>
00042 #include <map>
00043 
00044 #include "MutableMesh.hpp"
00045 #include "TrianglesMeshWriter.hpp"
00046 
00055 class Cylindrical2dMesh : public MutableMesh<2,2>
00056 {
00057     friend class TestCylindrical2dMesh;
00058 private:
00059 
00061     double mWidth;
00062 
00064     double mTop;
00065 
00067     double mBottom;
00068 
00070     std::vector<unsigned> mLeftOriginals;
00071 
00073     std::vector<unsigned> mLeftImages;
00074 
00076     std::map<unsigned, unsigned> mImageToLeftOriginalNodeMap;
00077 
00079     std::vector<unsigned> mRightOriginals;
00080 
00082     std::vector<unsigned> mRightImages;
00083 
00085     std::map<unsigned, unsigned> mImageToRightOriginalNodeMap;
00086 
00088     std::set<unsigned> mLeftPeriodicBoundaryElementIndices;
00089 
00091     std::set<unsigned> mRightPeriodicBoundaryElementIndices;
00092 
00094     std::vector<unsigned > mTopHaloNodes;
00095 
00097     std::vector<unsigned > mBottomHaloNodes;
00098 
00100     bool mMismatchedBoundaryElements;
00101 
00108     void UpdateTopAndBottom();
00109 
00118     void CreateHaloNodes();
00119 
00126     void CreateMirrorNodes();
00127 
00140     void ReconstructCylindricalMesh();
00141 
00148     void DeleteHaloNodes();
00149 
00160     void CorrectNonPeriodicMesh();
00161 
00172     void GenerateVectorsOfElementsStraddlingPeriodicBoundaries();
00173 
00181     unsigned GetCorrespondingNodeIndex(unsigned nodeIndex);
00182 
00193     void UseTheseElementsToDecideMeshing(std::set<unsigned>& rMainSideElements);
00194 
00196     friend class boost::serialization::access;
00208     template<class Archive>
00209     void serialize(Archive & archive, const unsigned int version)
00210     {
00211         archive & boost::serialization::base_object<MutableMesh<2,2> >(*this);
00212         archive & mWidth;
00213         archive & mTop;
00214         archive & mBottom;
00215     }
00216 
00217 public:
00218 
00224     Cylindrical2dMesh(double width);
00225 
00233     Cylindrical2dMesh(double width, std::vector<Node<2>*> nodes);
00234 
00238     ~Cylindrical2dMesh();
00239 
00250     void ReMesh(NodeMap& rMap);
00251 
00262     c_vector<double, 2> GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2);
00263 
00274     void SetNode(unsigned index, ChastePoint<2> point, bool concreteMove);
00275 
00285     double GetWidth(const unsigned& rDimension) const;
00286 
00293     unsigned AddNode(Node<2>* pNewNode);
00294 
00298     bool GetInstanceOfMismatchedBoundaryNodes();
00299 };
00300 
00301 namespace boost
00302 {
00303 namespace serialization
00304 {
00308 template<class Archive>
00309 inline void save_construct_data(
00310     Archive & ar, const Cylindrical2dMesh * t, const BOOST_PFTO unsigned int file_version)
00311 {
00312     // Save data required to construct instance
00313     const double width = t->GetWidth(0);
00314     ar & width;
00315 }
00316 
00320 template<class Archive>
00321 inline void load_construct_data(
00322     Archive & ar, Cylindrical2dMesh * t, const unsigned int file_version)
00323 {
00324     // Retrieve data from archive required to construct new instance
00325     double width;
00326     ar & width;
00327 
00328     // Invoke inplace constructor to initialise instance
00329     ::new(t)Cylindrical2dMesh(width);
00330 }
00331 }
00332 } // namespace ...
00333 
00334 #include "SerializationExportWrapper.hpp"
00335 CHASTE_CLASS_EXPORT(Cylindrical2dMesh)
00336 
00337 #endif /*CYLINDRICAL2DMESH_HPP_*/