Chaste Commit::8b5d759ac2eb95e67ae57699734101efccb0a0a9
MutableElement.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 MUTABLEELEMENT_HPP_
36#define MUTABLEELEMENT_HPP_
37
38#include "AbstractElement.hpp"
39#include "Edge.hpp"
40#include "EdgeHelper.hpp"
41
43#include <boost/serialization/base_object.hpp>
44#include <boost/serialization/vector.hpp>
45
46template<unsigned SPACE_DIM>
47class EdgeHelper;
48
53template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
54class MutableElement : public AbstractElement<ELEMENT_DIM, SPACE_DIM>
55{
56private:
70 template<class Archive>
71 void serialize(Archive & archive, const unsigned int version)
72 {
73 archive & boost::serialization::base_object<AbstractElement<ELEMENT_DIM, SPACE_DIM> >(*this);
74 }
75
76protected:
77
79 std::vector<Edge<SPACE_DIM>*> mEdges;
80
83
84public:
85
92 MutableElement(unsigned index);
93
100 MutableElement(unsigned index,
101 const std::vector<Node<SPACE_DIM>*>& rNodes);
102
103
107 virtual ~MutableElement();
108
114 void RegisterWithNodes();
115
122 void MarkAsDeleted();
123
129 void ResetIndex(unsigned index);
130
137 void UpdateNode(const unsigned& rIndex, Node<SPACE_DIM>* pNode);
138
144 void DeleteNode(const unsigned& rIndex);
145
152 void AddNode(Node<SPACE_DIM>* pNode, const unsigned& rIndex);
153
161 unsigned GetNodeLocalIndex(unsigned globalIndex) const;
162
166 void RegisterWithEdges();
167
171 void RebuildEdges();
172
178 virtual bool IsElementOnBoundary() const;
179
185 void SetEdgeHelper(EdgeHelper<SPACE_DIM>* pEdgeHelper);
186
190 void ClearEdges();
191
195 void BuildEdges();
196
202 unsigned GetEdgeGlobalIndex(unsigned localIndex) const;
203
209 Edge<SPACE_DIM>* GetEdge(unsigned localIndex) const;
210
214 unsigned GetNumEdges() const;
215
221 std::set<unsigned> GetNeighbouringElementAtEdgeIndex(unsigned localIndex);
222
230 bool ContainsEdge(const Edge<SPACE_DIM>* pEdge) const;
231
239 long GetLocalEdgeIndex(const Edge<SPACE_DIM>* pEdge) const;
240};
241
243// Specialization for 1d elements //
244// //
245// 1d elements are just edges (lines) //
247
252template<unsigned SPACE_DIM>
253class MutableElement<1, SPACE_DIM> : public AbstractElement<1,SPACE_DIM>
254{
255protected:
256
258 std::vector<Edge<SPACE_DIM>*> mEdges;
259
262
263public:
264
271 MutableElement(unsigned index, const std::vector<Node<SPACE_DIM>*>& rNodes);
272
279 MutableElement(unsigned index);
280
284 virtual ~MutableElement();
285
292 void UpdateNode(const unsigned& rIndex, Node<SPACE_DIM>* pNode);
293
299 void RegisterWithNodes();
300
307 void MarkAsDeleted();
308
314 void ResetIndex(unsigned index);
315
321 void DeleteNode(const unsigned& rIndex);
322
329 void AddNode(Node<SPACE_DIM>* pNode, const unsigned& rIndex);
330
337 Edge<SPACE_DIM>* GetEdge(unsigned localIndex) const;
338
346 bool ContainsEdge(const Edge<SPACE_DIM>* pEdge) const;
347
351 unsigned GetNumEdges() const;
352
358 void SetEdgeHelper(EdgeHelper<SPACE_DIM>* pEdgeHelper);
359
363 void BuildEdges();
364
368 void ClearEdges();
369
375 unsigned GetEdgeGlobalIndex(unsigned localIndex) const;
376
382 std::set<unsigned> GetNeighbouringElementAtEdgeIndex(unsigned localIndex);
383
391 unsigned GetNodeLocalIndex(unsigned globalIndex) const;
392
396 void RegisterWithEdges();
397
401 void RebuildEdges();
402
408 virtual bool IsElementOnBoundary() const;
409
417 long GetLocalEdgeIndex(const Edge<SPACE_DIM>* pEdge) const;
418};
419
420#endif /*MUTABLEELEMENT_HPP_*/
Definition Edge.hpp:52
std::vector< Edge< SPACE_DIM > * > mEdges
EdgeHelper< SPACE_DIM > * mEdgeHelper
std::vector< Edge< SPACE_DIM > * > mEdges
std::set< unsigned > GetNeighbouringElementAtEdgeIndex(unsigned localIndex)
unsigned GetEdgeGlobalIndex(unsigned localIndex) const
void serialize(Archive &archive, const unsigned int version)
void ResetIndex(unsigned index)
virtual bool IsElementOnBoundary() const
long GetLocalEdgeIndex(const Edge< SPACE_DIM > *pEdge) const
EdgeHelper< SPACE_DIM > * mEdgeHelper
void DeleteNode(const unsigned &rIndex)
virtual ~MutableElement()
bool ContainsEdge(const Edge< SPACE_DIM > *pEdge) const
void UpdateNode(const unsigned &rIndex, Node< SPACE_DIM > *pNode)
friend class boost::serialization::access
Edge< SPACE_DIM > * GetEdge(unsigned localIndex) const
void SetEdgeHelper(EdgeHelper< SPACE_DIM > *pEdgeHelper)
unsigned GetNodeLocalIndex(unsigned globalIndex) const
void AddNode(Node< SPACE_DIM > *pNode, const unsigned &rIndex)
unsigned GetNumEdges() const
Definition Node.hpp:59