MutableVertexMesh.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef MUTABLEVERTEXMESH_HPP_
00029 #define MUTABLEVERTEXMESH_HPP_
00030
00031
00032 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00033 class VertexMeshWriter;
00034
00035 #include <iostream>
00036 #include <map>
00037 #include <algorithm>
00038
00039 #include "ChasteSerialization.hpp"
00040 #include <boost/serialization/vector.hpp>
00041 #include <boost/serialization/base_object.hpp>
00042 #include <boost/serialization/split_member.hpp>
00043
00044 #include "VertexMesh.hpp"
00045
00049 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00050 class MutableVertexMesh : public VertexMesh<ELEMENT_DIM, SPACE_DIM>
00051 {
00052 friend class TestMutableVertexMesh;
00053 friend class TestMutableVertexMeshReMesh;
00054
00055 protected:
00056
00058 double mCellRearrangementThreshold;
00059
00064 double mCellRearrangementRatio;
00065
00067 double mT2Threshold;
00068
00070 bool mCheckForInternalIntersections;
00071
00073 std::vector<unsigned> mDeletedNodeIndices;
00074
00076 std::vector<unsigned> mDeletedElementIndices;
00077
00082 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT1Swaps;
00083
00088 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT3Swaps;
00089
00102 unsigned DivideElement(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00103 unsigned nodeAIndex,
00104 unsigned nodeBIndex,
00105 bool placeOriginalElementBelow=false);
00106
00118 bool CheckForT1Swaps(VertexElementMap& rElementMap);
00119
00132 bool CheckForT2Swaps(VertexElementMap& rElementMap);
00133
00141 bool CheckForIntersections();
00142
00154 void IdentifySwapType(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, VertexElementMap& rElementMap);
00155
00163 void PerformNodeMerge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00164
00174 void PerformT1Swap(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, std::set<unsigned>& rElementsContainingNodes);
00175
00184 void PerformIntersectionSwap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
00185
00193 void PerformT2Swap(VertexElement<ELEMENT_DIM,SPACE_DIM>& rElement);
00194
00203 void PerformT3Swap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
00204
00213 void PerformVoidRemoval(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, Node<SPACE_DIM>* pNodeC);
00214
00216 friend class boost::serialization::access;
00217
00228 template<class Archive>
00229 void serialize(Archive & archive, const unsigned int version)
00230 {
00231
00232 archive & mCellRearrangementThreshold;
00233 archive & mCellRearrangementRatio;
00234 archive & mT2Threshold;
00235 archive & mCheckForInternalIntersections;
00236 archive & mDeletedNodeIndices;
00237 archive & mDeletedElementIndices;
00238
00239
00240
00241 archive & boost::serialization::base_object<VertexMesh<ELEMENT_DIM, SPACE_DIM> >(*this);
00242 }
00243
00244 public:
00245
00256 MutableVertexMesh(std::vector<Node<SPACE_DIM>*> nodes,
00257 std::vector<VertexElement<ELEMENT_DIM, SPACE_DIM>*> vertexElements,
00258 double cellRearrangementThreshold=0.01,
00259 double t2Threshold=0.001,
00260 double cellRearrangementRatio=1.5);
00261
00265 MutableVertexMesh();
00266
00270 virtual ~MutableVertexMesh();
00271
00277 void SetCellRearrangementThreshold(double cellRearrangementThreshold);
00278
00284 void SetT2Threshold(double t2Threshold);
00285
00291 void SetCellRearrangementRatio(double cellRearrangementRatio);
00292
00299 virtual void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM> point);
00300
00306 void SetCheckForInternalIntersections(bool checkForInternalIntersections);
00307
00311 double GetCellRearrangementThreshold() const;
00312
00316 double GetT2Threshold() const;
00317
00321 double GetCellRearrangementRatio() const;
00322
00326 unsigned GetNumNodes() const;
00327
00331 unsigned GetNumElements() const;
00332
00336 bool GetCheckForInternalIntersections() const;
00337
00341 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT1Swaps();
00342
00346 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT3Swaps();
00347
00351 void ClearLocationsOfT1Swaps();
00352
00356 void ClearLocationsOfT3Swaps();
00357
00358
00367 unsigned AddNode(Node<SPACE_DIM>* pNewNode);
00368
00376 void DeleteElementPriorToReMesh(unsigned index);
00377
00385 void DeleteNodePriorToReMesh(unsigned index);
00386
00397 unsigned DivideElementAlongShortAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00398 bool placeOriginalElementBelow=false);
00399
00415 unsigned DivideElementAlongGivenAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00416 c_vector<double, SPACE_DIM> axisOfDivision,
00417 bool placeOriginalElementBelow=false);
00418
00426 unsigned AddElement(VertexElement<ELEMENT_DIM, SPACE_DIM>* pNewElement);
00427
00431 void Clear();
00432
00439 void DivideEdge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00440
00449 void RemoveDeletedNodesAndElements(VertexElementMap& rElementMap);
00450
00454 void RemoveDeletedNodes();
00455
00463 void ReMesh(VertexElementMap& rElementMap);
00464
00469 void ReMesh();
00470 };
00471
00472 #include "SerializationExportWrapper.hpp"
00473 EXPORT_TEMPLATE_CLASS_ALL_DIMS(MutableVertexMesh);
00474
00475 #endif