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
00102 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT2Swaps;
00103
00108 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT3Swaps;
00109
00122 unsigned DivideElement(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00123 unsigned nodeAIndex,
00124 unsigned nodeBIndex,
00125 bool placeOriginalElementBelow=false);
00126
00142 bool CheckForSwapsFromShortEdges(VertexElementMap& rElementMap);
00143
00152 bool CheckForIntersections();
00153
00167 virtual void IdentifySwapType(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, VertexElementMap& rElementMap);
00168
00179 void PerformNodeMerge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00180
00194 void PerformT1Swap(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, std::set<unsigned>& rElementsContainingNodes);
00195
00205 void PerformIntersectionSwap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
00206
00216 void PerformT2Swap(VertexElement<ELEMENT_DIM,SPACE_DIM>& rElement);
00217
00228 void PerformT3Swap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
00229
00240 void PerformVoidRemoval(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, Node<SPACE_DIM>* pNodeC);
00241
00243 friend class boost::serialization::access;
00244
00255 template<class Archive>
00256 void serialize(Archive & archive, const unsigned int version)
00257 {
00258
00259 archive & mCellRearrangementThreshold;
00260 archive & mCellRearrangementRatio;
00261 archive & mT2Threshold;
00262 archive & mCheckForInternalIntersections;
00263 archive & mDeletedNodeIndices;
00264 archive & mDeletedElementIndices;
00266
00267 archive & boost::serialization::base_object<VertexMesh<ELEMENT_DIM, SPACE_DIM> >(*this);
00268 }
00269
00270 public:
00271
00282 MutableVertexMesh(std::vector<Node<SPACE_DIM>*> nodes,
00283 std::vector<VertexElement<ELEMENT_DIM, SPACE_DIM>*> vertexElements,
00284 double cellRearrangementThreshold=0.01,
00285 double t2Threshold=0.001,
00286 double cellRearrangementRatio=1.5);
00287
00291 MutableVertexMesh();
00292
00296 virtual ~MutableVertexMesh();
00297
00303 void SetCellRearrangementThreshold(double cellRearrangementThreshold);
00304
00310 void SetT2Threshold(double t2Threshold);
00311
00317 void SetCellRearrangementRatio(double cellRearrangementRatio);
00318
00325 virtual void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM> point);
00326
00332 void SetCheckForInternalIntersections(bool checkForInternalIntersections);
00333
00337 double GetCellRearrangementThreshold() const;
00338
00342 double GetT2Threshold() const;
00343
00347 double GetCellRearrangementRatio() const;
00348
00352 unsigned GetNumNodes() const;
00353
00357 unsigned GetNumElements() const;
00358
00362 bool GetCheckForInternalIntersections() const;
00363
00367 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT1Swaps();
00368
00372 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT2Swaps();
00373
00377 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT3Swaps();
00378
00382 void ClearLocationsOfT1Swaps();
00383
00387 void ClearLocationsOfT2Swaps();
00388
00392 void ClearLocationsOfT3Swaps();
00393
00402 unsigned AddNode(Node<SPACE_DIM>* pNewNode);
00403
00411 void DeleteElementPriorToReMesh(unsigned index);
00412
00420 void DeleteNodePriorToReMesh(unsigned index);
00421
00430 unsigned DivideElementAlongShortAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00431 bool placeOriginalElementBelow=false);
00432
00446 unsigned DivideElementAlongGivenAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00447 c_vector<double, SPACE_DIM> axisOfDivision,
00448 bool placeOriginalElementBelow=false);
00449
00457 unsigned AddElement(VertexElement<ELEMENT_DIM, SPACE_DIM>* pNewElement);
00458
00471 bool CheckForT2Swaps(VertexElementMap& rElementMap);
00472
00476 void Clear();
00477
00484 void DivideEdge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00485
00494 void RemoveDeletedNodesAndElements(VertexElementMap& rElementMap);
00495
00499 void RemoveDeletedNodes();
00500
00513 virtual void ReMesh(VertexElementMap& rElementMap);
00514
00521 void ReMesh();
00522 };
00523
00524 #include "SerializationExportWrapper.hpp"
00525 EXPORT_TEMPLATE_CLASS_ALL_DIMS(MutableVertexMesh)
00526
00527 #endif