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>
325 else if ( owning_process == 0 )
334 template<
unsigned SPACE_DIM>
340 template<
unsigned SPACE_DIM>
346 template<
unsigned SPACE_DIM>
352 template<
unsigned SPACE_DIM>
358 template<
unsigned SPACE_DIM>
361 unsigned location_in_nodes_vector = 0;
365 this->
mNodes.push_back(pNewNode);
366 location_in_nodes_vector = this->
mNodes.size() - 1;
372 delete this->
mNodes[location_in_nodes_vector];
373 this->
mNodes[location_in_nodes_vector] = pNewNode;
387 template<
unsigned SPACE_DIM>
394 template<
unsigned SPACE_DIM>
402 template<
unsigned SPACE_DIM>
406 pNewNode->
SetIndex(fresh_global_index);
410 return fresh_global_index;
413 template<
unsigned SPACE_DIM>
417 assert(!concreteMove);
420 this->
GetNode(nodeIndex)->SetPoint(point);
423 template<
unsigned SPACE_DIM>
427 unsigned index = pMovedNode->GetIndex();
428 c_vector<double, SPACE_DIM> location = pMovedNode->rGetLocation();
432 if (pMovedNode->HasNodeAttributes())
437 unsigned region = pMovedNode->GetRegion();
440 bool is_particle = pMovedNode->IsParticle();
443 for (
unsigned i=0; i<pMovedNode->GetNumNodeAttributes(); i++)
445 double attribute = pMovedNode->rGetNodeAttributes()[i];
453 template<
unsigned SPACE_DIM>
456 if (this->
GetNode(index)->IsDeleted())
458 EXCEPTION(
"Trying to delete a deleted node");
463 this->
mNodes[local_index]->MarkAsDeleted();
468 template<
unsigned SPACE_DIM>
477 template<
unsigned SPACE_DIM>
480 assert(!(separation < 0.0));
485 template<
unsigned SPACE_DIM>
505 template<
unsigned SPACE_DIM>
514 c_vector<double, 2*SPACE_DIM> new_domain_size = current_domain_size;
516 double fudge = 1e-14;
518 for (
unsigned d=0; d < SPACE_DIM; d++)
521 if ( !is_periodic(d) )
530 template<
unsigned SPACE_DIM>
535 int is_local_node_close = 0;
543 c_vector<double, SPACE_DIM> location;
544 location = node_iter->rGetLocation();
547 for (
unsigned d=0; d<SPACE_DIM; d++)
549 if ( !is_periodic(d) &&
552 is_local_node_close = 1;
556 if (is_local_node_close)
563 int is_any_node_close = 0;
564 MPI_Allreduce(&is_local_node_close, &is_any_node_close, 1, MPI_INT, MPI_SUM,
PetscTools::GetWorld());
566 return (is_any_node_close > 0);
569 template<
unsigned SPACE_DIM>
579 template<
unsigned SPACE_DIM>
585 template<
unsigned SPACE_DIM>
592 c_vector<double, 2*SPACE_DIM> domain_size;
593 for (
unsigned i=0; i < SPACE_DIM; i++)
601 template<
unsigned SPACE_DIM>
606 bool isPeriodicInX =
false;
607 bool isPeriodicInY =
false;
608 bool isPeriodicInZ =
false;
610 for (
unsigned i=0; i<SPACE_DIM; i++ )
614 isPeriodicInX = isDimPeriodic(i);
618 isPeriodicInY = isDimPeriodic(i);
622 isPeriodicInZ = isDimPeriodic(i);
630 template<
unsigned SPACE_DIM>
643 template<
unsigned SPACE_DIM>
656 template<
unsigned SPACE_DIM>
669 template<
unsigned SPACE_DIM>
683 template<
unsigned SPACE_DIM>
689 template<
unsigned SPACE_DIM>
699 double fudge = 1e-14;
700 for (
unsigned d=0; d < SPACE_DIM; d++)
702 current_domain_size[2*d] = current_domain_size[2*d] + fudge;
703 current_domain_size[2*d+1] = current_domain_size[2*d+1] - fudge;
708 template<
unsigned SPACE_DIM>
714 for (
unsigned i=0; i<this->
mNodes.size(); i++)
720 template<
unsigned SPACE_DIM>
724 unsigned live_index=0;
725 for (
unsigned i=0; i<this->
mNodes.size(); i++)
728 if (!this->
mNodes[i]->IsDeleted())
730 indices[live_index] = this->
mNodes[i]->GetIndex();
std::vector< unsigned > & rGetHaloNodesRight()
bool IsANodeCloseToDomainBoundary()
unsigned CalculateContainingBox(Node< DIM > *pNode)
bool mCalculateNodeNeighbours
std::vector< unsigned > & rGetNodesToSendLeft()
virtual unsigned GetMaximumNodeIndex()
std::vector< unsigned > & rGetHaloNodesToSendLeft()
void EnlargeBoxCollection()
void SetNode(unsigned nodeIndex, ChastePoint< SPACE_DIM > point, bool concreteMove=false)
void CalculateBoundaryNodePairs(std::vector< Node< DIM > *> &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > *> > &rNodePairs)
void AddNodeAttribute(double attribute)
void SetRadius(double radius)
const ChastePoint< SPACE_DIM > & rGetUpperCorner() const
c_vector< double, 2 *DIM > rGetDomainSize() const
virtual ChasteCuboid< SPACE_DIM > CalculateBoundingBox() const
std::vector< bool > & rGetInitiallyOwnedNodes()
#define EXCEPTION(message)
double mMaximumInteractionDistance
void SetCalculateNodeNeighbours(bool calculateNodeNeighbours)
unsigned GetNumNodes() 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)
void SetIndex(unsigned index)
unsigned GetIndex() const
Node< SPACE_DIM > * GetNodeOrHaloNode(unsigned index) const
unsigned GetNumLocalRows() const
std::vector< double > & rGetNodeAttributes()
void SetUpBoxCollection(const std::vector< Node< SPACE_DIM > * > &rNodes)
Node< SPACE_DIM > * GetNode(unsigned index) const
unsigned GetProcessOwningNode(Node< DIM > *pNode)
void SetupLocalBoxesHalfOnly()
std::vector< unsigned > & rGetHaloNodesToSendRight()
std::vector< unsigned > mDeletedNodeIndices
virtual double GetWidth(const unsigned &rDimension) 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)
void SetIsParticle(bool isParticle)
double GetMaximumInteractionDistance()
unsigned SolveNodeMapping(unsigned index) const
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)
void SetInitialBoxCollection(const c_vector< double, 2 *SPACE_DIM > domainSize, double maxInteractionDistance)
DistributedBoxCollection< SPACE_DIM > * mpBoxCollection
bool GetIsPeriodicAcrossProcs() const
void SetMaximumInteractionDistance(double maxDistance)
NodeIterator GetNodeIteratorBegin(bool skipDeletedNodes=true)
void UpdateBoxCollection()
int LoadBalance(std::vector< int > localDistribution)
void CalculateInteriorNodePairs(std::vector< Node< DIM > *> &rNodes, std::vector< std::pair< Node< DIM > *, Node< DIM > *> > &rNodePairs)
void AddHaloNode(boost::shared_ptr< Node< SPACE_DIM > > pNewNode)
void CalculateNodesOutsideLocalDomain()
std::vector< unsigned > mNodesToSendLeft
void SetRegion(unsigned region)
void SetMeshHasChangedSinceLoading()
void SetMinimumNodeDomainBoundarySeparation(double separation)
unsigned AddNode(Node< SPACE_DIM > *pNewNode)
DistributedBoxCollection< SPACE_DIM > * GetBoxCollection()
bool GetIsPeriodicAcrossProcsFromBoxCollection() const
std::vector< unsigned > & rGetNodesToSendRight()
unsigned mMaxAddedNodeIndex
std::vector< unsigned > GetAllNodeIndices() const
std::vector< boost::shared_ptr< Node< SPACE_DIM > > > mHaloNodes
std::vector< bool > mLocalInitialNodes
double mMinimumNodeDomainBoundarySeparation
std::vector< unsigned > mDeletedGlobalNodeIndices
Box< DIM > & rGetHaloBox(unsigned boxIndex)
std::map< unsigned, unsigned > mNodesMapping
bool IsOwned(c_vector< double, SPACE_DIM > &location)
void ClearBoxCollection()
const ChastePoint< SPACE_DIM > & rGetLowerCorner() const
void ConstructNodesWithoutMesh(const std::vector< Node< SPACE_DIM > *> &rNodes, double maxInteractionDistance)
void AddMovedNode(boost::shared_ptr< Node< SPACE_DIM > > pMovedNode)
Box< DIM > & rGetBox(unsigned boxIndex)
std::map< unsigned, unsigned > mHaloNodesMapping
c_vector< bool, DIM > GetIsPeriodicAllDims() const
void CalculateBoundaryNodePairs(std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > *> > &rNodePairs)
double GetWidth(const unsigned &rDimension) const
std::vector< unsigned > mNodesToSendRight