43 #include "Cylindrical2dMesh.hpp" 63 for (
unsigned index=0; index<nodes.size(); index++)
65 Node<2>* p_temp_node = nodes[index];
68 assert( 0 <= x && x < width);
69 mNodes.push_back(p_temp_node);
90 double half_way = 0.5*
mWidth;
105 c_vector<double, 2> location;
106 location = node_iter->rGetLocation();
107 unsigned this_node_index = node_iter->GetIndex();
108 double this_node_x_location = location[0];
111 assert(0.0 <= location[0]);
112 assert(location[0] <=
mWidth);
115 if (this_node_x_location < half_way)
128 c_vector<double, 2> location;
130 location[0] = location[0] +
mWidth;
140 c_vector<double, 2> location;
142 location[0] = location[0] -
mWidth;
163 double halo_node_separation =
mWidth/((
double)(num_halo_nodes));
164 double y_top_coordinate =
mTop + halo_node_separation;
165 double y_bottom_coordinate =
mBottom - halo_node_separation;
167 c_vector<double, 2> location;
168 for (
unsigned i=0; i<num_halo_nodes; i++)
170 double x_coordinate = 0.5*halo_node_separation + (
double)(i)*halo_node_separation;
173 location[0] = x_coordinate;
174 location[1] = y_top_coordinate;
178 location[1] = y_bottom_coordinate;
188 rMap.
Resize(old_num_all_nodes);
192 for (
unsigned i=0; i<old_num_all_nodes; i++)
194 if (
mNodes[i]->IsDeleted())
271 bool boundary_element_made =
false;
272 unsigned elem_index = 0;
274 while (elem_index<num_elements && !boundary_element_made)
279 boundary_element_made =
true;
280 std::vector<Node<2>*> nodes;
281 nodes.push_back(p_element->
GetNode(0));
282 nodes.push_back(p_element->
GetNode(1));
301 for (
unsigned i=0; i<rMap.
GetSize(); i++)
340 unsigned number_of_left_image_nodes = 0;
341 unsigned number_of_right_image_nodes = 0;
343 for (
unsigned i=0; i<3; i++)
345 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
349 number_of_left_image_nodes++;
353 number_of_right_image_nodes++;
358 if (number_of_right_image_nodes >= 1)
360 elem_iter->MarkAsDeleted();
365 if (number_of_left_image_nodes == 3)
367 elem_iter->MarkAsDeleted();
376 if (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2)
378 for (
unsigned i=0; i<3; i++)
380 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
384 elem_iter->ReplaceNode(
mNodes[this_node_index],
mNodes[it->second]);
399 unsigned number_of_image_nodes = 0;
400 for (
unsigned i=0; i<2; i++)
406 number_of_image_nodes++;
410 number_of_image_nodes++;
414 if (number_of_image_nodes == 2)
425 if (number_of_image_nodes == 1)
427 for (
unsigned i=0; i<2; i++)
477 c_vector<double, 2> vector = rLocation2 - rLocation1;
478 vector[0] = fmod(vector[0],
mWidth);
484 if (vector[0] > 0.5*
mWidth)
488 else if (vector[0] < -0.5*
mWidth)
516 assert(rDimension==0 || rDimension==1);
534 SetNode(node_index, new_node_point,
false);
563 unsigned elem_index = *left_iter;
571 c_vector<unsigned,3> original_element_node_indices;
572 c_vector<unsigned,3> corresponding_element_node_indices;
573 for (
unsigned i=0; i<3; i++)
584 unsigned corresponding_elem_index = *right_iter;
588 bool is_corresponding_node =
true;
590 for (
unsigned i=0; i<3; i++)
592 if ((corresponding_element_node_indices[i] != p_corresponding_element->
GetNodeGlobalIndex(0)) &&
593 (corresponding_element_node_indices[i] != p_corresponding_element->
GetNodeGlobalIndex(1)) &&
594 (corresponding_element_node_indices[i] != p_corresponding_element->
GetNodeGlobalIndex(2)) )
596 is_corresponding_node =
false;
601 if (is_corresponding_node)
604 temp_left_hand_side_elements.erase(elem_index);
605 temp_right_hand_side_elements.erase(corresponding_elem_index);
622 if (temp_left_hand_side_elements.empty() || temp_right_hand_side_elements.empty())
624 assert(temp_right_hand_side_elements.empty());
625 assert(temp_left_hand_side_elements.empty());
629 if (temp_right_hand_side_elements.size() == 2 && temp_left_hand_side_elements.size() == 2)
631 if (temp_right_hand_side_elements.size() == 2)
651 assert(rMainSideElements.size() == 2);
654 std::set<unsigned> main_four_nodes;
655 for (std::set<unsigned>::iterator left_iter = rMainSideElements.begin();
656 left_iter != rMainSideElements.end();
659 unsigned elem_index = *left_iter;
661 for (
unsigned i=0; i<3; i++)
664 main_four_nodes.insert(index);
667 assert(main_four_nodes.size() == 4);
669 std::set<unsigned> other_four_nodes;
670 for (std::set<unsigned>::iterator iter = main_four_nodes.begin();
671 iter != main_four_nodes.end();
676 assert(other_four_nodes.size() == 4);
682 std::vector<unsigned> corresponding_elements;
690 if (!(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(0))==other_four_nodes.end()) &&
691 !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(1))==other_four_nodes.end()) &&
692 !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(2))==other_four_nodes.end()) )
694 corresponding_elements.push_back(elem_iter->GetIndex());
695 elem_iter->MarkAsDeleted();
699 assert(corresponding_elements.size() == 2);
703 for (std::set<unsigned>::iterator iter = rMainSideElements.begin();
704 iter != rMainSideElements.end();
708 std::vector<Node<2>*> nodes;
711 for (
unsigned i=0; i<3; i++)
719 this->
mElements.push_back(p_new_element);
736 unsigned incidences_of_zero_left_image_nodes = 0;
737 unsigned incidences_of_zero_right_image_nodes = 0;
744 unsigned number_of_left_image_nodes = 0;
745 unsigned number_of_right_image_nodes = 0;
747 for (
unsigned i=0; i<3; i++)
749 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
753 number_of_left_image_nodes++;
757 number_of_right_image_nodes++;
761 if ((number_of_left_image_nodes == 0) && (number_of_right_image_nodes == 1 || number_of_right_image_nodes == 2) )
763 incidences_of_zero_left_image_nodes++;
765 if ((number_of_right_image_nodes == 0) && (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2) )
767 incidences_of_zero_right_image_nodes++;
781 if (number_of_right_image_nodes == 1 || number_of_right_image_nodes == 2)
787 if (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2)
806 unsigned corresponding_node_index = UINT_MAX;
833 std::vector<unsigned>::iterator left_im_iter = std::find(
mLeftImages.begin(),
mLeftImages.end(), nodeIndex);
843 assert(corresponding_node_index != UINT_MAX);
844 return corresponding_node_index;
std::vector< c_matrix< double, SPACE_DIM, ELEMENT_DIM > > mElementJacobians
ElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
std::vector< Element< ELEMENT_DIM, SPACE_DIM > * > mElements
c_vector< double, DIM > & rGetLocation()
std::vector< unsigned > mDeletedBoundaryElementIndices
unsigned GetNodeGlobalIndex(unsigned localIndex) const
void SetNode(unsigned index, ChastePoint< 2 > point, bool concreteMove)
ElementIterator GetElementIteratorEnd()
std::set< unsigned > mLeftPeriodicBoundaryElementIndices
std::vector< unsigned > mTopHaloNodes
Node< SPACE_DIM > * GetNode(unsigned index) const
unsigned GetCorrespondingNodeIndex(unsigned nodeIndex)
std::vector< c_matrix< double, ELEMENT_DIM, SPACE_DIM > > mElementInverseJacobians
void UseTheseElementsToDecideMeshing(std::set< unsigned > &rMainSideElements)
Element< ELEMENT_DIM, SPACE_DIM > * GetElement(unsigned index) const
void ReplaceNode(Node< SPACE_DIM > *pOldNode, Node< SPACE_DIM > *pNewNode)
NodeIterator GetNodeIteratorEnd()
std::vector< unsigned > mLeftOriginals
void ReIndex(NodeMap &map)
virtual ChasteCuboid< SPACE_DIM > CalculateBoundingBox() const
virtual unsigned GetNumAllNodes() const
virtual void SetNode(unsigned index, ChastePoint< SPACE_DIM > point, bool concreteMove=true)
virtual unsigned AddNode(Node< SPACE_DIM > *pNewNode)
void SetNewIndex(unsigned oldIndex, unsigned newIndex)
Node< SPACE_DIM > * GetNode(unsigned localIndex) const
std::vector< unsigned > mDeletedNodeIndices
const ChastePoint< SPACE_DIM > & rGetUpperCorner() const
std::vector< Node< SPACE_DIM > * > mNodes
c_vector< double, 2 > GetVectorFromAtoB(const c_vector< double, 2 > &rLocation1, const c_vector< double, 2 > &rLocation2)
void SetCoordinate(unsigned i, double value)
std::vector< BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > * > mBoundaryElements
std::map< unsigned, unsigned > mImageToRightOriginalNodeMap
void SetDeleted(unsigned index)
std::vector< double > mElementJacobianDeterminants
std::vector< unsigned > mRightOriginals
std::vector< c_vector< double, SPACE_DIM > > mBoundaryElementWeightedDirections
void GenerateVectorsOfElementsStraddlingPeriodicBoundaries()
void UpdateTopAndBottom()
unsigned AddNode(Node< 2 > *pNewNode)
NodeIterator GetNodeIteratorBegin(bool skipDeletedNodes=true)
std::vector< unsigned > mLeftImages
void CorrectNonPeriodicMesh()
std::vector< unsigned > mRightImages
BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > * GetBoundaryElement(unsigned index) const
const c_vector< double, SPACE_DIM > & rGetLocation() const
unsigned GetNumAllElements() const
bool IsDeleted(unsigned index)
unsigned GetNewIndex(unsigned oldIndex) const
unsigned GetIndex() const
ChastePoint< SPACE_DIM > GetPoint() const
virtual double GetWidth(const unsigned &rDimension) const
std::vector< double > mBoundaryElementJacobianDeterminants
unsigned GetNumAllBoundaryElements() const
#define CHASTE_CLASS_EXPORT(T)
Cylindrical2dMesh(double width)
std::set< unsigned > mRightPeriodicBoundaryElementIndices
void DeleteBoundaryNodeAt(unsigned index)
std::map< unsigned, unsigned > mImageToLeftOriginalNodeMap
std::vector< unsigned > mDeletedElementIndices
void Resize(unsigned size)
void ReconstructCylindricalMesh()
std::vector< unsigned > mBottomHaloNodes
double GetWidth(const unsigned &rDimension) const
const ChastePoint< SPACE_DIM > & rGetLowerCorner() const