Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
MutableVertexMesh.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 MUTABLEVERTEXMESH_HPP_
36#define MUTABLEVERTEXMESH_HPP_
37
38// Forward declaration prevents circular include chain
39template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
41
42#include <iostream>
43#include <map>
44#include <algorithm>
45
47#include <boost/serialization/vector.hpp>
48#include <boost/serialization/base_object.hpp>
49#include <boost/serialization/split_member.hpp>
50
51#include "VertexMesh.hpp"
52#include "EdgeHelper.hpp"
53#include "RandomNumberGenerator.hpp"
54
55#include "VertexMeshOperationRecorder.hpp"
66template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
67class MutableVertexMesh : public VertexMesh<ELEMENT_DIM, SPACE_DIM>
68{
69 friend class TestMutableVertexMesh;
70 friend class TestMutableVertexMeshReMesh;
71 friend class TestMutableVertexMeshRosetteMethods;
72 friend class TestMutableVertexEdges;
73 friend class TestCellEdgeInteriorSrn;
74 friend class TestMutableVertexMeshOperationsWithPopulationSrn;
75protected:
78
81
84
90
93
96
99
102
105
108
110 std::vector<unsigned> mDeletedNodeIndices;
111
113 std::vector<unsigned> mDeletedElementIndices;
114
122
126 c_vector<double, SPACE_DIM> mLastT2SwapLocation;
127
132 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfIntersectionSwaps;
133
147 unsigned nodeAIndex,
148 unsigned nodeBIndex,
149 bool placeOriginalElementBelow=false);
150
162 virtual bool CheckForSwapsFromShortEdges();
163
173
184 virtual void IdentifySwapType(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
185public:
196 void PerformNodeMerge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
197private:
211 void PerformT1Swap(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, std::set<unsigned>& rElementsContainingNodes);
212
222 void PerformIntersectionSwap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
223
234
245 void PerformT3Swap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
246
258
269 virtual void HandleHighOrderJunctions(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
270
283
293 void PerformProtorosetteResolution(Node<SPACE_DIM>* pProtorosetteNode);
294
306
313 void CheckForRosettes();
314
327 c_vector<double, 2> WidenEdgeOrCorrectIntersectionLocationIfNecessary(unsigned indexA, unsigned indexB, c_vector<double, 2> intersection);
328
331
342 template<class Archive>
343 void serialize(Archive & archive, const unsigned int version)
344 {
345 // NOTE - Subclasses must archive their member variables BEFORE calling this method.
347 archive & mCellRearrangementRatio;
348 archive & mT2Threshold;
353 archive & mDeletedNodeIndices;
354 archive & mDeletedElementIndices;
356 archive & mOperationRecorder;
357 archive & mCheckForT3Swaps;
358 archive & mCheckForT3Swaps;
360 archive & boost::serialization::base_object<VertexMesh<ELEMENT_DIM, SPACE_DIM> >(*this);
361 }
362public:
363
380 MutableVertexMesh(std::vector<Node<SPACE_DIM>*> nodes,
381 std::vector<VertexElement<ELEMENT_DIM, SPACE_DIM>*> vertexElements,
382 double cellRearrangementThreshold=0.01,
383 double t2Threshold=0.001,
384 double cellRearrangementRatio=1.5,
385 double protorosetteFormationProbability=0.0,
386 double protorosetteResolutionProbabilityPerTimestep=0.0,
387 double rosetteResolutionProbabilityPerTimestep=0.0);
388
393
397 virtual ~MutableVertexMesh();
398
404 void SetCellRearrangementThreshold(double cellRearrangementThreshold);
405
411 void SetT2Threshold(double t2Threshold);
412
418 void SetCellRearrangementRatio(double cellRearrangementRatio);
419
425 void SetProtorosetteFormationProbability(double protorosetteFormationProbability);
426
432 void SetProtorosetteResolutionProbabilityPerTimestep(double protorosetteResolutionProbabilityPerTimestep);
433
439 void SetRosetteResolutionProbabilityPerTimestep(double rosetteResolutionProbabilityPerTimestep);
440
447 virtual void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM> point);
448
454 void SetCheckForInternalIntersections(bool checkForInternalIntersections);
455
461 void SetCheckForT3Swaps(bool checkForT3Swaps);
462
466 double GetCellRearrangementThreshold() const;
467
471 double GetT2Threshold() const;
472
476 double GetCellRearrangementRatio() const;
477
484
491
498
507 void SetDistanceForT3SwapChecking( double distanceForT3SwapChecking );
508
514 double GetDistanceForT3SwapChecking() const;
515
519 unsigned GetNumNodes() const;
520
524 unsigned GetNumElements() const;
525
530
536 bool GetCheckForT3Swaps() const;
537
541 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT1Swaps();
542
546 c_vector<double, SPACE_DIM> GetLastT2SwapLocation();
547
552 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT3Swaps();
553
557 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfIntersectionSwaps();
558
563
568
573
582 unsigned AddNode(Node<SPACE_DIM>* pNewNode);
583
591 void DeleteElementPriorToReMesh(unsigned index);
592
600 void DeleteNodePriorToReMesh(unsigned index);
601
611 bool placeOriginalElementBelow=false);
612
627 c_vector<double, SPACE_DIM> axisOfDivision,
628 bool placeOriginalElementBelow=false);
629
638
651 bool CheckForT2Swaps(VertexElementMap& rElementMap);
652
656 void Clear();
657
664 void DivideEdge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
665
675
679 void RemoveDeletedNodes();
680
693 virtual void ReMesh(VertexElementMap& rElementMap);
694
701 void ReMesh();
702
706 void SetMeshOperationTracking(const bool track);
707
712};
713
716
717#endif /*MUTABLEVERTEXMESH_HPP_*/
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
void SetCheckForT3Swaps(bool checkForT3Swaps)
void RemoveDeletedNodesAndElements(VertexElementMap &rElementMap)
void PerformNodeMerge(Node< SPACE_DIM > *pNodeA, Node< SPACE_DIM > *pNodeB)
double GetRosetteResolutionProbabilityPerTimestep() const
virtual bool CheckForSwapsFromShortEdges()
c_vector< double, SPACE_DIM > GetLastT2SwapLocation()
double GetCellRearrangementThreshold() const
void serialize(Archive &archive, const unsigned int version)
double mRosetteResolutionProbabilityPerTimestep
virtual void IdentifySwapType(Node< SPACE_DIM > *pNodeA, Node< SPACE_DIM > *pNodeB)
double GetProtorosetteFormationProbability() const
void DeleteElementPriorToReMesh(unsigned index)
void PerformRosetteRankIncrease(Node< SPACE_DIM > *pNodeA, Node< SPACE_DIM > *pNodeB)
void PerformT1Swap(Node< SPACE_DIM > *pNodeA, Node< SPACE_DIM > *pNodeB, std::set< unsigned > &rElementsContainingNodes)
void PerformVoidRemoval(Node< SPACE_DIM > *pNodeA, Node< SPACE_DIM > *pNodeB, Node< SPACE_DIM > *pNodeC)
unsigned AddNode(Node< SPACE_DIM > *pNewNode)
void SetCheckForInternalIntersections(bool checkForInternalIntersections)
double GetCellRearrangementRatio() const
double GetDistanceForT3SwapChecking() const
std::vector< c_vector< double, SPACE_DIM > > GetLocationsOfT3Swaps()
void SetRosetteResolutionProbabilityPerTimestep(double rosetteResolutionProbabilityPerTimestep)
bool CheckForT2Swaps(VertexElementMap &rElementMap)
std::vector< unsigned > mDeletedNodeIndices
void SetProtorosetteFormationProbability(double protorosetteFormationProbability)
void SetDistanceForT3SwapChecking(double distanceForT3SwapChecking)
unsigned DivideElementAlongGivenAxis(VertexElement< ELEMENT_DIM, SPACE_DIM > *pElement, c_vector< double, SPACE_DIM > axisOfDivision, bool placeOriginalElementBelow=false)
unsigned GetNumNodes() const
void SetProtorosetteResolutionProbabilityPerTimestep(double protorosetteResolutionProbabilityPerTimestep)
void DeleteNodePriorToReMesh(unsigned index)
c_vector< double, 2 > WidenEdgeOrCorrectIntersectionLocationIfNecessary(unsigned indexA, unsigned indexB, c_vector< double, 2 > intersection)
std::vector< unsigned > mDeletedElementIndices
std::vector< c_vector< double, SPACE_DIM > > GetLocationsOfT1Swaps()
double mProtorosetteFormationProbability
void PerformT3Swap(Node< SPACE_DIM > *pNode, unsigned elementIndex)
unsigned GetNumElements() const
std::vector< c_vector< double, SPACE_DIM > > mLocationsOfIntersectionSwaps
double GetProtorosetteResolutionProbabilityPerTimestep() const
unsigned DivideElementAlongShortAxis(VertexElement< ELEMENT_DIM, SPACE_DIM > *pElement, bool placeOriginalElementBelow=false)
double mProtorosetteResolutionProbabilityPerTimestep
void PerformT2Swap(VertexElement< ELEMENT_DIM, SPACE_DIM > &rElement)
void PerformProtorosetteResolution(Node< SPACE_DIM > *pProtorosetteNode)
unsigned AddElement(VertexElement< ELEMENT_DIM, SPACE_DIM > *pNewElement)
std::vector< c_vector< double, SPACE_DIM > > GetLocationsOfIntersectionSwaps()
void DivideEdge(Node< SPACE_DIM > *pNodeA, Node< SPACE_DIM > *pNodeB)
void SetMeshOperationTracking(const bool track)
friend class boost::serialization::access
virtual void HandleHighOrderJunctions(Node< SPACE_DIM > *pNodeA, Node< SPACE_DIM > *pNodeB)
void SetCellRearrangementRatio(double cellRearrangementRatio)
void PerformRosetteRankDecrease(Node< SPACE_DIM > *pRosetteNode)
virtual void SetNode(unsigned nodeIndex, ChastePoint< SPACE_DIM > point)
VertexMeshOperationRecorder< ELEMENT_DIM, SPACE_DIM > * GetOperationRecorder()
void PerformIntersectionSwap(Node< SPACE_DIM > *pNode, unsigned elementIndex)
bool GetCheckForT3Swaps() const
VertexMeshOperationRecorder< ELEMENT_DIM, SPACE_DIM > mOperationRecorder
double GetT2Threshold() const
unsigned DivideElement(VertexElement< ELEMENT_DIM, SPACE_DIM > *pElement, unsigned nodeAIndex, unsigned nodeBIndex, bool placeOriginalElementBelow=false)
bool GetCheckForInternalIntersections() const
void SetT2Threshold(double t2Threshold)
c_vector< double, SPACE_DIM > mLastT2SwapLocation
void SetCellRearrangementThreshold(double cellRearrangementThreshold)
Definition Node.hpp:59