43#include "Cylindrical2dMesh.hpp"
45#include "VtkMeshWriter.hpp"
50 mHaloScalingFactor(2.0),
63 mHaloScalingFactor(2.0),
68 for (
unsigned index=0; index<nodes.size(); index++)
70 Node<2>* p_temp_node = nodes[index];
73 assert( 0 <= x && x < width);
74 mNodes.push_back(p_temp_node);
94 double half_way = 0.5*
mWidth;
109 c_vector<double, 2> location;
110 location = node_iter->rGetLocation();
111 unsigned this_node_index = node_iter->GetIndex();
112 double this_node_x_location = location[0];
115 assert(0.0 <= location[0]);
116 assert(location[0] <=
mWidth);
119 if (this_node_x_location < half_way)
132 c_vector<double, 2> location {};
134 location[0] = location[0] +
mWidth;
144 c_vector<double, 2> location {};
146 location[0] = location[0] -
mWidth;
167 double halo_node_separation =
mWidth / (
static_cast<double>(num_halo_nodes));
171 c_vector<double, 2> location;
172 for (
unsigned i=0; i<num_halo_nodes; i++)
174 double x_coordinate = 0.5 * halo_node_separation +
static_cast<double>(i) * halo_node_separation;
177 location[0] = x_coordinate;
178 location[1] = y_top_coordinate;
182 location[1] = y_bottom_coordinate;
192 rMap.
Resize(old_num_all_nodes);
196 for (
unsigned i=0; i<old_num_all_nodes; i++)
198 if (
mNodes[i]->IsDeleted())
275 bool boundary_element_made =
false;
276 unsigned elem_index = 0;
278 while (elem_index<num_elements && !boundary_element_made)
283 boundary_element_made =
true;
284 std::vector<Node<2>*> nodes;
285 nodes.push_back(p_element->
GetNode(0));
286 nodes.push_back(p_element->
GetNode(1));
305 for (
unsigned i=0; i<rMap.
GetSize(); i++)
344 unsigned number_of_left_image_nodes = 0;
345 unsigned number_of_right_image_nodes = 0;
347 for (
unsigned i=0; i<3; i++)
349 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
353 number_of_left_image_nodes++;
357 number_of_right_image_nodes++;
362 if (number_of_right_image_nodes >= 1)
364 elem_iter->MarkAsDeleted();
369 if (number_of_left_image_nodes == 3)
371 elem_iter->MarkAsDeleted();
380 if (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2)
382 for (
unsigned i=0; i<3; i++)
384 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
388 elem_iter->ReplaceNode(
mNodes[this_node_index],
mNodes[it->second]);
403 unsigned number_of_image_nodes = 0;
404 for (
unsigned i=0; i<2; i++)
410 number_of_image_nodes++;
414 number_of_image_nodes++;
418 if (number_of_image_nodes == 2)
429 if (number_of_image_nodes == 1)
431 for (
unsigned i=0; i<2; i++)
481 c_vector<double, 2> vector = rLocation2 - rLocation1;
482 vector[0] = fmod(vector[0],
mWidth);
488 if (vector[0] > 0.5*
mWidth)
492 else if (vector[0] < -0.5*
mWidth)
520 assert(rDimension==0 || rDimension==1);
538 SetNode(node_index, new_node_point,
false);
567 unsigned elem_index = *left_iter;
575 c_vector<unsigned,3> original_element_node_indices;
576 c_vector<unsigned,3> corresponding_element_node_indices;
577 for (
unsigned i=0; i<3; i++)
588 unsigned corresponding_elem_index = *right_iter;
592 bool is_corresponding_node =
true;
594 for (
unsigned i=0; i<3; i++)
596 if ((corresponding_element_node_indices[i] != p_corresponding_element->
GetNodeGlobalIndex(0)) &&
597 (corresponding_element_node_indices[i] != p_corresponding_element->
GetNodeGlobalIndex(1)) &&
598 (corresponding_element_node_indices[i] != p_corresponding_element->
GetNodeGlobalIndex(2)) )
600 is_corresponding_node =
false;
605 if (is_corresponding_node)
608 temp_left_hand_side_elements.erase(elem_index);
609 temp_right_hand_side_elements.erase(corresponding_elem_index);
626 if (temp_left_hand_side_elements.empty() || temp_right_hand_side_elements.empty())
628 assert(temp_right_hand_side_elements.empty());
629 assert(temp_left_hand_side_elements.empty());
633 if (temp_right_hand_side_elements.size() == 2 && temp_left_hand_side_elements.size() == 2)
635 if (temp_right_hand_side_elements.size() == 2)
655 assert(rMainSideElements.size() == 2);
658 std::set<unsigned> main_four_nodes;
659 for (std::set<unsigned>::iterator left_iter = rMainSideElements.begin();
660 left_iter != rMainSideElements.end();
663 unsigned elem_index = *left_iter;
665 for (
unsigned i=0; i<3; i++)
668 main_four_nodes.insert(index);
671 assert(main_four_nodes.size() == 4);
673 std::set<unsigned> other_four_nodes;
674 for (std::set<unsigned>::iterator iter = main_four_nodes.begin();
675 iter != main_four_nodes.end();
680 assert(other_four_nodes.size() == 4);
686 std::vector<unsigned> corresponding_elements;
694 if (!(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(0))==other_four_nodes.end()) &&
695 !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(1))==other_four_nodes.end()) &&
696 !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(2))==other_four_nodes.end()) )
698 corresponding_elements.push_back(elem_iter->GetIndex());
699 elem_iter->MarkAsDeleted();
703 assert(corresponding_elements.size() == 2);
707 for (std::set<unsigned>::iterator iter = rMainSideElements.begin();
708 iter != rMainSideElements.end();
712 std::vector<Node<2>*> nodes;
715 for (
unsigned i=0; i<3; i++)
723 this->
mElements.push_back(p_new_element);
745 unsigned number_of_left_image_nodes = 0;
746 unsigned number_of_right_image_nodes = 0;
748 for (
unsigned i=0; i<3; i++)
750 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
754 number_of_left_image_nodes++;
758 number_of_right_image_nodes++;
773 if (number_of_right_image_nodes == 1 || number_of_right_image_nodes == 2)
779 if (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2)
797 unsigned corresponding_node_index = UINT_MAX;
824 std::vector<unsigned>::iterator left_im_iter = std::find(
mLeftImages.begin(),
mLeftImages.end(), nodeIndex);
834 assert(corresponding_node_index != UINT_MAX);
835 return corresponding_node_index;
845 assert(haloScalingFactor >= 0.0);
856 assert(haloOffset >= 0.0);
#define CHASTE_CLASS_EXPORT(T)
void ReplaceNode(Node< SPACE_DIM > *pOldNode, Node< SPACE_DIM > *pNewNode)
Node< SPACE_DIM > * GetNode(unsigned localIndex) const
unsigned GetNodeGlobalIndex(unsigned localIndex) const
unsigned GetIndex() const
virtual unsigned GetNumAllNodes() const
virtual ChasteCuboid< SPACE_DIM > CalculateBoundingBox() const
NodeIterator GetNodeIteratorEnd()
virtual double GetWidth(const unsigned &rDimension) const
Node< SPACE_DIM > * GetNode(unsigned index) const
std::vector< Node< SPACE_DIM > * > mNodes
NodeIterator GetNodeIteratorBegin(bool skipDeletedNodes=true)
unsigned GetNumAllBoundaryElements() const
ElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
ElementIterator GetElementIteratorEnd()
Element< ELEMENT_DIM, SPACE_DIM > * GetElement(unsigned index) const
std::vector< Element< ELEMENT_DIM, SPACE_DIM > * > mElements
BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > * GetBoundaryElement(unsigned index) const
unsigned GetNumAllElements() const
std::vector< BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > * > mBoundaryElements
const ChastePoint< SPACE_DIM > & rGetUpperCorner() const
const ChastePoint< SPACE_DIM > & rGetLowerCorner() const
c_vector< double, DIM > & rGetLocation()
void SetCoordinate(unsigned i, double value)
void ReconstructCylindricalMesh()
std::vector< unsigned > mLeftImages
unsigned AddNode(Node< 2 > *pNewNode)
unsigned GetCorrespondingNodeIndex(unsigned nodeIndex)
std::vector< unsigned > mRightImages
std::map< unsigned, unsigned > mImageToLeftOriginalNodeMap
void CorrectNonPeriodicMesh()
double GetWidth(const unsigned &rDimension) const
void GenerateVectorsOfElementsStraddlingPeriodicBoundaries()
double GetHaloOffset() const
c_vector< double, 2 > GetVectorFromAtoB(const c_vector< double, 2 > &rLocation1, const c_vector< double, 2 > &rLocation2)
std::map< unsigned, unsigned > mImageToRightOriginalNodeMap
void SetHaloOffset(double haloOffset)
void SetHaloScalingFactor(double haloScalingFactor)
Cylindrical2dMesh(double width)
std::vector< unsigned > mTopHaloNodes
double GetHaloScalingFactor() const
void SetNode(unsigned index, ChastePoint< 2 > point, bool concreteMove)
std::vector< unsigned > mRightOriginals
std::vector< unsigned > mLeftOriginals
std::vector< unsigned > mBottomHaloNodes
std::set< unsigned > mRightPeriodicBoundaryElementIndices
double mHaloScalingFactor
std::set< unsigned > mLeftPeriodicBoundaryElementIndices
void UseTheseElementsToDecideMeshing(std::set< unsigned > &rMainSideElements)
void UpdateTopAndBottom()
void ReIndex(NodeMap &map)
virtual void SetNode(unsigned index, ChastePoint< SPACE_DIM > point, bool concreteMove=true)
std::vector< unsigned > mDeletedBoundaryElementIndices
void DeleteBoundaryNodeAt(unsigned index)
std::vector< unsigned > mDeletedElementIndices
std::vector< unsigned > mDeletedNodeIndices
virtual unsigned AddNode(Node< SPACE_DIM > *pNewNode)
void SetDeleted(unsigned index)
unsigned GetNewIndex(unsigned oldIndex) const
void SetNewIndex(unsigned oldIndex, unsigned newIndex)
void Resize(unsigned size)
bool IsDeleted(unsigned index)
const c_vector< double, SPACE_DIM > & rGetLocation() const
ChastePoint< SPACE_DIM > GetPoint() const
std::vector< c_matrix< double, ELEMENT_DIM, SPACE_DIM > > mElementInverseJacobians
std::vector< double > mBoundaryElementJacobianDeterminants
std::vector< c_vector< double, SPACE_DIM > > mBoundaryElementWeightedDirections
std::vector< c_matrix< double, SPACE_DIM, ELEMENT_DIM > > mElementJacobians
std::vector< double > mElementJacobianDeterminants