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
00029
00030
00031
00032
00033
00034
00035 #ifndef MUTABLEVERTEXMESH_HPP_
00036 #define MUTABLEVERTEXMESH_HPP_
00037
00038
00039 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00040 class VertexMeshWriter;
00041
00042 #include <iostream>
00043 #include <map>
00044 #include <algorithm>
00045
00046 #include "ChasteSerialization.hpp"
00047 #include <boost/serialization/vector.hpp>
00048 #include <boost/serialization/base_object.hpp>
00049 #include <boost/serialization/split_member.hpp>
00050
00051 #include "VertexMesh.hpp"
00052
00063 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00064 class MutableVertexMesh : public VertexMesh<ELEMENT_DIM, SPACE_DIM>
00065 {
00066 friend class TestMutableVertexMesh;
00067 friend class TestMutableVertexMeshReMesh;
00068
00069 protected:
00070
00072 double mCellRearrangementThreshold;
00073
00078 double mCellRearrangementRatio;
00079
00081 double mT2Threshold;
00082
00084 bool mCheckForInternalIntersections;
00085
00087 std::vector<unsigned> mDeletedNodeIndices;
00088
00090 std::vector<unsigned> mDeletedElementIndices;
00091
00096 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT1Swaps;
00097
00101 c_vector<double, SPACE_DIM> mLastT2SwapLocation;
00102
00107 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT3Swaps;
00108
00121 unsigned DivideElement(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00122 unsigned nodeAIndex,
00123 unsigned nodeBIndex,
00124 bool placeOriginalElementBelow=false);
00125
00137 bool CheckForSwapsFromShortEdges();
00138
00147 bool CheckForIntersections();
00148
00159 virtual void IdentifySwapType(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00160
00171 void PerformNodeMerge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00172
00186 void PerformT1Swap(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, std::set<unsigned>& rElementsContainingNodes);
00187
00197 void PerformIntersectionSwap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
00198
00208 void PerformT2Swap(VertexElement<ELEMENT_DIM,SPACE_DIM>& rElement);
00209
00220 void PerformT3Swap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
00221
00232 void PerformVoidRemoval(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, Node<SPACE_DIM>* pNodeC);
00233
00246 c_vector<double, 2> WidenEdgeOrCorrectIntersectionLocationIfNecessary(unsigned indexA, unsigned indexB, c_vector<double,2> intersection);
00247
00249 friend class boost::serialization::access;
00250
00261 template<class Archive>
00262 void serialize(Archive & archive, const unsigned int version)
00263 {
00264
00265 archive & mCellRearrangementThreshold;
00266 archive & mCellRearrangementRatio;
00267 archive & mT2Threshold;
00268 archive & mCheckForInternalIntersections;
00269 archive & mDeletedNodeIndices;
00270 archive & mDeletedElementIndices;
00272
00273 archive & boost::serialization::base_object<VertexMesh<ELEMENT_DIM, SPACE_DIM> >(*this);
00274 }
00275
00276 public:
00277
00288 MutableVertexMesh(std::vector<Node<SPACE_DIM>*> nodes,
00289 std::vector<VertexElement<ELEMENT_DIM, SPACE_DIM>*> vertexElements,
00290 double cellRearrangementThreshold=0.01,
00291 double t2Threshold=0.001,
00292 double cellRearrangementRatio=1.5);
00293
00297 MutableVertexMesh();
00298
00302 virtual ~MutableVertexMesh();
00303
00309 void SetCellRearrangementThreshold(double cellRearrangementThreshold);
00310
00316 void SetT2Threshold(double t2Threshold);
00317
00323 void SetCellRearrangementRatio(double cellRearrangementRatio);
00324
00331 virtual void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM> point);
00332
00338 void SetCheckForInternalIntersections(bool checkForInternalIntersections);
00339
00343 double GetCellRearrangementThreshold() const;
00344
00348 double GetT2Threshold() const;
00349
00353 double GetCellRearrangementRatio() const;
00354
00358 unsigned GetNumNodes() const;
00359
00363 unsigned GetNumElements() const;
00364
00368 bool GetCheckForInternalIntersections() const;
00369
00373 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT1Swaps();
00374
00378 c_vector<double, SPACE_DIM> GetLastT2SwapLocation();
00379
00383 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT3Swaps();
00384
00388 void ClearLocationsOfT1Swaps();
00389
00393 void ClearLocationsOfT3Swaps();
00394
00403 unsigned AddNode(Node<SPACE_DIM>* pNewNode);
00404
00412 void DeleteElementPriorToReMesh(unsigned index);
00413
00421 void DeleteNodePriorToReMesh(unsigned index);
00422
00431 unsigned DivideElementAlongShortAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00432 bool placeOriginalElementBelow=false);
00433
00447 unsigned DivideElementAlongGivenAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00448 c_vector<double, SPACE_DIM> axisOfDivision,
00449 bool placeOriginalElementBelow=false);
00450
00458 unsigned AddElement(VertexElement<ELEMENT_DIM, SPACE_DIM>* pNewElement);
00459
00472 bool CheckForT2Swaps(VertexElementMap& rElementMap);
00473
00477 void Clear();
00478
00485 void DivideEdge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00486
00495 void RemoveDeletedNodesAndElements(VertexElementMap& rElementMap);
00496
00500 void RemoveDeletedNodes();
00501
00514 virtual void ReMesh(VertexElementMap& rElementMap);
00515
00522 void ReMesh();
00523 };
00524
00525 #include "SerializationExportWrapper.hpp"
00526 EXPORT_TEMPLATE_CLASS_ALL_DIMS(MutableVertexMesh)
00527
00528 #endif