Chaste Release::3.1
|
00001 /* 00002 00003 Copyright (c) 2005-2012, University of Oxford. 00004 All rights reserved. 00005 00006 University of Oxford means the Chancellor, Masters and Scholars of the 00007 University of Oxford, having an administrative office at Wellington 00008 Square, Oxford OX1 2JD, UK. 00009 00010 This file is part of Chaste. 00011 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions are met: 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright notice, 00017 this list of conditions and the following disclaimer in the documentation 00018 and/or other materials provided with the distribution. 00019 * Neither the name of the University of Oxford nor the names of its 00020 contributors may be used to endorse or promote products derived from this 00021 software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 */ 00035 #ifndef MUTABLEVERTEXMESH_HPP_ 00036 #define MUTABLEVERTEXMESH_HPP_ 00037 00038 // Forward declaration prevents circular include chain 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 00056 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM> 00057 class MutableVertexMesh : public VertexMesh<ELEMENT_DIM, SPACE_DIM> 00058 { 00059 friend class TestMutableVertexMesh; 00060 friend class TestMutableVertexMeshReMesh; 00061 00062 protected: 00063 00065 double mCellRearrangementThreshold; 00066 00071 double mCellRearrangementRatio; 00072 00074 double mT2Threshold; 00075 00077 bool mCheckForInternalIntersections; 00078 00080 std::vector<unsigned> mDeletedNodeIndices; 00081 00083 std::vector<unsigned> mDeletedElementIndices; 00084 00089 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT1Swaps; 00090 00095 std::vector< c_vector<double, SPACE_DIM> > mLocationsOfT3Swaps; 00096 00109 unsigned DivideElement(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement, 00110 unsigned nodeAIndex, 00111 unsigned nodeBIndex, 00112 bool placeOriginalElementBelow=false); 00113 00125 bool CheckForT1Swaps(VertexElementMap& rElementMap); 00126 00139 bool CheckForT2Swaps(VertexElementMap& rElementMap); 00140 00148 bool CheckForIntersections(); 00149 00161 void IdentifySwapType(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, VertexElementMap& rElementMap); 00162 00170 void PerformNodeMerge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB); 00171 00181 void PerformT1Swap(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, std::set<unsigned>& rElementsContainingNodes); 00182 00191 void PerformIntersectionSwap(Node<SPACE_DIM>* pNode, unsigned elementIndex); 00192 00200 void PerformT2Swap(VertexElement<ELEMENT_DIM,SPACE_DIM>& rElement); 00201 00210 void PerformT3Swap(Node<SPACE_DIM>* pNode, unsigned elementIndex); 00211 00220 void PerformVoidRemoval(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, Node<SPACE_DIM>* pNodeC); 00221 00223 friend class boost::serialization::access; 00224 00235 template<class Archive> 00236 void serialize(Archive & archive, const unsigned int version) 00237 { 00238 // NOTE - Subclasses must archive their member variables BEFORE calling this method. 00239 archive & mCellRearrangementThreshold; 00240 archive & mCellRearrangementRatio; 00241 archive & mT2Threshold; 00242 archive & mCheckForInternalIntersections; 00243 archive & mDeletedNodeIndices; 00244 archive & mDeletedElementIndices; 00245 // archive & mLocationsOfT1Swaps; 00246 // archive & mLocationsOfT3Swaps; 00247 00248 archive & boost::serialization::base_object<VertexMesh<ELEMENT_DIM, SPACE_DIM> >(*this); 00249 } 00250 00251 public: 00252 00263 MutableVertexMesh(std::vector<Node<SPACE_DIM>*> nodes, 00264 std::vector<VertexElement<ELEMENT_DIM, SPACE_DIM>*> vertexElements, 00265 double cellRearrangementThreshold=0.01, 00266 double t2Threshold=0.001, 00267 double cellRearrangementRatio=1.5); 00268 00272 MutableVertexMesh(); 00273 00277 virtual ~MutableVertexMesh(); 00278 00284 void SetCellRearrangementThreshold(double cellRearrangementThreshold); 00285 00291 void SetT2Threshold(double t2Threshold); 00292 00298 void SetCellRearrangementRatio(double cellRearrangementRatio); 00299 00306 virtual void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM> point); 00307 00313 void SetCheckForInternalIntersections(bool checkForInternalIntersections); 00314 00318 double GetCellRearrangementThreshold() const; 00319 00323 double GetT2Threshold() const; 00324 00328 double GetCellRearrangementRatio() const; 00329 00333 unsigned GetNumNodes() const; 00334 00338 unsigned GetNumElements() const; 00339 00343 bool GetCheckForInternalIntersections() const; 00344 00348 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT1Swaps(); 00349 00353 std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT3Swaps(); 00354 00358 void ClearLocationsOfT1Swaps(); 00359 00363 void ClearLocationsOfT3Swaps(); 00364 00365 00374 unsigned AddNode(Node<SPACE_DIM>* pNewNode); 00375 00383 void DeleteElementPriorToReMesh(unsigned index); 00384 00392 void DeleteNodePriorToReMesh(unsigned index); 00393 00404 unsigned DivideElementAlongShortAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement, 00405 bool placeOriginalElementBelow=false); 00406 00422 unsigned DivideElementAlongGivenAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement, 00423 c_vector<double, SPACE_DIM> axisOfDivision, 00424 bool placeOriginalElementBelow=false); 00425 00433 unsigned AddElement(VertexElement<ELEMENT_DIM, SPACE_DIM>* pNewElement); 00434 00438 void Clear(); 00439 00446 void DivideEdge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB); 00447 00456 void RemoveDeletedNodesAndElements(VertexElementMap& rElementMap); 00457 00461 void RemoveDeletedNodes(); 00462 00470 void ReMesh(VertexElementMap& rElementMap); 00471 00476 void ReMesh(); 00477 }; 00478 00479 #include "SerializationExportWrapper.hpp" 00480 EXPORT_TEMPLATE_CLASS_ALL_DIMS(MutableVertexMesh); 00481 00482 #endif /*MUTABLEVERTEXMESH_HPP_*/