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 #include "ArchiveLocationInfo.hpp"
00046
00050 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00051 class MutableVertexMesh : public VertexMesh<ELEMENT_DIM, SPACE_DIM>
00052 {
00053 friend class TestMutableVertexMesh;
00054 friend class TestMutableVertexMeshReMesh;
00055
00056 protected:
00057
00059 double mCellRearrangementThreshold;
00060
00065 double mCellRearrangementRatio;
00066
00068 double mT2Threshold;
00069
00071 std::vector<unsigned> mDeletedNodeIndices;
00072
00074 std::vector<unsigned> mDeletedElementIndices;
00075
00080 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT1Swaps ;
00081
00086 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT3Swaps;
00087
00100 unsigned DivideElement(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00101 unsigned nodeAIndex,
00102 unsigned nodeBIndex,
00103 bool placeOriginalElementBelow=false);
00104
00116 bool CheckForT1Swaps(VertexElementMap& rElementMap);
00117
00130 bool CheckForT2Swaps(VertexElementMap& rElementMap);
00131
00139 bool CheckForIntersections();
00140
00152 void IdentifySwapType(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, VertexElementMap& rElementMap);
00153
00161 void PerformNodeMerge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00162
00172 void PerformT1Swap(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, std::set<unsigned>& rElementsContainingNodes);
00173
00181 void PerformT2Swap(VertexElement<ELEMENT_DIM,SPACE_DIM>& rElement);
00182
00191 void PerformT3Swap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
00192
00201 void PerformVoidRemoval(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, Node<SPACE_DIM>* pNodeC);
00202
00204 friend class boost::serialization::access;
00205
00216 template<class Archive>
00217 void serialize(Archive & archive, const unsigned int version)
00218 {
00219
00220 archive & mCellRearrangementThreshold;
00221 archive & mCellRearrangementRatio;
00222 archive & mT2Threshold;
00223 archive & mDeletedNodeIndices;
00224 archive & mDeletedElementIndices;
00225
00226
00227
00228 archive & boost::serialization::base_object<VertexMesh<ELEMENT_DIM, SPACE_DIM> >(*this);
00229 }
00230
00231 public:
00232
00243 MutableVertexMesh(std::vector<Node<SPACE_DIM>*> nodes,
00244 std::vector<VertexElement<ELEMENT_DIM, SPACE_DIM>*> vertexElements,
00245 double cellRearrangementThreshold=0.01,
00246 double t2Threshold=0.001,
00247 double cellRearrangementRatio=1.5);
00248
00252 MutableVertexMesh();
00253
00257 virtual ~MutableVertexMesh();
00258
00264 void SetCellRearrangementThreshold(double cellRearrangementThreshold);
00265
00271 void SetT2Threshold(double t2Threshold);
00272
00278 void SetCellRearrangementRatio(double cellRearrangementRatio);
00279
00286 virtual void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM> point);
00287
00291 double GetCellRearrangementThreshold() const;
00292
00296 double GetT2Threshold() const;
00297
00301 double GetCellRearrangementRatio() const;
00302
00306 unsigned GetNumNodes() const;
00307
00311 unsigned GetNumElements() const;
00312
00316 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT1Swaps();
00317
00321 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT3Swaps();
00322
00326 void ClearLocationsOfT1Swaps();
00327
00331 void ClearLocationsOfT3Swaps();
00332
00333
00342 unsigned AddNode(Node<SPACE_DIM>* pNewNode);
00343
00351 void DeleteElementPriorToReMesh(unsigned index);
00352
00360 void DeleteNodePriorToReMesh(unsigned index);
00361
00372 unsigned DivideElementAlongShortAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00373 bool placeOriginalElementBelow=false);
00374
00390 unsigned DivideElementAlongGivenAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00391 c_vector<double, SPACE_DIM> axisOfDivision,
00392 bool placeOriginalElementBelow=false);
00393
00401 unsigned AddElement(VertexElement<ELEMENT_DIM, SPACE_DIM>* pNewElement);
00402
00406 void Clear();
00407
00414 void DivideEdge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00415
00424 void RemoveDeletedNodesAndElements(VertexElementMap& rElementMap);
00425
00429 void RemoveDeletedNodes();
00430
00438 void ReMesh(VertexElementMap& rElementMap);
00439
00444 void ReMesh();
00445 };
00446
00447 #include "SerializationExportWrapper.hpp"
00448 EXPORT_TEMPLATE_CLASS_ALL_DIMS(MutableVertexMesh);
00449
00450 #endif