Chaste  Release::3.4
Cylindrical2dMesh.hpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 #ifndef CYLINDRICAL2DMESH_HPP_
36 #define CYLINDRICAL2DMESH_HPP_
37 
38 #include "ChasteSerialization.hpp"
39 #include <boost/serialization/base_object.hpp>
40 
41 #include <cmath>
42 #include <map>
43 
44 #include "MutableMesh.hpp"
45 #include "TrianglesMeshWriter.hpp"
46 
55 class Cylindrical2dMesh : public MutableMesh<2,2>
56 {
57  friend class TestCylindrical2dMesh;
58 private:
59 
61  double mWidth;
62 
64  double mTop;
65 
67  double mBottom;
68 
70  std::vector<unsigned> mLeftOriginals;
71 
73  std::vector<unsigned> mLeftImages;
74 
76  std::map<unsigned, unsigned> mImageToLeftOriginalNodeMap;
77 
79  std::vector<unsigned> mRightOriginals;
80 
82  std::vector<unsigned> mRightImages;
83 
85  std::map<unsigned, unsigned> mImageToRightOriginalNodeMap;
86 
89 
92 
94  std::vector<unsigned > mTopHaloNodes;
95 
97  std::vector<unsigned > mBottomHaloNodes;
98 
101 
108  void UpdateTopAndBottom();
109 
118  void CreateHaloNodes();
119 
126  void CreateMirrorNodes();
127 
141 
148  void DeleteHaloNodes();
149 
160  void CorrectNonPeriodicMesh();
161 
173 
181  unsigned GetCorrespondingNodeIndex(unsigned nodeIndex);
182 
193  void UseTheseElementsToDecideMeshing(std::set<unsigned>& rMainSideElements);
194 
208  template<class Archive>
209  void serialize(Archive & archive, const unsigned int version)
210  {
211  archive & boost::serialization::base_object<MutableMesh<2,2> >(*this);
212  archive & mWidth;
213  archive & mTop;
214  archive & mBottom;
215  }
216 
217 public:
218 
224  Cylindrical2dMesh(double width);
225 
233  Cylindrical2dMesh(double width, std::vector<Node<2>*> nodes);
234 
239 
250  void ReMesh(NodeMap& rMap);
251 
262  c_vector<double, 2> GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2);
263 
274  void SetNode(unsigned index, ChastePoint<2> point, bool concreteMove);
275 
285  double GetWidth(const unsigned& rDimension) const;
286 
293  unsigned AddNode(Node<2>* pNewNode);
294 
299 };
300 
301 namespace boost
302 {
303 namespace serialization
304 {
308 template<class Archive>
309 inline void save_construct_data(
310  Archive & ar, const Cylindrical2dMesh * t, const unsigned int file_version)
311 {
312  // Save data required to construct instance
313  const double width = t->GetWidth(0);
314  ar & width;
315 }
316 
320 template<class Archive>
321 inline void load_construct_data(
322  Archive & ar, Cylindrical2dMesh * t, const unsigned int file_version)
323 {
324  // Retrieve data from archive required to construct new instance
325  double width;
326  ar & width;
327 
328  // Invoke inplace constructor to initialise instance
329  ::new(t)Cylindrical2dMesh(width);
330 }
331 }
332 } // namespace ...
333 
334 #include "SerializationExportWrapper.hpp"
336 
337 #endif /*CYLINDRICAL2DMESH_HPP_*/
Definition: Node.hpp:58
void SetNode(unsigned index, ChastePoint< 2 > point, bool concreteMove)
std::set< unsigned > mLeftPeriodicBoundaryElementIndices
std::vector< unsigned > mTopHaloNodes
unsigned GetCorrespondingNodeIndex(unsigned nodeIndex)
void UseTheseElementsToDecideMeshing(std::set< unsigned > &rMainSideElements)
std::vector< unsigned > mLeftOriginals
friend class boost::serialization::access
c_vector< double, 2 > GetVectorFromAtoB(const c_vector< double, 2 > &rLocation1, const c_vector< double, 2 > &rLocation2)
std::map< unsigned, unsigned > mImageToRightOriginalNodeMap
std::vector< unsigned > mRightOriginals
bool GetInstanceOfMismatchedBoundaryNodes()
void GenerateVectorsOfElementsStraddlingPeriodicBoundaries()
unsigned AddNode(Node< 2 > *pNewNode)
void serialize(Archive &archive, const unsigned int version)
std::vector< unsigned > mLeftImages
std::vector< unsigned > mRightImages
#define CHASTE_CLASS_EXPORT(T)
Cylindrical2dMesh(double width)
std::set< unsigned > mRightPeriodicBoundaryElementIndices
std::map< unsigned, unsigned > mImageToLeftOriginalNodeMap
std::vector< unsigned > mBottomHaloNodes
double GetWidth(const unsigned &rDimension) const