Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
Edge.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
36#ifndef EDGE_HPP_
37#define EDGE_HPP_
38
39#include <set>
40#include <vector>
42#include <boost/serialization/serialization.hpp>
43#include <boost/serialization/set.hpp>
44#include <boost/serialization/vector.hpp>
45#include "Node.hpp"
46
50template<unsigned SPACE_DIM>
51class Edge
52{
53private:
54
56 unsigned mIndex;
57
60
62 std::vector<Node<SPACE_DIM>*> mNodes;
63
65 std::set<unsigned> mElementIndices;
66 friend class boost::serialization::access;
73 template<class Archive>
74 void serialize(Archive & archive, const unsigned int version)
75 {
76 archive & mElementIndices;
77 archive & mIndex;
78 archive & mNodes;
79 }
80public:
81
88 explicit Edge(unsigned index);
89
97 Edge(unsigned index, Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
98
107 static std::pair<unsigned, unsigned> GenerateMapIndex(unsigned index1, unsigned index2);
108
112 void MarkAsDeleted();
113
117 bool IsDeleted();
118
124 void SetIndex(unsigned index);
125
129 unsigned GetIndex() const;
130
134 std::pair<unsigned, unsigned> GetMapIndex();
135
139 void RemoveNodes();
140
147 void SetNodes(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
148
155 void ReplaceNode(Node<SPACE_DIM>* pOldNode, Node<SPACE_DIM>* pNewNode);
156
162 Node<SPACE_DIM>* GetNode(unsigned index) const;
163
167 unsigned GetNumNodes();
168
174 bool ContainsNode(Node<SPACE_DIM>* pNode) const;
175
179 c_vector<double, SPACE_DIM> rGetCentreLocation();
180
184 double rGetLength();
185
193 std::set<unsigned> GetOtherElements(unsigned elementIndex);
194
200 void AddElement(unsigned elementIndex);
201
207 void RemoveElement(unsigned elementIndex);
208
215 std::set<unsigned> GetNeighbouringElementIndices();
216
220 unsigned GetNumElements();
221
225 bool IsBoundaryEdge() const;
226
234 bool operator==(const Edge<SPACE_DIM>& rEdge) const;
235};
236
238// Declare identifier for the serializer
240
241namespace boost
242{
243namespace serialization
244{
248template<class Archive, unsigned SPACE_DIM>
249inline void save_construct_data(
250 Archive & ar, const Edge<SPACE_DIM> * t, const unsigned int file_version)
251{
252 const Node<SPACE_DIM>* const p_Node0 = t->GetNode(0);
253 ar & p_Node0;
254 const Node<SPACE_DIM>* const p_Node1 = t->GetNode(1);
255 ar & p_Node1;
256
257 unsigned index = t->GetIndex();
258 ar << index;
259}
260
264template<class Archive, unsigned SPACE_DIM>
265inline void load_construct_data(
266 Archive & ar, Edge<SPACE_DIM> * t, const unsigned int file_version)
267{
268 // Retrieve data from archive required to construct new instance of Edge
269 Node<SPACE_DIM>* p_Node0;
270 ar & p_Node0;
271 Node<SPACE_DIM>* p_Node1;
272 ar & p_Node1;
273
274 unsigned index;
275 ar >> index;
276
277 // Invoke inplace constructor to initialise instance
278 ::new(t)Edge<SPACE_DIM>(index, p_Node0, p_Node1);
279}
280
281}
282} // namespace ...
283#endif /* EDGE_HPP_ */
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
Definition Edge.hpp:52
bool ContainsNode(Node< SPACE_DIM > *pNode) const
Definition Edge.cpp:140
void SetNodes(Node< SPACE_DIM > *pNodeA, Node< SPACE_DIM > *pNodeB)
Definition Edge.cpp:102
void RemoveElement(unsigned elementIndex)
Definition Edge.cpp:187
void serialize(Archive &archive, const unsigned int version)
Definition Edge.hpp:74
c_vector< double, SPACE_DIM > rGetCentreLocation()
Definition Edge.cpp:153
std::set< unsigned > GetNeighbouringElementIndices()
Definition Edge.cpp:193
unsigned GetIndex() const
Definition Edge.cpp:81
double rGetLength()
Definition Edge.cpp:160
Node< SPACE_DIM > * GetNode(unsigned index) const
Definition Edge.cpp:128
bool mIsDeleted
Definition Edge.hpp:59
static std::pair< unsigned, unsigned > GenerateMapIndex(unsigned index1, unsigned index2)
Definition Edge.cpp:56
std::set< unsigned > GetOtherElements(unsigned elementIndex)
Definition Edge.cpp:167
bool IsDeleted()
Definition Edge.cpp:69
void MarkAsDeleted()
Definition Edge.cpp:63
bool operator==(const Edge< SPACE_DIM > &rEdge) const
Definition Edge.cpp:220
unsigned GetNumNodes()
Definition Edge.cpp:134
std::set< unsigned > mElementIndices
Definition Edge.hpp:65
unsigned mIndex
Definition Edge.hpp:56
void ReplaceNode(Node< SPACE_DIM > *pOldNode, Node< SPACE_DIM > *pNewNode)
Definition Edge.cpp:114
void SetIndex(unsigned index)
Definition Edge.cpp:75
void RemoveNodes()
Definition Edge.cpp:96
unsigned GetNumElements()
Definition Edge.cpp:208
bool IsBoundaryEdge() const
Definition Edge.cpp:214
void AddElement(unsigned elementIndex)
Definition Edge.cpp:181
std::vector< Node< SPACE_DIM > * > mNodes
Definition Edge.hpp:62
std::pair< unsigned, unsigned > GetMapIndex()
Definition Edge.cpp:87
Definition Node.hpp:59