Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
Toroidal2dMesh.hpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, 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
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35#ifndef TOROIDAL2DMESH_HPP_
36#define TOROIDAL2DMESH_HPP_
37
39#include <boost/serialization/base_object.hpp>
40
41#include <cmath>
42#include <map>
43
44#include "MutableMesh.hpp"
45#include "TrianglesMeshWriter.hpp"
46
55class Toroidal2dMesh : public MutableMesh<2,2>
56{
57 friend class TestToroidal2dMesh;
58private:
59
61 double mWidth;
62
64 double mHeight;
65
67 std::vector<unsigned> mLeftOriginals;
68
70 std::vector<unsigned> mLeftImages;
71
73 std::map<unsigned, unsigned> mImageToLeftOriginalNodeMap;
74
76 std::vector<unsigned> mRightOriginals;
77
79 std::vector<unsigned> mRightImages;
80
82 std::map<unsigned, unsigned> mImageToRightOriginalNodeMap;
83
86
89
91 std::vector<unsigned> mBottomOriginals;
92
94 std::vector<unsigned> mBottomImages;
95
97 std::map<unsigned, unsigned> mImageToBottomOriginalNodeMap;
98
100 std::vector<unsigned> mTopOriginals;
101
103 std::vector<unsigned> mTopImages;
104
106 std::map<unsigned, unsigned> mImageToTopOriginalNodeMap;
107
110
113
114
117
125 void CreateMirrorNodes();
126
140
154
166
178
179
191
203
211 unsigned GetCorrespondingCylindricalNodeIndex(unsigned nodeIndex);
212
220 unsigned GetCorrespondingToroidalNodeIndex(unsigned nodeIndex);
221
235 template<class Archive>
236 void serialize(Archive & archive, const unsigned int version)
237 {
238 archive & boost::serialization::base_object<MutableMesh<2,2> >(*this);
239 archive & mWidth;
240 archive & mHeight;
241 }
242
243public:
244
251 Toroidal2dMesh(double width, double depth);
252
261 Toroidal2dMesh(double width, double depth, std::vector<Node<2>*> nodes);
262
267
278 void ReMesh(NodeMap& rMap);
279
290 c_vector<double, 2> GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2);
291
302 void SetNode(unsigned index, ChastePoint<2> point, bool concreteMove);
303
313 double GetWidth(const unsigned& rDimension) const;
314
321 unsigned AddNode(Node<2>* pNewNode);
322
327
332 void RefreshMesh();
333};
334
335namespace boost
336{
337namespace serialization
338{
342template<class Archive>
343inline void save_construct_data(
344 Archive & ar, const Toroidal2dMesh * t, const unsigned int file_version)
345{
346 // Save data required to construct instance
347 const double width = t->GetWidth(0);
348 ar & width;
349 const double depth = t->GetWidth(1);
350 ar & depth;
351}
352
356template<class Archive>
357inline void load_construct_data(
358 Archive & ar, Toroidal2dMesh * t, const unsigned int file_version)
359{
360 // Retrieve data from archive required to construct new instance
361 double width;
362 ar & width;
363 double depth;
364 ar & depth;
365
366 // Invoke inplace constructor to initialise instance
367 ::new(t)Toroidal2dMesh(width,depth);
368}
369}
370} // namespace ...
371
374
375#endif /*TOROIDAL2DMESH_HPP_*/
gcov doesn't like this file...
#define CHASTE_CLASS_EXPORT(T)
Definition Node.hpp:59
std::vector< unsigned > mBottomOriginals
std::map< unsigned, unsigned > mImageToRightOriginalNodeMap
void GenerateVectorsOfElementsStraddlingToroidalPeriodicBoundaries()
std::vector< unsigned > mLeftImages
std::vector< unsigned > mRightOriginals
std::set< unsigned > mBottomPeriodicBoundaryElementIndices
void ReconstructToroidalMesh()
std::map< unsigned, unsigned > mImageToTopOriginalNodeMap
std::set< unsigned > mTopPeriodicBoundaryElementIndices
std::vector< unsigned > mLeftOriginals
unsigned GetCorrespondingToroidalNodeIndex(unsigned nodeIndex)
void SetNode(unsigned index, ChastePoint< 2 > point, bool concreteMove)
void CorrectToroidalNonPeriodicMesh()
void serialize(Archive &archive, const unsigned int version)
bool GetInstanceOfMismatchedBoundaryNodes()
std::set< unsigned > mLeftPeriodicBoundaryElementIndices
std::map< unsigned, unsigned > mImageToBottomOriginalNodeMap
c_vector< double, 2 > GetVectorFromAtoB(const c_vector< double, 2 > &rLocation1, const c_vector< double, 2 > &rLocation2)
std::vector< unsigned > mRightImages
std::set< unsigned > mRightPeriodicBoundaryElementIndices
std::vector< unsigned > mTopOriginals
unsigned GetCorrespondingCylindricalNodeIndex(unsigned nodeIndex)
void ReconstructCylindricalMesh()
double GetWidth(const unsigned &rDimension) const
std::vector< unsigned > mBottomImages
friend class boost::serialization::access
std::map< unsigned, unsigned > mImageToLeftOriginalNodeMap
unsigned AddNode(Node< 2 > *pNewNode)
void CorrectCylindricalNonPeriodicMesh()
std::vector< unsigned > mTopImages
void GenerateVectorsOfElementsStraddlingCylindricalPeriodicBoundaries()