00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <map>
00037
00038
00039
00040
00041
00042
00043 #include "Cylindrical2dMesh.hpp"
00044 #include "Exception.hpp"
00045
00046 Cylindrical2dMesh::Cylindrical2dMesh(double width)
00047 : MutableMesh<2,2>(),
00048 mWidth(width)
00049 {
00050 assert(width > 0.0);
00051 }
00052
00053 Cylindrical2dMesh::~Cylindrical2dMesh()
00054 {
00055 }
00056
00057 Cylindrical2dMesh::Cylindrical2dMesh(double width, std::vector<Node<2>* > nodes)
00058 : MutableMesh<2,2>(),
00059 mWidth(width)
00060 {
00061 assert(width > 0.0);
00062
00063 for (unsigned index=0; index<nodes.size(); index++)
00064 {
00065 Node<2>* p_temp_node = nodes[index];
00066 double x = p_temp_node->rGetLocation()[0];
00067 UNUSED_OPT(x);
00068 assert( 0 <= x && x < width);
00069 mNodes.push_back(p_temp_node);
00070 }
00071
00072 NodeMap node_map(nodes.size());
00073 ReMesh(node_map);
00074 }
00075
00076
00077
00078
00079
00080
00081 void Cylindrical2dMesh::UpdateTopAndBottom()
00082 {
00083 ChasteCuboid<2> bounding_box = CalculateBoundingBox();
00084 mBottom = bounding_box.rGetLowerCorner()[1];
00085 mTop = bounding_box.rGetUpperCorner()[1];
00086 }
00087
00088 void Cylindrical2dMesh::CreateMirrorNodes()
00089 {
00090 double half_way = 0.5*mWidth;
00091
00092 mLeftOriginals.clear();
00093 mLeftImages.clear();
00094 mImageToLeftOriginalNodeMap.clear();
00095 mRightOriginals.clear();
00096 mRightImages.clear();
00097 mImageToRightOriginalNodeMap.clear();
00098 mLeftPeriodicBoundaryElementIndices.clear();
00099 mRightPeriodicBoundaryElementIndices.clear();
00100
00101 for (AbstractMesh<2,2>::NodeIterator node_iter = GetNodeIteratorBegin();
00102 node_iter != GetNodeIteratorEnd();
00103 ++node_iter)
00104 {
00105 c_vector<double, 2> location = node_iter->rGetLocation();
00106 unsigned this_node_index = node_iter->GetIndex();
00107 double this_node_x_location = location[0];
00108
00109
00110 assert(0.0 <= location[0]);
00111 assert(location[0] <= mWidth);
00112
00113
00114 if (this_node_x_location < half_way)
00115 {
00116 mLeftOriginals.push_back(this_node_index);
00117 }
00118 else
00119 {
00120 mRightOriginals.push_back(this_node_index);
00121 }
00122 }
00123
00124
00125 for (unsigned i=0; i<mLeftOriginals.size(); i++)
00126 {
00127 c_vector<double, 2> location = mNodes[mLeftOriginals[i]]->rGetLocation();
00128 location[0] = location[0] + mWidth;
00129
00130 unsigned new_node_index = MutableMesh<2,2>::AddNode(new Node<2>(0, location));
00131 mLeftImages.push_back(new_node_index);
00132 mImageToLeftOriginalNodeMap[new_node_index] = mLeftOriginals[i];
00133 }
00134
00135
00136 for (unsigned i=0; i<mRightOriginals.size(); i++)
00137 {
00138 c_vector<double, 2> location = mNodes[mRightOriginals[i]]->rGetLocation();
00139 location[0] = location[0] - mWidth;
00140
00141 unsigned new_node_index = MutableMesh<2,2>::AddNode(new Node<2>(0, location));
00142 mRightImages.push_back(new_node_index);
00143 mImageToRightOriginalNodeMap[new_node_index] = mRightOriginals[i];
00144 }
00145
00146 assert(mRightOriginals.size() == mRightImages.size());
00147 assert(mLeftOriginals.size() == mLeftImages.size());
00148 assert(mImageToLeftOriginalNodeMap.size() == mLeftOriginals.size());
00149 assert(mImageToRightOriginalNodeMap.size() == mRightOriginals.size());
00150 }
00151
00152 void Cylindrical2dMesh::CreateHaloNodes()
00153 {
00154 UpdateTopAndBottom();
00155
00156 mTopHaloNodes.clear();
00157 mBottomHaloNodes.clear();
00158
00159 unsigned num_halo_nodes = (unsigned)(floor(mWidth*2.0));
00160 double halo_node_separation = mWidth/((double)(num_halo_nodes));
00161 double y_top_coordinate = mTop + halo_node_separation;
00162 double y_bottom_coordinate = mBottom - halo_node_separation;
00163
00164 c_vector<double, 2> location;
00165 for (unsigned i=0; i<num_halo_nodes; i++)
00166 {
00167 double x_coordinate = 0.5*halo_node_separation + (double)(i)*halo_node_separation;
00168
00169
00170 location[0] = x_coordinate;
00171 location[1] = y_top_coordinate;
00172 unsigned new_node_index = MutableMesh<2,2>::AddNode(new Node<2>(0, location));
00173 mTopHaloNodes.push_back(new_node_index);
00174
00175 location[1] = y_bottom_coordinate;
00176 new_node_index = MutableMesh<2,2>::AddNode(new Node<2>(0, location));
00177 mBottomHaloNodes.push_back(new_node_index);
00178 }
00179 }
00180
00181 void Cylindrical2dMesh::ReMesh(NodeMap& rMap)
00182 {
00183 unsigned old_num_all_nodes = GetNumAllNodes();
00184
00185 rMap.Resize(old_num_all_nodes);
00186 rMap.ResetToIdentity();
00187
00188
00189 for (unsigned i=0; i<old_num_all_nodes; i++)
00190 {
00191 if (mNodes[i]->IsDeleted())
00192 {
00193 rMap.SetDeleted(i);
00194 }
00195 }
00196
00197 CreateHaloNodes();
00198
00199
00200 CreateMirrorNodes();
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 NodeMap big_map(GetNumAllNodes());
00211 MutableMesh<2,2>::ReMesh(big_map);
00212
00213
00214
00215
00216
00217
00218 assert(big_map.IsIdentityMap());
00219
00220
00221 mImageToLeftOriginalNodeMap.clear();
00222 mImageToRightOriginalNodeMap.clear();
00223
00224 assert(mLeftOriginals.size() == mLeftImages.size());
00225 assert(mRightOriginals.size() == mRightImages.size());
00226
00227 for (unsigned i=0; i<mLeftOriginals.size(); i++)
00228 {
00229 mLeftOriginals[i] = big_map.GetNewIndex(mLeftOriginals[i]);
00230 mLeftImages[i] = big_map.GetNewIndex(mLeftImages[i]);
00231 mImageToLeftOriginalNodeMap[mLeftImages[i]] = mLeftOriginals[i];
00232 }
00233
00234 for (unsigned i=0; i<mRightOriginals.size(); i++)
00235 {
00236 mRightOriginals[i] = big_map.GetNewIndex(mRightOriginals[i]);
00237 mRightImages[i] = big_map.GetNewIndex(mRightImages[i]);
00238 mImageToRightOriginalNodeMap[mRightImages[i]] = mRightOriginals[i];
00239 }
00240
00241 for (unsigned i=0; i<mTopHaloNodes.size(); i++)
00242 {
00243 mTopHaloNodes[i] = big_map.GetNewIndex(mTopHaloNodes[i]);
00244 mBottomHaloNodes[i] = big_map.GetNewIndex(mBottomHaloNodes[i]);
00245 }
00246
00247
00248
00249
00250
00251 CorrectNonPeriodicMesh();
00252
00253
00254
00255
00256
00257
00258 ReconstructCylindricalMesh();
00259
00260 DeleteHaloNodes();
00261
00262
00263
00264
00265
00266
00267 unsigned num_elements = GetNumAllElements();
00268 bool boundary_element_made = false;
00269 unsigned elem_index = 0;
00270
00271 while (elem_index<num_elements && !boundary_element_made)
00272 {
00273 Element<2,2>* p_element = GetElement(elem_index);
00274 if (!p_element->IsDeleted())
00275 {
00276 boundary_element_made = true;
00277 std::vector<Node<2>*> nodes;
00278 nodes.push_back(p_element->GetNode(0));
00279 nodes.push_back(p_element->GetNode(1));
00280 BoundaryElement<1,2>* p_boundary_element = new BoundaryElement<1,2>(0, nodes);
00281 p_boundary_element->RegisterWithNodes();
00282 mBoundaryElements.push_back(p_boundary_element);
00283 this->mBoundaryElementWeightedDirections.push_back(zero_vector<double>(2));
00284 this->mBoundaryElementJacobianDeterminants.push_back(0.0);
00285 }
00286 elem_index++;
00287 }
00288
00289
00290 NodeMap reindex_map(GetNumAllNodes());
00291 ReIndex(reindex_map);
00292 assert(!reindex_map.IsIdentityMap());
00293
00294
00295
00296
00297
00298 for (unsigned i=0; i<rMap.GetSize(); i++)
00299 {
00300 if (reindex_map.IsDeleted(i))
00301 {
00302
00303
00304
00305
00306
00307 assert(rMap.IsDeleted(i));
00308 }
00309 else
00310 {
00311 rMap.SetNewIndex(i, reindex_map.GetNewIndex(i));
00312 }
00313 }
00314
00315
00316 mLeftOriginals.clear();
00317 mLeftImages.clear();
00318 mImageToLeftOriginalNodeMap.clear();
00319 mRightOriginals.clear();
00320 mRightImages.clear();
00321 mImageToRightOriginalNodeMap.clear();
00322 mLeftPeriodicBoundaryElementIndices.clear();
00323 mRightPeriodicBoundaryElementIndices.clear();
00324 }
00325
00326 void Cylindrical2dMesh::ReconstructCylindricalMesh()
00327 {
00328
00329
00330
00331
00332 for (MutableMesh<2,2>::ElementIterator elem_iter = GetElementIteratorBegin();
00333 elem_iter != GetElementIteratorEnd();
00334 ++elem_iter)
00335 {
00336
00337 unsigned number_of_left_image_nodes = 0;
00338 unsigned number_of_right_image_nodes = 0;
00339
00340 for (unsigned i=0; i<3; i++)
00341 {
00342 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
00343
00344 if (mImageToLeftOriginalNodeMap.find(this_node_index) != mImageToLeftOriginalNodeMap.end())
00345 {
00346 number_of_left_image_nodes++;
00347 }
00348 else if (mImageToRightOriginalNodeMap.find(this_node_index) != mImageToRightOriginalNodeMap.end())
00349 {
00350 number_of_right_image_nodes++;
00351 }
00352 }
00353
00354
00355 if (number_of_right_image_nodes >= 1)
00356 {
00357 elem_iter->MarkAsDeleted();
00358 mDeletedElementIndices.push_back(elem_iter->GetIndex());
00359 }
00360
00361
00362 if (number_of_left_image_nodes == 3)
00363 {
00364 elem_iter->MarkAsDeleted();
00365 mDeletedElementIndices.push_back(elem_iter->GetIndex());
00366 }
00367
00368
00369
00370
00371
00372
00373 if (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2)
00374 {
00375 for (unsigned i=0; i<3; i++)
00376 {
00377 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
00378 std::map<unsigned, unsigned>::iterator it = mImageToLeftOriginalNodeMap.find(this_node_index);
00379 if (it != mImageToLeftOriginalNodeMap.end())
00380 {
00381 elem_iter->ReplaceNode(mNodes[this_node_index], mNodes[it->second]);
00382 }
00383 }
00384 }
00385 }
00386
00387
00388
00389
00390
00391 for (unsigned elem_index = 0; elem_index<GetNumAllBoundaryElements(); elem_index++)
00392 {
00393 BoundaryElement<1,2>* p_boundary_element = GetBoundaryElement(elem_index);
00394 if (!p_boundary_element->IsDeleted())
00395 {
00396 unsigned number_of_image_nodes = 0;
00397 for (unsigned i=0; i<2; i++)
00398 {
00399 unsigned this_node_index = p_boundary_element->GetNodeGlobalIndex(i);
00400
00401 if (mImageToLeftOriginalNodeMap.find(this_node_index) != mImageToLeftOriginalNodeMap.end())
00402 {
00403 number_of_image_nodes++;
00404 }
00405 else if (mImageToRightOriginalNodeMap.find(this_node_index) != mImageToRightOriginalNodeMap.end())
00406 {
00407 number_of_image_nodes++;
00408 }
00409 }
00410
00411 if (number_of_image_nodes == 2)
00412 {
00413 p_boundary_element->MarkAsDeleted();
00414 mDeletedBoundaryElementIndices.push_back(p_boundary_element->GetIndex());
00415 }
00416
00417
00418
00419
00420
00421
00422 if (number_of_image_nodes == 1)
00423 {
00424 for (unsigned i=0; i<2; i++)
00425 {
00426 unsigned this_node_index = p_boundary_element->GetNodeGlobalIndex(i);
00427 std::map<unsigned, unsigned>::iterator it = mImageToLeftOriginalNodeMap.find(this_node_index);
00428 if (it != mImageToLeftOriginalNodeMap.end())
00429 {
00430 p_boundary_element->ReplaceNode(mNodes[this_node_index], mNodes[it->second]);
00431 }
00432 else
00433 {
00434 it = mImageToRightOriginalNodeMap.find(this_node_index);
00435 if (it != mImageToRightOriginalNodeMap.end())
00436 {
00437 p_boundary_element->MarkAsDeleted();
00438 mDeletedBoundaryElementIndices.push_back(p_boundary_element->GetIndex());
00439 }
00440 }
00441 }
00442 }
00443 }
00444 }
00445
00446
00447 for (unsigned i=0; i<mLeftImages.size(); i++)
00448 {
00449 mNodes[mLeftImages[i]]->MarkAsDeleted();
00450 mDeletedNodeIndices.push_back(mLeftImages[i]);
00451 }
00452
00453 for (unsigned i=0; i<mRightImages.size(); i++)
00454 {
00455 mNodes[mRightImages[i]]->MarkAsDeleted();
00456 mDeletedNodeIndices.push_back(mRightImages[i]);
00457 }
00458 }
00459
00460 void Cylindrical2dMesh::DeleteHaloNodes()
00461 {
00462 assert(mTopHaloNodes.size() == mBottomHaloNodes.size());
00463 for (unsigned i=0; i<mTopHaloNodes.size(); i++)
00464 {
00465 DeleteBoundaryNodeAt(mTopHaloNodes[i]);
00466 DeleteBoundaryNodeAt(mBottomHaloNodes[i]);
00467 }
00468 }
00469
00470 c_vector<double, 2> Cylindrical2dMesh::GetVectorFromAtoB(const c_vector<double, 2>& rLocation1, const c_vector<double, 2>& rLocation2)
00471 {
00472 assert(mWidth > 0.0);
00473
00474 c_vector<double, 2> vector = rLocation2 - rLocation1;
00475 vector[0] = fmod(vector[0], mWidth);
00476
00477
00478
00479
00480
00481 if (vector[0] > 0.5*mWidth)
00482 {
00483 vector[0] -= mWidth;
00484 }
00485 else if (vector[0] < -0.5*mWidth)
00486 {
00487 vector[0] += mWidth;
00488 }
00489 return vector;
00490 }
00491
00492 void Cylindrical2dMesh::SetNode(unsigned index, ChastePoint<2> point, bool concreteMove)
00493 {
00494
00495 if (point.rGetLocation()[0] >= mWidth)
00496 {
00497
00498 point.SetCoordinate(0, point.rGetLocation()[0] - mWidth);
00499 }
00500 else if (point.rGetLocation()[0] < 0.0)
00501 {
00502
00503 point.SetCoordinate(0, point.rGetLocation()[0] + mWidth);
00504 }
00505
00506
00507 MutableMesh<2,2>::SetNode(index, point, concreteMove);
00508 }
00509
00510 double Cylindrical2dMesh::GetWidth(const unsigned& rDimension) const
00511 {
00512 double width = 0.0;
00513 assert(rDimension==0 || rDimension==1);
00514 if (rDimension==0)
00515 {
00516 width = mWidth;
00517 }
00518 else
00519 {
00520 width = MutableMesh<2,2>::GetWidth(rDimension);
00521 }
00522 return width;
00523 }
00524
00525 unsigned Cylindrical2dMesh::AddNode(Node<2>* pNewNode)
00526 {
00527 unsigned node_index = MutableMesh<2,2>::AddNode(pNewNode);
00528
00529
00530 ChastePoint<2> new_node_point = pNewNode->GetPoint();
00531 SetNode(node_index, new_node_point, false);
00532
00533 return node_index;
00534 }
00535
00536 void Cylindrical2dMesh::CorrectNonPeriodicMesh()
00537 {
00538 GenerateVectorsOfElementsStraddlingPeriodicBoundaries();
00539
00540
00541
00542
00543
00544 std::set<unsigned> temp_left_hand_side_elements = mLeftPeriodicBoundaryElementIndices;
00545 std::set<unsigned> temp_right_hand_side_elements = mRightPeriodicBoundaryElementIndices;
00546
00547
00548
00549
00550
00551
00552
00553 assert(mLeftPeriodicBoundaryElementIndices.size()==mRightPeriodicBoundaryElementIndices.size());
00554
00555
00556 for (std::set<unsigned>::iterator left_iter = mLeftPeriodicBoundaryElementIndices.begin();
00557 left_iter != mLeftPeriodicBoundaryElementIndices.end();
00558 ++left_iter)
00559 {
00560 unsigned elem_index = *left_iter;
00561
00562 Element<2,2>* p_element = GetElement(elem_index);
00563
00564
00565
00566
00567
00568 c_vector<unsigned,3> original_element_node_indices;
00569 c_vector<unsigned,3> corresponding_element_node_indices;
00570 for (unsigned i=0; i<3; i++)
00571 {
00572 original_element_node_indices[i] = p_element->GetNodeGlobalIndex(i);
00573 corresponding_element_node_indices[i] = GetCorrespondingNodeIndex(original_element_node_indices[i]);
00574 }
00575
00576
00577 for (std::set<unsigned>::iterator right_iter = mRightPeriodicBoundaryElementIndices.begin();
00578 right_iter != mRightPeriodicBoundaryElementIndices.end();
00579 ++right_iter)
00580 {
00581 unsigned corresponding_elem_index = *right_iter;
00582
00583 Element<2,2>* p_corresponding_element = GetElement(corresponding_elem_index);
00584
00585 bool is_corresponding_node = true;
00586
00587 for (unsigned i=0; i<3; i++)
00588 {
00589 if ( (corresponding_element_node_indices[i] != p_corresponding_element->GetNodeGlobalIndex(0)) &&
00590 (corresponding_element_node_indices[i] != p_corresponding_element->GetNodeGlobalIndex(1)) &&
00591 (corresponding_element_node_indices[i] != p_corresponding_element->GetNodeGlobalIndex(2)) )
00592 {
00593 is_corresponding_node = false;
00594 break;
00595 }
00596 }
00597
00598 if (is_corresponding_node)
00599 {
00600
00601 temp_left_hand_side_elements.erase(elem_index);
00602 temp_right_hand_side_elements.erase(corresponding_elem_index);
00603 }
00604 }
00605 }
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619 if (temp_left_hand_side_elements.empty() || temp_right_hand_side_elements.empty())
00620 {
00621 assert(temp_right_hand_side_elements.empty());
00622 assert(temp_left_hand_side_elements.empty());
00623 }
00624 else
00625 {
00626 if (temp_right_hand_side_elements.size() == 2 && temp_left_hand_side_elements.size() == 2)
00627 {
00628 if (temp_right_hand_side_elements.size() == 2)
00629 {
00630
00631 UseTheseElementsToDecideMeshing(temp_right_hand_side_elements);
00632 }
00633 else
00634 {
00635
00636
00637
00638
00639
00640 NEVER_REACHED;
00641 }
00642 }
00643 }
00644 }
00645
00646 void Cylindrical2dMesh::UseTheseElementsToDecideMeshing(std::set<unsigned>& rMainSideElements)
00647 {
00648 assert(rMainSideElements.size() == 2);
00649
00650
00651 std::set<unsigned> main_four_nodes;
00652 for (std::set<unsigned>::iterator left_iter = rMainSideElements.begin();
00653 left_iter != rMainSideElements.end();
00654 ++left_iter)
00655 {
00656 unsigned elem_index = *left_iter;
00657 Element<2,2>* p_element = GetElement(elem_index);
00658 for (unsigned i=0; i<3; i++)
00659 {
00660 unsigned index = p_element->GetNodeGlobalIndex(i);
00661 main_four_nodes.insert(index);
00662 }
00663 }
00664 assert(main_four_nodes.size() == 4);
00665
00666 std::set<unsigned> other_four_nodes;
00667 for (std::set<unsigned>::iterator iter = main_four_nodes.begin();
00668 iter != main_four_nodes.end();
00669 ++iter)
00670 {
00671 other_four_nodes.insert(GetCorrespondingNodeIndex(*iter));
00672 }
00673 assert(other_four_nodes.size() == 4);
00674
00675
00676
00677
00678
00679 std::vector<unsigned> corresponding_elements;
00680
00681
00682 for (MutableMesh<2,2>::ElementIterator elem_iter = GetElementIteratorBegin();
00683 elem_iter != GetElementIteratorEnd();
00684 ++elem_iter)
00685 {
00686
00687 if (!(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(0))==other_four_nodes.end()) &&
00688 !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(1))==other_four_nodes.end()) &&
00689 !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(2))==other_four_nodes.end()) )
00690 {
00691 corresponding_elements.push_back(elem_iter->GetIndex());
00692 elem_iter->MarkAsDeleted();
00693 mDeletedElementIndices.push_back(elem_iter->GetIndex());
00694 }
00695 }
00696 assert(corresponding_elements.size() == 2);
00697
00698
00699 unsigned num_elements = GetNumAllElements();
00700 for (std::set<unsigned>::iterator iter = rMainSideElements.begin();
00701 iter != rMainSideElements.end();
00702 ++iter)
00703 {
00704 Element<2,2>* p_main_element = GetElement(*iter);
00705 std::vector<Node<2>*> nodes;
00706
00707
00708 for (unsigned i=0; i<3; i++)
00709 {
00710 unsigned main_node = p_main_element->GetNodeGlobalIndex(i);
00711 nodes.push_back(this->GetNode(GetCorrespondingNodeIndex(main_node)));
00712 }
00713
00714
00715 Element<2,2>* p_new_element = new Element<2,2>(num_elements, nodes);
00716 this->mElements.push_back(p_new_element);
00717 this->mElementJacobians.push_back(zero_matrix<double>(2,2));
00718 this->mElementInverseJacobians.push_back(zero_matrix<double>(2,2));
00719 this->mElementJacobianDeterminants.push_back(0.0);
00720 num_elements++;
00721 }
00722
00723
00724 NodeMap map(GetNumAllNodes());
00725 this->ReIndex(map);
00726 }
00727
00728 void Cylindrical2dMesh::GenerateVectorsOfElementsStraddlingPeriodicBoundaries()
00729 {
00730 mLeftPeriodicBoundaryElementIndices.clear();
00731 mRightPeriodicBoundaryElementIndices.clear();
00732
00733 unsigned incidences_of_zero_left_image_nodes = 0;
00734 unsigned incidences_of_zero_right_image_nodes = 0;
00735
00736 for (MutableMesh<2,2>::ElementIterator elem_iter = GetElementIteratorBegin();
00737 elem_iter != GetElementIteratorEnd();
00738 ++elem_iter)
00739 {
00740
00741 unsigned number_of_left_image_nodes = 0;
00742 unsigned number_of_right_image_nodes = 0;
00743
00744 for (unsigned i=0; i<3; i++)
00745 {
00746 unsigned this_node_index = elem_iter->GetNodeGlobalIndex(i);
00747
00748 if (mImageToLeftOriginalNodeMap.find(this_node_index) != mImageToLeftOriginalNodeMap.end())
00749 {
00750 number_of_left_image_nodes++;
00751 }
00752 else if (mImageToRightOriginalNodeMap.find(this_node_index) != mImageToRightOriginalNodeMap.end())
00753 {
00754 number_of_right_image_nodes++;
00755 }
00756 }
00757
00758 if ( (number_of_left_image_nodes == 0) && (number_of_right_image_nodes == 1 || number_of_right_image_nodes == 2) )
00759 {
00760 incidences_of_zero_left_image_nodes++;
00761 }
00762 if ( (number_of_right_image_nodes == 0) && (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2) )
00763 {
00764 incidences_of_zero_right_image_nodes++;
00765 }
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778 if (number_of_right_image_nodes == 1 || number_of_right_image_nodes == 2)
00779 {
00780 mLeftPeriodicBoundaryElementIndices.insert(elem_iter->GetIndex());
00781 }
00782
00783
00784 if (number_of_left_image_nodes == 1 || number_of_left_image_nodes == 2)
00785 {
00786 mRightPeriodicBoundaryElementIndices.insert(elem_iter->GetIndex());
00787 }
00788 }
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798 assert(mLeftPeriodicBoundaryElementIndices.size() == mRightPeriodicBoundaryElementIndices.size());
00799 }
00800
00801 unsigned Cylindrical2dMesh::GetCorrespondingNodeIndex(unsigned nodeIndex)
00802 {
00803 unsigned corresponding_node_index = UINT_MAX;
00804
00805
00806 std::vector<unsigned>::iterator right_orig_iter = std::find(mRightOriginals.begin(), mRightOriginals.end(), nodeIndex);
00807 if (right_orig_iter != mRightOriginals.end())
00808 {
00809 corresponding_node_index = mRightImages[right_orig_iter - mRightOriginals.begin()];
00810 }
00811 else
00812 {
00813
00814 std::vector<unsigned>::iterator right_im_iter = std::find(mRightImages.begin(), mRightImages.end(), nodeIndex);
00815 if (right_im_iter != mRightImages.end())
00816 {
00817 corresponding_node_index = mRightOriginals[right_im_iter - mRightImages.begin()];
00818 }
00819 else
00820 {
00821
00822 std::vector<unsigned>::iterator left_orig_iter = std::find(mLeftOriginals.begin(), mLeftOriginals.end(), nodeIndex);
00823 if (left_orig_iter != mLeftOriginals.end())
00824 {
00825 corresponding_node_index = mLeftImages[left_orig_iter - mLeftOriginals.begin()];
00826 }
00827 else
00828 {
00829
00830 std::vector<unsigned>::iterator left_im_iter = std::find(mLeftImages.begin(), mLeftImages.end(), nodeIndex);
00831 if (left_im_iter != mLeftImages.end())
00832 {
00833 corresponding_node_index = mLeftOriginals[left_im_iter - mLeftImages.begin()];
00834 }
00835 }
00836 }
00837 }
00838
00839
00840 assert(corresponding_node_index != UINT_MAX);
00841 return corresponding_node_index;
00842 }
00843
00844
00845 #include "SerializationExportWrapperForCpp.hpp"
00846 CHASTE_CLASS_EXPORT(Cylindrical2dMesh)