NodesOnlyMesh.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
00036 #ifndef NODESONLYMESH_HPP_
00037 #define NODESONLYMESH_HPP_
00038
00039 #include "ChasteSerialization.hpp"
00040 #include <boost/serialization/base_object.hpp>
00041 #include <boost/serialization/map.hpp>
00042
00043 #include "PetscTools.hpp"
00044 #include "DistributedBoxCollection.hpp"
00045 #include "MutableMesh.hpp"
00046
00051 template<unsigned SPACE_DIM>
00052 class NodesOnlyMesh: public MutableMesh<SPACE_DIM, SPACE_DIM>
00053 {
00054 private:
00055
00056 friend class TestNodesOnlyMesh;
00057
00059 friend class boost::serialization::access;
00060
00072 template<class Archive>
00073 void serialize(Archive & archive, const unsigned int version)
00074 {
00075 archive & mMaximumInteractionDistance;
00076 archive & mMinimumNodeDomainBoundarySeparation;
00077 archive & boost::serialization::base_object<MutableMesh<SPACE_DIM, SPACE_DIM> >(*this);
00078 }
00079
00081 std::vector<boost::shared_ptr<Node<SPACE_DIM> > > mHaloNodes;
00082
00084 double mMaximumInteractionDistance;
00085
00087 std::map<unsigned, unsigned> mNodesMapping;
00088
00090 std::map<unsigned, unsigned> mHaloNodesMapping;
00091
00093 unsigned mIndexCounter;
00094
00096 double mMinimumNodeDomainBoundarySeparation;
00097
00099 std::vector<unsigned> mDeletedGlobalNodeIndices;
00100
00102 std::vector<unsigned> mNodesToSendRight;
00103
00105 std::vector<unsigned> mNodesToSendLeft;
00106
00109 std::vector<bool> mLocalInitialNodes;
00110
00113 unsigned mMaxAddedNodeIndex;
00114
00116 DistributedBoxCollection<SPACE_DIM>* mpBoxCollection;
00117
00119 bool mCalculateNodeNeighbours;
00120
00141 unsigned GetNextAvailableIndex();
00142
00144 void EnlargeBoxCollection();
00145
00149 bool IsANodeCloseToDomainBoundary();
00150
00156 void SetUpBoxCollection(const std::vector<Node<SPACE_DIM>* >& rNodes);
00157
00163 void RemoveDeletedNodes(NodeMap& map);
00164
00166 void UpdateNodeIndices();
00167
00173 void AddNodeWithFixedIndex(Node<SPACE_DIM>* pNewNode);
00174
00175 protected:
00176
00178 void ClearBoxCollection();
00179
00188 virtual void SetUpBoxCollection(double cutOffLength, c_vector<double, 2*SPACE_DIM> domainSize, int numLocalRows = PETSC_DECIDE, bool isPeriodic = false);
00189
00191 DistributedBoxCollection<SPACE_DIM>* GetBoxCollection();
00192
00193 public:
00194
00196 NodesOnlyMesh();
00197
00199 virtual ~NodesOnlyMesh();
00200
00212 void ConstructNodesWithoutMesh(const std::vector<Node<SPACE_DIM>*>& rNodes, double maxInteractionDistance);
00213
00221 void ConstructNodesWithoutMesh(const AbstractMesh<SPACE_DIM,SPACE_DIM>& rGeneratingMesh, double maxInteractionDistance);
00222
00224 std::vector<bool>& rGetInitiallyOwnedNodes();
00225
00227 void Clear();
00228
00236 unsigned SolveNodeMapping(unsigned index) const;
00237
00245 Node<SPACE_DIM>* GetNodeOrHaloNode(unsigned index) const;
00246
00252 bool IsOwned(c_vector<double, SPACE_DIM>& location);
00253
00258 unsigned GetNumNodes() const;
00259
00265 virtual unsigned GetMaximumNodeIndex();
00266
00272 void SetMaximumInteractionDistance(double maxDistance);
00273
00277 double GetMaximumInteractionDistance();
00278
00285 double GetWidth(const unsigned& rDimension) const;
00286
00292 void SetCalculateNodeNeighbours(bool calculateNodeNeighbours);
00293
00300 void CalculateInteriorNodePairs(std::vector<std::pair<Node<SPACE_DIM>*, Node<SPACE_DIM>*> >& rNodePairs, std::map<unsigned, std::set<unsigned> >& rNodeNeighbours);
00301
00308 void CalculateBoundaryNodePairs(std::vector<std::pair<Node<SPACE_DIM>*, Node<SPACE_DIM>*> >& rNodePairs, std::map<unsigned, std::set<unsigned> >& rNodeNeighbours);
00309
00317 void ReMesh(NodeMap& rMap);
00318
00324 void SetInitialBoxCollection(const c_vector<double, 2*SPACE_DIM> domainSize, double maxInteractionDistance);
00325
00329 void UpdateBoxCollection();
00330
00335 void ResizeBoxCollection();
00336
00340 void AddNodesToBoxes();
00341
00345 void AddHaloNodesToBoxes();
00346
00350 void CalculateNodesOutsideLocalDomain();
00351
00355 std::vector<unsigned>& rGetNodesToSendLeft();
00356
00360 std::vector<unsigned>& rGetNodesToSendRight();
00361
00365 std::vector<unsigned>& rGetHaloNodesToSendRight();
00366
00370 std::vector<unsigned>& rGetHaloNodesToSendLeft();
00371
00376 void AddHaloNode(boost::shared_ptr<Node<SPACE_DIM> > pNewNode);
00377
00381 void ClearHaloNodes();
00382
00389 unsigned AddNode(Node<SPACE_DIM>* pNewNode);
00390
00395 void AddMovedNode(boost::shared_ptr<Node<SPACE_DIM> > pMovedNode);
00396
00402 void DeleteNode(unsigned index);
00403
00409 void DeleteMovedNode(unsigned index);
00410
00416 void SetMinimumNodeDomainBoundarySeparation(double separation);
00417
00422 void LoadBalanceMesh();
00423
00429 void ConstructFromMeshReader(AbstractMeshReader<SPACE_DIM, SPACE_DIM>& rMeshReader);
00430 };
00431
00432 #include "SerializationExportWrapper.hpp"
00433 EXPORT_TEMPLATE_CLASS_SAME_DIMS(NodesOnlyMesh)
00434
00435 #endif