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 = node_iter->rGetLocation();
106 unsigned this_node_index = node_iter->GetIndex();
107 double this_node_x_location = location[0];
110 assert(0.0 <= location[0]);
111 assert(location[0] <=
mWidth);
114 if (this_node_x_location < half_way)
128 location[0] = location[0] +
mWidth;
139 location[0] = location[0] -
mWidth;
160 double halo_node_separation =
mWidth/((
double)(num_halo_nodes));
161 double y_top_coordinate =
mTop + halo_node_separation;
162 double y_bottom_coordinate =
mBottom - halo_node_separation;
164 c_vector<double, 2> location;
165 for (
unsigned i=0; i<num_halo_nodes; i++)
167 double x_coordinate = 0.5*halo_node_separation + (
double)(i)*halo_node_separation;
170 location[0] = x_coordinate;
171 location[1] = y_top_coordinate;
175 location[1] = y_bottom_coordinate;
185 rMap.
Resize(old_num_all_nodes);
189 for (
unsigned i=0; i<old_num_all_nodes; i++)
191 if (
mNodes[i]->IsDeleted())
268 bool boundary_element_made =
false;
269 unsigned elem_index = 0;
271 while (elem_index<num_elements && !boundary_element_made)
276 boundary_element_made =
true;
277 std::vector<Node<2>*> nodes;
278 nodes.push_back(p_element->
GetNode(0));
279 nodes.push_back(p_element->
GetNode(1));
298 for (
unsigned i=0; i<rMap.
GetSize(); i++)
337 unsigned number_of_left_image_nodes = 0;
338 unsigned number_of_right_image_nodes = 0;
340 for (
unsigned i=0; i<3; i++)
342 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
346 number_of_left_image_nodes++;
350 number_of_right_image_nodes++;
355 if (number_of_right_image_nodes >= 1)
357 elem_iter->MarkAsDeleted();
362 if (number_of_left_image_nodes == 3)
364 elem_iter->MarkAsDeleted();
373 if (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2)
375 for (
unsigned i=0; i<3; i++)
377 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
381 elem_iter->ReplaceNode(
mNodes[this_node_index],
mNodes[it->second]);
396 unsigned number_of_image_nodes = 0;
397 for (
unsigned i=0; i<2; i++)
403 number_of_image_nodes++;
407 number_of_image_nodes++;
411 if (number_of_image_nodes == 2)
422 if (number_of_image_nodes == 1)
424 for (
unsigned i=0; i<2; i++)
474 c_vector<double, 2> vector = rLocation2 - rLocation1;
475 vector[0] = fmod(vector[0],
mWidth);
481 if (vector[0] > 0.5*
mWidth)
485 else if (vector[0] < -0.5*
mWidth)
513 assert(rDimension==0 || rDimension==1);
531 SetNode(node_index, new_node_point,
false);
560 unsigned elem_index = *left_iter;
568 c_vector<unsigned,3> original_element_node_indices;
569 c_vector<unsigned,3> corresponding_element_node_indices;
570 for (
unsigned i=0; i<3; i++)
581 unsigned corresponding_elem_index = *right_iter;
585 bool is_corresponding_node =
true;
587 for (
unsigned i=0; i<3; i++)
589 if ( (corresponding_element_node_indices[i] != p_corresponding_element->
GetNodeGlobalIndex(0)) &&
590 (corresponding_element_node_indices[i] != p_corresponding_element->
GetNodeGlobalIndex(1)) &&
591 (corresponding_element_node_indices[i] != p_corresponding_element->
GetNodeGlobalIndex(2)) )
593 is_corresponding_node =
false;
598 if (is_corresponding_node)
601 temp_left_hand_side_elements.erase(elem_index);
602 temp_right_hand_side_elements.erase(corresponding_elem_index);
619 if (temp_left_hand_side_elements.empty() || temp_right_hand_side_elements.empty())
621 assert(temp_right_hand_side_elements.empty());
622 assert(temp_left_hand_side_elements.empty());
626 if (temp_right_hand_side_elements.size() == 2 && temp_left_hand_side_elements.size() == 2)
628 if (temp_right_hand_side_elements.size() == 2)
648 assert(rMainSideElements.size() == 2);
651 std::set<unsigned> main_four_nodes;
652 for (std::set<unsigned>::iterator left_iter = rMainSideElements.begin();
653 left_iter != rMainSideElements.end();
656 unsigned elem_index = *left_iter;
658 for (
unsigned i=0; i<3; i++)
661 main_four_nodes.insert(index);
664 assert(main_four_nodes.size() == 4);
666 std::set<unsigned> other_four_nodes;
667 for (std::set<unsigned>::iterator iter = main_four_nodes.begin();
668 iter != main_four_nodes.end();
673 assert(other_four_nodes.size() == 4);
679 std::vector<unsigned> corresponding_elements;
687 if (!(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(0))==other_four_nodes.end()) &&
688 !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(1))==other_four_nodes.end()) &&
689 !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(2))==other_four_nodes.end()) )
691 corresponding_elements.push_back(elem_iter->GetIndex());
692 elem_iter->MarkAsDeleted();
696 assert(corresponding_elements.size() == 2);
700 for (std::set<unsigned>::iterator iter = rMainSideElements.begin();
701 iter != rMainSideElements.end();
705 std::vector<Node<2>*> nodes;
708 for (
unsigned i=0; i<3; i++)
716 this->
mElements.push_back(p_new_element);
733 unsigned incidences_of_zero_left_image_nodes = 0;
734 unsigned incidences_of_zero_right_image_nodes = 0;
741 unsigned number_of_left_image_nodes = 0;
742 unsigned number_of_right_image_nodes = 0;
744 for (
unsigned i=0; i<3; i++)
746 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
750 number_of_left_image_nodes++;
754 number_of_right_image_nodes++;
758 if ( (number_of_left_image_nodes == 0) && (number_of_right_image_nodes == 1 || number_of_right_image_nodes == 2) )
760 incidences_of_zero_left_image_nodes++;
762 if ( (number_of_right_image_nodes == 0) && (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2) )
764 incidences_of_zero_right_image_nodes++;
778 if (number_of_right_image_nodes == 1 || number_of_right_image_nodes == 2)
784 if (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2)
803 unsigned corresponding_node_index = UINT_MAX;
830 std::vector<unsigned>::iterator left_im_iter = std::find(
mLeftImages.begin(),
mLeftImages.end(), nodeIndex);
840 assert(corresponding_node_index != UINT_MAX);
841 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