41 #ifdef OOMPH_HAS_TRIANGLE_LIB 46 namespace TriangleHelper
50 const bool& clear_hole_data)
74 if (clear_hole_data) free(triangulate_io.
holelist);
78 if(clear_hole_data) {free(triangulate_io.
regionlist);}
117 triangle_io.
holelist = (
double *) NULL;
125 triangle_io.
edgelist = (
int *) NULL;
127 triangle_io.
normlist = (
double *) NULL;
168 "Point attributes are not currently copied across",
169 "TriangleHelper::deep_copy_of_triangulateio_representation",
170 OOMPH_EXCEPTION_LOCATION);
215 "Triangle areas are not currently copied across",
216 "TriangleHelper::deep_copy_of_triangulateio_representation",
217 OOMPH_EXCEPTION_LOCATION);
223 "Triangle neighbours are not currently copied across",
224 "TriangleHelper::deep_copy_of_triangulateio_representation",
225 OOMPH_EXCEPTION_LOCATION);
260 (
double*) malloc(triangle_out.
numberofholes * 2 *
sizeof(
double));
283 "Edges are not currently copied across",
284 "TriangleHelper::deep_copy_of_triangulateio_representation",
285 OOMPH_EXCEPTION_LOCATION);
291 "Edge markers are not currently copied across",
292 "TriangleHelper::deep_copy_of_triangulateio_representation",
293 OOMPH_EXCEPTION_LOCATION);
299 "Normals are not currently copied across",
300 "TriangleHelper::deep_copy_of_triangulateio_representation",
301 OOMPH_EXCEPTION_LOCATION);
313 std::ostream &poly_file)
316 poly_file.precision(20);
324 bool point_markers=
true;
327 poly_file << point_markers <<
"\n";
330 poly_file <<
"#Points\n";
334 poly_file << n+1 <<
" " 338 for(
int i=0;
i<n_attr;++
i)
351 poly_file <<
"#Lines\n";
354 bool seg_markers=
true;
357 poly_file << seg_markers <<
"\n";
362 poly_file << n+1 <<
" " 374 poly_file <<
"#No holes\n";
379 poly_file << h+1 <<
" " 381 << triangle_io.
holelist[2*h+1] <<
"\n";
385 poly_file <<
"#Assignment of attributes to regions\n";
391 poly_file << r+1 <<
" ";
392 for(
unsigned i=0;
i<4;
i++)
411 bool &use_attributes)
417 std::ifstream element_file(element_file_name.c_str(),std::ios_base::in);
420 if(!element_file.is_open())
422 std::string error_msg(
"Failed to open element file: ");
423 error_msg +=
"\"" + element_file_name +
"\".";
425 OOMPH_EXCEPTION_LOCATION);
430 const unsigned n_element =
435 const unsigned n_local_node =
440 const unsigned n_attributes =
457 int dummy_element_number;
464 for(
unsigned e=0;
e<n_element;
e++)
466 element_file >> dummy_element_number;
467 for(
unsigned j=0;j<n_local_node;j++)
472 for(
unsigned j=0;j<n_attributes;j++)
479 element_file.close();
483 std::ifstream node_file(node_file_name.c_str(),std::ios_base::in);
486 if(!node_file.is_open())
488 std::string error_msg(
"Failed to open node file: ");
489 error_msg +=
"\"" + node_file_name +
"\".";
491 OOMPH_EXCEPTION_LOCATION);
501 node_file>>dimension;
507 OOMPH_CURRENT_FUNCTION,
508 OOMPH_EXCEPTION_LOCATION);
514 unsigned n_point_attributes =
518 unsigned boundary_markers_flag;
519 node_file >> boundary_markers_flag;
523 (
double*) malloc(triangle_io.
numberofpoints * 2 *
sizeof(
double));
527 if(boundary_markers_flag)
534 unsigned dummy_node_number;
540 for(
unsigned i=0;
i<n_node;
i++)
542 node_file>>dummy_node_number;
545 for(
unsigned j=0;j<n_point_attributes;++j)
550 if(boundary_markers_flag)
562 std::ifstream poly_file(poly_file_name.c_str(),std::ios_base::in);
565 if(!poly_file.is_open())
567 std::string error_msg(
"Failed to open poly file: ");
568 error_msg +=
"\"" + poly_file_name +
"\".";
570 OOMPH_EXCEPTION_LOCATION);
574 unsigned n_node_poly;
575 poly_file >> n_node_poly;
578 poly_file >> dimension;
581 unsigned attribute_flag;
582 poly_file >> attribute_flag;
585 poly_file >> boundary_markers_flag;
591 for(
unsigned i=0;
i<n_node_poly;
i++)
598 for(
unsigned j=0;j<attribute_flag;++j)
603 if(boundary_markers_flag==1)
618 poly_file >> boundary_markers_flag;
623 if(boundary_markers_flag)
630 unsigned dummy_segment_number;
633 for(
unsigned i=0;
i<n_segment;
i++)
635 poly_file >> dummy_segment_number;
638 if(boundary_markers_flag)
646 unsigned n_hole =
static_cast<unsigned>(triangle_io.
numberofholes);
650 (
double*) malloc(triangle_io.
numberofholes * 2 *
sizeof(
double));
656 for(
unsigned ihole=0;ihole<n_hole;ihole++)
659 poly_file >> dummy_hole;
660 poly_file >> triangle_io.
holelist[2*ihole];
661 poly_file >> triangle_io.
holelist[2*ihole+1];
666 unsigned n_regions =
static_cast<unsigned>(triangle_io.
numberofregions);
674 {use_attributes=
true;}
677 unsigned dummy_region;
680 for(
unsigned iregion=0;iregion<n_regions;iregion++)
683 poly_file >> dummy_region;
684 poly_file >> triangle_io.
regionlist[4*iregion];
685 poly_file >> triangle_io.
regionlist[4*iregion+1];
686 poly_file >> triangle_io.
regionlist[4*iregion+2];
691 poly_file.ignore(80,
'\n');
696 std::ostringstream error_message;
697 error_message <<
"Please use another region id different from zero.\n" 698 <<
"It is internally used as the default region number.\n";
700 OOMPH_CURRENT_FUNCTION,
701 OOMPH_EXCEPTION_LOCATION);
714 std::ostream &dump_file)
718 <<
" # number of elements in TriangulateIO" << std::endl;
721 <<
" # number of nodes in each triangle" << std::endl;
724 <<
" # number of triangle attributes" << std::endl;
730 unsigned counter=0, counter2=0;
731 for(
int e=0;
e<n_element;++
e)
735 <<
" # element number " << std::endl;
736 for(
int n=0;n<n_local_node;++n)
738 dump_file << triangle_io.
trianglelist[counter] << std::endl;
742 dump_file << n_attribute
743 <<
" # number of attributes" << std::endl;
744 for(
int n=0;n<n_attribute;++n)
754 <<
" # number of points in TriangulateIO" << std::endl;
756 <<
" # number of point attributes" << std::endl;
758 bool point_marker_flag =
true;
760 dump_file << point_marker_flag
761 <<
" # point marker flag" << std::endl;
767 counter=0; counter2=0;
768 for(
int n=0;n<n_nodes;++n)
770 dump_file << n <<
" # point number " << std::endl;
773 dump_file << triangle_io.
pointlist[counter] << std::endl;
776 dump_file << n_point_attributes <<
" # number of point attributes " 779 for(
int i=0;
i<n_point_attributes;++
i)
786 dump_file << point_marker_flag <<
" # point marker flag " 789 if(point_marker_flag)
797 <<
" # Number of segments in TriangulateIO " << std::endl;
800 bool seg_marker_flag=
true;
803 dump_file << seg_marker_flag <<
" # segment marker flag " << std::endl;
808 for(
int n=0;n<n_segments;++n)
810 dump_file << n <<
" # segment number " << std::endl;
813 dump_file << triangle_io.
segmentlist[counter] << std::endl;
818 dump_file << seg_marker_flag <<
" # segment marker flag " << std::endl;
826 dump_file << triangle_io.
numberofholes <<
" # number of holes " << std::endl;
829 for(
int h=0;h<n_hole;++h)
831 dump_file << h <<
" # hole number " << std::endl;
832 dump_file << triangle_io.
holelist[2*h] << std::endl;
833 dump_file << triangle_io.
holelist[2*h+1] << std::endl;
838 <<
" # number of regions " << std::endl;
843 for(
int r=0;r<n_region;++r)
845 dump_file << r <<
" # region number " << std::endl;
846 for(
unsigned i=0;
i<4;
i++)
848 dump_file << triangle_io.
regionlist[counter] << std::endl;
866 getline(restart_file,input_string,
'#');
868 restart_file.ignore(80,
'\n');
873 getline(restart_file,input_string,
'#');
875 restart_file.ignore(80,
'\n');
880 getline(restart_file,input_string,
'#');
882 restart_file.ignore(80,
'\n');
905 unsigned counter=0, counter2=0;
906 for(
int e=0;
e<n_element;++
e)
909 getline(restart_file,input_string);
910 for(
int n=0;n<n_local_node;++n)
912 getline(restart_file,input_string);
913 triangle_io.
trianglelist[counter] = atoi(input_string.c_str());
917 getline(restart_file,input_string);
918 for(
int n=0;n<n_attribute;++n)
920 getline(restart_file,input_string);
928 getline(restart_file,input_string,
'#');
930 restart_file.ignore(80,
'\n');
934 getline(restart_file,input_string,
'#');
936 restart_file.ignore(80,
'\n');
940 getline(restart_file,input_string,
'#');
942 restart_file.ignore(80,
'\n');
943 int point_marker_flag = atoi(input_string.c_str());
947 (
double*) malloc(triangle_io.
numberofpoints * 2 *
sizeof(
double));
951 if(point_marker_flag)
961 counter=0; counter2=0;
962 for(
int n=0;n<n_nodes;++n)
965 getline(restart_file,input_string);
969 getline(restart_file,input_string);
970 triangle_io.
pointlist[counter] = atof(input_string.c_str());
975 getline(restart_file,input_string);
978 for(
int i=0;
i<n_point_attributes;++
i)
980 getline(restart_file,input_string);
982 atof(input_string.c_str());
987 getline(restart_file,input_string);
989 if(point_marker_flag)
991 getline(restart_file,input_string);
997 getline(restart_file,input_string,
'#');
998 restart_file.ignore(80,
'\n');
1002 getline(restart_file,input_string,
'#');
1004 restart_file.ignore(80,
'\n');
1005 int seg_marker_flag = atoi(input_string.c_str());
1019 for(
int n=0;n<n_segments;++n)
1021 getline(restart_file,input_string);
1023 for(
int i=0;
i<2;++
i)
1025 getline(restart_file,input_string);
1026 triangle_io.
segmentlist[counter] = atoi(input_string.c_str());
1031 getline(restart_file,input_string);
1034 getline(restart_file,input_string);
1040 getline(restart_file,input_string,
'#');
1041 restart_file.ignore(80,
'\n');
1046 (
double*) malloc(triangle_io.
numberofholes * 2 *
sizeof(
double));
1050 for(
int h=0;h<n_hole;++h)
1053 getline(restart_file,input_string);
1055 getline(restart_file,input_string);
1056 triangle_io.
holelist[2*h] = atof(input_string.c_str());
1057 getline(restart_file,input_string);
1058 triangle_io.
holelist[2*h+1] = atof(input_string.c_str());
1062 getline(restart_file,input_string,
'#');
1063 restart_file.ignore(80,
'\n');
1074 for(
int r=0;r<n_region;++r)
1076 getline(restart_file,input_string);
1077 for(
unsigned i=0;
i<4;
i++)
1079 getline(restart_file,input_string);
1080 triangle_io.
regionlist[counter] = atof(input_string.c_str());
1098 namespace ToleranceForVertexMismatchInPolygons
1126 const unsigned &vertex_number,
1127 const double &tolerance_for_connection)
1131 unsigned n_vertices = polyline_pt->
nvertex();
1133 if (n_vertices <= vertex_number)
1135 std::ostringstream error_stream;
1137 <<
"The vertex number you provided (" << vertex_number
1138 <<
") is greater\n than the number of vertices (" 1139 << n_vertices <<
"in the specified TriangleMeshPolyLine.\n" 1140 <<
"Remember that the vertex index starts at 0" << std::endl
1141 <<
"Source boundary (" << boundary_id() <<
") wants to connect " 1142 <<
"to destination boundary (" << polyline_pt->
boundary_id()
1143 <<
")" << std::endl;
1145 OOMPH_CURRENT_FUNCTION,
1146 OOMPH_EXCEPTION_LOCATION);
1154 this->initial_vertex_coordinate(v_src);
1157 double error = sqrt((v_src[0] - v_dst[0])*(v_src[0] - v_dst[0]) +
1158 (v_src[1] - v_dst[1])*(v_src[1] - v_dst[1]));
1160 if (error > tolerance_for_connection)
1162 std::ostringstream error_stream;
1164 <<
"The associated vertices for the connection" 1165 <<
"\nare not close enough. Their respective values are:\n" 1166 <<
"Source boundary id:(" << this->boundary_id() <<
")\n" 1167 <<
"Source vertex x:(" << v_src[0] <<
") y:(" << v_src[1] <<
")\n" 1168 <<
"Destination boundary id:(" << polyline_pt->
boundary_id() <<
")" 1169 <<
"\nAssociated vertex x:(" << v_dst[0] <<
") y:(" << v_dst[1] <<
")" 1170 <<
"\nThe corresponding distance is: ("<< error <<
") but the " 1171 <<
"allowed\ntolerance is: (" << tolerance_for_connection <<
")" 1174 OOMPH_CURRENT_FUNCTION,
1175 OOMPH_EXCEPTION_LOCATION);
1180 Initial_vertex_connected =
true;
1181 Initial_vertex_connected_bnd_id = polyline_pt->
boundary_id();
1182 Initial_vertex_connected_n_vertex = vertex_number;
1183 Initial_vertex_connected_n_chunk = polyline_pt->
boundary_chunk();
1196 const unsigned &vertex_number,
1197 const double &tolerance_for_connection)
1201 unsigned n_vertices = polyline_pt->
nvertex();
1203 if (n_vertices <= vertex_number)
1205 std::ostringstream error_stream;
1207 <<
"The vertex number you provided (" << vertex_number
1208 <<
") is greater\n than the number of vertices (" 1209 << n_vertices <<
"in the specified TriangleMeshPolyLine.\n" 1210 <<
"Remember that the vertex index starts at 0" << std::endl
1211 <<
"Source boundary (" << boundary_id() <<
") wants to connect " 1212 <<
"to destination boundary (" << polyline_pt->
boundary_id()
1213 <<
")" << std::endl;
1215 OOMPH_CURRENT_FUNCTION,
1216 OOMPH_EXCEPTION_LOCATION);
1224 this->final_vertex_coordinate(v_src);
1227 double error = sqrt((v_src[0] - v_dst[0])*(v_src[0] - v_dst[0]) +
1228 (v_src[1] - v_dst[1])*(v_src[1] - v_dst[1]));
1230 if (error > tolerance_for_connection)
1232 std::ostringstream error_stream;
1234 <<
"The associated vertices for the connection" 1235 <<
"\nare not close enough. Their respective values are:\n" 1236 <<
"Source boundary id:(" << this->boundary_id() <<
")\n" 1237 <<
"Source vertex x:(" << v_src[0] <<
") y:(" << v_src[1] <<
")\n" 1238 <<
"Destination boundary id:(" << polyline_pt->
boundary_id() <<
")" 1239 <<
"\nAssociated vertex x:(" << v_dst[0] <<
") y:(" << v_dst[1] <<
")" 1240 <<
"\nThe corresponding distance is: ("<< error <<
") but the " 1241 <<
"allowed\ntolerance is: (" << tolerance_for_connection <<
")" 1244 OOMPH_CURRENT_FUNCTION,
1245 OOMPH_EXCEPTION_LOCATION);
1250 Final_vertex_connected =
true;
1251 Final_vertex_connected_bnd_id = polyline_pt->
boundary_id();
1252 Final_vertex_connected_n_vertex = vertex_number;
1267 const double &s_value,
1268 const double &tolerance_for_connection)
1272 double z_initial = curviline_pt->
zeta_start();
1273 double z_final = curviline_pt->
zeta_end();
1274 double z_max = std::max(z_initial,z_final);
1275 double z_min = std::min(z_initial,z_final);
1276 if (s_value < z_min || z_max < s_value)
1278 std::ostringstream error_stream;
1280 <<
"The s value you provided for connection (" << s_value
1281 <<
") is out\nof the limits of the specified " 1282 <<
"TriangleMeshCurviLine.\nThe limits are [" << z_initial
1283 <<
", " << z_final <<
"]" << std::endl
1284 <<
"Source boundary (" << boundary_id() <<
") wants to connect " 1285 <<
"to destination boundary (" << curviline_pt->
boundary_id()
1286 <<
")" << std::endl;
1288 OOMPH_CURRENT_FUNCTION,
1289 OOMPH_EXCEPTION_LOCATION);
1298 this->initial_vertex_coordinate(v_src);
1301 double error = sqrt((v_src[0] - v_dst[0])*(v_src[0] - v_dst[0]) +
1302 (v_src[1] - v_dst[1])*(v_src[1] - v_dst[1]));
1303 if (error >= tolerance_for_connection)
1305 std::ostringstream error_stream;
1307 <<
"The associated vertex for the provided connection s value\n" 1308 <<
"are not close enough. Their respective values are:\n" 1309 <<
"Source boundary id:(" << this->boundary_id() <<
")\n" 1310 <<
"Source vertex x:(" << v_src[0] <<
") y:(" << v_src[1] <<
")\n" 1311 <<
"Destination boundary id:(" << curviline_pt->
boundary_id() <<
")" 1312 <<
"\nDestination s value (" << s_value <<
")\n" 1313 <<
"Associated vertex x:(" << v_dst[0] <<
") y:(" << v_dst[1] <<
")" 1314 <<
"\nThe corresponding distance is: ("<< error <<
") but the " 1315 <<
"allowed\ntolerance is: (" << tolerance_for_connection <<
")" 1318 OOMPH_CURRENT_FUNCTION,
1319 OOMPH_EXCEPTION_LOCATION);
1324 Initial_vertex_connected_to_curviline =
true;
1325 Initial_vertex_connected =
true;
1326 Initial_vertex_connected_bnd_id = curviline_pt->
boundary_id();
1327 Initial_vertex_connected_n_chunk = curviline_pt->
boundary_chunk();
1333 Initial_s_connection_value = s_value;
1334 Tolerance_for_s_connection = tolerance_for_connection;
1350 const double &s_value,
1351 const double &tolerance_for_connection)
1355 double z_initial = curviline_pt->
zeta_start();
1356 double z_final = curviline_pt->
zeta_end();
1357 double z_max = std::max(z_initial,z_final);
1358 double z_min = std::min(z_initial,z_final);
1359 if (s_value < z_min || z_max < s_value)
1361 std::ostringstream error_stream;
1363 <<
"The s value you provided for connection (" << s_value
1364 <<
") is out\nof the limits of the specified " 1365 <<
"TriangleMeshCurviLine.\nThe limits are [" << z_initial
1366 <<
", " << z_final <<
"]" << std::endl
1367 <<
"Source boundary (" << boundary_id() <<
") wants to connect " 1368 <<
"to destination boundary (" << curviline_pt->
boundary_id()
1369 <<
")" << std::endl;
1371 OOMPH_CURRENT_FUNCTION,
1372 OOMPH_EXCEPTION_LOCATION);
1381 this->final_vertex_coordinate(v_src);
1385 double error = sqrt((v_src[0] - v_dst[0])*(v_src[0] - v_dst[0]) +
1386 (v_src[1] - v_dst[1])*(v_src[1] - v_dst[1]));
1388 if (error >= tolerance_for_connection)
1390 std::ostringstream error_stream;
1392 <<
"The associated vertex for the provided connection s value\n" 1393 <<
"are not close enough. Their respective values are:\n" 1394 <<
"Source boundary id:(" << this->boundary_id() <<
")\n" 1395 <<
"Source vertex x:(" << v_src[0] <<
") y:(" << v_src[1] <<
")\n" 1396 <<
"Destination boundary id:(" << curviline_pt->
boundary_id() <<
")" 1397 <<
"\nDestination s value (" << s_value <<
")\n" 1398 <<
"Associated vertex x:(" << v_dst[0] <<
") y:(" << v_dst[1] <<
")" 1399 <<
"\nThe corresponding distance is: ("<< error <<
") but the " 1400 <<
"allowed\ntolerance is: (" << tolerance_for_connection <<
")" 1403 OOMPH_CURRENT_FUNCTION,
1404 OOMPH_EXCEPTION_LOCATION);
1409 Final_vertex_connected_to_curviline =
true;
1410 Final_vertex_connected =
true;
1411 Final_vertex_connected_bnd_id = curviline_pt->
boundary_id();
1418 Final_s_connection_value = s_value;
1419 Tolerance_for_s_connection = tolerance_for_connection;
1437 const bool &is_internal_point_fixed) :
1439 Internal_point_pt(internal_point_pt),
1440 Is_internal_point_fixed(is_internal_point_fixed)
1453 std::ostringstream error_stream;
1455 <<
"Sorry -- I'm afraid we insist that a closed curve is\n" 1456 <<
"specified by at least two separate CurveSections.\n" 1457 <<
"You've only specified (" << n_boundaries <<
")" << std::endl;
1459 OOMPH_CURRENT_FUNCTION,
1460 OOMPH_EXCEPTION_LOCATION);
1465 for (
unsigned i=0;
i<n_boundaries-1;
i++)
1472 curve_section_pt[
i]->final_vertex_coordinate(v1);
1478 curve_section_pt[
i+1]->initial_vertex_coordinate(v2);
1481 double error = sqrt(pow(v1[0]-v2[0],2)+pow(v1[1]-v2[1],2));
1485 std::ostringstream error_stream;
1487 <<
"The start and end points of curve section boundary parts\n" <<
i 1488 <<
" and " <<
i+1<<
" don't match when judged with the tolerance of " 1490 <<
" which\nis specified in the namespace variable\n" 1491 <<
"ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n" 1492 <<
"These are the vertices coordinates:\n" 1493 <<
"Curve section ("<<
i<<
") final vertex: (" 1494 << v1[0] <<
", "<< v1[1] <<
")\n" 1495 <<
"Curve section ("<<
i+1<<
") initial vertex: (" 1496 << v2[0] <<
", "<< v2[1] <<
")\n" 1497 <<
"The distance between the vertices is ("<<error<<
")\n" 1498 <<
"Feel free to adjust this or to recompile the code without\n" 1499 <<
"paranoia if you think this is OK...\n" 1503 OOMPH_CURRENT_FUNCTION,
1504 OOMPH_EXCEPTION_LOCATION);
1515 if (current_polyline && next_polyline)
1517 unsigned last_vertex = current_polyline->
nvertex() - 1;
1538 double error = sqrt(pow(v2[0]-v1[0],2)+pow(v2[1]-v1[1],2));
1542 std::ostringstream error_stream;
1544 <<
"The start and end points of the first and last curve segment\n" 1545 <<
"boundary parts don't match when judged \nwith the tolerance of " 1547 <<
" which is specified in the namespace \nvariable " 1548 <<
"ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n" 1549 <<
"Feel free to adjust this or to recompile the code without\n" 1550 <<
"paranoia if you think this is OK...\n" 1554 OOMPH_CURRENT_FUNCTION,
1555 OOMPH_EXCEPTION_LOCATION);
1566 if (first_polyline && last_polyline)
1568 unsigned last_vertex = last_polyline->
nvertex() - 1;
1604 Enable_redistribution_of_segments_between_polylines(false),
1605 Can_update_configuration(false),
1606 Polygon_fixed(false)
1610 const unsigned n_bound = boundary_polyline_pt.size();
1614 for (
unsigned p = 0; p < n_bound; p++)
1618 if (tmp_polyline_pt == 0)
1620 std::ostringstream error_stream;
1622 <<
"The (" << p <<
") TriangleMeshCurveSection is not a " 1623 <<
"TriangleMeshPolyLine.\nThe TriangleMeshPolygon object" 1624 <<
"is constituent of only TriangleMeshPolyLine objects.\n" 1625 <<
"Verify that all the constituent elements of the " 1626 <<
"TriangleMeshPolygon\nare instantiated as " 1627 <<
"TriangleMeshPolyLines." << std::endl;
1629 OOMPH_CURRENT_FUNCTION,
1630 OOMPH_EXCEPTION_LOCATION);
1635 bool contiguous=
true;
1636 unsigned i_offensive=0;
1641 std::ostringstream error_stream;
1643 <<
"Sorry -- I'm afraid we insist that a closed curve is\n" 1644 <<
"specified by at least two separate TriangleMeshPolyLines.\n" 1645 <<
"You've only specified (" << n_bound <<
")" << std::endl;
1647 "TriangleMeshPolygon::TriangleMeshPolygon()",
1648 OOMPH_EXCEPTION_LOCATION);
1653 for(
unsigned i=0;
i<n_bound-1;
i++)
1658 vertex_coordinate(last_vertex);
1664 double error=sqrt(pow(v1[0]-v2[0],2)+pow(v1[1]-v2[1],2));
1686 vertex_coordinate(last_vertex);
1690 double error=sqrt(pow(v1[0]-v2[0],2)+pow(v1[1]-v2[1],2));
1695 i_offensive=n_bound-1;
1705 std::ostringstream error_stream;
1707 <<
"The polylines specified \n" 1708 <<
"should define a closed geometry, i.e. the first/last vertex of\n" 1709 <<
"adjacent polylines should match.\n\n" 1710 <<
"Your polyline number "<< i_offensive
1711 <<
" has no contiguous neighbour, when judged \nwith the tolerance of " 1713 <<
" which is specified in the namespace \nvariable " 1714 <<
"ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n" 1715 <<
"Feel free to adjust this or to recompile the code without\n" 1716 <<
"paranoia if you think this is OK...\n" 1719 "TriangleMeshPolygon::TriangleMeshPolygon()",
1720 OOMPH_EXCEPTION_LOCATION);
1741 unsigned npolyline=boundary_polyline_pt.size();
1745 unsigned nvert=boundary_polyline_pt[
i]->nvertex();
1746 for (
unsigned j=0;j<nvert;j++)
1752 double dist=sqrt(pow(first_vertex[0]-last_vertex[0],2)+
1753 pow(first_vertex[1]-last_vertex[1],2));
1757 std::ostringstream error_stream;
1759 <<
"The start and end points of polylines " <<
i 1760 <<
" and " <<
i+1<<
" don't match when judged\n" 1761 <<
"with the tolerance (" 1763 <<
") which is specified in the namespace \nvariable " 1764 <<
"ToleranceForVertexMismatchInPolygons::" 1765 <<
"Tolerable_error.\n\n" 1766 <<
"Feel free to adjust this or to recompile the " 1768 <<
"paranoia if you think this is OK...\n" 1772 "TriangleMeshPolygon::TriangleMeshPolygon()",
1773 OOMPH_EXCEPTION_LOCATION);
1779 polygon_vertex.push_back(
1791 nvertex=polygon_vertex.size();
1794 unsigned intersect_counter=0;
1798 for (
unsigned i=1;
i<=nvertex;
i++)
1813 (p2[1]-p1[1])+p1[0];
1814 if ( (p1[0] == p2[0]) ||
1817 intersect_counter++;
1827 if (intersect_counter%2==0)
1829 std::ostringstream error_stream;
1831 <<
"The internal point at " 1834 <<
" isn't in the polygon that describes the internal closed " 1835 <<
"curve!\nPolygon vertices are at: \n";
1836 for (
unsigned i=0;
i<nvertex;
i++)
1838 error_stream << polygon_vertex[
i][0] <<
" " 1839 << polygon_vertex[
i][1] <<
"\n";
1842 <<
"This may be because the internal point is defined by a\n" 1843 <<
"GeomObject that has deformed so much that it's \n" 1844 <<
"swept over the (initial) internal point.\n" 1845 <<
"If so, you should update the position of the internal point. \n" 1846 <<
"This could be done automatically by generating \n" 1847 <<
"an internal mesh inside the polygon and using one\n" 1848 <<
"of its internal nodes as the internal point. Actually not \n" 1849 <<
"why triangle doesn't do that automatically....\n";
1852 "TriangleMeshPolygon::TriangleMeshPolygon()",
1853 OOMPH_EXCEPTION_LOCATION);
1884 for (
unsigned i=0;
i<n_boundaries-1;
i++)
1898 double error = sqrt(pow(v1[0]-v2[0],2)+pow(v1[1]-v2[1],2));
1901 std::ostringstream error_stream;
1903 <<
"The start and end points of curve section boundary parts " <<
i 1904 <<
" and " <<
i+1<<
" don't match when judged \nwith the tolerance of " 1906 <<
" which is specified in the namespace \nvariable " 1907 <<
"ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n" 1908 <<
"Feel free to adjust this or to recompile the code without\n" 1909 <<
"paranoia if you think this is OK...\n" 1913 OOMPH_CURRENT_FUNCTION,
1914 OOMPH_EXCEPTION_LOCATION);
1924 if (current_polyline && next_polyline)
1926 unsigned last_vertex = current_polyline->
nvertex() - 1;
1936 #ifdef OOMPH_HAS_TRIANGLE_LIB 1949 std::map<unsigned, double> ®ions_areas,
1984 std::map<unsigned, std::map<unsigned, unsigned> > boundary_chunk_n_vertices;
2007 std::map<unsigned,std::map<unsigned,Vector<vertex_connection_info> > >
2028 std::map<unsigned,std::map<unsigned,Vector<base_vertex_info> > >
2032 const unsigned n_outer_polygons = outer_polygons_pt.size();
2034 for (
unsigned i = 0;
i < n_outer_polygons;
i++)
2037 const unsigned n_polylines = outer_polygons_pt[
i]->npolyline();
2039 for (
unsigned p = 0; p < n_polylines; p++)
2043 outer_polygons_pt[
i]->polyline_pt(p);
2046 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2049 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2056 boundary_chunk_n_vertices[bound_id][bound_chunk] = n_vertices;
2062 if (p < n_polylines - 1)
2065 next_polyline_pt = outer_polygons_pt[
i]->polyline_pt(p+1);
2070 next_polyline_pt = outer_polygons_pt[
i]->polyline_pt(0);
2074 add_connection_matrix_info_helper(tmp_polyline_pt,
2080 initialise_base_vertex(tmp_polyline_pt, base_vertices);
2087 const unsigned n_internal_polygons = internal_polygons_pt.size();
2089 for (
unsigned i = 0;
i < n_internal_polygons;
i++)
2092 const unsigned n_polylines = internal_polygons_pt[
i]->npolyline();
2094 for (
unsigned p = 0; p < n_polylines; p++)
2098 internal_polygons_pt[
i]->polyline_pt(p);
2101 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2104 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2111 boundary_chunk_n_vertices[bound_id][bound_chunk] = n_vertices;
2117 if (p < n_polylines - 1)
2120 next_polyline_pt = internal_polygons_pt[
i]->polyline_pt(p+1);
2125 next_polyline_pt = internal_polygons_pt[
i]->polyline_pt(0);
2129 add_connection_matrix_info_helper(tmp_polyline_pt,
2135 initialise_base_vertex(tmp_polyline_pt, base_vertices);
2142 const unsigned n_open_curves = open_curves_pt.size();
2144 for (
unsigned i = 0;
i < n_open_curves;
i++)
2147 const unsigned n_polylines = open_curves_pt[
i]->ncurve_section();
2149 for (
unsigned p = 0; p < n_polylines; p++)
2153 open_curves_pt[
i]->polyline_pt(p);
2156 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2159 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2166 boundary_chunk_n_vertices[bound_id][bound_chunk] = n_vertices;
2172 if (p < n_polylines - 1)
2175 next_polyline_pt = open_curves_pt[
i]->polyline_pt(p+1);
2184 add_connection_matrix_info_helper(tmp_polyline_pt,
2190 initialise_base_vertex(tmp_polyline_pt, base_vertices);
2205 for (
unsigned i = 0;
i < n_outer_polygons;
i++)
2208 const unsigned n_polylines = outer_polygons_pt[
i]->npolyline();
2210 for (
unsigned p = 0; p < n_polylines; p++)
2214 outer_polygons_pt[
i]->polyline_pt(p);
2217 add_base_vertex_info_helper(tmp_polyline_pt,
2220 boundary_chunk_n_vertices);
2228 for (
unsigned i = 0;
i < n_internal_polygons;
i++)
2231 const unsigned n_polylines = internal_polygons_pt[
i]->npolyline();
2233 for (
unsigned p = 0; p < n_polylines; p++)
2237 internal_polygons_pt[
i]->polyline_pt(p);
2240 add_base_vertex_info_helper(tmp_polyline_pt,
2243 boundary_chunk_n_vertices);
2251 for (
unsigned i = 0;
i < n_open_curves;
i++)
2254 const unsigned n_polylines = open_curves_pt[
i]->ncurve_section();
2256 for (
unsigned p = 0; p < n_polylines; p++)
2260 open_curves_pt[
i]->polyline_pt(p);
2263 add_base_vertex_info_helper(tmp_polyline_pt,
2266 boundary_chunk_n_vertices);
2284 std::map<unsigned, std::map<unsigned, Vector<int> > >
2285 boundary_chunk_vertex_to_global_vertex_id;
2290 for (std::map<
unsigned, std::map<unsigned, unsigned> >::iterator it =
2291 boundary_chunk_n_vertices.begin();
2292 it != boundary_chunk_n_vertices.end();
2296 const unsigned b = (*it).first;
2299 for (std::map<unsigned, unsigned>::iterator itt = (*it).second.begin();
2300 itt != (*it).second.end(); itt++)
2303 const unsigned c = (*itt).first;
2307 const unsigned n_vertices = boundary_chunk_n_vertices[b][c];
2311 boundary_chunk_vertex_to_global_vertex_id[b][c].resize(n_vertices,-1);
2318 unsigned global_vertex_number = 0;
2328 unsigned n_vertices_outer_polygons = 0;
2331 for (
unsigned i = 0;
i < n_outer_polygons;
i++)
2334 const unsigned n_polylines = outer_polygons_pt[
i]->npolyline();
2336 for (
unsigned p = 0; p < n_polylines; p++)
2340 outer_polygons_pt[
i]->polyline_pt(p);
2343 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2346 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2356 base_vertices[bound_id][bnd_chunk][0];
2361 std::ostringstream error_message;
2363 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2365 <<
"The initial vertex of the current polyline has no base\n" 2366 <<
"vertex assigned\n" 2367 <<
"Outer polygon number: ("<<
i <<
")\n\n" 2368 <<
"Polyline number: ("<<p<<
")\n" 2369 <<
"Boundary id: (" << bound_id <<
")\n" 2370 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n";
2373 OOMPH_EXCEPTION_LOCATION);
2378 unsigned bvbi = initial_base_vertex_info.
boundary_id;
2385 int global_vertex_id =
2386 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2389 if (global_vertex_id != -1)
2393 boundary_chunk_vertex_to_global_vertex_id
2394 [bound_id][bnd_chunk][0] = global_vertex_id;
2399 boundary_chunk_vertex_to_global_vertex_id
2400 [bvbi][bvbc][bvvn] = global_vertex_number;
2403 boundary_chunk_vertex_to_global_vertex_id
2404 [bound_id][bnd_chunk][0] = global_vertex_number;
2407 global_vertex_number++;
2413 global_vertices.push_back(vertex);
2421 n_vertices_outer_polygons++;
2427 for (
unsigned v = 1; v < n_vertices-1; v++)
2431 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
2440 if (global_vertex_id == -1)
2443 boundary_chunk_vertex_to_global_vertex_id
2444 [bound_id][bnd_chunk][v] = global_vertex_number;
2447 global_vertex_number++;
2452 global_vertices.push_back(vertex);
2457 n_vertices_outer_polygons++;
2466 base_vertices[bound_id][bnd_chunk][1];
2471 std::ostringstream error_message;
2473 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2475 <<
"The final vertex of the current polyline has no base\n" 2476 <<
"vertex assigned\n" 2477 <<
"Outer polygon number: ("<<
i <<
")\n\n" 2478 <<
"Polyline number: ("<<p<<
")\n" 2479 <<
"Boundary id: (" << bound_id <<
")\n" 2480 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n";
2483 OOMPH_EXCEPTION_LOCATION);
2496 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2499 if (global_vertex_id != -1)
2503 boundary_chunk_vertex_to_global_vertex_id
2504 [bound_id][bnd_chunk][n_vertices-1] = global_vertex_id;
2509 boundary_chunk_vertex_to_global_vertex_id
2510 [bvbi][bvbc][bvvn] = global_vertex_number;
2513 boundary_chunk_vertex_to_global_vertex_id
2514 [bound_id][bnd_chunk][n_vertices-1] = global_vertex_number;
2517 global_vertex_number++;
2524 global_vertices.push_back(vertex);
2532 n_vertices_outer_polygons++;
2540 unsigned n_vertices_internal_polygons = 0;
2543 for (
unsigned i = 0;
i < n_internal_polygons;
i++)
2546 const unsigned n_polylines = internal_polygons_pt[
i]->npolyline();
2548 for (
unsigned p = 0; p < n_polylines; p++)
2552 internal_polygons_pt[
i]->polyline_pt(p);
2555 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2558 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2568 base_vertices[bound_id][bnd_chunk][0];
2573 std::ostringstream error_message;
2575 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2577 <<
"The initial vertex of the current polyline has no base\n" 2578 <<
"vertex assigned\n" 2579 <<
"Internal polygon number: ("<<
i <<
")\n\n" 2580 <<
"Polyline number: ("<<p<<
")\n" 2581 <<
"Boundary id: (" << bound_id <<
")\n" 2582 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n";
2585 OOMPH_EXCEPTION_LOCATION);
2590 unsigned bvbi = initial_base_vertex_info.
boundary_id;
2597 int global_vertex_id =
2598 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2601 if (global_vertex_id != -1)
2605 boundary_chunk_vertex_to_global_vertex_id
2606 [bound_id][bnd_chunk][0] = global_vertex_id;
2611 boundary_chunk_vertex_to_global_vertex_id
2612 [bvbi][bvbc][bvvn] = global_vertex_number;
2615 boundary_chunk_vertex_to_global_vertex_id
2616 [bound_id][bnd_chunk][0] = global_vertex_number;
2619 global_vertex_number++;
2625 global_vertices.push_back(vertex);
2633 n_vertices_internal_polygons++;
2639 for (
unsigned v = 1; v < n_vertices-1; v++)
2643 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
2652 if (global_vertex_id == -1)
2655 boundary_chunk_vertex_to_global_vertex_id
2656 [bound_id][bnd_chunk][v] = global_vertex_number;
2659 global_vertex_number++;
2664 global_vertices.push_back(vertex);
2669 n_vertices_internal_polygons++;
2678 base_vertices[bound_id][bnd_chunk][1];
2683 std::ostringstream error_message;
2685 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2687 <<
"The final vertex of the current polyline has no base\n" 2688 <<
"vertex assigned\n" 2689 <<
"Internal polygon number: ("<<
i <<
")\n\n" 2690 <<
"Polyline number: ("<<p<<
")\n" 2691 <<
"Boundary id: (" << bound_id <<
")\n" 2692 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n";
2695 OOMPH_EXCEPTION_LOCATION);
2708 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2711 if (global_vertex_id != -1)
2715 boundary_chunk_vertex_to_global_vertex_id
2716 [bound_id][bnd_chunk][n_vertices-1] = global_vertex_id;
2721 boundary_chunk_vertex_to_global_vertex_id
2722 [bvbi][bvbc][bvvn] = global_vertex_number;
2725 boundary_chunk_vertex_to_global_vertex_id
2726 [bound_id][bnd_chunk][n_vertices-1] = global_vertex_number;
2729 global_vertex_number++;
2736 global_vertices.push_back(vertex);
2744 n_vertices_internal_polygons++;
2752 unsigned n_vertices_open_curves = 0;
2755 for (
unsigned i = 0;
i < n_open_curves;
i++)
2758 const unsigned n_polylines = open_curves_pt[
i]->ncurve_section();
2760 for (
unsigned p = 0; p < n_polylines; p++)
2764 open_curves_pt[
i]->polyline_pt(p);
2767 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2770 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2780 base_vertices[bound_id][bnd_chunk][0];
2785 std::ostringstream error_message;
2787 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2789 <<
"The initial vertex of the current polyline has no base\n" 2790 <<
"vertex assigned\n" 2791 <<
"Open curve number: ("<<
i <<
")\n\n" 2792 <<
"Polyline number: ("<<p<<
")\n" 2793 <<
"Boundary id: (" << bound_id <<
")\n" 2794 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n";
2797 OOMPH_EXCEPTION_LOCATION);
2802 unsigned bvbi = initial_base_vertex_info.
boundary_id;
2809 int global_vertex_id =
2810 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2813 if (global_vertex_id != -1)
2817 boundary_chunk_vertex_to_global_vertex_id
2818 [bound_id][bnd_chunk][0] = global_vertex_id;
2823 boundary_chunk_vertex_to_global_vertex_id
2824 [bvbi][bvbc][bvvn] = global_vertex_number;
2827 boundary_chunk_vertex_to_global_vertex_id
2828 [bound_id][bnd_chunk][0] = global_vertex_number;
2831 global_vertex_number++;
2837 global_vertices.push_back(vertex);
2845 n_vertices_open_curves++;
2851 for (
unsigned v = 1; v < n_vertices-1; v++)
2855 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
2864 if (global_vertex_id == -1)
2867 boundary_chunk_vertex_to_global_vertex_id
2868 [bound_id][bnd_chunk][v] = global_vertex_number;
2871 global_vertex_number++;
2876 global_vertices.push_back(vertex);
2881 n_vertices_open_curves++;
2890 base_vertices[bound_id][bnd_chunk][1];
2895 std::ostringstream error_message;
2897 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2899 <<
"The final vertex of the current polyline has no base\n" 2900 <<
"vertex assigned\n" 2901 <<
"Open curve number: ("<<
i <<
")\n\n" 2902 <<
"Polyline number: ("<<p<<
")\n" 2903 <<
"Boundary id: (" << bound_id <<
")\n" 2904 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n";
2907 OOMPH_EXCEPTION_LOCATION);
2920 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2923 if (global_vertex_id != -1)
2927 boundary_chunk_vertex_to_global_vertex_id
2928 [bound_id][bnd_chunk][n_vertices-1] = global_vertex_id;
2933 boundary_chunk_vertex_to_global_vertex_id
2934 [bvbi][bvbc][bvvn] = global_vertex_number;
2937 boundary_chunk_vertex_to_global_vertex_id
2938 [bound_id][bnd_chunk][n_vertices-1] = global_vertex_number;
2941 global_vertex_number++;
2948 global_vertices.push_back(vertex);
2956 n_vertices_open_curves++;
2972 const unsigned n_global_vertices = n_vertices_outer_polygons +
2973 n_vertices_internal_polygons +
2974 n_vertices_open_curves;
2979 const unsigned added_global_vertices = global_vertices.size();
2980 if (added_global_vertices != n_global_vertices)
2982 std::ostringstream error_stream;
2984 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2986 <<
"The number of added vertices to the global vertices container\n" 2987 <<
"is different from the pre-computed number of vertices\n" 2988 <<
"Added number of vertices: ("<<added_global_vertices<<
")\n" 2989 <<
"Pre-computed number of global vertices: ("<<n_global_vertices<<
")\n";
2992 OOMPH_EXCEPTION_LOCATION);
2997 if (global_vertex_number != n_global_vertices)
2999 std::ostringstream error_stream;
3001 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3003 <<
"The counter for the global number of vertices is different from\n" 3004 <<
"the pre-computed number of vertices\n" 3005 <<
"Global vertices counter: ("<<global_vertex_number<<
")\n" 3006 <<
"Pre-computed number of global vertices: ("<<n_global_vertices<<
")\n";
3009 OOMPH_EXCEPTION_LOCATION);
3034 for (
unsigned i = 0;
i < n_outer_polygons;
i++)
3037 const unsigned n_polylines = outer_polygons_pt[
i]->npolyline();
3040 for (
unsigned p = 0; p < n_polylines; p++)
3043 const unsigned bound_id =
3044 outer_polygons_pt[
i]->polyline_pt(p)->boundary_id();
3047 const unsigned n_vertices =
3048 outer_polygons_pt[
i]->polyline_pt(p)->nvertex();
3051 const unsigned bnd_chunk =
3052 outer_polygons_pt[
i]->polyline_pt(p)->boundary_chunk();
3055 for (
unsigned v = 1; v < n_vertices; v++)
3058 const int global_vertex_id_v_1 =
3059 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v-1];
3062 if (global_vertex_id_v_1 == -1)
3066 outer_polygons_pt[
i]->polyline_pt(p)->vertex_coordinate(v-1);
3067 std::ostringstream error_message;
3069 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3071 <<
"The global vertex number for the current vertex has not\n" 3072 <<
"been assigned\n." 3073 <<
"Outer polygon number: ("<<
i <<
")\n\n" 3074 <<
"Polyline number: ("<<p<<
")\n" 3075 <<
"Boundary id: (" << bound_id <<
")\n" 3076 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n" 3077 <<
"Vertex["<<v-1<<
"]: (" 3078 << current_vertex[0]<<
", "<<current_vertex[1]<<
")\n";
3081 OOMPH_EXCEPTION_LOCATION);
3086 const int global_vertex_id_v =
3087 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
3090 if (global_vertex_id_v == -1)
3094 outer_polygons_pt[
i]->polyline_pt(p)->vertex_coordinate(v);
3095 std::ostringstream error_message;
3097 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3099 <<
"The global vertex number for the current vertex has not\n" 3100 <<
"been assigned\n." 3101 <<
"Outer polygon number: ("<<
i <<
")\n\n" 3102 <<
"Polyline number: ("<<p<<
")\n" 3103 <<
"Boundary id: (" << bound_id <<
")\n" 3104 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n" 3105 <<
"Vertex["<<v<<
"]: (" 3106 << current_vertex[0]<<
", "<<current_vertex[1]<<
")\n";
3109 OOMPH_EXCEPTION_LOCATION);
3115 current_segment[0] = global_vertex_id_v_1;
3116 current_segment[1] = global_vertex_id_v;
3117 global_segments.push_back(current_segment);
3120 global_segment_markers.push_back(bound_id);
3129 for (
unsigned i = 0;
i < n_internal_polygons;
i++)
3132 const unsigned n_polylines = internal_polygons_pt[
i]->npolyline();
3135 for (
unsigned p = 0; p < n_polylines; p++)
3138 const unsigned bound_id =
3139 internal_polygons_pt[
i]->polyline_pt(p)->boundary_id();
3142 const unsigned n_vertices =
3143 internal_polygons_pt[
i]->polyline_pt(p)->nvertex();
3146 const unsigned bnd_chunk =
3147 internal_polygons_pt[
i]->polyline_pt(p)->boundary_chunk();
3150 for (
unsigned v = 1; v < n_vertices; v++)
3153 const int global_vertex_id_v_1 =
3154 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v-1];
3157 if (global_vertex_id_v_1 == -1)
3161 internal_polygons_pt[
i]->polyline_pt(p)->vertex_coordinate(v-1);
3162 std::ostringstream error_message;
3164 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3166 <<
"The global vertex number for the current vertex has not\n" 3167 <<
"been assigned\n." 3168 <<
"Internal polygon number: ("<<
i <<
")\n\n" 3169 <<
"Polyline number: ("<<p<<
")\n" 3170 <<
"Boundary id: (" << bound_id <<
")\n" 3171 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n" 3172 <<
"Vertex["<<v-1<<
"]: (" 3173 << current_vertex[0]<<
", "<<current_vertex[1]<<
")\n";
3176 OOMPH_EXCEPTION_LOCATION);
3181 const int global_vertex_id_v =
3182 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
3185 if (global_vertex_id_v == -1)
3189 internal_polygons_pt[
i]->polyline_pt(p)->vertex_coordinate(v);
3190 std::ostringstream error_message;
3192 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3194 <<
"The global vertex number for the current vertex has not\n" 3195 <<
"been assigned\n." 3196 <<
"Internal polygon number: ("<<
i <<
")\n\n" 3197 <<
"Polyline number: ("<<p<<
")\n" 3198 <<
"Boundary id: (" << bound_id <<
")\n" 3199 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n" 3200 <<
"Vertex["<<v<<
"]: (" 3201 << current_vertex[0]<<
", "<<current_vertex[1]<<
")\n";
3204 OOMPH_EXCEPTION_LOCATION);
3210 current_segment[0] = global_vertex_id_v_1;
3211 current_segment[1] = global_vertex_id_v;
3212 global_segments.push_back(current_segment);
3215 global_segment_markers.push_back(bound_id);
3224 for (
unsigned i = 0;
i < n_open_curves;
i++)
3227 const unsigned n_polylines = open_curves_pt[
i]->ncurve_section();
3230 for (
unsigned p = 0; p < n_polylines; p++)
3233 const unsigned bound_id =
3234 open_curves_pt[
i]->polyline_pt(p)->boundary_id();
3237 const unsigned n_vertices =
3238 open_curves_pt[
i]->polyline_pt(p)->nvertex();
3241 const unsigned bnd_chunk =
3242 open_curves_pt[
i]->polyline_pt(p)->boundary_chunk();
3245 for (
unsigned v = 1; v < n_vertices; v++)
3248 const int global_vertex_id_v_1 =
3249 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v-1];
3252 if (global_vertex_id_v_1 == -1)
3256 open_curves_pt[
i]->polyline_pt(p)->vertex_coordinate(v-1);
3257 std::ostringstream error_message;
3259 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3261 <<
"The global vertex number for the current vertex has not\n" 3262 <<
"been assigned\n." 3263 <<
"Open curve number: ("<<
i <<
")\n\n" 3264 <<
"Polyline number: ("<<p<<
")\n" 3265 <<
"Boundary id: (" << bound_id <<
")\n" 3266 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n" 3267 <<
"Vertex["<<v-1<<
"]: (" 3268 << current_vertex[0]<<
", "<<current_vertex[1]<<
")\n";
3271 OOMPH_EXCEPTION_LOCATION);
3276 const int global_vertex_id_v =
3277 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
3280 if (global_vertex_id_v == -1)
3284 open_curves_pt[
i]->polyline_pt(p)->vertex_coordinate(v);
3285 std::ostringstream error_message;
3287 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3289 <<
"The global vertex number for the current vertex has not\n" 3290 <<
"been assigned\n." 3291 <<
"Open curve number: ("<<
i <<
")\n\n" 3292 <<
"Polyline number: ("<<p<<
")\n" 3293 <<
"Boundary id: (" << bound_id <<
")\n" 3294 <<
"Boundary chunk: ("<<bnd_chunk<<
")\n" 3295 <<
"Vertex["<<v<<
"]: (" 3296 << current_vertex[0]<<
", "<<current_vertex[1]<<
")\n";
3299 OOMPH_EXCEPTION_LOCATION);
3305 current_segment[0] = global_vertex_id_v_1;
3306 current_segment[1] = global_vertex_id_v;
3307 global_segments.push_back(current_segment);
3310 global_segment_markers.push_back(bound_id);
3329 const unsigned n_global_segments = global_segments.size();
3335 (
double *) malloc(triangulate_io.
numberofpoints * 2 *
sizeof(
double));
3347 for (
unsigned i = 0;
i < n_global_vertices;
i++, ii+=2)
3349 triangulate_io.
pointlist[ii] = global_vertices[
i][0];
3350 triangulate_io.
pointlist[ii+1] = global_vertices[
i][1];
3356 for (
unsigned i = 0;
i < n_global_segments;
i++, ii+=2)
3360 triangulate_io.
segmentlist[ii] = global_segments[
i][0] + 1;
3361 triangulate_io.
segmentlist[ii+1] = global_segments[
i][1] + 1;
3370 unsigned n_regions = regions_coordinates.size();
3382 regions_coordinates.begin();
3383 it_regions != regions_coordinates.end();
3387 unsigned region_id = (*it_regions).first;
3389 triangulate_io.
regionlist[4*p-4] = ((*it_regions).second)[0];
3391 triangulate_io.
regionlist[4*p-3] = ((*it_regions).second)[1];
3393 triangulate_io.
regionlist[4*p-2] =
static_cast<double>(region_id);
3396 triangulate_io.
regionlist[4*p-1] = regions_areas[region_id];
3407 const unsigned n_extra_holes = extra_holes_coordinates.size();
3411 for(
unsigned h = 0; h < n_internal_polygons; h++)
3413 if (!internal_polygons_pt[h]->internal_point().empty())
3415 internal_polygon_marked_as_hole.push_back(h);
3421 const unsigned n_internal_polygons_are_holes =
3422 internal_polygon_marked_as_hole.size();
3426 n_internal_polygons_are_holes;
3430 (
double*) malloc(triangulate_io.
numberofholes * 2 *
sizeof(
double));
3433 unsigned count_hole = 0;
3435 for(; count_hole < n_internal_polygons_are_holes*2; count_hole+=2)
3437 const unsigned index_intenal_polygon_is_hole =
3438 internal_polygon_marked_as_hole[count_hole/2];
3439 triangulate_io.
holelist[count_hole]=
3440 internal_polygons_pt[index_intenal_polygon_is_hole]->internal_point()[0];
3441 triangulate_io.
holelist[count_hole+1]=
3442 internal_polygons_pt[index_intenal_polygon_is_hole]->internal_point()[1];
3446 for (
unsigned i_eh = 0;
3447 count_hole < 2*(n_extra_holes + n_internal_polygons_are_holes);
3448 count_hole+=2, i_eh++)
3450 triangulate_io.
holelist[count_hole] = extra_holes_coordinates[i_eh][0];
3451 triangulate_io.
holelist[count_hole+1] = extra_holes_coordinates[i_eh][1];
3469 const unsigned bound_id = polyline_pt->
boundary_id();
3482 connection_matrix[bound_id][bound_chunk].resize(2);
3492 connection_matrix[bound_id][bound_chunk][0] = default_vertex_connection_info;
3494 connection_matrix[bound_id][bound_chunk][1] = default_vertex_connection_info;
3497 if (connected_init_end)
3520 connection_matrix[bound_id][bound_chunk][0] = initial_vertex_info;
3524 if (connected_final_end)
3547 connection_matrix[bound_id][bound_chunk][1] = final_vertex_info;
3556 if (next_polyline_pt != 0)
3559 const unsigned next_bound_id = next_polyline_pt->
boundary_id();
3562 const unsigned next_bound_chunk = next_polyline_pt->
boundary_chunk();
3576 connection_matrix[bound_id][bound_chunk][1] = final_vertex_info;
3594 const unsigned bound_id = polyline_pt->
boundary_id();
3614 base_vertices[bound_id][bound_chunk].resize(2);
3616 base_vertices[bound_id][bound_chunk][0] = default_base_vertex_info;
3618 base_vertices[bound_id][bound_chunk][1] = default_base_vertex_info;
3631 std::map<
unsigned, std::map<unsigned, unsigned> >
3632 &boundary_chunk_nvertices)
3637 const unsigned bound_id = polyline_pt->
boundary_id();
3640 const unsigned n_vertices = polyline_pt->
nvertex();
3646 std::map<Vector<unsigned>,
bool > done;
3649 for (
unsigned v = 0; v < n_vertices; v++)
3655 bool repeat =
false;
3659 unsigned ibnd_id = bound_id;
3660 unsigned ibnd_chunk = bound_chunk;
3661 unsigned ivertex_number = v;
3664 unsigned base_bnd_id = 0;
3665 unsigned base_bnd_chunk = 0;
3666 unsigned base_vertex_number = 0;
3680 const unsigned i_n_vertices =
3681 boundary_chunk_nvertices[ibnd_id][ibnd_chunk];
3684 bool is_initial =
false;
3685 if (ivertex_number == 0) {is_initial =
true;}
3686 bool is_final =
false;
3687 if (ivertex_number == i_n_vertices - 1) {is_final =
true;}
3690 if (is_initial || is_final)
3698 current_vertex_base_info = base_vertices[ibnd_id][ibnd_chunk][0];
3703 current_vertex_base_info = base_vertices[ibnd_id][ibnd_chunk][1];
3714 connection_matrix[ibnd_id][ibnd_chunk][0];
3718 vertex_connect_info =
3719 connection_matrix[ibnd_id][ibnd_chunk][0];
3723 vertex_connect_info =
3724 connection_matrix[ibnd_id][ibnd_chunk][1];
3730 const bool current_is_connected =
3734 if (current_is_connected)
3737 const unsigned iibnd_id =
3741 const unsigned iibnd_chunk =
3745 const unsigned iivertex_number =
3749 const unsigned ii_n_vertices =
3750 boundary_chunk_nvertices[iibnd_id][iibnd_chunk];
3754 bool new_is_initial =
false;
3755 if (iivertex_number == 0) {new_is_initial =
true;}
3756 bool new_is_final =
false;
3757 if (iivertex_number == ii_n_vertices - 1) {new_is_final =
true;}
3760 if (new_is_initial || new_is_final)
3768 new_vertex_base_info =
3769 base_vertices[iibnd_id][iibnd_chunk][0];
3771 else if (new_is_final)
3774 new_vertex_base_info =
3775 base_vertices[iibnd_id][iibnd_chunk][1];
3780 check_done[0] = iibnd_id;
3781 check_done[1] = iibnd_chunk;
3782 check_done[2] = iivertex_number;
3784 if (!done[check_done])
3789 iter_bnd_id.push_back(ibnd_id);
3790 iter_bnd_chunk.push_back(ibnd_chunk);
3791 iter_vertex_number.push_back(ivertex_number);
3794 current_done[0] = ibnd_id;
3795 current_done[1] = ibnd_chunk;
3796 current_done[2] = ivertex_number;
3799 done[current_done] =
true;
3803 ibnd_chunk = iibnd_chunk;
3804 ivertex_number = iivertex_number;
3819 iter_bnd_id.push_back(ibnd_id);
3820 iter_bnd_chunk.push_back(ibnd_chunk);
3821 iter_vertex_number.push_back(ivertex_number);
3830 current_done[0] = ibnd_id;
3831 current_done[1] = ibnd_chunk;
3832 current_done[2] = ivertex_number;
3835 done[current_done] =
true;
3842 base_vertices[ibnd_id][ibnd_chunk][0].is_base_vertex =
3848 base_vertices[ibnd_id][ibnd_chunk][1].is_base_vertex =
3854 base_bnd_id = ibnd_id;
3856 base_bnd_chunk = ibnd_chunk;
3858 base_vertex_number = ivertex_number;
3867 current_done[0] = ibnd_id;
3868 current_done[1] = ibnd_chunk;
3869 current_done[2] = ivertex_number;
3872 done[current_done] =
true;
3876 base_bnd_id = iibnd_id;
3878 base_bnd_chunk = iibnd_chunk;
3880 base_vertex_number = iivertex_number;
3891 iter_bnd_id.push_back(ibnd_id);
3892 iter_bnd_chunk.push_back(ibnd_chunk);
3893 iter_vertex_number.push_back(ivertex_number);
3896 current_done[0] = ibnd_id;
3897 current_done[1] = ibnd_chunk;
3898 current_done[2] = ivertex_number;
3901 done[current_done] =
true;
3905 base_bnd_id = iibnd_id;
3907 base_bnd_chunk = iibnd_chunk;
3909 base_vertex_number = iivertex_number;
3919 iter_bnd_id.push_back(ibnd_id);
3920 iter_bnd_chunk.push_back(ibnd_chunk);
3921 iter_vertex_number.push_back(ivertex_number);
3924 current_done[0] = ibnd_id;
3925 current_done[1] = ibnd_chunk;
3926 current_done[2] = ivertex_number;
3929 done[current_done] =
true;
3935 base_vertices[ibnd_id][ibnd_chunk][0].is_base_vertex =
true;
3940 base_vertices[ibnd_id][ibnd_chunk][1].is_base_vertex =
true;
3945 base_bnd_id = ibnd_id;
3947 base_bnd_chunk = ibnd_chunk;
3949 base_vertex_number = ivertex_number;
3960 base_bnd_id = ibnd_id;
3962 base_bnd_chunk = ibnd_chunk;
3964 base_vertex_number = ivertex_number;
3975 base_bnd_id = current_vertex_base_info.
boundary_id;
3979 base_vertex_number = current_vertex_base_info.
vertex_number;
3990 const unsigned n_vertex_references = iter_bnd_id.size();
3992 for (
unsigned r = 0; r < n_vertex_references; r++)
3995 const unsigned rbnd_id = iter_bnd_id[r];
3996 const unsigned rbnd_chunk = iter_bnd_chunk[r];
3997 const unsigned rvertex_number = iter_vertex_number[r];
4001 const unsigned r_n_vertices =
4002 boundary_chunk_nvertices[rbnd_id][rbnd_chunk];
4005 bool is_initial =
false;
4006 if (rvertex_number == 0) {is_initial =
true;}
4007 bool is_final =
false;
4008 if (rvertex_number == r_n_vertices - 1) {is_final =
true;}
4015 base_vertices[rbnd_id][rbnd_chunk][0].has_base_vertex_assigned =
true;
4017 base_vertices[rbnd_id][rbnd_chunk][0].boundary_id = base_bnd_id;
4019 base_vertices[rbnd_id][rbnd_chunk][0].boundary_chunk = base_bnd_chunk;
4021 base_vertices[rbnd_id][rbnd_chunk][0].vertex_number=base_vertex_number;
4028 base_vertices[rbnd_id][rbnd_chunk][1].has_base_vertex_assigned =
true;
4030 base_vertices[rbnd_id][rbnd_chunk][1].boundary_id = base_bnd_id;
4032 base_vertices[rbnd_id][rbnd_chunk][1].boundary_chunk = base_bnd_chunk;
4034 base_vertices[rbnd_id][rbnd_chunk][1].vertex_number=base_vertex_number;
4054 unsigned n_bound = this->nboundary();
4055 for (
unsigned b = 0; b < n_bound; b++)
4058 GeomObject*
const geom_object_pt = this->boundary_geom_object_pt(b);
4061 if (geom_object_pt != 0)
4065 const unsigned n_boundary_node = this->nboundary_node(b);
4066 for (
unsigned n = 0; n < n_boundary_node; ++n)
4069 Node*
const nod_pt = this->boundary_node_pt(b,n);
4076 for (
unsigned t = 0;
t < n_tvalues; ++
t)
4079 geom_object_pt->
position(
t,b_coord,new_x);
4082 for (
unsigned i = 0;
i < 2;
i++)
4084 nod_pt->
x(
t,
i) = new_x[
i];
4099 const unsigned n_vertex=polygon_vertices.size();
4105 unsigned intersect_counter=0;
4109 for (
unsigned i=1;
i<=n_vertex;
i++)
4114 if (point[1] > std::min(p1[1],p2[1]))
4116 if (point[1] <= std::max(p1[1],p2[1]))
4118 if (point[0] <= std::max(p1[0],p2[0]))
4122 double xintersect=(point[1]-p1[1])*(p2[0]-p1[0])/(p2[1]-p1[1])+p1[0];
4123 if ((p1[0]==p2[0]) || (point[0]<=xintersect))
4125 intersect_counter++;
4135 if (intersect_counter%2==0)
4153 unsigned &vertex_number)
4157 bool found_vertex_number =
false;
4160 const unsigned n_vertices = dst_polyline_pt->
nvertex();
4164 for (
unsigned i = 0;
i < n_vertices;
i++)
4171 (vertex_coordinates[0] - current_vertex[0])*
4172 (vertex_coordinates[0] - current_vertex[0])
4174 (vertex_coordinates[1] - current_vertex[1])*
4175 (vertex_coordinates[1] - current_vertex[1]);
4185 found_vertex_number =
true;
4193 return found_vertex_number;
4197 #ifdef OOMPH_HAS_TRIANGLE_LIB 4208 const bool initial_connection=
4212 const bool final_connection=
4216 if (initial_connection || final_connection)
4236 bool copy_reversed=
false;
4239 double dist_initial=
4240 ((output_initial_vertex[0] - input_initial_vertex[0]) *
4241 (output_initial_vertex[0] - input_initial_vertex[0]))
4243 ((output_initial_vertex[1] - input_initial_vertex[1]) *
4244 (output_initial_vertex[1] - input_initial_vertex[1]));
4245 dist_initial=sqrt(dist_initial);
4249 ((output_final_vertex[0] - input_final_vertex[0]) *
4250 (output_final_vertex[0] - input_final_vertex[0]))
4252 ((output_final_vertex[1] - input_final_vertex[1]) *
4253 (output_final_vertex[1] - input_final_vertex[1]));
4254 dist_final=sqrt(dist_final);
4258 const double dist=dist_initial + dist_final;
4262 double dist_initial_rev=
4263 ((input_initial_vertex[0] - output_final_vertex[0]) *
4264 (input_initial_vertex[0] - output_final_vertex[0]))
4266 ((input_initial_vertex[1] - output_final_vertex[1]) *
4267 (input_initial_vertex[1] - output_final_vertex[1]));
4268 dist_initial_rev=sqrt(dist_initial_rev);
4272 double dist_final_rev=
4273 ((input_final_vertex[0] - output_initial_vertex[0]) *
4274 (input_final_vertex[0] - output_initial_vertex[0]))
4276 ((input_final_vertex[1] - output_initial_vertex[1]) *
4277 (input_final_vertex[1] - output_initial_vertex[1]));
4278 dist_final_rev=sqrt(dist_final_rev);
4282 const double dist_rev=dist_initial_rev + dist_final_rev;
4286 if (dist <= dist_rev)
4289 copy_reversed=
false;
4291 else if (dist_rev < dist)
4317 double initial_s_connection =
4323 double s_tolerance =
4327 get_associated_vertex_to_svalue(
4328 initial_s_connection, bnd_id, s_tolerance);
4359 double final_s_connection =
4365 double s_tolerance =
4369 get_associated_vertex_to_svalue(
4370 final_s_connection, bnd_id, s_tolerance);
4406 double initial_s_connection =
4412 double s_tolerance =
4416 get_associated_vertex_to_svalue(
4417 initial_s_connection, bnd_id, s_tolerance);
4447 double final_s_connection =
4453 double s_tolerance =
4457 get_associated_vertex_to_svalue(
4458 final_s_connection, bnd_id, s_tolerance);
4485 const bool initial_connection=
4489 const bool final_connection=
4493 if (initial_connection || final_connection)
4513 bool copy_reversed=
false;
4516 double dist_initial=
4517 ((output_initial_vertex[0] - input_initial_vertex[0]) *
4518 (output_initial_vertex[0] - input_initial_vertex[0]))
4520 ((output_initial_vertex[1] - input_initial_vertex[1]) *
4521 (output_initial_vertex[1] - input_initial_vertex[1]));
4522 dist_initial=sqrt(dist_initial);
4526 ((output_final_vertex[0] - input_final_vertex[0]) *
4527 (output_final_vertex[0] - input_final_vertex[0]))
4529 ((output_final_vertex[1] - input_final_vertex[1]) *
4530 (output_final_vertex[1] - input_final_vertex[1]));
4531 dist_final=sqrt(dist_final);
4535 const double dist=dist_initial + dist_final;
4539 double dist_initial_rev=
4540 ((input_initial_vertex[0] - output_final_vertex[0]) *
4541 (input_initial_vertex[0] - output_final_vertex[0]))
4543 ((input_initial_vertex[1] - output_final_vertex[1]) *
4544 (input_initial_vertex[1] - output_final_vertex[1]));
4545 dist_initial_rev=sqrt(dist_initial_rev);
4549 double dist_final_rev=
4550 ((input_final_vertex[0] - output_initial_vertex[0]) *
4551 (input_final_vertex[0] - output_initial_vertex[0]))
4553 ((input_final_vertex[1] - output_initial_vertex[1]) *
4554 (input_final_vertex[1] - output_initial_vertex[1]));
4555 dist_final_rev=sqrt(dist_final_rev);
4559 const double dist_rev=dist_initial_rev + dist_final_rev;
4563 if (dist <= dist_rev)
4566 copy_reversed=
false;
4568 else if (dist_rev < dist)
4599 double initial_s_connection =
4605 double s_tolerance =
4609 get_associated_vertex_to_svalue(
4610 initial_s_connection, bnd_id, s_tolerance);
4643 double final_s_connection =
4649 double s_tolerance =
4653 get_associated_vertex_to_svalue(
4654 final_s_connection, bnd_id, s_tolerance);
4692 double initial_s_connection =
4698 double s_tolerance =
4702 get_associated_vertex_to_svalue(
4703 initial_s_connection, bnd_id, s_tolerance);
4737 double final_s_connection =
4743 double s_tolerance =
4747 get_associated_vertex_to_svalue(
4748 final_s_connection, bnd_id, s_tolerance);
4772 #endif // OOMPH_HAS_TRIANGLE_LIB TriangleMeshClosedCurve(const Vector< TriangleMeshCurveSection *> &curve_section_pt, const Vector< double > &internal_point_pt=Vector< double >(0), const bool &is_internal_point_fixed=false)
Constructor prototype.
virtual TriangleMeshCurveSection * curve_section_pt(const unsigned &i) const
Pointer to i-th constituent curve section.
unsigned boundary_chunk() const
void add_base_vertex_info_helper(TriangleMeshPolyLine *polyline_pt, std::map< unsigned, std::map< unsigned, Vector< base_vertex_info > > > &base_vertices, std::map< unsigned, std::map< unsigned, Vector< vertex_connection_info > > > &connection_matrix, std::map< unsigned, std::map< unsigned, unsigned > > &boundary_chunk_nvertices)
Helps to identify the base vertex of the given polyline.
double * pointlist
Pointer to list of points x coordinate followed by y coordinate.
void set_initial_vertex_connected()
Sets the initial vertex as connected.
double * pointattributelist
Pointer to list of point attributes.
int * pointmarkerlist
Pointer to list of point markers.
void write_triangulateio_to_polyfile(TriangulateIO &triangle_io, std::ostream &poly_file)
Write the triangulateio data to disk as a poly file, mainly used for debugging.
void connect_final_vertex_to_curviline(TriangleMeshCurviLine *curviline_pt, const double &s_value, const double &tolerance_for_connection=1.0e-14)
Connects the final vertex of the curve section to a desired target curviline by specifying the s valu...
TriangleMeshPolyLine * polyline_pt(const unsigned &i) const
Pointer to i-th constituent polyline.
virtual void initial_vertex_coordinate(Vector< double > &vertex)=0
Get first vertex coordinates.
Data structure filled when the connection matrix is created, for each polyline, there are two vertex_...
double final_s_connection_value() const
Gets the s value to which the final end is connected.
double zeta_end()
End coordinate in terms of the GeomObject's intrinsic coordinate.
bool has_base_vertex_assigned
void unset_initial_vertex_connected_to_curviline()
Sets the initial vertex as non connected to a curviline.
unsigned final_vertex_connected_n_chunk() const
Gets the boundary chunk to which the final end is connected.
unsigned vertex_number_to_connect
double zeta_start()
Start coordinate in terms of the GeomObject's intrinsic coordinate.
unsigned boundary_chunk_to_connect
TimeStepper *& position_time_stepper_pt()
Return a pointer to the position timestepper.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
void connect_initial_vertex_to_curviline(TriangleMeshCurviLine *curviline_pt, const double &s_value, const double &tolerance_for_connection=1.0e-14)
Connects the initial vertex of the curve section to a desired target curviline by specifying the s va...
virtual void position(const Vector< double > &zeta, Vector< double > &r) const =0
Parametrised position on object at current time: r(zeta).
TriangleMeshPolyLine * polyline_pt(const unsigned &i) const
Pointer to i-th constituent polyline.
unsigned boundary_id() const
Boundary ID.
bool is_initial_vertex_connected() const
Test whether initial vertex is connected or not.
virtual void get_coordinates_on_boundary(const unsigned &b, const unsigned &k, Vector< double > &boundary_zeta)
Return the vector of the k-th generalised boundary coordinates on mesh boundary b. Broken virtual interface provides run-time error checking.
Data structure to store the base vertex info, initial or final vertex in the polylines have an associ...
void create_triangulateio_from_polyfiles(const std::string &node_file_name, const std::string &element_file_name, const std::string &poly_file_name, TriangulateIO &triangle_io, bool &use_attributes)
bool is_final_vertex_connected_to_curviline() const
Test whether the final vertex is connected to a curviline.
const bool get_connected_vertex_number_on_destination_polyline(TriangleMeshPolyLine *dst_polyline_pt, Vector< double > &vertex_coordinates, unsigned &vertex_number)
Gets the vertex number on the destination polyline (used to create the connections among shared bound...
GeomObject * geom_object_pt()
Pointer to GeomObject that represents this part of the boundary.
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Vector< double > Internal_point_pt
Vector of vertex coordinates.
unsigned nvertex() const
Number of vertices.
Class defining a polyline for use in Triangle Mesh generation.
void connect_final_vertex_to_polyline(TriangleMeshPolyLine *polyline_pt, const unsigned &vertex_number, const double &tolerance_for_connection=1.0e-14)
Connects the final vertex of the curve section to a desired target polyline by specifying the vertex ...
unsigned initial_vertex_connected_n_vertex() const
Gets the vertex number to which the initial end is connected.
unsigned boundary_id() const
Boundary id.
void clear_triangulateio(TriangulateIO &triangulate_io, const bool &clear_hole_data)
Clear TriangulateIO structure.
void add_connection_matrix_info_helper(TriangleMeshPolyLine *polyline_pt, std::map< unsigned, std::map< unsigned, Vector< vertex_connection_info > > > &connection_matrix, TriangleMeshPolyLine *next_polyline_pt=0)
Helps to add information to the connection matrix of the given polyline.
double * triangleattributelist
double Tolerable_error
Acceptable discrepancy for mismatch in vertex coordinates. In paranoid mode, the code will die if the...
TriangleMeshOpenCurve(const Vector< TriangleMeshCurveSection *> &curve_section_pt)
Constructor.
virtual void final_vertex_coordinate(Vector< double > &vertex)=0
Get last vertex coordinates.
unsigned boundary_chunk() const
void connect_initial_vertex_to_polyline(TriangleMeshPolyLine *polyline_pt, const unsigned &vertex_number, const double &tolerance_for_connection=1.0e-14)
Connects the initial vertex of the curve section to a desired target polyline by specifying the verte...
bool is_final_vertex_connected() const
Test whether final vertex is connected or not.
void set_final_vertex_connected()
Sets the final vertex as connected.
void snap_nodes_onto_geometric_objects()
Snap the boundary nodes onto any curvilinear boundaries defined by geometric objects.
void copy_connection_information_to_sub_polylines(TriangleMeshCurveSection *input_curve_pt, TriangleMeshCurveSection *output_curve_pt)
Helper function to copy the connection information from the input curve(polyline or curviline) to the...
void build_triangulateio(Vector< TriangleMeshPolygon *> &outer_polygons_pt, Vector< TriangleMeshPolygon *> &internal_polygons_pt, Vector< TriangleMeshOpenCurve *> &open_curves_pt, Vector< Vector< double > > &extra_holes_coordinates, std::map< unsigned, Vector< double > > ®ions_coordinates, std::map< unsigned, double > ®ions_areas, TriangulateIO &triangulate_io)
Create TriangulateIO object from outer boundaries, internal boundaries, and open curves. Add the holes and regions information as well.
Base class defining a closed curve for the Triangle mesh generation.
Vector< TriangleMeshCurveSection * > Curve_section_pt
Vector of curve sections.
void initialise_triangulateio(TriangulateIO &triangle_io)
Initialise TriangulateIO structure.
double tolerance_for_s_connection() const
Gets the tolerance value for connections among curvilines.
int numberoftriangleattributes
int numberofpointattributes
TriangulateIO deep_copy_of_triangulateio_representation(TriangulateIO &triangle_io, const bool &quiet)
Make (partial) deep copy of TriangulateIO object. We only copy those items we need within oomph-lib's...
TriangleMeshPolygon(const Vector< TriangleMeshCurveSection *> &boundary_polyline_pt, const Vector< double > &internal_point_pt=Vector< double >(0), const bool &is_internal_point_fixed=false)
Constructor: Specify vector of pointers to TriangleMeshCurveSection that define the boundary of the s...
void dump_triangulateio(TriangulateIO &triangle_io, std::ostream &dump_file)
Write all the triangulateio data to disk in a dump file that can then be used to restart simulations...
void copy_connection_information(TriangleMeshCurveSection *input_curve_pt, TriangleMeshCurveSection *output_curve_pt)
Helper function to copy the connection information from the input curve(polyline or curviline) to the...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
unsigned boundary_id_to_connect
double * trianglearealist
bool is_internal_point_fixed() const
Test whether the internal point is fixed.
Vector< double > vertex_coordinate(const unsigned &i) const
Coordinate vector of i-th vertex (const version)
double initial_s_connection_value() const
Gets the s value to which the initial end is connected.
unsigned final_vertex_connected_bnd_id() const
Gets the id to which the final end is connected.
unsigned initial_vertex_connected_n_chunk() const
Gets the boundary chunk to which the initial end is connected.
void read_triangulateio(std::istream &restart_file, TriangulateIO &triangle_io)
Read the triangulateio data from a dump file on disk, which can then be used to restart simulations...
void unset_final_vertex_connected_to_curviline()
Sets the final vertex as non connected to a curviline.
static bool Suppress_warning_about_regions_and_boundaries
Public static flag to suppress warning; defaults to false.
virtual unsigned nprev_values() const =0
Number of previous values available: 0 for static, 1 for BDF<1>,...
void initialise_base_vertex(TriangleMeshPolyLine *polyline_pt, std::map< unsigned, std::map< unsigned, Vector< base_vertex_info > > > &base_vertices)
Initialise the base vertex structure, set every vertex to no visited and not being a base vertex...
unsigned final_vertex_connected_n_vertex() const
Sets the vertex number to which the final end is connected.
void add_connection_point(const double &z_value, const double &tol=1.0e-12)
bool is_initial_vertex_connected_to_curviline() const
Test whether the initial vertex is connected to a curviline.
bool is_point_inside_polygon_helper(Vector< Vector< double > > polygon_vertices, Vector< double > point)
Helper function that checks if a given point is inside a polygon.
unsigned initial_vertex_connected_bnd_id() const
Gets the id to which the initial end is connected.
unsigned npolyline() const
Number of constituent polylines.