Cylindrical2dMesh.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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 
00170     unsigned GetCorrespondingNodeIndex(unsigned nodeIndex);
00171 
00180     void UseTheseElementsToDecideMeshing(std::set<unsigned>& rMainSideElements);
00181 
00183     friend class boost::serialization::access;
00194     template<class Archive>
00195     void serialize(Archive & archive, const unsigned int version)
00196     {
00197         archive & mWidth;
00198         archive & mTop;
00199         archive & mBottom;
00200 
00201         archive & boost::serialization::base_object<MutableMesh<2,2> >(*this);
00202     }
00203 
00204 public:
00205 
00211     Cylindrical2dMesh(double width);
00212 
00220     Cylindrical2dMesh(double width, std::vector<Node<2> *> nodes);
00221 
00225     ~Cylindrical2dMesh();
00226 
00237     void ReMesh(NodeMap &map);
00238 
00247     c_vector<double, 2> GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2);
00248 
00262     void SetNode(unsigned index, ChastePoint<2> point, bool concreteMove);
00263 
00269     double GetWidth(const unsigned& rDimension) const;
00270 
00280     unsigned AddNode(Node<2>* pNewNode);
00281 
00282 };
00283 
00284 
00285 namespace boost
00286 {
00287 namespace serialization
00288 {
00292 template<class Archive>
00293 inline void save_construct_data(
00294     Archive & ar, const Cylindrical2dMesh * t, const BOOST_PFTO unsigned int file_version)
00295 {
00296     // Save data required to construct instance
00297     const double width = t->GetWidth(0);
00298     ar << width;
00299 }
00300 
00304 template<class Archive>
00305 inline void load_construct_data(
00306     Archive & ar, Cylindrical2dMesh * t, const unsigned int file_version)
00307 {
00308     // Retrieve data from archive required to construct new instance
00309     double width;
00310     ar >> width;
00311 
00312     // Invoke inplace constructor to initialise instance
00313     ::new(t)Cylindrical2dMesh(width);
00314 }
00315 }
00316 } // namespace ...
00317 
00318 #include "SerializationExportWrapper.hpp"
00319 CHASTE_CLASS_EXPORT(Cylindrical2dMesh)
00320 
00321 #endif /*CYLINDRICAL2DMESH_HPP_*/

Generated by  doxygen 1.6.2