MutableVertexMesh.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 #ifndef MUTABLEVERTEXMESH_HPP_
00029 #define MUTABLEVERTEXMESH_HPP_
00030 
00031 // Forward declaration prevents circular include chain
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 
00141 
00153     void IdentifySwapType(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, VertexElementMap& rElementMap);
00154 
00162     void PerformNodeMerge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00163 
00173     void PerformT1Swap(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, std::set<unsigned>& rElementsContainingNodes);
00174 
00182     void PerformT2Swap(VertexElement<ELEMENT_DIM,SPACE_DIM>& rElement);
00183 
00192     void PerformT3Swap(Node<SPACE_DIM>* pNode, unsigned elementIndex);
00193 
00202     void PerformVoidRemoval(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB, Node<SPACE_DIM>* pNodeC);
00203 
00205     friend class boost::serialization::access;
00206 
00217     template<class Archive>
00218     void serialize(Archive & archive, const unsigned int version)
00219     {
00220         // NOTE - Subclasses must archive their member variables BEFORE calling this method.
00221         archive & mCellRearrangementThreshold;
00222         archive & mCellRearrangementRatio;
00223         archive & mT2Threshold;
00224         archive & mDeletedNodeIndices;
00225         archive & mDeletedElementIndices;
00226 //        archive & mLocationsOfT1Swaps;
00227 //        archive & mLocationsOfT3Swaps;
00228 
00229         archive & boost::serialization::base_object<VertexMesh<ELEMENT_DIM, SPACE_DIM> >(*this);
00230     }
00231 
00232 
00233 public:
00234 
00236     //                             Methods                              //
00238 
00249     MutableVertexMesh(std::vector<Node<SPACE_DIM>*> nodes,
00250                       std::vector<VertexElement<ELEMENT_DIM, SPACE_DIM>*> vertexElements,
00251                       double cellRearrangementThreshold=0.01,
00252                       double t2Threshold=0.001,
00253                       double cellRearrangementRatio=1.5);
00254 
00258     MutableVertexMesh();
00259 
00263     virtual ~MutableVertexMesh();
00264 
00270     void SetCellRearrangementThreshold(double cellRearrangementThreshold);
00271 
00277     void SetT2Threshold(double t2Threshold);
00278 
00284     void SetCellRearrangementRatio(double cellRearrangementRatio);
00285 
00292     virtual void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM> point);
00293 
00297     double GetCellRearrangementThreshold() const;
00298 
00302     double GetT2Threshold() const;
00303 
00307     double GetCellRearrangementRatio() const;
00308 
00312     unsigned GetNumNodes() const;
00313 
00317     unsigned GetNumElements() const;
00318 
00322     std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT1Swaps();
00323 
00327     std::vector< c_vector<double, SPACE_DIM> > GetLocationsOfT3Swaps();
00328 
00332     void ClearLocationsOfT1Swaps();
00333 
00337     void ClearLocationsOfT3Swaps();
00338 
00339 
00348     unsigned AddNode(Node<SPACE_DIM>* pNewNode);
00349 
00357     void DeleteElementPriorToReMesh(unsigned index);
00358 
00369     unsigned DivideElementAlongShortAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00370                                          bool placeOriginalElementBelow=false);
00371 
00387     unsigned DivideElementAlongGivenAxis(VertexElement<ELEMENT_DIM,SPACE_DIM>* pElement,
00388                                          c_vector<double, SPACE_DIM> axisOfDivision,
00389                                          bool placeOriginalElementBelow=false);
00390 
00398     unsigned AddElement(VertexElement<ELEMENT_DIM, SPACE_DIM>* pNewElement);
00399 
00403     void Clear();
00404 
00411     void DivideEdge(Node<SPACE_DIM>* pNodeA, Node<SPACE_DIM>* pNodeB);
00412 
00421     void RemoveDeletedNodesAndElements(VertexElementMap& rElementMap);
00422 
00426     void RemoveDeletedNodes();
00427 
00435     void ReMesh(VertexElementMap& rElementMap);
00436 
00441     void ReMesh();
00442 };
00443 
00444 #include "SerializationExportWrapper.hpp"
00445 EXPORT_TEMPLATE_CLASS_ALL_DIMS(MutableVertexMesh);
00446 
00447 #endif /*MUTABLEVERTEXMESH_HPP_*/

Generated on Mon Nov 1 12:35:23 2010 for Chaste by  doxygen 1.5.5