36 #ifdef OOMPH_HAS_TRIANGLE_LIB
41 namespace TriangleHelper
45 const bool& clear_hole_data)
69 if (clear_hole_data) free(triangulate_io.
holelist);
115 triangle_io.
holelist = (
double*)NULL;
125 triangle_io.
normlist = (
double*)NULL;
146 (
double*)malloc(triangle_out.
numberofpoints * 2 *
sizeof(
double));
166 "Point attributes are not currently copied across",
167 "TriangleHelper::deep_copy_of_triangulateio_representation",
168 OOMPH_EXCEPTION_LOCATION);
213 "Triangle areas are not currently copied across",
214 "TriangleHelper::deep_copy_of_triangulateio_representation",
215 OOMPH_EXCEPTION_LOCATION);
221 "Triangle neighbours are not currently copied across",
222 "TriangleHelper::deep_copy_of_triangulateio_representation",
223 OOMPH_EXCEPTION_LOCATION);
258 (
double*)malloc(triangle_out.
numberofholes * 2 *
sizeof(
double));
280 "Edges are not currently copied across",
281 "TriangleHelper::deep_copy_of_triangulateio_representation",
282 OOMPH_EXCEPTION_LOCATION);
288 "Edge markers are not currently copied across",
289 "TriangleHelper::deep_copy_of_triangulateio_representation",
290 OOMPH_EXCEPTION_LOCATION);
296 "Normals are not currently copied across",
297 "TriangleHelper::deep_copy_of_triangulateio_representation",
298 OOMPH_EXCEPTION_LOCATION);
309 std::ostream& poly_file)
312 poly_file.precision(20);
317 poly_file << triangle_io.
numberofpoints <<
" " << 2 <<
" " << n_attr
320 bool point_markers =
true;
323 point_markers =
false;
326 poly_file << point_markers <<
"\n";
329 poly_file <<
"#Points\n";
333 poly_file << n + 1 <<
" " << triangle_io.
pointlist[2 * n] <<
" "
334 << triangle_io.
pointlist[2 * n + 1] <<
" ";
336 for (
int i = 0;
i < n_attr; ++
i)
349 poly_file <<
"#Lines\n";
352 bool seg_markers =
true;
358 poly_file << seg_markers <<
"\n";
363 poly_file << n + 1 <<
" " << triangle_io.
segmentlist[2 * n] <<
" "
374 poly_file <<
"#No holes\n";
379 poly_file << h + 1 <<
" " << triangle_io.
holelist[2 * h] <<
" "
380 << triangle_io.
holelist[2 * h + 1] <<
"\n";
384 poly_file <<
"#Assignment of attributes to regions\n";
390 poly_file << r + 1 <<
" ";
391 for (
unsigned i = 0;
i < 4;
i++)
393 poly_file << triangle_io.
regionlist[4 * r +
i] <<
" ";
409 bool& use_attributes)
415 std::ifstream element_file(element_file_name.c_str(), std::ios_base::in);
418 if (!element_file.is_open())
420 std::string error_msg(
"Failed to open element file: ");
421 error_msg +=
"\"" + element_file_name +
"\".";
423 error_msg, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
428 const unsigned n_element =
433 const unsigned n_local_node =
438 const unsigned n_attributes =
446 if (n_attributes > 0)
454 int dummy_element_number;
457 unsigned counter = 0;
458 unsigned counter2 = 0;
461 for (
unsigned e = 0;
e < n_element;
e++)
463 element_file >> dummy_element_number;
464 for (
unsigned j = 0; j < n_local_node; j++)
469 for (
unsigned j = 0; j < n_attributes; j++)
476 element_file.close();
480 std::ifstream node_file(node_file_name.c_str(), std::ios_base::in);
483 if (!node_file.is_open())
485 std::string error_msg(
"Failed to open node file: ");
486 error_msg +=
"\"" + node_file_name +
"\".";
488 error_msg, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
493 unsigned n_node =
static_cast<unsigned>(triangle_io.
numberofpoints);
497 node_file >> dimension;
503 OOMPH_CURRENT_FUNCTION,
504 OOMPH_EXCEPTION_LOCATION);
510 unsigned n_point_attributes =
514 unsigned boundary_markers_flag;
515 node_file >> boundary_markers_flag;
523 if (boundary_markers_flag)
530 unsigned dummy_node_number;
536 for (
unsigned i = 0;
i < n_node;
i++)
538 node_file >> dummy_node_number;
540 node_file >> triangle_io.
pointlist[2 *
i + 1];
541 for (
unsigned j = 0; j < n_point_attributes; ++j)
546 if (boundary_markers_flag)
558 std::ifstream poly_file(poly_file_name.c_str(), std::ios_base::in);
561 if (!poly_file.is_open())
563 std::string error_msg(
"Failed to open poly file: ");
564 error_msg +=
"\"" + poly_file_name +
"\".";
566 error_msg, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
570 unsigned n_node_poly;
571 poly_file >> n_node_poly;
574 poly_file >> dimension;
577 unsigned attribute_flag;
578 poly_file >> attribute_flag;
581 poly_file >> boundary_markers_flag;
587 for (
unsigned i = 0;
i < n_node_poly;
i++)
594 for (
unsigned j = 0; j < attribute_flag; ++j)
599 if (boundary_markers_flag == 1)
613 poly_file >> boundary_markers_flag;
618 if (boundary_markers_flag)
625 unsigned dummy_segment_number;
628 for (
unsigned i = 0;
i < n_segment;
i++)
630 poly_file >> dummy_segment_number;
633 if (boundary_markers_flag)
641 unsigned n_hole =
static_cast<unsigned>(triangle_io.
numberofholes);
645 (
double*)malloc(triangle_io.
numberofholes * 2 *
sizeof(
double));
651 for (
unsigned ihole = 0; ihole < n_hole; ihole++)
654 poly_file >> dummy_hole;
655 poly_file >> triangle_io.
holelist[2 * ihole];
656 poly_file >> triangle_io.
holelist[2 * ihole + 1];
661 unsigned n_regions =
static_cast<unsigned>(triangle_io.
numberofregions);
670 use_attributes =
true;
674 unsigned dummy_region;
677 for (
unsigned iregion = 0; iregion < n_regions; iregion++)
680 poly_file >> dummy_region;
681 poly_file >> triangle_io.
regionlist[4 * iregion];
682 poly_file >> triangle_io.
regionlist[4 * iregion + 1];
683 poly_file >> triangle_io.
regionlist[4 * iregion + 2];
684 triangle_io.
regionlist[4 * iregion + 3] = 0.0;
688 poly_file.ignore(80,
'\n');
691 if (triangle_io.
regionlist[4 * iregion + 2] == 0)
693 std::ostringstream error_message;
695 <<
"Please use another region id different from zero.\n"
696 <<
"It is internally used as the default region number.\n";
698 OOMPH_CURRENT_FUNCTION,
699 OOMPH_EXCEPTION_LOCATION);
713 <<
" # number of elements in TriangulateIO" << std::endl;
716 <<
" # number of nodes in each triangle" << std::endl;
719 <<
" # number of triangle attributes" << std::endl;
725 unsigned counter = 0, counter2 = 0;
726 for (
int e = 0;
e < n_element; ++
e)
729 dump_file <<
e <<
" # element number " << std::endl;
730 for (
int n = 0; n < n_local_node; ++n)
732 dump_file << triangle_io.
trianglelist[counter] << std::endl;
736 dump_file << n_attribute <<
" # number of attributes" << std::endl;
737 for (
int n = 0; n < n_attribute; ++n)
747 <<
" # number of points in TriangulateIO" << std::endl;
749 <<
" # number of point attributes" << std::endl;
751 bool point_marker_flag =
true;
754 point_marker_flag =
false;
756 dump_file << point_marker_flag <<
" # point marker flag" << std::endl;
764 for (
int n = 0; n < n_nodes; ++n)
766 dump_file << n <<
" # point number " << std::endl;
767 for (
int i = 0;
i < 2; ++
i)
769 dump_file << triangle_io.
pointlist[counter] << std::endl;
772 dump_file << n_point_attributes <<
" # number of point attributes "
775 for (
int i = 0;
i < n_point_attributes; ++
i)
780 dump_file << point_marker_flag <<
" # point marker flag " << std::endl;
782 if (point_marker_flag)
790 <<
" # Number of segments in TriangulateIO " << std::endl;
793 bool seg_marker_flag =
true;
796 seg_marker_flag =
false;
799 dump_file << seg_marker_flag <<
" # segment marker flag " << std::endl;
804 for (
int n = 0; n < n_segments; ++n)
806 dump_file << n <<
" # segment number " << std::endl;
807 for (
int i = 0;
i < 2; ++
i)
809 dump_file << triangle_io.
segmentlist[counter] << std::endl;
814 dump_file << seg_marker_flag <<
" # segment marker flag " << std::endl;
822 dump_file << triangle_io.
numberofholes <<
" # number of holes "
826 for (
int h = 0; h < n_hole; ++h)
828 dump_file << h <<
" # hole number " << std::endl;
829 dump_file << triangle_io.
holelist[2 * h] << std::endl;
830 dump_file << triangle_io.
holelist[2 * h + 1] << std::endl;
840 for (
int r = 0; r < n_region; ++r)
842 dump_file << r <<
" # region number " << std::endl;
843 for (
unsigned i = 0;
i < 4;
i++)
845 dump_file << triangle_io.
regionlist[counter] << std::endl;
863 getline(restart_file, input_string,
'#');
865 restart_file.ignore(80,
'\n');
870 getline(restart_file, input_string,
'#');
872 restart_file.ignore(80,
'\n');
877 getline(restart_file, input_string,
'#');
879 restart_file.ignore(80,
'\n');
901 unsigned counter = 0, counter2 = 0;
902 for (
int e = 0;
e < n_element; ++
e)
905 getline(restart_file, input_string);
906 for (
int n = 0; n < n_local_node; ++n)
908 getline(restart_file, input_string);
909 triangle_io.
trianglelist[counter] = atoi(input_string.c_str());
913 getline(restart_file, input_string);
914 for (
int n = 0; n < n_attribute; ++n)
916 getline(restart_file, input_string);
918 atof(input_string.c_str());
925 getline(restart_file, input_string,
'#');
927 restart_file.ignore(80,
'\n');
931 getline(restart_file, input_string,
'#');
933 restart_file.ignore(80,
'\n');
937 getline(restart_file, input_string,
'#');
939 restart_file.ignore(80,
'\n');
940 int point_marker_flag = atoi(input_string.c_str());
948 if (point_marker_flag)
960 for (
int n = 0; n < n_nodes; ++n)
963 getline(restart_file, input_string);
965 for (
int i = 0;
i < 2; ++
i)
967 getline(restart_file, input_string);
968 triangle_io.
pointlist[counter] = atof(input_string.c_str());
973 getline(restart_file, input_string);
976 for (
int i = 0;
i < n_point_attributes; ++
i)
978 getline(restart_file, input_string);
984 getline(restart_file, input_string);
986 if (point_marker_flag)
988 getline(restart_file, input_string);
994 getline(restart_file, input_string,
'#');
995 restart_file.ignore(80,
'\n');
999 getline(restart_file, input_string,
'#');
1001 restart_file.ignore(80,
'\n');
1002 int seg_marker_flag = atoi(input_string.c_str());
1007 if (seg_marker_flag)
1016 for (
int n = 0; n < n_segments; ++n)
1018 getline(restart_file, input_string);
1020 for (
int i = 0;
i < 2; ++
i)
1022 getline(restart_file, input_string);
1023 triangle_io.
segmentlist[counter] = atoi(input_string.c_str());
1028 getline(restart_file, input_string);
1029 if (seg_marker_flag)
1031 getline(restart_file, input_string);
1037 getline(restart_file, input_string,
'#');
1038 restart_file.ignore(80,
'\n');
1043 (
double*)malloc(triangle_io.
numberofholes * 2 *
sizeof(
double));
1047 for (
int h = 0; h < n_hole; ++h)
1050 getline(restart_file, input_string);
1052 getline(restart_file, input_string);
1053 triangle_io.
holelist[2 * h] = atof(input_string.c_str());
1054 getline(restart_file, input_string);
1055 triangle_io.
holelist[2 * h + 1] = atof(input_string.c_str());
1059 getline(restart_file, input_string,
'#');
1060 restart_file.ignore(80,
'\n');
1071 for (
int r = 0; r < n_region; ++r)
1073 getline(restart_file, input_string);
1074 for (
unsigned i = 0;
i < 4;
i++)
1076 getline(restart_file, input_string);
1077 triangle_io.
regionlist[counter] = atof(input_string.c_str());
1095 namespace ToleranceForVertexMismatchInPolygons
1122 const unsigned& vertex_number,
1123 const double& tolerance_for_connection)
1126 unsigned n_vertices = polyline_pt->
nvertex();
1128 if (n_vertices <= vertex_number)
1130 std::ostringstream error_stream;
1131 error_stream <<
"The vertex number you provided (" << vertex_number
1132 <<
") is greater\n than the number of vertices ("
1133 << n_vertices <<
"in the specified TriangleMeshPolyLine.\n"
1134 <<
"Remember that the vertex index starts at 0" << std::endl
1136 <<
") wants to connect "
1137 <<
"to destination boundary (" << polyline_pt->
boundary_id()
1138 <<
")" << std::endl;
1140 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1151 double error = sqrt((v_src[0] - v_dst[0]) * (v_src[0] - v_dst[0]) +
1152 (v_src[1] - v_dst[1]) * (v_src[1] - v_dst[1]));
1154 if (error > tolerance_for_connection)
1156 std::ostringstream error_stream;
1157 error_stream <<
"The associated vertices for the connection"
1158 <<
"\nare not close enough. Their respective values are:\n"
1159 <<
"Source boundary id:(" << this->
boundary_id() <<
")\n"
1160 <<
"Source vertex x:(" << v_src[0] <<
") y:(" << v_src[1]
1162 <<
"Destination boundary id:(" << polyline_pt->
boundary_id()
1164 <<
"\nAssociated vertex x:(" << v_dst[0] <<
") y:("
1166 <<
"\nThe corresponding distance is: (" << error
1168 <<
"allowed\ntolerance is: (" << tolerance_for_connection
1169 <<
")" << std::endl;
1171 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1191 const unsigned& vertex_number,
1192 const double& tolerance_for_connection)
1195 unsigned n_vertices = polyline_pt->
nvertex();
1197 if (n_vertices <= vertex_number)
1199 std::ostringstream error_stream;
1200 error_stream <<
"The vertex number you provided (" << vertex_number
1201 <<
") is greater\n than the number of vertices ("
1202 << n_vertices <<
"in the specified TriangleMeshPolyLine.\n"
1203 <<
"Remember that the vertex index starts at 0" << std::endl
1205 <<
") wants to connect "
1206 <<
"to destination boundary (" << polyline_pt->
boundary_id()
1207 <<
")" << std::endl;
1209 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1220 double error = sqrt((v_src[0] - v_dst[0]) * (v_src[0] - v_dst[0]) +
1221 (v_src[1] - v_dst[1]) * (v_src[1] - v_dst[1]));
1223 if (error > tolerance_for_connection)
1225 std::ostringstream error_stream;
1226 error_stream <<
"The associated vertices for the connection"
1227 <<
"\nare not close enough. Their respective values are:\n"
1228 <<
"Source boundary id:(" << this->
boundary_id() <<
")\n"
1229 <<
"Source vertex x:(" << v_src[0] <<
") y:(" << v_src[1]
1231 <<
"Destination boundary id:(" << polyline_pt->
boundary_id()
1233 <<
"\nAssociated vertex x:(" << v_dst[0] <<
") y:("
1235 <<
"\nThe corresponding distance is: (" << error
1237 <<
"allowed\ntolerance is: (" << tolerance_for_connection
1238 <<
")" << std::endl;
1240 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1261 const double& s_value,
1262 const double& tolerance_for_connection)
1265 double z_initial = curviline_pt->
zeta_start();
1266 double z_final = curviline_pt->
zeta_end();
1267 double z_max = std::max(z_initial, z_final);
1268 double z_min = std::min(z_initial, z_final);
1269 if (s_value < z_min || z_max < s_value)
1271 std::ostringstream error_stream;
1272 error_stream <<
"The s value you provided for connection (" << s_value
1273 <<
") is out\nof the limits of the specified "
1274 <<
"TriangleMeshCurviLine.\nThe limits are [" << z_initial
1275 <<
", " << z_final <<
"]" << std::endl
1277 <<
") wants to connect "
1278 <<
"to destination boundary (" << curviline_pt->
boundary_id()
1279 <<
")" << std::endl;
1281 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1293 double error = sqrt((v_src[0] - v_dst[0]) * (v_src[0] - v_dst[0]) +
1294 (v_src[1] - v_dst[1]) * (v_src[1] - v_dst[1]));
1295 if (error >= tolerance_for_connection)
1297 std::ostringstream error_stream;
1299 <<
"The associated vertex for the provided connection s value\n"
1300 <<
"are not close enough. Their respective values are:\n"
1301 <<
"Source boundary id:(" << this->
boundary_id() <<
")\n"
1302 <<
"Source vertex x:(" << v_src[0] <<
") y:(" << v_src[1] <<
")\n"
1303 <<
"Destination boundary id:(" << curviline_pt->
boundary_id() <<
")"
1304 <<
"\nDestination s value (" << s_value <<
")\n"
1305 <<
"Associated vertex x:(" << v_dst[0] <<
") y:(" << v_dst[1] <<
")"
1306 <<
"\nThe corresponding distance is: (" << error <<
") but the "
1307 <<
"allowed\ntolerance is: (" << tolerance_for_connection <<
")"
1310 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1340 const double& s_value,
1341 const double& tolerance_for_connection)
1344 double z_initial = curviline_pt->
zeta_start();
1345 double z_final = curviline_pt->
zeta_end();
1346 double z_max = std::max(z_initial, z_final);
1347 double z_min = std::min(z_initial, z_final);
1348 if (s_value < z_min || z_max < s_value)
1350 std::ostringstream error_stream;
1351 error_stream <<
"The s value you provided for connection (" << s_value
1352 <<
") is out\nof the limits of the specified "
1353 <<
"TriangleMeshCurviLine.\nThe limits are [" << z_initial
1354 <<
", " << z_final <<
"]" << std::endl
1356 <<
") wants to connect "
1357 <<
"to destination boundary (" << curviline_pt->
boundary_id()
1358 <<
")" << std::endl;
1360 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1373 double error = sqrt((v_src[0] - v_dst[0]) * (v_src[0] - v_dst[0]) +
1374 (v_src[1] - v_dst[1]) * (v_src[1] - v_dst[1]));
1376 if (error >= tolerance_for_connection)
1378 std::ostringstream error_stream;
1380 <<
"The associated vertex for the provided connection s value\n"
1381 <<
"are not close enough. Their respective values are:\n"
1382 <<
"Source boundary id:(" << this->
boundary_id() <<
")\n"
1383 <<
"Source vertex x:(" << v_src[0] <<
") y:(" << v_src[1] <<
")\n"
1384 <<
"Destination boundary id:(" << curviline_pt->
boundary_id() <<
")"
1385 <<
"\nDestination s value (" << s_value <<
")\n"
1386 <<
"Associated vertex x:(" << v_dst[0] <<
") y:(" << v_dst[1] <<
")"
1387 <<
"\nThe corresponding distance is: (" << error <<
") but the "
1388 <<
"allowed\ntolerance is: (" << tolerance_for_connection <<
")"
1391 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1423 const bool& is_internal_point_fixed)
1425 Internal_point_pt(internal_point_pt),
1426 Is_internal_point_fixed(is_internal_point_fixed)
1436 if (n_boundaries < 2)
1438 std::ostringstream error_stream;
1439 error_stream <<
"Sorry -- I'm afraid we insist that a closed curve is\n"
1440 <<
"specified by at least two separate CurveSections.\n"
1441 <<
"You've only specified (" << n_boundaries <<
")"
1444 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1449 for (
unsigned i = 0;
i < n_boundaries - 1;
i++)
1464 double error = sqrt(pow(v1[0] - v2[0], 2) + pow(v1[1] - v2[1], 2));
1468 std::ostringstream error_stream;
1470 <<
"The start and end points of curve section boundary parts\n"
1471 <<
i <<
" and " <<
i + 1
1472 <<
" don't match when judged with the tolerance of "
1474 <<
" which\nis specified in the namespace variable\n"
1475 <<
"ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n"
1476 <<
"These are the vertices coordinates:\n"
1477 <<
"Curve section (" <<
i <<
") final vertex: (" << v1[0] <<
", "
1479 <<
"Curve section (" <<
i + 1 <<
") initial vertex: (" << v2[0]
1480 <<
", " << v2[1] <<
")\n"
1481 <<
"The distance between the vertices is (" << error <<
")\n"
1482 <<
"Feel free to adjust this or to recompile the code without\n"
1483 <<
"paranoia if you think this is OK...\n"
1486 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1497 if (current_polyline && next_polyline)
1499 unsigned last_vertex = current_polyline->
nvertex() - 1;
1520 double error = sqrt(pow(v2[0] - v1[0], 2) + pow(v2[1] - v1[1], 2));
1524 std::ostringstream error_stream;
1526 <<
"The start and end points of the first and last curve segment\n"
1527 <<
"boundary parts don't match when judged \nwith the tolerance of "
1529 <<
" which is specified in the namespace \nvariable "
1530 <<
"ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n"
1531 <<
"Feel free to adjust this or to recompile the code without\n"
1532 <<
"paranoia if you think this is OK...\n"
1535 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1546 if (first_polyline && last_polyline)
1548 unsigned last_vertex = last_polyline->
nvertex() - 1;
1580 const bool& is_internal_point_fixed)
1583 boundary_polyline_pt, internal_point_pt, is_internal_point_fixed),
1584 Enable_redistribution_of_segments_between_polylines(false),
1585 Can_update_configuration(false),
1586 Polygon_fixed(false)
1589 const unsigned n_bound = boundary_polyline_pt.size();
1593 for (
unsigned p = 0; p < n_bound; p++)
1597 if (tmp_polyline_pt == 0)
1599 std::ostringstream error_stream;
1600 error_stream <<
"The (" << p <<
") TriangleMeshCurveSection is not a "
1601 <<
"TriangleMeshPolyLine.\nThe TriangleMeshPolygon object"
1602 <<
"is constituent of only TriangleMeshPolyLine objects.\n"
1603 <<
"Verify that all the constituent elements of the "
1604 <<
"TriangleMeshPolygon\nare instantiated as "
1605 <<
"TriangleMeshPolyLines." << std::endl;
1607 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1612 bool contiguous =
true;
1613 unsigned i_offensive = 0;
1618 std::ostringstream error_stream;
1620 <<
"Sorry -- I'm afraid we insist that a closed curve is\n"
1621 <<
"specified by at least two separate TriangleMeshPolyLines.\n"
1622 <<
"You've only specified (" << n_bound <<
")" << std::endl;
1624 "TriangleMeshPolygon::TriangleMeshPolygon()",
1625 OOMPH_EXCEPTION_LOCATION);
1630 for (
unsigned i = 0;
i < n_bound - 1;
i++)
1640 double error = sqrt(pow(v1[0] - v2[0], 2) + pow(v1[1] - v2[1], 2));
1666 double error = sqrt(pow(v1[0] - v2[0], 2) + pow(v1[1] - v2[1], 2));
1671 i_offensive = n_bound - 1;
1681 std::ostringstream error_stream;
1683 <<
"The polylines specified \n"
1684 <<
"should define a closed geometry, i.e. the first/last vertex of\n"
1685 <<
"adjacent polylines should match.\n\n"
1686 <<
"Your polyline number " << i_offensive
1687 <<
" has no contiguous neighbour, when judged \nwith the tolerance of "
1689 <<
" which is specified in the namespace \nvariable "
1690 <<
"ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n"
1691 <<
"Feel free to adjust this or to recompile the code without\n"
1692 <<
"paranoia if you think this is OK...\n"
1695 "TriangleMeshPolygon::TriangleMeshPolygon()",
1696 OOMPH_EXCEPTION_LOCATION);
1709 unsigned nvertex = 0;
1716 unsigned npolyline = boundary_polyline_pt.size();
1720 unsigned nvert = boundary_polyline_pt[
i]->nvertex();
1721 for (
unsigned j = 0; j < nvert; j++)
1724 if ((
i > 1) && (j == 0))
1727 double dist = sqrt(pow(first_vertex[0] - last_vertex[0], 2) +
1728 pow(first_vertex[1] - last_vertex[1], 2));
1731 std::ostringstream error_stream;
1733 <<
"The start and end points of polylines " <<
i <<
" and "
1734 <<
i + 1 <<
" don't match when judged\n"
1735 <<
"with the tolerance ("
1737 <<
") which is specified in the namespace \nvariable "
1738 <<
"ToleranceForVertexMismatchInPolygons::"
1739 <<
"Tolerable_error.\n\n"
1740 <<
"Feel free to adjust this or to recompile the "
1742 <<
"paranoia if you think this is OK...\n"
1745 "TriangleMeshPolygon::TriangleMeshPolygon()",
1746 OOMPH_EXCEPTION_LOCATION);
1752 polygon_vertex.push_back(
polyline_pt(
i)->vertex_coordinate(j));
1763 nvertex = polygon_vertex.size();
1766 unsigned intersect_counter = 0;
1770 for (
unsigned i = 1;
i <= nvertex;
i++)
1784 (p2[0] - p1[0]) / (p2[1] - p1[1]) +
1788 intersect_counter++;
1798 if (intersect_counter % 2 == 0)
1800 std::ostringstream error_stream;
1804 <<
" isn't in the polygon that describes the internal closed "
1805 <<
"curve!\nPolygon vertices are at: \n";
1806 for (
unsigned i = 0;
i < nvertex;
i++)
1808 error_stream << polygon_vertex[
i][0] <<
" " << polygon_vertex[
i][1]
1812 <<
"This may be because the internal point is defined by a\n"
1813 <<
"GeomObject that has deformed so much that it's \n"
1814 <<
"swept over the (initial) internal point.\n"
1815 <<
"If so, you should update the position of the internal point. \n"
1816 <<
"This could be done automatically by generating \n"
1817 <<
"an internal mesh inside the polygon and using one\n"
1818 <<
"of its internal nodes as the internal point. Actually not \n"
1819 <<
"why triangle doesn't do that automatically....\n";
1821 "TriangleMeshPolygon::TriangleMeshPolygon()",
1822 OOMPH_EXCEPTION_LOCATION);
1849 for (
unsigned i = 0;
i < n_boundaries - 1;
i++)
1862 double error = sqrt(pow(v1[0] - v2[0], 2) + pow(v1[1] - v2[1], 2));
1865 std::ostringstream error_stream;
1867 <<
"The start and end points of curve section boundary parts " <<
i
1869 <<
" don't match when judged \nwith the tolerance of "
1871 <<
" which is specified in the namespace \nvariable "
1872 <<
"ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n"
1873 <<
"Feel free to adjust this or to recompile the code without\n"
1874 <<
"paranoia if you think this is OK...\n"
1877 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1887 if (current_polyline && next_polyline)
1889 unsigned last_vertex = current_polyline->
nvertex() - 1;
1898 #ifdef OOMPH_HAS_TRIANGLE_LIB
1911 std::map<unsigned, double>& regions_areas,
1946 std::map<unsigned, std::map<unsigned, unsigned>> boundary_chunk_n_vertices;
1969 std::map<unsigned, std::map<unsigned, Vector<vertex_connection_info>>>
1990 std::map<unsigned, std::map<unsigned, Vector<base_vertex_info>>>
1994 const unsigned n_outer_polygons = outer_polygons_pt.size();
1996 for (
unsigned i = 0;
i < n_outer_polygons;
i++)
1999 const unsigned n_polylines = outer_polygons_pt[
i]->npolyline();
2001 for (
unsigned p = 0; p < n_polylines; p++)
2005 outer_polygons_pt[
i]->polyline_pt(p);
2008 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2011 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2018 boundary_chunk_n_vertices[bound_id][bound_chunk] = n_vertices;
2024 if (p < n_polylines - 1)
2027 next_polyline_pt = outer_polygons_pt[
i]->polyline_pt(p + 1);
2032 next_polyline_pt = outer_polygons_pt[
i]->polyline_pt(0);
2037 tmp_polyline_pt, connection_matrix, next_polyline_pt);
2048 const unsigned n_internal_polygons = internal_polygons_pt.size();
2050 for (
unsigned i = 0;
i < n_internal_polygons;
i++)
2053 const unsigned n_polylines = internal_polygons_pt[
i]->npolyline();
2055 for (
unsigned p = 0; p < n_polylines; p++)
2059 internal_polygons_pt[
i]->polyline_pt(p);
2062 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2065 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2072 boundary_chunk_n_vertices[bound_id][bound_chunk] = n_vertices;
2078 if (p < n_polylines - 1)
2081 next_polyline_pt = internal_polygons_pt[
i]->polyline_pt(p + 1);
2086 next_polyline_pt = internal_polygons_pt[
i]->polyline_pt(0);
2091 tmp_polyline_pt, connection_matrix, next_polyline_pt);
2102 const unsigned n_open_curves = open_curves_pt.size();
2104 for (
unsigned i = 0;
i < n_open_curves;
i++)
2107 const unsigned n_polylines = open_curves_pt[
i]->ncurve_section();
2109 for (
unsigned p = 0; p < n_polylines; p++)
2113 open_curves_pt[
i]->polyline_pt(p);
2116 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2119 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2126 boundary_chunk_n_vertices[bound_id][bound_chunk] = n_vertices;
2132 if (p < n_polylines - 1)
2135 next_polyline_pt = open_curves_pt[
i]->polyline_pt(p + 1);
2145 tmp_polyline_pt, connection_matrix, next_polyline_pt);
2164 for (
unsigned i = 0;
i < n_outer_polygons;
i++)
2167 const unsigned n_polylines = outer_polygons_pt[
i]->npolyline();
2169 for (
unsigned p = 0; p < n_polylines; p++)
2173 outer_polygons_pt[
i]->polyline_pt(p);
2179 boundary_chunk_n_vertices);
2187 for (
unsigned i = 0;
i < n_internal_polygons;
i++)
2190 const unsigned n_polylines = internal_polygons_pt[
i]->npolyline();
2192 for (
unsigned p = 0; p < n_polylines; p++)
2196 internal_polygons_pt[
i]->polyline_pt(p);
2202 boundary_chunk_n_vertices);
2210 for (
unsigned i = 0;
i < n_open_curves;
i++)
2213 const unsigned n_polylines = open_curves_pt[
i]->ncurve_section();
2215 for (
unsigned p = 0; p < n_polylines; p++)
2219 open_curves_pt[
i]->polyline_pt(p);
2225 boundary_chunk_n_vertices);
2243 std::map<unsigned, std::map<unsigned, Vector<int>>>
2244 boundary_chunk_vertex_to_global_vertex_id;
2249 for (std::map<
unsigned, std::map<unsigned, unsigned>>::iterator it =
2250 boundary_chunk_n_vertices.begin();
2251 it != boundary_chunk_n_vertices.end();
2255 const unsigned b = (*it).first;
2258 for (std::map<unsigned, unsigned>::iterator itt = (*it).second.begin();
2259 itt != (*it).second.end();
2263 const unsigned c = (*itt).first;
2267 const unsigned n_vertices = boundary_chunk_n_vertices[b][c];
2271 boundary_chunk_vertex_to_global_vertex_id[b][c].resize(n_vertices, -1);
2278 unsigned global_vertex_number = 0;
2288 unsigned n_vertices_outer_polygons = 0;
2291 for (
unsigned i = 0;
i < n_outer_polygons;
i++)
2294 const unsigned n_polylines = outer_polygons_pt[
i]->npolyline();
2296 for (
unsigned p = 0; p < n_polylines; p++)
2300 outer_polygons_pt[
i]->polyline_pt(p);
2303 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2306 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2316 base_vertices[bound_id][bnd_chunk][0];
2321 std::ostringstream error_message;
2323 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2325 <<
"The initial vertex of the current polyline has no base\n"
2326 <<
"vertex assigned\n"
2327 <<
"Outer polygon number: (" <<
i <<
")\n\n"
2328 <<
"Polyline number: (" << p <<
")\n"
2329 <<
"Boundary id: (" << bound_id <<
")\n"
2330 <<
"Boundary chunk: (" << bnd_chunk <<
")\n";
2332 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
2337 unsigned bvbi = initial_base_vertex_info.
boundary_id;
2344 int global_vertex_id =
2345 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2348 if (global_vertex_id != -1)
2352 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][0] =
2358 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn] =
2359 global_vertex_number;
2362 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][0] =
2363 global_vertex_number;
2366 global_vertex_number++;
2372 global_vertices.push_back(vertex);
2379 n_vertices_outer_polygons++;
2385 for (
unsigned v = 1; v < n_vertices - 1; v++)
2389 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
2398 if (global_vertex_id == -1)
2401 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v] =
2402 global_vertex_number;
2405 global_vertex_number++;
2410 global_vertices.push_back(vertex);
2415 n_vertices_outer_polygons++;
2424 base_vertices[bound_id][bnd_chunk][1];
2429 std::ostringstream error_message;
2431 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2433 <<
"The final vertex of the current polyline has no base\n"
2434 <<
"vertex assigned\n"
2435 <<
"Outer polygon number: (" <<
i <<
")\n\n"
2436 <<
"Polyline number: (" << p <<
")\n"
2437 <<
"Boundary id: (" << bound_id <<
")\n"
2438 <<
"Boundary chunk: (" << bnd_chunk <<
")\n";
2440 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
2453 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2456 if (global_vertex_id != -1)
2460 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk]
2467 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn] =
2468 global_vertex_number;
2471 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk]
2473 global_vertex_number;
2476 global_vertex_number++;
2483 global_vertices.push_back(vertex);
2490 n_vertices_outer_polygons++;
2498 unsigned n_vertices_internal_polygons = 0;
2501 for (
unsigned i = 0;
i < n_internal_polygons;
i++)
2504 const unsigned n_polylines = internal_polygons_pt[
i]->npolyline();
2506 for (
unsigned p = 0; p < n_polylines; p++)
2510 internal_polygons_pt[
i]->polyline_pt(p);
2513 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2516 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2526 base_vertices[bound_id][bnd_chunk][0];
2531 std::ostringstream error_message;
2533 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2535 <<
"The initial vertex of the current polyline has no base\n"
2536 <<
"vertex assigned\n"
2537 <<
"Internal polygon number: (" <<
i <<
")\n\n"
2538 <<
"Polyline number: (" << p <<
")\n"
2539 <<
"Boundary id: (" << bound_id <<
")\n"
2540 <<
"Boundary chunk: (" << bnd_chunk <<
")\n";
2542 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
2547 unsigned bvbi = initial_base_vertex_info.
boundary_id;
2554 int global_vertex_id =
2555 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2558 if (global_vertex_id != -1)
2562 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][0] =
2568 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn] =
2569 global_vertex_number;
2572 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][0] =
2573 global_vertex_number;
2576 global_vertex_number++;
2582 global_vertices.push_back(vertex);
2589 n_vertices_internal_polygons++;
2595 for (
unsigned v = 1; v < n_vertices - 1; v++)
2599 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
2608 if (global_vertex_id == -1)
2611 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v] =
2612 global_vertex_number;
2615 global_vertex_number++;
2620 global_vertices.push_back(vertex);
2625 n_vertices_internal_polygons++;
2634 base_vertices[bound_id][bnd_chunk][1];
2639 std::ostringstream error_message;
2641 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2643 <<
"The final vertex of the current polyline has no base\n"
2644 <<
"vertex assigned\n"
2645 <<
"Internal polygon number: (" <<
i <<
")\n\n"
2646 <<
"Polyline number: (" << p <<
")\n"
2647 <<
"Boundary id: (" << bound_id <<
")\n"
2648 <<
"Boundary chunk: (" << bnd_chunk <<
")\n";
2650 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
2663 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2666 if (global_vertex_id != -1)
2670 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk]
2677 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn] =
2678 global_vertex_number;
2681 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk]
2683 global_vertex_number;
2686 global_vertex_number++;
2693 global_vertices.push_back(vertex);
2700 n_vertices_internal_polygons++;
2708 unsigned n_vertices_open_curves = 0;
2711 for (
unsigned i = 0;
i < n_open_curves;
i++)
2714 const unsigned n_polylines = open_curves_pt[
i]->ncurve_section();
2716 for (
unsigned p = 0; p < n_polylines; p++)
2720 open_curves_pt[
i]->polyline_pt(p);
2723 const unsigned bound_id = tmp_polyline_pt->
boundary_id();
2726 const unsigned n_vertices = tmp_polyline_pt->
nvertex();
2736 base_vertices[bound_id][bnd_chunk][0];
2741 std::ostringstream error_message;
2743 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2745 <<
"The initial vertex of the current polyline has no base\n"
2746 <<
"vertex assigned\n"
2747 <<
"Open curve number: (" <<
i <<
")\n\n"
2748 <<
"Polyline number: (" << p <<
")\n"
2749 <<
"Boundary id: (" << bound_id <<
")\n"
2750 <<
"Boundary chunk: (" << bnd_chunk <<
")\n";
2752 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
2757 unsigned bvbi = initial_base_vertex_info.
boundary_id;
2764 int global_vertex_id =
2765 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2768 if (global_vertex_id != -1)
2772 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][0] =
2778 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn] =
2779 global_vertex_number;
2782 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][0] =
2783 global_vertex_number;
2786 global_vertex_number++;
2792 global_vertices.push_back(vertex);
2799 n_vertices_open_curves++;
2805 for (
unsigned v = 1; v < n_vertices - 1; v++)
2809 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
2818 if (global_vertex_id == -1)
2821 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v] =
2822 global_vertex_number;
2825 global_vertex_number++;
2830 global_vertices.push_back(vertex);
2835 n_vertices_open_curves++;
2844 base_vertices[bound_id][bnd_chunk][1];
2849 std::ostringstream error_message;
2851 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2853 <<
"The final vertex of the current polyline has no base\n"
2854 <<
"vertex assigned\n"
2855 <<
"Open curve number: (" <<
i <<
")\n\n"
2856 <<
"Polyline number: (" << p <<
")\n"
2857 <<
"Boundary id: (" << bound_id <<
")\n"
2858 <<
"Boundary chunk: (" << bnd_chunk <<
")\n";
2860 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
2873 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn];
2876 if (global_vertex_id != -1)
2880 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk]
2887 boundary_chunk_vertex_to_global_vertex_id[bvbi][bvbc][bvvn] =
2888 global_vertex_number;
2891 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk]
2893 global_vertex_number;
2896 global_vertex_number++;
2903 global_vertices.push_back(vertex);
2910 n_vertices_open_curves++;
2926 const unsigned n_global_vertices = n_vertices_outer_polygons +
2927 n_vertices_internal_polygons +
2928 n_vertices_open_curves;
2933 const unsigned added_global_vertices = global_vertices.size();
2934 if (added_global_vertices != n_global_vertices)
2936 std::ostringstream error_stream;
2938 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2940 <<
"The number of added vertices to the global vertices container\n"
2941 <<
"is different from the pre-computed number of vertices\n"
2942 <<
"Added number of vertices: (" << added_global_vertices <<
")\n"
2943 <<
"Pre-computed number of global vertices: (" << n_global_vertices
2946 error_stream.str(), output_string, OOMPH_EXCEPTION_LOCATION);
2951 if (global_vertex_number != n_global_vertices)
2953 std::ostringstream error_stream;
2955 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
2957 <<
"The counter for the global number of vertices is different from\n"
2958 <<
"the pre-computed number of vertices\n"
2959 <<
"Global vertices counter: (" << global_vertex_number <<
")\n"
2960 <<
"Pre-computed number of global vertices: (" << n_global_vertices
2963 error_stream.str(), output_string, OOMPH_EXCEPTION_LOCATION);
2988 for (
unsigned i = 0;
i < n_outer_polygons;
i++)
2991 const unsigned n_polylines = outer_polygons_pt[
i]->npolyline();
2994 for (
unsigned p = 0; p < n_polylines; p++)
2997 const unsigned bound_id =
2998 outer_polygons_pt[
i]->polyline_pt(p)->boundary_id();
3001 const unsigned n_vertices =
3002 outer_polygons_pt[
i]->polyline_pt(p)->nvertex();
3005 const unsigned bnd_chunk =
3006 outer_polygons_pt[
i]->polyline_pt(p)->boundary_chunk();
3009 for (
unsigned v = 1; v < n_vertices; v++)
3012 const int global_vertex_id_v_1 =
3013 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk]
3017 if (global_vertex_id_v_1 == -1)
3021 outer_polygons_pt[
i]->polyline_pt(p)->vertex_coordinate(v - 1);
3022 std::ostringstream error_message;
3024 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3026 <<
"The global vertex number for the current vertex has not\n"
3027 <<
"been assigned\n."
3028 <<
"Outer polygon number: (" <<
i <<
")\n\n"
3029 <<
"Polyline number: (" << p <<
")\n"
3030 <<
"Boundary id: (" << bound_id <<
")\n"
3031 <<
"Boundary chunk: (" << bnd_chunk <<
")\n"
3032 <<
"Vertex[" << v - 1 <<
"]: (" << current_vertex[0] <<
", "
3033 << current_vertex[1] <<
")\n";
3035 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
3040 const int global_vertex_id_v =
3041 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
3044 if (global_vertex_id_v == -1)
3048 outer_polygons_pt[
i]->polyline_pt(p)->vertex_coordinate(v);
3049 std::ostringstream error_message;
3051 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3053 <<
"The global vertex number for the current vertex has not\n"
3054 <<
"been assigned\n."
3055 <<
"Outer polygon number: (" <<
i <<
")\n\n"
3056 <<
"Polyline number: (" << p <<
")\n"
3057 <<
"Boundary id: (" << bound_id <<
")\n"
3058 <<
"Boundary chunk: (" << bnd_chunk <<
")\n"
3059 <<
"Vertex[" << v <<
"]: (" << current_vertex[0] <<
", "
3060 << current_vertex[1] <<
")\n";
3062 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
3068 current_segment[0] = global_vertex_id_v_1;
3069 current_segment[1] = global_vertex_id_v;
3070 global_segments.push_back(current_segment);
3073 global_segment_markers.push_back(bound_id);
3082 for (
unsigned i = 0;
i < n_internal_polygons;
i++)
3085 const unsigned n_polylines = internal_polygons_pt[
i]->npolyline();
3088 for (
unsigned p = 0; p < n_polylines; p++)
3091 const unsigned bound_id =
3092 internal_polygons_pt[
i]->polyline_pt(p)->boundary_id();
3095 const unsigned n_vertices =
3096 internal_polygons_pt[
i]->polyline_pt(p)->nvertex();
3099 const unsigned bnd_chunk =
3100 internal_polygons_pt[
i]->polyline_pt(p)->boundary_chunk();
3103 for (
unsigned v = 1; v < n_vertices; v++)
3106 const int global_vertex_id_v_1 =
3107 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk]
3111 if (global_vertex_id_v_1 == -1)
3115 internal_polygons_pt[
i]->polyline_pt(p)->vertex_coordinate(v - 1);
3116 std::ostringstream error_message;
3118 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3120 <<
"The global vertex number for the current vertex has not\n"
3121 <<
"been assigned\n."
3122 <<
"Internal polygon number: (" <<
i <<
")\n\n"
3123 <<
"Polyline number: (" << p <<
")\n"
3124 <<
"Boundary id: (" << bound_id <<
")\n"
3125 <<
"Boundary chunk: (" << bnd_chunk <<
")\n"
3126 <<
"Vertex[" << v - 1 <<
"]: (" << current_vertex[0] <<
", "
3127 << current_vertex[1] <<
")\n";
3129 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
3134 const int global_vertex_id_v =
3135 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
3138 if (global_vertex_id_v == -1)
3142 internal_polygons_pt[
i]->polyline_pt(p)->vertex_coordinate(v);
3143 std::ostringstream error_message;
3145 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3147 <<
"The global vertex number for the current vertex has not\n"
3148 <<
"been assigned\n."
3149 <<
"Internal polygon number: (" <<
i <<
")\n\n"
3150 <<
"Polyline number: (" << p <<
")\n"
3151 <<
"Boundary id: (" << bound_id <<
")\n"
3152 <<
"Boundary chunk: (" << bnd_chunk <<
")\n"
3153 <<
"Vertex[" << v <<
"]: (" << current_vertex[0] <<
", "
3154 << current_vertex[1] <<
")\n";
3156 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
3162 current_segment[0] = global_vertex_id_v_1;
3163 current_segment[1] = global_vertex_id_v;
3164 global_segments.push_back(current_segment);
3167 global_segment_markers.push_back(bound_id);
3176 for (
unsigned i = 0;
i < n_open_curves;
i++)
3179 const unsigned n_polylines = open_curves_pt[
i]->ncurve_section();
3182 for (
unsigned p = 0; p < n_polylines; p++)
3185 const unsigned bound_id =
3186 open_curves_pt[
i]->polyline_pt(p)->boundary_id();
3189 const unsigned n_vertices =
3190 open_curves_pt[
i]->polyline_pt(p)->nvertex();
3193 const unsigned bnd_chunk =
3194 open_curves_pt[
i]->polyline_pt(p)->boundary_chunk();
3197 for (
unsigned v = 1; v < n_vertices; v++)
3200 const int global_vertex_id_v_1 =
3201 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk]
3205 if (global_vertex_id_v_1 == -1)
3209 open_curves_pt[
i]->polyline_pt(p)->vertex_coordinate(v - 1);
3210 std::ostringstream error_message;
3212 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3214 <<
"The global vertex number for the current vertex has not\n"
3215 <<
"been assigned\n."
3216 <<
"Open curve number: (" <<
i <<
")\n\n"
3217 <<
"Polyline number: (" << p <<
")\n"
3218 <<
"Boundary id: (" << bound_id <<
")\n"
3219 <<
"Boundary chunk: (" << bnd_chunk <<
")\n"
3220 <<
"Vertex[" << v - 1 <<
"]: (" << current_vertex[0] <<
", "
3221 << current_vertex[1] <<
")\n";
3223 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
3228 const int global_vertex_id_v =
3229 boundary_chunk_vertex_to_global_vertex_id[bound_id][bnd_chunk][v];
3232 if (global_vertex_id_v == -1)
3236 open_curves_pt[
i]->polyline_pt(p)->vertex_coordinate(v);
3237 std::ostringstream error_message;
3239 "UnstructuredTwoDMeshGeometryBase::build_triangulateio()";
3241 <<
"The global vertex number for the current vertex has not\n"
3242 <<
"been assigned\n."
3243 <<
"Open curve number: (" <<
i <<
")\n\n"
3244 <<
"Polyline number: (" << p <<
")\n"
3245 <<
"Boundary id: (" << bound_id <<
")\n"
3246 <<
"Boundary chunk: (" << bnd_chunk <<
")\n"
3247 <<
"Vertex[" << v <<
"]: (" << current_vertex[0] <<
", "
3248 << current_vertex[1] <<
")\n";
3250 error_message.str(), output_string, OOMPH_EXCEPTION_LOCATION);
3256 current_segment[0] = global_vertex_id_v_1;
3257 current_segment[1] = global_vertex_id_v;
3258 global_segments.push_back(current_segment);
3261 global_segment_markers.push_back(bound_id);
3280 const unsigned n_global_segments = global_segments.size();
3286 (
double*)malloc(triangulate_io.
numberofpoints * 2 *
sizeof(
double));
3298 for (
unsigned i = 0;
i < n_global_vertices;
i++, ii += 2)
3300 triangulate_io.
pointlist[ii] = global_vertices[
i][0];
3301 triangulate_io.
pointlist[ii + 1] = global_vertices[
i][1];
3307 for (
unsigned i = 0;
i < n_global_segments;
i++, ii += 2)
3311 triangulate_io.
segmentlist[ii] = global_segments[
i][0] + 1;
3312 triangulate_io.
segmentlist[ii + 1] = global_segments[
i][1] + 1;
3321 unsigned n_regions = regions_coordinates.size();
3333 regions_coordinates.begin();
3334 it_regions != regions_coordinates.end();
3338 unsigned region_id = (*it_regions).first;
3340 triangulate_io.
regionlist[4 * p - 4] = ((*it_regions).second)[0];
3342 triangulate_io.
regionlist[4 * p - 3] = ((*it_regions).second)[1];
3344 triangulate_io.
regionlist[4 * p - 2] =
static_cast<double>(region_id);
3347 triangulate_io.
regionlist[4 * p - 1] = regions_areas[region_id];
3358 const unsigned n_extra_holes = extra_holes_coordinates.size();
3362 for (
unsigned h = 0; h < n_internal_polygons; h++)
3364 if (!internal_polygons_pt[h]->internal_point().empty())
3366 internal_polygon_marked_as_hole.push_back(h);
3372 const unsigned n_internal_polygons_are_holes =
3373 internal_polygon_marked_as_hole.size();
3377 n_extra_holes + n_internal_polygons_are_holes;
3381 (
double*)malloc(triangulate_io.
numberofholes * 2 *
sizeof(
double));
3384 unsigned count_hole = 0;
3386 for (; count_hole < n_internal_polygons_are_holes * 2; count_hole += 2)
3388 const unsigned index_intenal_polygon_is_hole =
3389 internal_polygon_marked_as_hole[count_hole / 2];
3390 triangulate_io.
holelist[count_hole] =
3391 internal_polygons_pt[index_intenal_polygon_is_hole]
3392 ->internal_point()[0];
3393 triangulate_io.
holelist[count_hole + 1] =
3394 internal_polygons_pt[index_intenal_polygon_is_hole]
3395 ->internal_point()[1];
3399 for (
unsigned i_eh = 0;
3400 count_hole < 2 * (n_extra_holes + n_internal_polygons_are_holes);
3401 count_hole += 2, i_eh++)
3403 triangulate_io.
holelist[count_hole] = extra_holes_coordinates[i_eh][0];
3404 triangulate_io.
holelist[count_hole + 1] =
3405 extra_holes_coordinates[i_eh][1];
3422 const unsigned bound_id = polyline_pt->
boundary_id();
3435 connection_matrix[bound_id][bound_chunk].resize(2);
3445 connection_matrix[bound_id][bound_chunk][0] =
3446 default_vertex_connection_info;
3448 connection_matrix[bound_id][bound_chunk][1] =
3449 default_vertex_connection_info;
3452 if (connected_init_end)
3475 connection_matrix[bound_id][bound_chunk][0] = initial_vertex_info;
3479 if (connected_final_end)
3502 connection_matrix[bound_id][bound_chunk][1] = final_vertex_info;
3511 if (next_polyline_pt != 0)
3514 const unsigned next_bound_id = next_polyline_pt->
boundary_id();
3517 const unsigned next_bound_chunk = next_polyline_pt->
boundary_chunk();
3531 connection_matrix[bound_id][bound_chunk][1] = final_vertex_info;
3548 const unsigned bound_id = polyline_pt->
boundary_id();
3568 base_vertices[bound_id][bound_chunk].resize(2);
3570 base_vertices[bound_id][bound_chunk][0] = default_base_vertex_info;
3572 base_vertices[bound_id][bound_chunk][1] = default_base_vertex_info;
3584 std::map<
unsigned, std::map<unsigned, unsigned>>& boundary_chunk_nvertices)
3589 const unsigned bound_id = polyline_pt->
boundary_id();
3592 const unsigned n_vertices = polyline_pt->
nvertex();
3598 std::map<Vector<unsigned>,
bool> done;
3601 for (
unsigned v = 0; v < n_vertices; v++)
3607 bool repeat =
false;
3611 unsigned ibnd_id = bound_id;
3612 unsigned ibnd_chunk = bound_chunk;
3613 unsigned ivertex_number = v;
3616 unsigned base_bnd_id = 0;
3617 unsigned base_bnd_chunk = 0;
3618 unsigned base_vertex_number = 0;
3632 const unsigned i_n_vertices =
3633 boundary_chunk_nvertices[ibnd_id][ibnd_chunk];
3636 bool is_initial =
false;
3637 if (ivertex_number == 0)
3641 bool is_final =
false;
3642 if (ivertex_number == i_n_vertices - 1)
3648 if (is_initial || is_final)
3656 current_vertex_base_info = base_vertices[ibnd_id][ibnd_chunk][0];
3661 current_vertex_base_info = base_vertices[ibnd_id][ibnd_chunk][1];
3672 connection_matrix[ibnd_id][ibnd_chunk][0];
3676 vertex_connect_info = connection_matrix[ibnd_id][ibnd_chunk][0];
3680 vertex_connect_info = connection_matrix[ibnd_id][ibnd_chunk][1];
3686 const bool current_is_connected =
3690 if (current_is_connected)
3693 const unsigned iibnd_id =
3697 const unsigned iibnd_chunk =
3701 const unsigned iivertex_number =
3705 const unsigned ii_n_vertices =
3706 boundary_chunk_nvertices[iibnd_id][iibnd_chunk];
3710 bool new_is_initial =
false;
3711 if (iivertex_number == 0)
3713 new_is_initial =
true;
3715 bool new_is_final =
false;
3716 if (iivertex_number == ii_n_vertices - 1)
3718 new_is_final =
true;
3722 if (new_is_initial || new_is_final)
3730 new_vertex_base_info =
3731 base_vertices[iibnd_id][iibnd_chunk][0];
3733 else if (new_is_final)
3736 new_vertex_base_info =
3737 base_vertices[iibnd_id][iibnd_chunk][1];
3742 check_done[0] = iibnd_id;
3743 check_done[1] = iibnd_chunk;
3744 check_done[2] = iivertex_number;
3746 if (!done[check_done])
3751 iter_bnd_id.push_back(ibnd_id);
3752 iter_bnd_chunk.push_back(ibnd_chunk);
3753 iter_vertex_number.push_back(ivertex_number);
3756 current_done[0] = ibnd_id;
3757 current_done[1] = ibnd_chunk;
3758 current_done[2] = ivertex_number;
3761 done[current_done] =
true;
3765 ibnd_chunk = iibnd_chunk;
3766 ivertex_number = iivertex_number;
3781 iter_bnd_id.push_back(ibnd_id);
3782 iter_bnd_chunk.push_back(ibnd_chunk);
3783 iter_vertex_number.push_back(ivertex_number);
3792 current_done[0] = ibnd_id;
3793 current_done[1] = ibnd_chunk;
3794 current_done[2] = ivertex_number;
3797 done[current_done] =
true;
3804 base_vertices[ibnd_id][ibnd_chunk][0].is_base_vertex =
3810 base_vertices[ibnd_id][ibnd_chunk][1].is_base_vertex =
3816 base_bnd_id = ibnd_id;
3818 base_bnd_chunk = ibnd_chunk;
3820 base_vertex_number = ivertex_number;
3829 current_done[0] = ibnd_id;
3830 current_done[1] = ibnd_chunk;
3831 current_done[2] = ivertex_number;
3834 done[current_done] =
true;
3838 base_bnd_id = iibnd_id;
3840 base_bnd_chunk = iibnd_chunk;
3842 base_vertex_number = iivertex_number;
3853 iter_bnd_id.push_back(ibnd_id);
3854 iter_bnd_chunk.push_back(ibnd_chunk);
3855 iter_vertex_number.push_back(ivertex_number);
3858 current_done[0] = ibnd_id;
3859 current_done[1] = ibnd_chunk;
3860 current_done[2] = ivertex_number;
3863 done[current_done] =
true;
3867 base_bnd_id = iibnd_id;
3869 base_bnd_chunk = iibnd_chunk;
3871 base_vertex_number = iivertex_number;
3881 iter_bnd_id.push_back(ibnd_id);
3882 iter_bnd_chunk.push_back(ibnd_chunk);
3883 iter_vertex_number.push_back(ivertex_number);
3886 current_done[0] = ibnd_id;
3887 current_done[1] = ibnd_chunk;
3888 current_done[2] = ivertex_number;
3891 done[current_done] =
true;
3897 base_vertices[ibnd_id][ibnd_chunk][0].is_base_vertex =
true;
3902 base_vertices[ibnd_id][ibnd_chunk][1].is_base_vertex =
true;
3907 base_bnd_id = ibnd_id;
3909 base_bnd_chunk = ibnd_chunk;
3911 base_vertex_number = ivertex_number;
3922 base_bnd_id = ibnd_id;
3924 base_bnd_chunk = ibnd_chunk;
3926 base_vertex_number = ivertex_number;
3937 base_bnd_id = current_vertex_base_info.
boundary_id;
3941 base_vertex_number = current_vertex_base_info.
vertex_number;
3952 const unsigned n_vertex_references = iter_bnd_id.size();
3954 for (
unsigned r = 0; r < n_vertex_references; r++)
3957 const unsigned rbnd_id = iter_bnd_id[r];
3958 const unsigned rbnd_chunk = iter_bnd_chunk[r];
3959 const unsigned rvertex_number = iter_vertex_number[r];
3963 const unsigned r_n_vertices =
3964 boundary_chunk_nvertices[rbnd_id][rbnd_chunk];
3967 bool is_initial =
false;
3968 if (rvertex_number == 0)
3972 bool is_final =
false;
3973 if (rvertex_number == r_n_vertices - 1)
3983 base_vertices[rbnd_id][rbnd_chunk][0].has_base_vertex_assigned =
true;
3985 base_vertices[rbnd_id][rbnd_chunk][0].boundary_id = base_bnd_id;
3987 base_vertices[rbnd_id][rbnd_chunk][0].boundary_chunk = base_bnd_chunk;
3989 base_vertices[rbnd_id][rbnd_chunk][0].vertex_number =
3997 base_vertices[rbnd_id][rbnd_chunk][1].has_base_vertex_assigned =
true;
3999 base_vertices[rbnd_id][rbnd_chunk][1].boundary_id = base_bnd_id;
4001 base_vertices[rbnd_id][rbnd_chunk][1].boundary_chunk = base_bnd_chunk;
4003 base_vertices[rbnd_id][rbnd_chunk][1].vertex_number =
4024 for (
unsigned b = 0; b < n_bound; b++)
4030 if (geom_object_pt != 0)
4035 for (
unsigned n = 0; n < n_boundary_node; ++n)
4044 unsigned n_tvalues =
4046 for (
unsigned t = 0;
t < n_tvalues; ++
t)
4049 geom_object_pt->
position(
t, b_coord, new_x);
4052 for (
unsigned i = 0;
i < 2;
i++)
4054 nod_pt->
x(
t,
i) = new_x[
i];
4069 const unsigned n_vertex = polygon_vertices.size();
4075 unsigned intersect_counter = 0;
4079 for (
unsigned i = 1;
i <= n_vertex;
i++)
4084 if (point[1] > std::min(p1[1], p2[1]))
4086 if (point[1] <= std::max(p1[1], p2[1]))
4088 if (point[0] <= std::max(p1[0], p2[0]))
4093 (point[1] - p1[1]) * (p2[0] - p1[0]) / (p2[1] - p1[1]) + p1[0];
4094 if ((p1[0] == p2[0]) || (point[0] <= xintersect))
4096 intersect_counter++;
4106 if (intersect_counter % 2 == 0)
4124 unsigned& vertex_number)
4128 bool found_vertex_number =
false;
4131 const unsigned n_vertices = dst_polyline_pt->
nvertex();
4135 for (
unsigned i = 0;
i < n_vertices;
i++)
4141 double dist = (vertex_coordinates[0] - current_vertex[0]) *
4142 (vertex_coordinates[0] - current_vertex[0]) +
4143 (vertex_coordinates[1] - current_vertex[1]) *
4144 (vertex_coordinates[1] - current_vertex[1]);
4154 found_vertex_number =
true;
4162 return found_vertex_number;
4166 #ifdef OOMPH_HAS_TRIANGLE_LIB
4177 const bool initial_connection =
4184 if (initial_connection || final_connection)
4204 bool copy_reversed =
false;
4207 double dist_initial =
4208 ((output_initial_vertex[0] - input_initial_vertex[0]) *
4209 (output_initial_vertex[0] - input_initial_vertex[0])) +
4210 ((output_initial_vertex[1] - input_initial_vertex[1]) *
4211 (output_initial_vertex[1] - input_initial_vertex[1]));
4212 dist_initial = sqrt(dist_initial);
4215 double dist_final = ((output_final_vertex[0] - input_final_vertex[0]) *
4216 (output_final_vertex[0] - input_final_vertex[0])) +
4217 ((output_final_vertex[1] - input_final_vertex[1]) *
4218 (output_final_vertex[1] - input_final_vertex[1]));
4219 dist_final = sqrt(dist_final);
4223 const double dist = dist_initial + dist_final;
4227 double dist_initial_rev =
4228 ((input_initial_vertex[0] - output_final_vertex[0]) *
4229 (input_initial_vertex[0] - output_final_vertex[0])) +
4230 ((input_initial_vertex[1] - output_final_vertex[1]) *
4231 (input_initial_vertex[1] - output_final_vertex[1]));
4232 dist_initial_rev = sqrt(dist_initial_rev);
4236 double dist_final_rev =
4237 ((input_final_vertex[0] - output_initial_vertex[0]) *
4238 (input_final_vertex[0] - output_initial_vertex[0])) +
4239 ((input_final_vertex[1] - output_initial_vertex[1]) *
4240 (input_final_vertex[1] - output_initial_vertex[1]));
4241 dist_final_rev = sqrt(dist_final_rev);
4245 const double dist_rev = dist_initial_rev + dist_final_rev;
4249 if (dist <= dist_rev)
4252 copy_reversed =
false;
4254 else if (dist_rev < dist)
4257 copy_reversed =
true;
4280 double initial_s_connection =
4290 initial_s_connection, bnd_id, s_tolerance);
4320 double final_s_connection =
4329 final_s_connection, bnd_id, s_tolerance);
4364 double initial_s_connection =
4373 initial_s_connection, bnd_id, s_tolerance);
4403 double final_s_connection =
4412 final_s_connection, bnd_id, s_tolerance);
4439 const bool initial_connection =
4446 if (initial_connection || final_connection)
4466 bool copy_reversed =
false;
4469 double dist_initial =
4470 ((output_initial_vertex[0] - input_initial_vertex[0]) *
4471 (output_initial_vertex[0] - input_initial_vertex[0])) +
4472 ((output_initial_vertex[1] - input_initial_vertex[1]) *
4473 (output_initial_vertex[1] - input_initial_vertex[1]));
4474 dist_initial = sqrt(dist_initial);
4477 double dist_final = ((output_final_vertex[0] - input_final_vertex[0]) *
4478 (output_final_vertex[0] - input_final_vertex[0])) +
4479 ((output_final_vertex[1] - input_final_vertex[1]) *
4480 (output_final_vertex[1] - input_final_vertex[1]));
4481 dist_final = sqrt(dist_final);
4485 const double dist = dist_initial + dist_final;
4489 double dist_initial_rev =
4490 ((input_initial_vertex[0] - output_final_vertex[0]) *
4491 (input_initial_vertex[0] - output_final_vertex[0])) +
4492 ((input_initial_vertex[1] - output_final_vertex[1]) *
4493 (input_initial_vertex[1] - output_final_vertex[1]));
4494 dist_initial_rev = sqrt(dist_initial_rev);
4498 double dist_final_rev =
4499 ((input_final_vertex[0] - output_initial_vertex[0]) *
4500 (input_final_vertex[0] - output_initial_vertex[0])) +
4501 ((input_final_vertex[1] - output_initial_vertex[1]) *
4502 (input_final_vertex[1] - output_initial_vertex[1]));
4503 dist_final_rev = sqrt(dist_final_rev);
4507 const double dist_rev = dist_initial_rev + dist_final_rev;
4511 if (dist <= dist_rev)
4514 copy_reversed =
false;
4516 else if (dist_rev < dist)
4519 copy_reversed =
true;
4547 double initial_s_connection =
4557 initial_s_connection, bnd_id, s_tolerance);
4591 double final_s_connection =
4600 final_s_connection, bnd_id, s_tolerance);
4638 double initial_s_connection =
4647 initial_s_connection, bnd_id, s_tolerance);
4681 double final_s_connection =
4690 final_s_connection, bnd_id, s_tolerance);
4711 bool UnstructuredTwoDMeshGeometryBase::
4712 Suppress_warning_about_regions_and_boundaries =
true;
/////////////////////////////////////////////////////////////////////
virtual void position(const Vector< double > &zeta, Vector< double > &r) const =0
Parametrised position on object at current time: r(zeta).
unsigned long nboundary_node(const unsigned &ibound) const
Return number of nodes on a particular boundary.
unsigned nboundary() const
Return number of boundaries.
Node *& boundary_node_pt(const unsigned &b, const unsigned &n)
Return pointer to node n on boundary b.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
double & x(const unsigned &i)
Return the i-th nodal coordinate.
TimeStepper *& position_time_stepper_pt()
Return a pointer to the position timestepper.
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....
An OomphLibError object which should be thrown when an run-time error is encountered....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
virtual unsigned nprev_values() const =0
Number of previous values available: 0 for static, 1 for BDF<1>,...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
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.
Vector< double > Internal_point_pt
Vector of vertex coordinates.
Base class for defining a triangle mesh boundary, this class has the methods that allow to connect th...
bool Initial_vertex_connected_to_curviline
States if the initial vertex is connected to a curviline.
virtual void initial_vertex_coordinate(Vector< double > &vertex)=0
Get first vertex coordinates.
bool is_initial_vertex_connected_to_curviline() const
Test whether the initial vertex is connected to a curviline.
bool Final_vertex_connected
Used for stating if the final end is connected to another boundary.
void unset_final_vertex_connected_to_curviline()
Sets the final vertex as non connected to a curviline.
unsigned Final_vertex_connected_n_vertex
Stores the vertex number used for connection with the final end.
double final_s_connection_value() const
Gets the s value to which the final end is connected.
bool Final_vertex_connected_to_curviline
States if the final vertex is connected to a curviline.
double Initial_s_connection_value
Stores the s value used for connecting the initial end with a curviline.
virtual unsigned boundary_id() const =0
Boundary id.
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...
double Final_s_connection_value
Stores the s value used for connecting the final end with a curviline.
double tolerance_for_s_connection() const
Gets the tolerance value for connections among curvilines.
unsigned Final_vertex_connected_bnd_id
Stores the id to which the initial end is connected.
unsigned Initial_vertex_connected_n_chunk
Stores the chunk number of the boundary to which is connected th initial end.
unsigned initial_vertex_connected_n_vertex() const
Gets the vertex number to which the initial end is connected.
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 final_vertex_connected_n_chunk() const
Gets the boundary chunk to which the final end is connected.
bool Initial_vertex_connected
Used for stating if the initial end is connected to another boundary.
unsigned final_vertex_connected_n_vertex() const
Sets the vertex number to which the final end is connected.
unsigned Initial_vertex_connected_n_vertex
Stores the vertex number used for connection with the initial end.
bool is_final_vertex_connected_to_curviline() const
Test whether the final vertex is connected to a curviline.
bool is_final_vertex_connected() const
Test whether final vertex is connected or not.
double Tolerance_for_s_connection
Tolerance used for connecting the ends to a curviline.
unsigned initial_vertex_connected_bnd_id() const
Gets the id to which the initial end is connected.
virtual void final_vertex_coordinate(Vector< double > &vertex)=0
Get last vertex coordinates.
bool is_initial_vertex_connected() const
Test whether initial vertex is connected or not.
void set_initial_vertex_connected()
Sets the initial vertex as connected.
unsigned Final_vertex_connected_n_chunk
Stores the chunk number of the boundary to which is connected th initial end.
void set_final_vertex_connected()
Sets the final vertex as connected.
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...
double initial_s_connection_value() const
Gets the s value to which the initial end is connected.
unsigned initial_vertex_connected_n_chunk() const
Gets the boundary chunk to which the initial end is connected.
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...
unsigned final_vertex_connected_bnd_id() const
Gets the id to which the final end is connected.
unsigned Initial_vertex_connected_bnd_id
Stores the id to which the initial end is connected.
void unset_initial_vertex_connected_to_curviline()
Sets the initial vertex as non connected to a curviline.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
Vector< TriangleMeshCurveSection * > Curve_section_pt
Vector of curve sections.
virtual TriangleMeshCurveSection * curve_section_pt(const unsigned &i) const
Pointer to i-th constituent curve section.
Class definining a curvilinear triangle mesh boundary in terms of a GeomObject. Curvlinear equivalent...
GeomObject * geom_object_pt()
Pointer to GeomObject that represents this part of the boundary.
void add_connection_point(const double &z_value, const double &tol=1.0e-12)
Add the connection point (z_value) to the connection points that receive the curviline.
unsigned boundary_chunk() const
Boundary chunk (Used when a boundary is represented by more than one polyline.
double zeta_start()
Start coordinate in terms of the GeomObject's intrinsic coordinate.
unsigned boundary_id() const
Boundary ID.
double zeta_end()
End coordinate in terms of the GeomObject's intrinsic coordinate.
TriangleMeshOpenCurve(const Vector< TriangleMeshCurveSection * > &curve_section_pt)
Constructor.
Class defining a polyline for use in Triangle Mesh generation.
unsigned boundary_chunk() const
Boundary chunk (Used when a boundary is represented by more than one polyline.
unsigned nvertex() const
Number of vertices.
Vector< double > vertex_coordinate(const unsigned &i) const
Coordinate vector of i-th vertex (const version)
unsigned boundary_id() const
Boundary id.
unsigned npolyline() const
Number of constituent polylines.
TriangleMeshPolyLine * polyline_pt(const unsigned &i) const
Pointer to i-th constituent polyline.
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...
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...
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.
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.
void snap_nodes_onto_geometric_objects()
Snap the boundary nodes onto any curvilinear boundaries defined by geometric objects.
std::map< unsigned, GeomObject * > & boundary_geom_object_pt()
Return direct access to the geometric object storage.
unsigned get_associated_vertex_to_svalue(double &target_s_value, unsigned &bnd_id)
Get the associated vertex to the given s value by looking to the list of s values created when changi...
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 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.
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...
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....
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 (a set of sorted vertices that conne...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
double Tolerable_error
Acceptable discrepancy for mismatch in vertex coordinates. In paranoid mode, the code will die if the...
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)
Create a triangulateio data file from ele node and poly files. This is used if the mesh is generated ...
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 initialise_triangulateio(TriangulateIO &triangle_io)
Initialise TriangulateIO structure.
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 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 clear_triangulateio(TriangulateIO &triangulate_io, const bool &clear_hole_data)
Clear TriangulateIO structure.
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...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
The Triangle data structure, modified from the triangle.h header supplied with triangle 1....
double * pointlist
Pointer to list of points x coordinate followed by y coordinate.
int numberoftriangleattributes
int * pointmarkerlist
Pointer to list of point markers.
double * trianglearealist
double * triangleattributelist
double * pointattributelist
Pointer to list of point attributes.
int numberofpointattributes
Data structure to store the base vertex info, initial or final vertex in the polylines have an associ...
bool has_base_vertex_assigned
Data structure filled when the connection matrix is created, for each polyline, there are two vertex_...
unsigned boundary_id_to_connect
unsigned boundary_chunk_to_connect
unsigned vertex_number_to_connect