37 #include "NodesOnlyMesh.hpp" 38 #include "ChasteCuboid.hpp" 40 template<
unsigned SPACE_DIM>
43 mMaximumInteractionDistance(1.0),
45 mMinimumNodeDomainBoundarySeparation(1.0),
46 mMaxAddedNodeIndex(0u),
47 mpBoxCollection(nullptr),
48 mCalculateNodeNeighbours(true)
52 template<
unsigned SPACE_DIM>
59 template<
unsigned SPACE_DIM>
62 assert(maxInteractionDistance > 0.0 && maxInteractionDistance < DBL_MAX);
73 for (
unsigned i=0; i<rNodes.size(); i++)
77 assert(!rNodes[i]->IsDeleted());
82 c_vector<double, SPACE_DIM> location = rNodes[i]->rGetLocation();
88 if (rNodes[i]->HasNodeAttributes())
93 this->
mNodes.push_back(p_node_copy);
101 template<
unsigned SPACE_DIM>
105 std::vector<Node<SPACE_DIM>*> temp_nodes(rNodes.size());
106 for(
unsigned idx=0; idx<rNodes.size(); idx++)
108 temp_nodes[idx] = rNodes[idx].get();
114 template<
unsigned SPACE_DIM>
120 template<
unsigned SPACE_DIM>
126 template<
unsigned SPACE_DIM>
129 std::map<unsigned, unsigned>::const_iterator node_position =
mNodesMapping.find(index);
136 return node_position->second;
139 template<
unsigned SPACE_DIM>
151 template<
unsigned SPACE_DIM>
157 template <
unsigned SPACE_DIM>
162 std::map<unsigned, unsigned>::const_iterator node_position =
mHaloNodesMapping.find(index);
166 p_node =
mHaloNodes[node_position->second].get();
173 assert(p_node !=
nullptr);
178 template<
unsigned SPACE_DIM>
184 template<
unsigned SPACE_DIM>
190 template<
unsigned SPACE_DIM>
196 template<
unsigned SPACE_DIM>
202 template<
unsigned SPACE_DIM>
208 template<
unsigned SPACE_DIM>
219 template<
unsigned SPACE_DIM>
225 template<
unsigned SPACE_DIM>
233 template<
unsigned SPACE_DIM>
241 template<
unsigned SPACE_DIM>
256 template<
unsigned SPACE_DIM>
259 typename std::vector<Node<SPACE_DIM>* >::iterator node_iter = this->
mNodes.begin();
260 while (node_iter != this->
mNodes.end())
262 if ((*node_iter)->IsDeleted())
270 node_iter = this->
mNodes.erase(node_iter);
279 template<
unsigned SPACE_DIM>
283 for (
unsigned location_in_vector=0; location_in_vector < this->
mNodes.size(); location_in_vector++)
285 unsigned global_index = this->
mNodes[location_in_vector]->GetIndex();
290 template<
unsigned SPACE_DIM>
316 template<
unsigned SPACE_DIM>
322 template<
unsigned SPACE_DIM>
328 template<
unsigned SPACE_DIM>
334 template<
unsigned SPACE_DIM>
340 template<
unsigned SPACE_DIM>
343 unsigned location_in_nodes_vector = 0;
347 this->
mNodes.push_back(pNewNode);
348 location_in_nodes_vector = this->
mNodes.size() - 1;
354 delete this->
mNodes[location_in_nodes_vector];
355 this->
mNodes[location_in_nodes_vector] = pNewNode;
369 template<
unsigned SPACE_DIM>
376 template<
unsigned SPACE_DIM>
384 template<
unsigned SPACE_DIM>
388 pNewNode->
SetIndex(fresh_global_index);
392 return fresh_global_index;
395 template<
unsigned SPACE_DIM>
399 assert(!concreteMove);
402 this->
GetNode(nodeIndex)->SetPoint(point);
405 template<
unsigned SPACE_DIM>
409 unsigned index = pMovedNode->GetIndex();
410 c_vector<double, SPACE_DIM> location = pMovedNode->rGetLocation();
414 if (pMovedNode->HasNodeAttributes())
419 unsigned region = pMovedNode->GetRegion();
422 bool is_particle = pMovedNode->IsParticle();
425 for (
unsigned i=0; i<pMovedNode->GetNumNodeAttributes(); i++)
427 double attribute = pMovedNode->rGetNodeAttributes()[i];
435 template<
unsigned SPACE_DIM>
438 if (this->
GetNode(index)->IsDeleted())
440 EXCEPTION(
"Trying to delete a deleted node");
445 this->
mNodes[local_index]->MarkAsDeleted();
450 template<
unsigned SPACE_DIM>
459 template<
unsigned SPACE_DIM>
462 assert(!(separation < 0.0));
467 template<
unsigned SPACE_DIM>
487 template<
unsigned SPACE_DIM>
496 c_vector<double, 2*SPACE_DIM> new_domain_size = current_domain_size;
498 double fudge = 1e-14;
501 for (
unsigned d=d0; d < SPACE_DIM; d++)
509 template<
unsigned SPACE_DIM>
514 int is_local_node_close = 0;
525 c_vector<double, SPACE_DIM> location;
526 location = node_iter->rGetLocation();
528 for (
unsigned d=d0; d<SPACE_DIM; d++)
532 is_local_node_close = 1;
536 if (is_local_node_close)
543 int is_any_node_close = 0;
544 MPI_Allreduce(&is_local_node_close, &is_any_node_close, 1, MPI_INT, MPI_SUM,
PetscTools::GetWorld());
546 return (is_any_node_close > 0);
549 template<
unsigned SPACE_DIM>
559 template<
unsigned SPACE_DIM>
565 template<
unsigned SPACE_DIM>
572 c_vector<double, 2*SPACE_DIM> domain_size;
573 for (
unsigned i=0; i < SPACE_DIM; i++)
582 template<
unsigned SPACE_DIM>
592 template<
unsigned SPACE_DIM>
605 template<
unsigned SPACE_DIM>
618 template<
unsigned SPACE_DIM>
631 template<
unsigned SPACE_DIM>
645 template<
unsigned SPACE_DIM>
655 double fudge = 1e-14;
656 for (
unsigned d=0; d < SPACE_DIM; d++)
658 current_domain_size[2*d] = current_domain_size[2*d] + fudge;
659 current_domain_size[2*d+1] = current_domain_size[2*d+1] - fudge;
664 template<
unsigned SPACE_DIM>
670 for (
unsigned i=0; i<this->
mNodes.size(); i++)
676 template<
unsigned SPACE_DIM>
680 unsigned live_index=0;
681 for (
unsigned i=0; i<this->
mNodes.size(); i++)
684 if (!this->
mNodes[i]->IsDeleted())
686 indices[live_index] = this->
mNodes[i]->GetIndex();
std::vector< unsigned > & rGetHaloNodesRight()
bool IsANodeCloseToDomainBoundary()
unsigned CalculateContainingBox(Node< DIM > *pNode)
bool mCalculateNodeNeighbours
void CalculateInteriorNodePairs(std::vector< Node< DIM > * > &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs)
std::vector< unsigned > & rGetNodesToSendLeft()
virtual unsigned GetMaximumNodeIndex()
std::vector< unsigned > & rGetHaloNodesToSendLeft()
void EnlargeBoxCollection()
void SetNode(unsigned nodeIndex, ChastePoint< SPACE_DIM > point, bool concreteMove=false)
c_vector< double, 2 *DIM > rGetDomainSize() const
void AddNodeAttribute(double attribute)
void SetRadius(double radius)
Node< SPACE_DIM > * GetNode(unsigned index) const
std::vector< bool > & rGetInitiallyOwnedNodes()
#define EXCEPTION(message)
Node< SPACE_DIM > * GetNodeOrHaloNode(unsigned index) const
double mMaximumInteractionDistance
void SetCalculateNodeNeighbours(bool calculateNodeNeighbours)
void CalculateBoundaryNodePairs(std::vector< Node< DIM > * > &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs)
std::vector< unsigned > GetAllNodeIndices() const
void ConstructFromMeshReader(AbstractMeshReader< SPACE_DIM, SPACE_DIM > &rMeshReader)
NodeIterator GetNodeIteratorEnd()
void ConstructFromMeshReader(AbstractMeshReader< ELEMENT_DIM, SPACE_DIM > &rMeshReader)
std::vector< int > CalculateNumberOfNodesInEachStrip()
void AddNodeWithFixedIndex(Node< SPACE_DIM > *pNewNode)
virtual ChasteCuboid< SPACE_DIM > CalculateBoundingBox() const
void SetIndex(unsigned index)
std::vector< double > & rGetNodeAttributes()
void SetUpBoxCollection(const std::vector< Node< SPACE_DIM > * > &rNodes)
unsigned GetProcessOwningNode(Node< DIM > *pNode)
bool GetIsPeriodicInX() const
unsigned GetNumLocalRows() const
void SetupLocalBoxesHalfOnly()
std::vector< unsigned > & rGetHaloNodesToSendRight()
std::vector< unsigned > mDeletedNodeIndices
const ChastePoint< SPACE_DIM > & rGetUpperCorner() const
void SetCalculateNodeNeighbours(bool calculateNodeNeighbours)
void AddHaloNodesToBoxes()
void CalculateInteriorNodePairs(std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > * > > &rNodePairs)
std::vector< Node< SPACE_DIM > * > mNodes
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
void DeleteNode(unsigned index)
double GetWidth(const unsigned &rDimension) const
void SetIsParticle(bool isParticle)
double GetMaximumInteractionDistance()
void DeleteMovedNode(unsigned index)
std::vector< unsigned > & rGetHaloNodesLeft()
unsigned GetNextAvailableIndex()
void RemoveDeletedNodes(NodeMap &map)
void ResizeBoxCollection()
void SetDeleted(unsigned index)
bool IsOwned(Node< DIM > *pNode)
unsigned SolveNodeMapping(unsigned index) const
void SetInitialBoxCollection(const c_vector< double, 2 *SPACE_DIM > domainSize, double maxInteractionDistance)
DistributedBoxCollection< SPACE_DIM > * mpBoxCollection
void SetMaximumInteractionDistance(double maxDistance)
NodeIterator GetNodeIteratorBegin(bool skipDeletedNodes=true)
void UpdateBoxCollection()
int LoadBalance(std::vector< int > localDistribution)
void AddHaloNode(boost::shared_ptr< Node< SPACE_DIM > > pNewNode)
void CalculateNodesOutsideLocalDomain()
std::vector< unsigned > mNodesToSendLeft
void ConstructNodesWithoutMesh(const std::vector< Node< SPACE_DIM > * > &rNodes, double maxInteractionDistance)
void SetRegion(unsigned region)
void SetMeshHasChangedSinceLoading()
void SetMinimumNodeDomainBoundarySeparation(double separation)
unsigned AddNode(Node< SPACE_DIM > *pNewNode)
DistributedBoxCollection< SPACE_DIM > * GetBoxCollection()
std::vector< unsigned > & rGetNodesToSendRight()
unsigned mMaxAddedNodeIndex
std::vector< boost::shared_ptr< Node< SPACE_DIM > > > mHaloNodes
std::vector< bool > mLocalInitialNodes
virtual double GetWidth(const unsigned &rDimension) const
double mMinimumNodeDomainBoundarySeparation
std::vector< unsigned > mDeletedGlobalNodeIndices
void CalculateBoundaryNodePairs(std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > * > > &rNodePairs)
Box< DIM > & rGetHaloBox(unsigned boxIndex)
std::map< unsigned, unsigned > mNodesMapping
bool IsOwned(c_vector< double, SPACE_DIM > &location)
void ClearBoxCollection()
unsigned GetIndex() const
void AddMovedNode(boost::shared_ptr< Node< SPACE_DIM > > pMovedNode)
Box< DIM > & rGetBox(unsigned boxIndex)
std::map< unsigned, unsigned > mHaloNodesMapping
unsigned GetNumNodes() const
std::vector< unsigned > mNodesToSendRight
const ChastePoint< SPACE_DIM > & rGetLowerCorner() const