100 std::map<std::pair<std::pair<int, int>, std::pair<int, int>>,
233 const unsigned& nnode1d)
236 if ((n != 0) && (n != nnode1d - 1) && (n != (nnode1d - 1) * nnode1d) &&
237 (n != nnode1d * nnode1d - 1) &&
238 (n != (nnode1d * nnode1d) * (nnode1d - 1) + 0) &&
239 (n != (nnode1d * nnode1d) * (nnode1d - 1) + nnode1d - 1) &&
240 (n != (nnode1d * nnode1d) * (nnode1d - 1) + (nnode1d - 1) * nnode1d) &&
241 (n != (nnode1d * nnode1d) * (nnode1d - 1) + nnode1d * nnode1d - 1))
243 std::ostringstream error_stream;
244 error_stream <<
"Node " << n
245 <<
" is not a vertex node in a brick element with "
246 << nnode1d <<
" nodes along each edge!";
249 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
254 a = n / (nnode1d * nnode1d);
255 b = (n - a * nnode1d * nnode1d) / nnode1d;
256 c = n - a * nnode1d * nnode1d - b * nnode1d;
258 result_vect[0] = 2 * c / (nnode1d - 1) - 1;
259 result_vect[1] = 2 * b / (nnode1d - 1) - 1;
260 result_vect[2] = 2 * a / (nnode1d - 1) - 1;
270 using namespace OcTreeNames;
273 if ((edge !=
LB) && (edge !=
RB) && (edge !=
DB) && (edge !=
UB) &&
274 (edge !=
LD) && (edge !=
RD) && (edge !=
LU) && (edge !=
RU) &&
275 (edge !=
LF) && (edge !=
RF) && (edge !=
DF) && (edge !=
UF))
277 std::ostringstream error_stream;
278 error_stream <<
"Edge " <<
Direct_string[edge] <<
"is not valid!";
280 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
401 OOMPH_CURRENT_FUNCTION,
402 OOMPH_EXCEPTION_LOCATION);
415 const unsigned& nnode1d)
417 using namespace OcTreeNames;
420 if ((vertex !=
LDB) && (vertex !=
RDB) && (vertex !=
LUB) &&
421 (vertex !=
RUB) && (vertex !=
LDF) && (vertex !=
RDF) &&
422 (vertex !=
LUF) && (vertex !=
RUF))
424 std::ostringstream error_stream;
425 error_stream <<
"Wrong vertex: " <<
Direct_string[vertex] << std::endl;
427 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
443 return nnode1d * (nnode1d - 1);
447 return nnode1d * nnode1d - 1;
452 return nnode1d * nnode1d * (nnode1d - 1);
457 return (nnode1d * nnode1d + 1) * (nnode1d - 1);
461 return nnode1d * nnode1d * nnode1d - nnode1d;
465 return nnode1d * nnode1d * nnode1d - 1;
470 std::ostringstream error_stream;
471 error_stream <<
"Never get here. vertex: " <<
Direct_string[vertex]
474 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
479 std::ostringstream error_stream;
480 error_stream <<
"Never get here. vertex: " <<
Direct_string[vertex]
483 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
493 using namespace OcTreeNames;
496 if ((n != 0) && (n != nnode1d - 1) && (n != (nnode1d - 1) * nnode1d) &&
497 (n != nnode1d * nnode1d - 1) &&
498 (n != (nnode1d * nnode1d) * (nnode1d - 1) + 0) &&
499 (n != (nnode1d * nnode1d) * (nnode1d - 1) + nnode1d - 1) &&
500 (n != (nnode1d * nnode1d) * (nnode1d - 1) + (nnode1d - 1) * nnode1d) &&
501 (n != (nnode1d * nnode1d) * (nnode1d - 1) + nnode1d * nnode1d - 1))
503 std::ostringstream error_stream;
504 error_stream <<
"Node " << n
505 <<
" is not a vertex node in a brick element with "
506 << nnode1d <<
" nodes along each edge!";
509 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
517 else if (n == nnode1d - 1)
521 else if (n == nnode1d * (nnode1d - 1))
525 else if (n == nnode1d * nnode1d - 1)
529 else if (n == nnode1d * nnode1d * (nnode1d - 1))
533 else if (n == (nnode1d * nnode1d + 1) * (nnode1d - 1))
537 else if (n == nnode1d * nnode1d * nnode1d - nnode1d)
541 else if (n == nnode1d * nnode1d * nnode1d - 1)
547 std::ostringstream error_stream;
548 error_stream <<
"Never get here. local node number: " << n
549 <<
" is not a vertex node in a brick element with "
550 << nnode1d <<
" nodes along each edge!" << std::endl;
552 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
567 const unsigned& nnode1d,
584 for (
unsigned i = 0;
i < 3;
i++)
587 vect_other_face[
i] = (vect_node1[
i] + vect_node2[
i]) / 2 - vect_face[
i];
590 if ((vect_other_face[
i] != 1) && (vect_other_face[
i] != -1) &&
591 (vect_other_face[
i] != 0))
594 OOMPH_CURRENT_FUNCTION,
595 OOMPH_EXCEPTION_LOCATION);
613 using namespace OcTreeNames;
614 int a = 0, b = 0, c = 0,
i, j;
635 std::ostringstream error_message_stream;
638 error_message_stream <<
"Bad axis (" << axis <<
"). Expected "
644 OOMPH_CURRENT_FUNCTION,
645 OOMPH_EXCEPTION_LOCATION);
647 for (
i = 0;
i < 3;
i++)
649 for (j = 0; j < 3; j++)
669 for (
i = 0;
i < 3;
i++)
671 for (j = 0; j < 3; j++)
674 for (k = 0; k < 3; k++)
676 Sum += mat1(
i, k) * mat2(k, j);
692 for (
i = 0;
i < 3;
i++)
695 for (k = 0; k < 3; k++)
697 sum += mat(
i, k) * vect1[k];
711 using namespace OcTreeNames;
714 if ((new_up !=
L) && (new_up !=
R) && (new_up !=
F) && (new_up !=
B) &&
715 (new_up !=
U) && (new_up !=
D))
717 std::ostringstream error_stream;
718 error_stream <<
"Wrong new_up: " <<
Direct_string[new_up] << std::endl;
720 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
722 if ((new_right !=
L) && (new_right !=
R) && (new_right !=
F) &&
723 (new_right !=
B) && (new_right !=
U) && (new_right !=
D))
725 std::ostringstream error_stream;
726 error_stream <<
"Wrong new_right: " <<
Direct_string[new_right]
729 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
739 vect_new_dir =
rotate(new_up, new_right, vect_dir);
751 const int& new_right,
754 using namespace OcTreeNames;
757 if ((new_up !=
L) && (new_up !=
R) && (new_up !=
F) && (new_up !=
B) &&
758 (new_up !=
U) && (new_up !=
D))
760 std::ostringstream error_stream;
761 error_stream <<
"Wrong new_up: " <<
Direct_string[new_up] << std::endl;
763 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
765 if ((new_right !=
L) && (new_right !=
R) && (new_right !=
F) &&
766 (new_right !=
B) && (new_right !=
U) && (new_right !=
D))
768 std::ostringstream error_stream;
769 error_stream <<
"Wrong new_right: " <<
Direct_string[new_right]
772 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
782 int axis1, axis2, angle1, angle2, nrot;
803 std::ostringstream error_stream;
804 error_stream <<
"New_right is " << new_right <<
" ("
806 <<
"It should be R, B, L, or F" << std::endl;
808 OOMPH_CURRENT_FUNCTION,
809 OOMPH_EXCEPTION_LOCATION);
840 std::ostringstream error_stream;
841 error_stream <<
"New_right is " << new_right <<
" ("
843 <<
"It should be R, B, L, or F" << std::endl;
845 OOMPH_CURRENT_FUNCTION,
846 OOMPH_EXCEPTION_LOCATION);
878 std::ostringstream error_stream;
879 error_stream <<
"New_right is " << new_right <<
" ("
881 <<
"It should be D, B, U, or F" << std::endl;
883 OOMPH_CURRENT_FUNCTION,
884 OOMPH_EXCEPTION_LOCATION);
916 std::ostringstream error_stream;
917 error_stream <<
"New_right is " << new_right <<
" ("
919 <<
"It should be D, B, U, or F" << std::endl;
921 OOMPH_CURRENT_FUNCTION,
922 OOMPH_EXCEPTION_LOCATION);
954 std::ostringstream error_stream;
955 error_stream <<
"New_right is " << new_right <<
" ("
957 <<
"It should be R, L, U, or D" << std::endl;
959 OOMPH_CURRENT_FUNCTION,
960 OOMPH_EXCEPTION_LOCATION);
991 std::ostringstream error_stream;
992 error_stream <<
"New_right is " << new_right <<
" ("
994 <<
"It should be R, L, U, or D" << std::endl;
996 OOMPH_CURRENT_FUNCTION,
997 OOMPH_EXCEPTION_LOCATION);
1020 for (
int i = 0;
i < 3;
i++)
1022 for (
int j = 0; j < 3; j++)
1024 mat3(
i, j) = mat1(
i, j);
1033 return vect_new_dir;
1042 using namespace OcTreeNames;
1048 std::ostringstream error_stream;
1049 error_stream <<
"Inconsistent enumeration! \n Tree::OMEGA="
1053 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2192 for (
int i = -1;
i < 2;
i++)
2194 for (
int j = -1; j < 2; j++)
2196 for (
int k = -1; k < 2; k++)
2206 num_elem = (
i + 1) * 9 + (j + 1) * 3 + (k + 1);
2294 oomph_info <<
"there might be a problem with Vector_to_direction"
2308 for (
int i =
LDB;
i <=
F;
i++)
2312 for (
int j = 0; j < 3; j++)
2319 for (
unsigned j = 0; j < 3; j++)
2344 oomph_info <<
"Direction Error !!" << std::endl;
2356 int new_up, new_right;
2364 std::map<std::pair<int, int>, std::set<std::pair<int, int>>>
2368 for (
int vertex =
LDB; vertex <=
RUF; vertex++)
2373 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2374 std::make_pair(new_up, new_right));
2379 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2380 std::make_pair(new_up, new_right));
2385 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2386 std::make_pair(new_up, new_right));
2391 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2392 std::make_pair(new_up, new_right));
2398 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2399 std::make_pair(new_up, new_right));
2404 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2405 std::make_pair(new_up, new_right));
2410 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2411 std::make_pair(new_up, new_right));
2416 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2417 std::make_pair(new_up, new_right));
2423 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2424 std::make_pair(new_up, new_right));
2429 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2430 std::make_pair(new_up, new_right));
2435 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2436 std::make_pair(new_up, new_right));
2441 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2442 std::make_pair(new_up, new_right));
2448 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2449 std::make_pair(new_up, new_right));
2454 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2455 std::make_pair(new_up, new_right));
2460 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2461 std::make_pair(new_up, new_right));
2466 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2467 std::make_pair(new_up, new_right));
2473 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2474 std::make_pair(new_up, new_right));
2479 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2480 std::make_pair(new_up, new_right));
2485 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2486 std::make_pair(new_up, new_right));
2491 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2492 std::make_pair(new_up, new_right));
2498 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2499 std::make_pair(new_up, new_right));
2504 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2505 std::make_pair(new_up, new_right));
2510 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2511 std::make_pair(new_up, new_right));
2516 required_rotation[std::make_pair(vertex, new_vertex)].insert(
2517 std::make_pair(new_up, new_right));
2525 std::map<int, Vector<int>> vertex_in_edge_neighbour;
2530 std::map<int, Vector<int>> other_vertex_on_edge;
2535 std::map<int, Vector<int>> other_vertex_in_edge_neighbour;
2538 vertex_in_edge_neighbour[
LDB].resize(3);
2539 vertex_in_edge_neighbour[
LDB][0] =
2541 vertex_in_edge_neighbour[
LDB][1] =
RDF;
2542 vertex_in_edge_neighbour[
LDB][2] =
RUB;
2544 other_vertex_on_edge[
LDB].resize(3);
2545 other_vertex_on_edge[
LDB][0] =
2547 other_vertex_on_edge[
LDB][1] =
LUB;
2548 other_vertex_on_edge[
LDB][2] =
LDF;
2550 other_vertex_in_edge_neighbour[
LDB].resize(3);
2551 other_vertex_in_edge_neighbour[
LDB][0] =
RUF;
2552 other_vertex_in_edge_neighbour[
LDB][1] =
RUF;
2553 other_vertex_in_edge_neighbour[
LDB][2] =
RUF;
2556 vertex_in_edge_neighbour[
RDB].resize(3);
2557 vertex_in_edge_neighbour[
RDB][0] =
2559 vertex_in_edge_neighbour[
RDB][1] =
LDF;
2560 vertex_in_edge_neighbour[
RDB][2] =
LUB;
2562 other_vertex_on_edge[
RDB].resize(3);
2563 other_vertex_on_edge[
RDB][0] =
2565 other_vertex_on_edge[
RDB][1] =
RUB;
2566 other_vertex_on_edge[
RDB][2] =
RDF;
2568 other_vertex_in_edge_neighbour[
RDB].resize(3);
2569 other_vertex_in_edge_neighbour[
RDB][0] =
LUF;
2570 other_vertex_in_edge_neighbour[
RDB][1] =
LUF;
2571 other_vertex_in_edge_neighbour[
RDB][2] =
LUF;
2574 vertex_in_edge_neighbour[
LUB].resize(3);
2575 vertex_in_edge_neighbour[
LUB][0] =
2577 vertex_in_edge_neighbour[
LUB][1] =
RUF;
2578 vertex_in_edge_neighbour[
LUB][2] =
RDB;
2580 other_vertex_on_edge[
LUB].resize(3);
2581 other_vertex_on_edge[
LUB][0] =
2583 other_vertex_on_edge[
LUB][1] =
LDB;
2584 other_vertex_on_edge[
LUB][2] =
LUF;
2586 other_vertex_in_edge_neighbour[
LUB].resize(3);
2587 other_vertex_in_edge_neighbour[
LUB][0] =
RDF;
2588 other_vertex_in_edge_neighbour[
LUB][1] =
RDF;
2589 other_vertex_in_edge_neighbour[
LUB][2] =
RDF;
2592 vertex_in_edge_neighbour[
RUB].resize(3);
2593 vertex_in_edge_neighbour[
RUB][0] =
2595 vertex_in_edge_neighbour[
RUB][1] =
LUF;
2596 vertex_in_edge_neighbour[
RUB][2] =
LDB;
2598 other_vertex_on_edge[
RUB].resize(3);
2599 other_vertex_on_edge[
RUB][0] =
2601 other_vertex_on_edge[
RUB][1] =
RDB;
2602 other_vertex_on_edge[
RUB][2] =
RUF;
2604 other_vertex_in_edge_neighbour[
RUB].resize(3);
2605 other_vertex_in_edge_neighbour[
RUB][0] =
LDF;
2606 other_vertex_in_edge_neighbour[
RUB][1] =
LDF;
2607 other_vertex_in_edge_neighbour[
RUB][2] =
LDF;
2610 vertex_in_edge_neighbour[
LDF].resize(3);
2611 vertex_in_edge_neighbour[
LDF][0] =
2613 vertex_in_edge_neighbour[
LDF][1] =
RDB;
2614 vertex_in_edge_neighbour[
LDF][2] =
RUF;
2616 other_vertex_on_edge[
LDF].resize(3);
2617 other_vertex_on_edge[
LDF][0] =
2619 other_vertex_on_edge[
LDF][1] =
LUF;
2620 other_vertex_on_edge[
LDF][2] =
LDB;
2622 other_vertex_in_edge_neighbour[
LDF].resize(3);
2623 other_vertex_in_edge_neighbour[
LDF][0] =
RUB;
2624 other_vertex_in_edge_neighbour[
LDF][1] =
RUB;
2625 other_vertex_in_edge_neighbour[
LDF][2] =
RUB;
2628 vertex_in_edge_neighbour[
RDF].resize(3);
2629 vertex_in_edge_neighbour[
RDF][0] =
2631 vertex_in_edge_neighbour[
RDF][1] =
LDB;
2632 vertex_in_edge_neighbour[
RDF][2] =
LUF;
2634 other_vertex_on_edge[
RDF].resize(3);
2635 other_vertex_on_edge[
RDF][0] =
2637 other_vertex_on_edge[
RDF][1] =
RUF;
2638 other_vertex_on_edge[
RDF][2] =
RDB;
2640 other_vertex_in_edge_neighbour[
RDF].resize(3);
2641 other_vertex_in_edge_neighbour[
RDF][0] =
LUB;
2642 other_vertex_in_edge_neighbour[
RDF][1] =
LUB;
2643 other_vertex_in_edge_neighbour[
RDF][2] =
LUB;
2646 vertex_in_edge_neighbour[
LUF].resize(3);
2647 vertex_in_edge_neighbour[
LUF][0] =
2649 vertex_in_edge_neighbour[
LUF][1] =
RUB;
2650 vertex_in_edge_neighbour[
LUF][2] =
RDF;
2652 other_vertex_on_edge[
LUF].resize(3);
2653 other_vertex_on_edge[
LUF][0] =
2655 other_vertex_on_edge[
LUF][1] =
LDF;
2656 other_vertex_on_edge[
LUF][2] =
LUB;
2658 other_vertex_in_edge_neighbour[
LUF].resize(3);
2659 other_vertex_in_edge_neighbour[
LUF][0] =
RDB;
2660 other_vertex_in_edge_neighbour[
LUF][1] =
RDB;
2661 other_vertex_in_edge_neighbour[
LUF][2] =
RDB;
2664 vertex_in_edge_neighbour[
RUF].resize(3);
2665 vertex_in_edge_neighbour[
RUF][0] =
2667 vertex_in_edge_neighbour[
RUF][1] =
LUB;
2668 vertex_in_edge_neighbour[
RUF][2] =
LDF;
2670 other_vertex_on_edge[
RUF].resize(3);
2671 other_vertex_on_edge[
RUF][0] =
2673 other_vertex_on_edge[
RUF][1] =
RDF;
2674 other_vertex_on_edge[
RUF][2] =
RUB;
2676 other_vertex_in_edge_neighbour[
RUF].resize(3);
2677 other_vertex_in_edge_neighbour[
RUF][0] =
LDB;
2678 other_vertex_in_edge_neighbour[
RUF][1] =
LDB;
2679 other_vertex_in_edge_neighbour[
RUF][2] =
LDB;
2683 for (
int vertex =
LDB; vertex <=
RUF; vertex++)
2686 for (
unsigned i = 0;
i < 3;
i++)
2689 int other_vertex = other_vertex_on_edge[vertex][
i];
2694 int unrotated_neigh_vertex = vertex_in_edge_neighbour[vertex][
i];
2699 int unrotated_neigh_other_vertex =
2700 other_vertex_in_edge_neighbour[vertex][
i];
2703 for (
int neigh_vertex =
LDB; neigh_vertex <=
RUF; neigh_vertex++)
2707 std::set<std::pair<int, int>> vertex_rot =
2708 required_rotation[std::make_pair(neigh_vertex,
2709 unrotated_neigh_vertex)];
2713 for (
int neigh_other_vertex =
LDB; neigh_other_vertex <=
RUF;
2714 neigh_other_vertex++)
2718 std::set<std::pair<int, int>> other_vertex_rot =
2719 required_rotation[std::make_pair(neigh_other_vertex,
2720 unrotated_neigh_other_vertex)];
2723 std::set<std::pair<int, int>> common_rotations;
2726 std::set_intersection(
2729 other_vertex_rot.begin(),
2730 other_vertex_rot.end(),
2731 inserter(common_rotations, common_rotations.begin()));
2734 if (common_rotations.size() > 0)
2736 for (std::set<std::pair<int, int>>::iterator it =
2737 common_rotations.begin();
2738 it != common_rotations.end();
2746 std::make_pair(vertex, neigh_vertex),
2747 std::make_pair(other_vertex, neigh_other_vertex))]
2753 std::make_pair(vertex, neigh_vertex),
2754 std::make_pair(other_vertex, neigh_other_vertex))]
2755 .second = it->second;
2770 OcTree* edge_neigh_pt)
const
2779 if (edge_neigh_pt == 0)
2784 using namespace OcTreeNames;
2793 bool in_neighbouring_tree =
false;
2795 OcTree* face_neigh_pt = 0;
2809 in_neighbouring_tree);
2812 if (face_neigh_pt != 0)
2814 if (face_neigh_pt == edge_neigh_pt)
2828 in_neighbouring_tree);
2831 if (face_neigh_pt != 0)
2833 if (face_neigh_pt == edge_neigh_pt)
2853 in_neighbouring_tree);
2856 if (face_neigh_pt != 0)
2858 if (face_neigh_pt == edge_neigh_pt)
2872 in_neighbouring_tree);
2874 if (face_neigh_pt != 0)
2876 if (face_neigh_pt == edge_neigh_pt)
2895 in_neighbouring_tree);
2898 if (face_neigh_pt != 0)
2900 if (face_neigh_pt == edge_neigh_pt)
2914 in_neighbouring_tree);
2916 if (face_neigh_pt != 0)
2918 if (face_neigh_pt == edge_neigh_pt)
2937 in_neighbouring_tree);
2940 if (face_neigh_pt != 0)
2942 if (face_neigh_pt == edge_neigh_pt)
2956 in_neighbouring_tree);
2959 if (face_neigh_pt != 0)
2961 if (face_neigh_pt == edge_neigh_pt)
2980 in_neighbouring_tree);
2983 if (face_neigh_pt != 0)
2985 if (face_neigh_pt == edge_neigh_pt)
2999 in_neighbouring_tree);
3001 if (face_neigh_pt != 0)
3003 if (face_neigh_pt == edge_neigh_pt)
3022 in_neighbouring_tree);
3025 if (face_neigh_pt != 0)
3027 if (face_neigh_pt == edge_neigh_pt)
3041 in_neighbouring_tree);
3043 if (face_neigh_pt != 0)
3045 if (face_neigh_pt == edge_neigh_pt)
3063 in_neighbouring_tree);
3066 if (face_neigh_pt != 0)
3068 if (face_neigh_pt == edge_neigh_pt)
3082 in_neighbouring_tree);
3085 if (face_neigh_pt != 0)
3087 if (face_neigh_pt == edge_neigh_pt)
3106 in_neighbouring_tree);
3109 if (face_neigh_pt != 0)
3111 if (face_neigh_pt == edge_neigh_pt)
3125 in_neighbouring_tree);
3128 if (face_neigh_pt != 0)
3130 if (face_neigh_pt == edge_neigh_pt)
3150 in_neighbouring_tree);
3153 if (face_neigh_pt != 0)
3155 if (face_neigh_pt == edge_neigh_pt)
3169 in_neighbouring_tree);
3172 if (face_neigh_pt != 0)
3174 if (face_neigh_pt == edge_neigh_pt)
3192 in_neighbouring_tree);
3195 if (face_neigh_pt != 0)
3197 if (face_neigh_pt == edge_neigh_pt)
3211 in_neighbouring_tree);
3214 if (face_neigh_pt != 0)
3216 if (face_neigh_pt == edge_neigh_pt)
3235 in_neighbouring_tree);
3238 if (face_neigh_pt != 0)
3240 if (face_neigh_pt == edge_neigh_pt)
3255 in_neighbouring_tree);
3258 if (face_neigh_pt != 0)
3260 if (face_neigh_pt == edge_neigh_pt)
3279 in_neighbouring_tree);
3282 if (face_neigh_pt != 0)
3284 if (face_neigh_pt == edge_neigh_pt)
3299 in_neighbouring_tree);
3302 if (face_neigh_pt != 0)
3304 if (face_neigh_pt == edge_neigh_pt)
3316 std::ostringstream error_stream;
3317 error_stream <<
"Never get here! Edge:" <<
Direct_string[edge] <<
" "
3318 << edge << std::endl;
3320 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
3379 bool& in_neighbouring_tree)
const
3381 using namespace OcTreeNames;
3384 if ((direction !=
L) && (direction !=
R) && (direction !=
F) &&
3385 (direction !=
B) && (direction !=
U) && (direction !=
D))
3387 std::ostringstream error_stream;
3388 error_stream <<
"Wrong direction: " <<
Direct_string[direction]
3391 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
3397 in_neighbouring_tree =
false;
3401 int max_level =
Level;
3407 double s_difflo = 0;
3408 double s_diffhi = 0;
3418 in_neighbouring_tree,
3422 OcTree* neighb_pt = return_pt;
3425 for (
unsigned i = 0;
i < 3;
i++)
3441 s_sw[0] =
S_base(0, reflected_dir) +
3442 S_steplo(0, reflected_dir) * s_difflo +
3443 S_stephi(0, reflected_dir) * s_diffhi;
3445 s_sw[1] =
S_base(1, reflected_dir) +
3446 S_steplo(1, reflected_dir) * s_difflo +
3447 S_stephi(1, reflected_dir) * s_diffhi;
3449 s_sw[2] =
S_base(2, reflected_dir) +
3450 S_steplo(2, reflected_dir) * s_difflo +
3451 S_stephi(2, reflected_dir) * s_diffhi;
3453 s_ne[0] =
S_base(0, reflected_dir) +
3454 S_steplo(0, reflected_dir) * pow(2.0, diff_level) +
3455 S_steplo(0, reflected_dir) * s_difflo +
3456 S_stephi(0, reflected_dir) * pow(2.0, diff_level) +
3457 S_stephi(0, reflected_dir) * s_diffhi;
3459 s_ne[1] =
S_base(1, reflected_dir) +
3460 S_steplo(1, reflected_dir) * pow(2.0, diff_level) +
3461 S_steplo(1, reflected_dir) * s_difflo +
3462 S_stephi(1, reflected_dir) * pow(2.0, diff_level) +
3463 S_stephi(1, reflected_dir) * s_diffhi;
3465 s_ne[2] =
S_base(2, reflected_dir) +
3466 S_steplo(2, reflected_dir) * pow(2.0, diff_level) +
3467 S_steplo(2, reflected_dir) * s_difflo +
3468 S_stephi(2, reflected_dir) * pow(2.0, diff_level) +
3469 S_stephi(2, reflected_dir) * s_diffhi;
3473 int new_dir = direction;
3523 for (
int i = 0;
i < 3;
i++)
3525 Mat_rot(
i, 0) = vect1[
i];
3526 Mat_rot(
i, 1) = vect2[
i];
3527 Mat_rot(
i, 2) = vect3[
i];
3534 for (
unsigned i = 0;
i < 3;
i++)
3538 translate_s_new[
i] = 0;
3539 for (
unsigned k = 0; k < 3; k++)
3541 s_ne_new[
i] += Mat_rot(
i, k) * s_ne[k];
3542 s_sw_new[
i] += Mat_rot(
i, k) * s_sw[k];
3543 translate_s_new[
i] += Mat_rot(
i, k) * translate_s[k];
3551 for (
unsigned i = 0;
i < 3;
i++)
3554 translate_s[
i] = std::abs(translate_s_new[
i]);
3619 const int& direction,
3620 const unsigned& i_root_edge_neighbour,
3621 unsigned& nroot_edge_neighbour,
3626 int& diff_level)
const
3628 using namespace OcTreeNames;
3631 if ((direction !=
LB) && (direction !=
RB) && (direction !=
DB) &&
3632 (direction !=
UB) && (direction !=
LD) && (direction !=
RD) &&
3633 (direction !=
LU) && (direction !=
RU) && (direction !=
LF) &&
3634 (direction !=
RF) && (direction !=
DF) && (direction !=
UF))
3636 std::ostringstream error_stream;
3637 error_stream <<
"Wrong direction: " <<
Direct_string[direction]
3640 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
3646 int max_level =
Level;
3659 i_root_edge_neighbour,
3660 nroot_edge_neighbour,
3673 OcTree* neighb_pt = return_pt;
3676 for (
unsigned i = 0;
i < 3;
i++)
3702 S_step_edge(0, reflected_dir) * pow(2.0, diff_level) +
3706 S_step_edge(1, reflected_dir) * pow(2.0, diff_level) +
3710 S_step_edge(2, reflected_dir) * pow(2.0, diff_level) +
3715 int new_dir = direction;
3729 new_dir =
rotate(new_up, new_right, direction);
3770 for (
int i = 0;
i < 3;
i++)
3772 Mat_rot(
i, 0) = vect1[
i];
3773 Mat_rot(
i, 1) = vect2[
i];
3774 Mat_rot(
i, 2) = vect3[
i];
3781 for (
unsigned i = 0;
i < 3;
i++)
3785 translate_s_new[
i] = 0;
3786 for (
unsigned k = 0; k < 3; k++)
3788 s_hi_new[
i] += Mat_rot(
i, k) * s_hi[k];
3789 s_lo_new[
i] += Mat_rot(
i, k) * s_lo[k];
3790 translate_s_new[
i] += Mat_rot(
i, k) * translate_s[k];
3798 for (
unsigned i = 0;
i < 3;
i++)
3801 translate_s[
i] = std::abs(translate_s_new[
i]);
3843 bool& in_neighbouring_tree,
3847 using namespace OcTreeNames;
3850 if ((direction !=
L) && (direction !=
R) && (direction !=
F) &&
3851 (direction !=
B) && (direction !=
U) && (direction !=
D))
3853 std::ostringstream error_stream;
3855 <<
" is not L, R, B, F, D or U." << std::endl;
3857 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
3866 in_neighbouring_tree =
false;
3885 in_neighbouring_tree,
3910 if (next_el_pt != 0)
3916 if ((next_el_pt->
Son_pt.size() == 0) ||
3917 (next_el_pt->
Level > max_level - 1))
3919 return_el_pt = next_el_pt;
3931 if (orig_root_pt != next_el_pt->
Root_pt)
3937 son_octant =
rotate(my_up, my_right, son_octant);
3940 return_el_pt =
dynamic_cast<OcTree*
>(next_el_pt->
Son_pt[son_octant]);
3966 in_neighbouring_tree =
true;
3979 return return_el_pt;
4016 const unsigned& i_root_edge_neighbour,
4017 unsigned& nroot_edge_neighbour,
4023 using namespace OcTreeNames;
4027 if ((direction !=
LB) && (direction !=
RB) && (direction !=
DB) &&
4028 (direction !=
UB) && (direction !=
LD) && (direction !=
RD) &&
4029 (direction !=
LU) && (direction !=
RU) && (direction !=
LF) &&
4030 (direction !=
RF) && (direction !=
DF) && (direction !=
UF))
4032 std::ostringstream error_stream;
4033 error_stream <<
"Wrong direction: " <<
Direct_string[direction]
4036 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
4042 nroot_edge_neighbour = 0;
4045 OcTree* return_el_pt = 0;
4061 i_root_edge_neighbour,
4062 nroot_edge_neighbour,
4077 bool in_neighbouring_tree =
false;
4080 double s_difflo = 0.0;
4081 double s_diffhi = 0.0;
4082 int diff_level_edge = 0;
4089 in_neighbouring_tree,
4112 if (next_el_pt != 0)
4118 if ((next_el_pt->
Son_pt.size() == 0) ||
4119 (next_el_pt->
Level > max_level - 1))
4121 return_el_pt = next_el_pt;
4133 if (orig_root_pt != next_el_pt->
Root_pt)
4139 son_octant =
rotate(my_up, my_right, son_octant);
4142 return_el_pt =
dynamic_cast<OcTree*
>(next_el_pt->
Son_pt[son_octant]);
4165 nroot_edge_neighbour =
4173 unsigned n_neigh = edge_neighbour_pt.size();
4180 dynamic_cast<OcTree*
>(edge_neighbour_pt[i_root_edge_neighbour]);
4188 return return_el_pt;
4208 unsigned long num_nodes = all_nodes_pt.size();
4210 for (
unsigned long i = 0;
i < num_nodes;
i++)
4212 all_nodes_pt[
i]->object_pt()->set_number(++count);
4216 std::ofstream neighbours_file;
4217 std::ofstream no_true_edge_file;
4218 std::ofstream neighbours_txt_file;
4220 double max_error_face = 0.0;
4222 all_nodes_pt, neighbours_file, neighbours_txt_file, max_error_face);
4224 double max_error_edge = 0.0;
4228 neighbours_txt_file,
4230 bool failed =
false;
4234 <<
"\n \n Failed self_test() for OcTree because of faces: Max. error "
4235 << max_error_face << std::endl
4243 <<
"\n \n Failed self_test() for OcTree because of edges: Max. error "
4244 << max_error_edge << std::endl
4249 double max_error = max_error_face;
4250 if (max_error_edge > max_error) max_error = max_error_edge;
4258 oomph_info <<
"Passed self_test() for OcTree: Max. error " << max_error
4276 std::ofstream& neighbours_file,
4277 std::ofstream& neighbours_txt_file,
4280 using namespace OcTreeNames;
4284 bool in_neighbouring_tree;
4302 unsigned long num_nodes = forest_nodes_pt.size();
4304 for (
unsigned long i = 0;
i < num_nodes;
i++)
4313 if (neighbours_file.is_open())
4315 neighbours_file <<
"#---------------------------------" << std::endl;
4316 neighbours_file <<
"#The element itself: " <<
i << std::endl;
4317 neighbours_file <<
"#---------------------------------" << std::endl;
4319 ->output_corners(neighbours_file,
"BLACK");
4324 for (
int direction =
L; direction <=
F; direction++)
4336 in_neighbouring_tree);
4342 if (neighbours_txt_file.is_open())
4348 << diff_level <<
". Inside the neighbour the face is "
4353 if (neighbours_file.is_open())
4355 neighbours_file <<
"#---------------------------------"
4359 <<
"\n#---------------------------------" << std::endl;
4361 ->output_corners(neighbours_file,
Colour[direction]);
4367 if (neighbours_file.is_open())
4369 neighbours_file <<
"ZONE I=2 C=" <<
Colour[direction]
4392 bool is_periodic =
false;
4393 if (in_neighbouring_tree)
4401 if (is_periodic ==
false)
4403 error = sqrt(pow(x_small[0] - x_large[0], 2) +
4404 pow(x_small[1] - x_large[1], 2) +
4405 pow(x_small[2] - x_large[2], 2));
4408 if (neighbours_txt_file.is_open())
4410 neighbours_txt_file <<
"Error (1) " << error << std::endl;
4413 if (std::fabs(error) > max_error)
4415 max_error = std::fabs(error);
4420 std::ofstream mismatch_file;
4424 mismatch_file.open(
"mismatch.dat");
4425 mismatch_file <<
"ZONE" << std::endl;
4426 mismatch_file << x_large[0] <<
" " << x_large[1] <<
" "
4427 << x_large[2] <<
" 2 \n";
4428 mismatch_file << x_small[0] <<
" " << x_small[1] <<
" "
4429 << x_small[2] <<
" 3 \n";
4432 if (neighbours_file.is_open())
4434 neighbours_file <<
"#SOUTH WEST: " << std::endl;
4435 neighbours_file << x_large[0] <<
" " << x_large[1] <<
" "
4436 << x_large[2] <<
" 40 \n";
4460 if (is_periodic ==
false)
4462 error = sqrt(pow(x_small[0] - x_large[0], 2) +
4463 pow(x_small[1] - x_large[1], 2) +
4464 pow(x_small[2] - x_large[2], 2));
4468 if (neighbours_file.is_open())
4470 neighbours_file <<
"#NORTH EAST: " << std::endl;
4471 neighbours_file << x_large[0] <<
" " << x_large[1] <<
" "
4472 << x_large[2] <<
" 80 \n";
4475 if (neighbours_txt_file.is_open())
4477 neighbours_txt_file <<
"Error (2) " << error << std::endl;
4480 if (std::fabs(error) > max_error)
4482 max_error = std::fabs(error);
4492 if (!mismatch_file.is_open())
4494 mismatch_file.open(
"mismatch.dat");
4496 mismatch_file <<
"ZONE" << std::endl;
4497 mismatch_file << x_large[0] <<
" " << x_large[1] <<
" "
4498 << x_large[2] <<
" 2 " << std::fabs(error)
4500 mismatch_file << x_small[0] <<
" " << x_small[1] <<
" "
4501 << x_small[2] <<
" 3 " << std::fabs(error)
4503 mismatch_file.close();
4512 if (neighbours_file.is_open())
4515 <<
"#---------------------------------\n"
4516 <<
"# No neighbour in direction: " <<
Direct_string[direction]
4518 <<
"#---------------------------------" << std::endl;
4521 ->output_corners(neighbours_file,
"WHITE");
4522 neighbours_file <<
"ZONE I=2 \n";
4523 neighbours_file <<
"-0.05 -0.05 -0.05 0 \n";
4524 neighbours_file <<
"-0.05 -0.05 -0.05 0 \n";
4528 if (neighbours_file.is_open())
4530 neighbours_file << std::endl << std::endl << std::endl;
4553 std::ofstream& neighbours_file,
4554 std::ofstream& no_true_edge_file,
4555 std::ofstream& neighbours_txt_file,
4558 using namespace OcTreeNames;
4579 unsigned long num_nodes = forest_nodes_pt.size();
4581 for (
unsigned long i = 0;
i < num_nodes;
i++)
4590 if (neighbours_file.is_open())
4592 neighbours_file <<
"#---------------------------------" << std::endl;
4593 neighbours_file <<
"# The element itself: &qu