46 unsigned int diag_1_node_1,
47 unsigned int diag_1_node_2,
48 unsigned int diag_2_node_1,
49 unsigned int diag_2_node_2)
51 return ((elem->
node_id(diag_1_node_1) > elem->
node_id(diag_2_node_1) &&
67 const bool perturb_boundary)
71 libmesh_assert ((factor >= 0.) && (factor <= 1.));
73 LOG_SCOPE(
"distort()",
"MeshTools::Modification");
77 std::unordered_set<dof_id_type> boundary_node_ids;
78 if (!perturb_boundary)
89 hmin[n.id()] =
std::min(hmin[n.id()],
90 static_cast<float>(elem->
hmin()));
94 const unsigned int seed = 123456;
108 if ((perturb_boundary || !boundary_node_ids.count(n)) && hmin[n] < 1.e20)
111 Point dir (static_cast<Real>(std::rand())/static_cast<Real>(RAND_MAX),
112 (
mesh.
mesh_dimension() > 1) ? static_cast<Real>(std::rand())/static_cast<Real>(RAND_MAX) : 0.,
113 ((
mesh.
mesh_dimension() == 3) ? static_cast<Real>(std::rand())/static_cast<Real>(RAND_MAX) : 0.));
115 dir(0) = (dir(0)-.5)*2.;
117 dir(1) = (dir(1)-.5)*2.;
119 dir(2) = (dir(2)-.5)*2.;
127 (*node)(0) += dir(0)*factor*hmin[n];
129 (*node)(1) += dir(1)*factor*hmin[n];
131 (*node)(2) += dir(2)*factor*hmin[n];
144 LOG_SCOPE(
"redistribute()",
"MeshTools::Modification");
149 std::unique_ptr<FunctionBase<Real>> myfunc = mapfunc.
clone();
153 (*myfunc)(*node, output_vec);
155 (*node)(0) = output_vec(0);
157 (*node)(1) = output_vec(1);
160 (*node)(2) = output_vec(2);
172 const Point p(xt, yt, zt);
210 const Real sp = std::sin(p), cp = std::cos(p);
211 const Real st = std::sin(t), ct = std::cos(t);
212 const Real ss = std::sin(s), cs = std::cos(s);
220 const Point pt = *node;
221 const Real x = pt(0);
222 const Real y = pt(1);
223 const Real z = pt(2);
224 *node =
Point(( cp*cs-sp*ct*ss)*x + ( sp*cs+cp*ct*ss)*y + (st*ss)*z,
225 (-cp*ss-sp*ct*cs)*x + (-sp*ss+cp*ct*cs)*y + (st*cs)*z,
226 ( sp*st)*x + (-cp*st)*y + (ct)*z );
229 libmesh_error_msg(
"MeshTools::Modification::rotate() requires libMesh to be compiled with LIBMESH_DIM==3");
239 const Real x_scale = xs;
245 libmesh_assert_equal_to (zs, 0.);
247 y_scale = z_scale = x_scale;
252 (*node)(0) *= x_scale;
259 (*node)(1) *= y_scale;
266 (*node)(2) *= z_scale;
282 std::vector<Elem *> new_elements;
284 unsigned int max_subelems = 1;
290 new_elements.reserve (max_subelems*n_orig_elem);
300 std::vector<Elem *> new_bndry_elements;
301 std::vector<unsigned short int> new_bndry_sides;
302 std::vector<boundary_id_type> new_bndry_ids;
307 bool added_new_ghost_point =
false;
320 #ifdef LIBMESH_ENABLE_UNIQUE_ID 329 libmesh_assert (!elem->
parent());
335 for (
unsigned int i = 0; i != max_subelems; ++i)
336 subelem[i] =
nullptr;
342 subelem[0] =
new Tri3;
343 subelem[1] =
new Tri3;
346 if ((elem->
point(0) - elem->
point(2)).norm() <
350 subelem[0]->set_node(1) = elem->
node_ptr(1);
351 subelem[0]->set_node(2) = elem->
node_ptr(2);
353 subelem[1]->set_node(0) = elem->
node_ptr(0);
354 subelem[1]->set_node(1) = elem->
node_ptr(2);
355 subelem[1]->set_node(2) = elem->
node_ptr(3);
360 subelem[0]->set_node(0) = elem->
node_ptr(0);
361 subelem[0]->set_node(1) = elem->
node_ptr(1);
362 subelem[0]->set_node(2) = elem->
node_ptr(3);
364 subelem[1]->set_node(0) = elem->
node_ptr(1);
365 subelem[1]->set_node(1) = elem->
node_ptr(2);
366 subelem[1]->set_node(2) = elem->
node_ptr(3);
376 added_new_ghost_point =
true;
378 subelem[0] =
new Tri6;
379 subelem[1] =
new Tri6;
390 if ((elem->
point(0) - elem->
point(2)).norm() <
393 subelem[0]->set_node(0) = elem->
node_ptr(0);
394 subelem[0]->set_node(1) = elem->
node_ptr(1);
395 subelem[0]->set_node(2) = elem->
node_ptr(2);
396 subelem[0]->set_node(3) = elem->
node_ptr(4);
397 subelem[0]->set_node(4) = elem->
node_ptr(5);
398 subelem[0]->set_node(5) = new_node;
400 subelem[1]->set_node(0) = elem->
node_ptr(0);
401 subelem[1]->set_node(1) = elem->
node_ptr(2);
402 subelem[1]->set_node(2) = elem->
node_ptr(3);
403 subelem[1]->set_node(3) = new_node;
404 subelem[1]->set_node(4) = elem->
node_ptr(6);
405 subelem[1]->set_node(5) = elem->
node_ptr(7);
411 subelem[0]->set_node(0) = elem->
node_ptr(3);
412 subelem[0]->set_node(1) = elem->
node_ptr(0);
413 subelem[0]->set_node(2) = elem->
node_ptr(1);
414 subelem[0]->set_node(3) = elem->
node_ptr(7);
415 subelem[0]->set_node(4) = elem->
node_ptr(4);
416 subelem[0]->set_node(5) = new_node;
418 subelem[1]->set_node(0) = elem->
node_ptr(1);
419 subelem[1]->set_node(1) = elem->
node_ptr(2);
420 subelem[1]->set_node(2) = elem->
node_ptr(3);
421 subelem[1]->set_node(3) = elem->
node_ptr(5);
422 subelem[1]->set_node(4) = elem->
node_ptr(6);
423 subelem[1]->set_node(5) = new_node;
431 subelem[0] =
new Tri6;
432 subelem[1] =
new Tri6;
435 if ((elem->
point(0) - elem->
point(2)).norm() <
439 subelem[0]->set_node(1) = elem->
node_ptr(1);
440 subelem[0]->set_node(2) = elem->
node_ptr(2);
441 subelem[0]->set_node(3) = elem->
node_ptr(4);
442 subelem[0]->set_node(4) = elem->
node_ptr(5);
443 subelem[0]->set_node(5) = elem->
node_ptr(8);
445 subelem[1]->set_node(0) = elem->
node_ptr(0);
446 subelem[1]->set_node(1) = elem->
node_ptr(2);
447 subelem[1]->set_node(2) = elem->
node_ptr(3);
448 subelem[1]->set_node(3) = elem->
node_ptr(8);
449 subelem[1]->set_node(4) = elem->
node_ptr(6);
450 subelem[1]->set_node(5) = elem->
node_ptr(7);
455 subelem[0]->set_node(0) = elem->
node_ptr(0);
456 subelem[0]->set_node(1) = elem->
node_ptr(1);
457 subelem[0]->set_node(2) = elem->
node_ptr(3);
458 subelem[0]->set_node(3) = elem->
node_ptr(4);
459 subelem[0]->set_node(4) = elem->
node_ptr(8);
460 subelem[0]->set_node(5) = elem->
node_ptr(7);
462 subelem[1]->set_node(0) = elem->
node_ptr(1);
463 subelem[1]->set_node(1) = elem->
node_ptr(2);
464 subelem[1]->set_node(2) = elem->
node_ptr(3);
465 subelem[1]->set_node(3) = elem->
node_ptr(5);
466 subelem[1]->set_node(4) = elem->
node_ptr(6);
467 subelem[1]->set_node(5) = elem->
node_ptr(8);
476 subelem[0] =
new Tet4;
477 subelem[1] =
new Tet4;
478 subelem[2] =
new Tet4;
496 if (split_first_diagonal(elem, 0,4, 1,3))
499 if (split_first_diagonal(elem, 0,5, 2,3))
502 if (split_first_diagonal(elem, 1,5, 2,4))
505 subelem[0]->set_node(1) = elem->
node_ptr(4);
506 subelem[0]->set_node(2) = elem->
node_ptr(5);
507 subelem[0]->set_node(3) = elem->
node_ptr(3);
509 subelem[1]->set_node(0) = elem->
node_ptr(0);
510 subelem[1]->set_node(1) = elem->
node_ptr(4);
511 subelem[1]->set_node(2) = elem->
node_ptr(1);
512 subelem[1]->set_node(3) = elem->
node_ptr(5);
514 subelem[2]->set_node(0) = elem->
node_ptr(0);
515 subelem[2]->set_node(1) = elem->
node_ptr(1);
516 subelem[2]->set_node(2) = elem->
node_ptr(2);
517 subelem[2]->set_node(3) = elem->
node_ptr(5);
521 libmesh_assert (split_first_diagonal(elem, 2,4, 1,5));
523 subelem[0]->set_node(0) = elem->
node_ptr(0);
524 subelem[0]->set_node(1) = elem->
node_ptr(4);
525 subelem[0]->set_node(2) = elem->
node_ptr(5);
526 subelem[0]->set_node(3) = elem->
node_ptr(3);
528 subelem[1]->set_node(0) = elem->
node_ptr(0);
529 subelem[1]->set_node(1) = elem->
node_ptr(4);
530 subelem[1]->set_node(2) = elem->
node_ptr(2);
531 subelem[1]->set_node(3) = elem->
node_ptr(5);
533 subelem[2]->set_node(0) = elem->
node_ptr(0);
534 subelem[2]->set_node(1) = elem->
node_ptr(1);
535 subelem[2]->set_node(2) = elem->
node_ptr(2);
536 subelem[2]->set_node(3) = elem->
node_ptr(4);
541 libmesh_assert (split_first_diagonal(elem, 2,3, 0,5));
544 libmesh_assert (split_first_diagonal(elem, 2,4, 1,5));
546 subelem[0]->set_node(0) = elem->
node_ptr(0);
547 subelem[0]->set_node(1) = elem->
node_ptr(4);
548 subelem[0]->set_node(2) = elem->
node_ptr(2);
549 subelem[0]->set_node(3) = elem->
node_ptr(3);
551 subelem[1]->set_node(0) = elem->
node_ptr(3);
552 subelem[1]->set_node(1) = elem->
node_ptr(4);
553 subelem[1]->set_node(2) = elem->
node_ptr(2);
554 subelem[1]->set_node(3) = elem->
node_ptr(5);
556 subelem[2]->set_node(0) = elem->
node_ptr(0);
557 subelem[2]->set_node(1) = elem->
node_ptr(1);
558 subelem[2]->set_node(2) = elem->
node_ptr(2);
559 subelem[2]->set_node(3) = elem->
node_ptr(4);
564 libmesh_assert (split_first_diagonal(elem, 1,3, 0,4));
567 if (split_first_diagonal(elem, 0,5, 2,3))
570 libmesh_assert (split_first_diagonal(elem, 1,5, 2,4));
572 subelem[0]->set_node(0) = elem->
node_ptr(1);
573 subelem[0]->set_node(1) = elem->
node_ptr(3);
574 subelem[0]->set_node(2) = elem->
node_ptr(4);
575 subelem[0]->set_node(3) = elem->
node_ptr(5);
577 subelem[1]->set_node(0) = elem->
node_ptr(1);
578 subelem[1]->set_node(1) = elem->
node_ptr(0);
579 subelem[1]->set_node(2) = elem->
node_ptr(3);
580 subelem[1]->set_node(3) = elem->
node_ptr(5);
582 subelem[2]->set_node(0) = elem->
node_ptr(0);
583 subelem[2]->set_node(1) = elem->
node_ptr(1);
584 subelem[2]->set_node(2) = elem->
node_ptr(2);
585 subelem[2]->set_node(3) = elem->
node_ptr(5);
589 libmesh_assert (split_first_diagonal(elem, 2,3, 0,5));
592 if (split_first_diagonal(elem, 1,5, 2,4))
594 subelem[0]->set_node(0) = elem->
node_ptr(0);
595 subelem[0]->set_node(1) = elem->
node_ptr(1);
596 subelem[0]->set_node(2) = elem->
node_ptr(2);
597 subelem[0]->set_node(3) = elem->
node_ptr(3);
599 subelem[1]->set_node(0) = elem->
node_ptr(3);
600 subelem[1]->set_node(1) = elem->
node_ptr(1);
601 subelem[1]->set_node(2) = elem->
node_ptr(2);
602 subelem[1]->set_node(3) = elem->
node_ptr(5);
604 subelem[2]->set_node(0) = elem->
node_ptr(1);
605 subelem[2]->set_node(1) = elem->
node_ptr(3);
606 subelem[2]->set_node(2) = elem->
node_ptr(4);
607 subelem[2]->set_node(3) = elem->
node_ptr(5);
611 libmesh_assert (split_first_diagonal(elem, 2,4, 1,5));
613 subelem[0]->set_node(0) = elem->
node_ptr(0);
614 subelem[0]->set_node(1) = elem->
node_ptr(1);
615 subelem[0]->set_node(2) = elem->
node_ptr(2);
616 subelem[0]->set_node(3) = elem->
node_ptr(3);
618 subelem[1]->set_node(0) = elem->
node_ptr(2);
619 subelem[1]->set_node(1) = elem->
node_ptr(3);
620 subelem[1]->set_node(2) = elem->
node_ptr(4);
621 subelem[1]->set_node(3) = elem->
node_ptr(5);
623 subelem[2]->set_node(0) = elem->
node_ptr(3);
624 subelem[2]->set_node(1) = elem->
node_ptr(1);
625 subelem[2]->set_node(2) = elem->
node_ptr(2);
626 subelem[2]->set_node(3) = elem->
node_ptr(4);
636 subelem[0] =
new Tet10;
637 subelem[1] =
new Tet10;
638 subelem[2] =
new Tet10;
641 if (split_first_diagonal(elem, 0,4, 1,3))
644 if (split_first_diagonal(elem, 0,5, 2,3))
647 if (split_first_diagonal(elem, 1,5, 2,4))
650 subelem[0]->set_node(1) = elem->
node_ptr(4);
651 subelem[0]->set_node(2) = elem->
node_ptr(5);
652 subelem[0]->set_node(3) = elem->
node_ptr(3);
654 subelem[0]->set_node(4) = elem->
node_ptr(15);
655 subelem[0]->set_node(5) = elem->
node_ptr(13);
656 subelem[0]->set_node(6) = elem->
node_ptr(17);
657 subelem[0]->set_node(7) = elem->
node_ptr(9);
658 subelem[0]->set_node(8) = elem->
node_ptr(12);
659 subelem[0]->set_node(9) = elem->
node_ptr(14);
661 subelem[1]->set_node(0) = elem->
node_ptr(0);
662 subelem[1]->set_node(1) = elem->
node_ptr(4);
663 subelem[1]->set_node(2) = elem->
node_ptr(1);
664 subelem[1]->set_node(3) = elem->
node_ptr(5);
666 subelem[1]->set_node(4) = elem->
node_ptr(15);
667 subelem[1]->set_node(5) = elem->
node_ptr(10);
668 subelem[1]->set_node(6) = elem->
node_ptr(6);
669 subelem[1]->set_node(7) = elem->
node_ptr(17);
670 subelem[1]->set_node(8) = elem->
node_ptr(13);
671 subelem[1]->set_node(9) = elem->
node_ptr(16);
673 subelem[2]->set_node(0) = elem->
node_ptr(0);
674 subelem[2]->set_node(1) = elem->
node_ptr(1);
675 subelem[2]->set_node(2) = elem->
node_ptr(2);
676 subelem[2]->set_node(3) = elem->
node_ptr(5);
678 subelem[2]->set_node(4) = elem->
node_ptr(6);
679 subelem[2]->set_node(5) = elem->
node_ptr(7);
680 subelem[2]->set_node(6) = elem->
node_ptr(8);
681 subelem[2]->set_node(7) = elem->
node_ptr(17);
682 subelem[2]->set_node(8) = elem->
node_ptr(16);
683 subelem[2]->set_node(9) = elem->
node_ptr(11);
687 libmesh_assert (split_first_diagonal(elem, 2,4, 1,5));
689 subelem[0]->set_node(0) = elem->
node_ptr(0);
690 subelem[0]->set_node(1) = elem->
node_ptr(4);
691 subelem[0]->set_node(2) = elem->
node_ptr(5);
692 subelem[0]->set_node(3) = elem->
node_ptr(3);
694 subelem[0]->set_node(4) = elem->
node_ptr(15);
695 subelem[0]->set_node(5) = elem->
node_ptr(13);
696 subelem[0]->set_node(6) = elem->
node_ptr(17);
697 subelem[0]->set_node(7) = elem->
node_ptr(9);
698 subelem[0]->set_node(8) = elem->
node_ptr(12);
699 subelem[0]->set_node(9) = elem->
node_ptr(14);
701 subelem[1]->set_node(0) = elem->
node_ptr(0);
702 subelem[1]->set_node(1) = elem->
node_ptr(4);
703 subelem[1]->set_node(2) = elem->
node_ptr(2);
704 subelem[1]->set_node(3) = elem->
node_ptr(5);
706 subelem[1]->set_node(4) = elem->
node_ptr(15);
707 subelem[1]->set_node(5) = elem->
node_ptr(16);
708 subelem[1]->set_node(6) = elem->
node_ptr(8);
709 subelem[1]->set_node(7) = elem->
node_ptr(17);
710 subelem[1]->set_node(8) = elem->
node_ptr(13);
711 subelem[1]->set_node(9) = elem->
node_ptr(11);
713 subelem[2]->set_node(0) = elem->
node_ptr(0);
714 subelem[2]->set_node(1) = elem->
node_ptr(1);
715 subelem[2]->set_node(2) = elem->
node_ptr(2);
716 subelem[2]->set_node(3) = elem->
node_ptr(4);
718 subelem[2]->set_node(4) = elem->
node_ptr(6);
719 subelem[2]->set_node(5) = elem->
node_ptr(7);
720 subelem[2]->set_node(6) = elem->
node_ptr(8);
721 subelem[2]->set_node(7) = elem->
node_ptr(15);
722 subelem[2]->set_node(8) = elem->
node_ptr(10);
723 subelem[2]->set_node(9) = elem->
node_ptr(16);
728 libmesh_assert (split_first_diagonal(elem, 2,3, 0,5));
731 libmesh_assert (split_first_diagonal(elem, 2,4, 1,5));
733 subelem[0]->set_node(0) = elem->
node_ptr(0);
734 subelem[0]->set_node(1) = elem->
node_ptr(4);
735 subelem[0]->set_node(2) = elem->
node_ptr(2);
736 subelem[0]->set_node(3) = elem->
node_ptr(3);
738 subelem[0]->set_node(4) = elem->
node_ptr(15);
739 subelem[0]->set_node(5) = elem->
node_ptr(16);
740 subelem[0]->set_node(6) = elem->
node_ptr(8);
741 subelem[0]->set_node(7) = elem->
node_ptr(9);
742 subelem[0]->set_node(8) = elem->
node_ptr(12);
743 subelem[0]->set_node(9) = elem->
node_ptr(17);
745 subelem[1]->set_node(0) = elem->
node_ptr(3);
746 subelem[1]->set_node(1) = elem->
node_ptr(4);
747 subelem[1]->set_node(2) = elem->
node_ptr(2);
748 subelem[1]->set_node(3) = elem->
node_ptr(5);
750 subelem[1]->set_node(4) = elem->
node_ptr(12);
751 subelem[1]->set_node(5) = elem->
node_ptr(16);
752 subelem[1]->set_node(6) = elem->
node_ptr(17);
753 subelem[1]->set_node(7) = elem->
node_ptr(14);
754 subelem[1]->set_node(8) = elem->
node_ptr(13);
755 subelem[1]->set_node(9) = elem->
node_ptr(11);
757 subelem[2]->set_node(0) = elem->
node_ptr(0);
758 subelem[2]->set_node(1) = elem->
node_ptr(1);
759 subelem[2]->set_node(2) = elem->
node_ptr(2);
760 subelem[2]->set_node(3) = elem->
node_ptr(4);
762 subelem[2]->set_node(4) = elem->
node_ptr(6);
763 subelem[2]->set_node(5) = elem->
node_ptr(7);
764 subelem[2]->set_node(6) = elem->
node_ptr(8);
765 subelem[2]->set_node(7) = elem->
node_ptr(15);
766 subelem[2]->set_node(8) = elem->
node_ptr(10);
767 subelem[2]->set_node(9) = elem->
node_ptr(16);
772 libmesh_assert (split_first_diagonal(elem, 1,3, 0,4));
775 if (split_first_diagonal(elem, 0,5, 2,3))
778 libmesh_assert (split_first_diagonal(elem, 1,5, 2,4));
780 subelem[0]->set_node(0) = elem->
node_ptr(1);
781 subelem[0]->set_node(1) = elem->
node_ptr(3);
782 subelem[0]->set_node(2) = elem->
node_ptr(4);
783 subelem[0]->set_node(3) = elem->
node_ptr(5);
785 subelem[0]->set_node(4) = elem->
node_ptr(15);
786 subelem[0]->set_node(5) = elem->
node_ptr(12);
787 subelem[0]->set_node(6) = elem->
node_ptr(10);
788 subelem[0]->set_node(7) = elem->
node_ptr(16);
789 subelem[0]->set_node(8) = elem->
node_ptr(14);
790 subelem[0]->set_node(9) = elem->
node_ptr(13);
792 subelem[1]->set_node(0) = elem->
node_ptr(1);
793 subelem[1]->set_node(1) = elem->
node_ptr(0);
794 subelem[1]->set_node(2) = elem->
node_ptr(3);
795 subelem[1]->set_node(3) = elem->
node_ptr(5);
797 subelem[1]->set_node(4) = elem->
node_ptr(6);
798 subelem[1]->set_node(5) = elem->
node_ptr(9);
799 subelem[1]->set_node(6) = elem->
node_ptr(15);
800 subelem[1]->set_node(7) = elem->
node_ptr(16);
801 subelem[1]->set_node(8) = elem->
node_ptr(17);
802 subelem[1]->set_node(9) = elem->
node_ptr(14);
804 subelem[2]->set_node(0) = elem->
node_ptr(0);
805 subelem[2]->set_node(1) = elem->
node_ptr(1);
806 subelem[2]->set_node(2) = elem->
node_ptr(2);
807 subelem[2]->set_node(3) = elem->
node_ptr(5);
809 subelem[2]->set_node(4) = elem->
node_ptr(6);
810 subelem[2]->set_node(5) = elem->
node_ptr(7);
811 subelem[2]->set_node(6) = elem->
node_ptr(8);
812 subelem[2]->set_node(7) = elem->
node_ptr(17);
813 subelem[2]->set_node(8) = elem->
node_ptr(16);
814 subelem[2]->set_node(9) = elem->
node_ptr(11);
818 libmesh_assert (split_first_diagonal(elem, 2,3, 0,5));
821 if (split_first_diagonal(elem, 1,5, 2,4))
823 subelem[0]->set_node(0) = elem->
node_ptr(0);
824 subelem[0]->set_node(1) = elem->
node_ptr(1);
825 subelem[0]->set_node(2) = elem->
node_ptr(2);
826 subelem[0]->set_node(3) = elem->
node_ptr(3);
828 subelem[0]->set_node(4) = elem->
node_ptr(6);
829 subelem[0]->set_node(5) = elem->
node_ptr(7);
830 subelem[0]->set_node(6) = elem->
node_ptr(8);
831 subelem[0]->set_node(7) = elem->
node_ptr(9);
832 subelem[0]->set_node(8) = elem->
node_ptr(15);
833 subelem[0]->set_node(9) = elem->
node_ptr(17);
835 subelem[1]->set_node(0) = elem->
node_ptr(3);
836 subelem[1]->set_node(1) = elem->
node_ptr(1);
837 subelem[1]->set_node(2) = elem->
node_ptr(2);
838 subelem[1]->set_node(3) = elem->
node_ptr(5);
840 subelem[1]->set_node(4) = elem->
node_ptr(15);
841 subelem[1]->set_node(5) = elem->
node_ptr(7);
842 subelem[1]->set_node(6) = elem->
node_ptr(17);
843 subelem[1]->set_node(7) = elem->
node_ptr(14);
844 subelem[1]->set_node(8) = elem->
node_ptr(16);
845 subelem[1]->set_node(9) = elem->
node_ptr(11);
847 subelem[2]->set_node(0) = elem->
node_ptr(1);
848 subelem[2]->set_node(1) = elem->
node_ptr(3);
849 subelem[2]->set_node(2) = elem->
node_ptr(4);
850 subelem[2]->set_node(3) = elem->
node_ptr(5);
852 subelem[2]->set_node(4) = elem->
node_ptr(15);
853 subelem[2]->set_node(5) = elem->
node_ptr(12);
854 subelem[2]->set_node(6) = elem->
node_ptr(10);
855 subelem[2]->set_node(7) = elem->
node_ptr(16);
856 subelem[2]->set_node(8) = elem->
node_ptr(14);
857 subelem[2]->set_node(9) = elem->
node_ptr(13);
861 libmesh_assert (split_first_diagonal(elem, 2,4, 1,5));
863 subelem[0]->set_node(0) = elem->
node_ptr(0);
864 subelem[0]->set_node(1) = elem->
node_ptr(1);
865 subelem[0]->set_node(2) = elem->
node_ptr(2);
866 subelem[0]->set_node(3) = elem->
node_ptr(3);
868 subelem[0]->set_node(4) = elem->
node_ptr(6);
869 subelem[0]->set_node(5) = elem->
node_ptr(7);
870 subelem[0]->set_node(6) = elem->
node_ptr(8);
871 subelem[0]->set_node(7) = elem->
node_ptr(9);
872 subelem[0]->set_node(8) = elem->
node_ptr(15);
873 subelem[0]->set_node(9) = elem->
node_ptr(17);
875 subelem[1]->set_node(0) = elem->
node_ptr(2);
876 subelem[1]->set_node(1) = elem->
node_ptr(3);
877 subelem[1]->set_node(2) = elem->
node_ptr(4);
878 subelem[1]->set_node(3) = elem->
node_ptr(5);
880 subelem[1]->set_node(4) = elem->
node_ptr(17);
881 subelem[1]->set_node(5) = elem->
node_ptr(12);
882 subelem[1]->set_node(6) = elem->
node_ptr(16);
883 subelem[1]->set_node(7) = elem->
node_ptr(11);
884 subelem[1]->set_node(8) = elem->
node_ptr(14);
885 subelem[1]->set_node(9) = elem->
node_ptr(13);
887 subelem[2]->set_node(0) = elem->
node_ptr(3);
888 subelem[2]->set_node(1) = elem->
node_ptr(1);
889 subelem[2]->set_node(2) = elem->
node_ptr(2);
890 subelem[2]->set_node(3) = elem->
node_ptr(4);
892 subelem[2]->set_node(4) = elem->
node_ptr(15);
893 subelem[2]->set_node(5) = elem->
node_ptr(7);
894 subelem[2]->set_node(6) = elem->
node_ptr(17);
895 subelem[2]->set_node(7) = elem->
node_ptr(12);
896 subelem[2]->set_node(8) = elem->
node_ptr(10);
897 subelem[2]->set_node(9) = elem->
node_ptr(16);
925 libMesh::err <<
"Error, encountered unimplemented element " 926 << Utility::enum_to_string<ElemType>(etype)
927 <<
" in MeshTools::Modification::all_tri()..." 929 libmesh_not_implemented();
936 for (
unsigned int i=0; i != max_subelems; ++i)
949 if (mesh_has_boundary_data || mesh_is_serial)
952 std::vector<boundary_id_type> bc_ids;
957 for (
const auto & b_id : bc_ids)
964 std::vector<dof_id_type> elem_side_nodes(elem_side->n_nodes());
965 for (
unsigned int esn=0,
966 n_esn = cast_int<unsigned int>(elem_side_nodes.size());
968 elem_side_nodes[esn] = elem_side->node_id(esn);
969 std::sort(elem_side_nodes.begin(), elem_side_nodes.end());
971 for (
unsigned int i=0; i != max_subelems; ++i)
974 for (
auto subside : subelem[i]->side_index_range())
976 std::unique_ptr<Elem> subside_elem = subelem[i]->build_side_ptr(subside);
984 std::vector<dof_id_type> subside_nodes(subside_elem->n_vertices());
985 for (
unsigned int ssn=0,
986 n_ssn = cast_int<unsigned int>(subside_nodes.size());
988 subside_nodes[ssn] = subside_elem->node_id(ssn);
989 std::sort(subside_nodes.begin(), subside_nodes.end());
993 if (std::includes(elem_side_nodes.begin(), elem_side_nodes.end(),
994 subside_nodes.begin(), subside_nodes.end()))
998 new_bndry_ids.push_back(b_id);
999 new_bndry_elements.push_back(subelem[i]);
1000 new_bndry_sides.push_back(subside);
1006 subelem[i]->set_neighbor(subside, const_cast<RemoteElem*>(
remote_elem));
1022 for (
unsigned int i=0; i != max_subelems; ++i)
1029 subelem[i]->set_id( max_orig_id + 6*elem->
id() + i );
1031 #ifdef LIBMESH_ENABLE_UNIQUE_ID 1032 subelem[i]->set_unique_id() = max_unique_id + 2*elem->
unique_id() + i;
1036 new_elements.push_back(subelem[i]);
1048 std::vector<Elem *>::iterator el = new_elements.begin();
1049 const std::vector<Elem *>::iterator
end = new_elements.end();
1050 for (; el !=
end; ++el)
1054 if (mesh_has_boundary_data)
1067 bool nbe_nonempty = new_bndry_elements.size();
1069 libmesh_assert(nbe_nonempty ||
1075 libmesh_assert_equal_to (new_bndry_elements.size(), new_bndry_sides.size());
1076 libmesh_assert_equal_to (new_bndry_sides.size(), new_bndry_ids.size());
1079 for (std::size_t s=0; s<new_bndry_elements.size(); ++s)
1093 if (added_new_ghost_point)
1107 const unsigned int n_iterations,
1118 std::unordered_set<dof_id_type> boundary_node_ids =
1121 for (
unsigned int iter=0; iter<n_iterations; iter++)
1127 for (
unsigned int refinement_level=0; refinement_level !=
n_levels;
1131 std::vector<Point> new_positions;
1132 std::vector<Real>
weight;
1146 if (refinement_level == 0)
1161 const Node & node0 =
side->node_ref(0);
1162 const Node & node1 =
side->node_ref(1);
1164 Real node_weight = 1.;
1168 Point diff = node0-node1;
1173 new_positions[id0].add_scaled( node1, node_weight );
1174 new_positions[id1].add_scaled( node0, node_weight );
1175 weight[id0] += node_weight;
1176 weight[id1] += node_weight;
1180 #ifdef LIBMESH_ENABLE_AMR 1216 new_positions[id] = point;
1220 #endif // #ifdef LIBMESH_ENABLE_AMR 1227 for (
unsigned int nid=0; nid<
mesh.
n_nodes(); ++nid)
1228 if (!boundary_node_ids.count(nid) &&
weight[nid] > 0.)
1238 const unsigned int son_begin = elem->
n_vertices();
1239 const unsigned int son_end = elem->
n_nodes();
1240 for (
unsigned int n=son_begin; n<son_end; n++)
1242 const unsigned int n_adjacent_vertices =
1246 for (
unsigned int v=0; v<n_adjacent_vertices; v++)
1259 #ifdef LIBMESH_ENABLE_AMR 1272 std::vector<Elem *> new_elements;
1275 std::vector<Elem *> saved_boundary_elements;
1276 std::vector<boundary_id_type> saved_bc_ids;
1277 std::vector<unsigned short int> saved_bc_sides;
1280 std::vector<boundary_id_type> bc_ids;
1304 #ifdef LIBMESH_ENABLE_UNIQUE_ID 1317 for (
const auto &
bc_id : bc_ids)
1320 saved_boundary_elements.push_back(copy);
1321 saved_bc_ids.push_back(
bc_id);
1322 saved_bc_sides.push_back(s);
1331 new_elements.push_back(copy);
1336 libmesh_assert_equal_to (saved_boundary_elements.size(), saved_bc_ids.size());
1337 libmesh_assert_equal_to (saved_bc_ids.size(), saved_bc_sides.size());
1344 for (
auto & new_elem : new_elements)
1355 libmesh_assert_equal_to (orig_id, added_elem->
id());
1362 for (std::size_t e=0; e<saved_boundary_elements.size(); ++e)
1370 #endif // #ifdef LIBMESH_ENABLE_AMR 1378 if (old_id == new_id)
1389 std::vector<boundary_id_type> bndry_ids;
1393 if (std::get<1>(t) == old_id)
1402 std::replace(bndry_ids.begin(), bndry_ids.end(), old_id, new_id);
1414 std::vector<boundary_id_type> bndry_ids;
1418 if (std::get<2>(t) == old_id)
1424 unsigned short int edge = std::get<1>(t);
1430 std::replace(bndry_ids.begin(), bndry_ids.end(), old_id, new_id);
1436 bi.
add_edge(elem, edge, bndry_ids);
1442 std::vector<boundary_id_type> bndry_ids;
1446 if (std::get<2>(t) == old_id)
1452 unsigned short int shellface = std::get<1>(t);
1458 std::replace(bndry_ids.begin(), bndry_ids.end(), old_id, new_id);
1470 std::vector<boundary_id_type> bndry_ids;
1474 if (std::get<2>(t) == old_id)
1480 unsigned short int side = std::get<1>(t);
1486 std::replace(bndry_ids.begin(), bndry_ids.end(), old_id, new_id);
1507 if (old_id == new_id)
std::size_t n_boundary_conds() const
A 2D triangular element with 3 nodes.
unique_id_type & set_unique_id()
const Elem * parent() const
virtual dof_id_type n_active_elem() const =0
virtual Node *& set_node(const unsigned int i)
void remove_edge(const Elem *elem, const unsigned short int edge)
A geometric point in (x,y,z) space associated with a DOF.
virtual unique_id_type parallel_max_unique_id() const =0
virtual element_iterator level_elements_begin(unsigned int level)=0
IntRange< unsigned short > side_index_range() const
void add_scaled(const TypeVector< T2 > &, const T)
void remove_id(boundary_id_type id)
void remove_shellface(const Elem *elem, const unsigned short int shellface)
void remove(const Node *node)
The base class for all geometric element types.
virtual float embedding_matrix(const unsigned int child_num, const unsigned int child_node_num, const unsigned int parent_node_num) const =0
unique_id_type unique_id() const
const Parallel::Communicator & comm() const
void shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface, std::vector< boundary_id_type > &vec_to_fill) const
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
const BoundaryInfo & get_boundary_info() const
long double max(long double a, double b)
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
void add(const TypeVector< T2 > &)
void build_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
A 2D triangular element with 6 nodes.
std::vector< boundary_id_type > boundary_ids(const Node *node) const
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i, bool proxy=true)=0
virtual element_iterator level_elements_end(unsigned int level)=0
virtual bool is_serial() const
TypeVector< T > unit() const
void libmesh_ignore(const Args &...)
void build_node_list(std::vector< dof_id_type > &node_id_list, std::vector< boundary_id_type > &bc_id_list) const
void add_node(const Node *node, const boundary_id_type id)
static const boundary_id_type invalid_id
virtual void delete_elem(Elem *e)=0
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual Real hmin() const
virtual unsigned int n_nodes() const =0
virtual Elem * add_elem(Elem *e)=0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual SimpleRange< node_iterator > node_ptr_range()=0
virtual dof_id_type max_elem_id() const =0
Used by the Mesh to keep track of boundary nodes and elements.
SimpleRange< I > as_range(const std::pair< I, I > &p)
static const dof_id_type invalid_id
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
OStreamProxy err(std::cerr)
virtual unsigned int n_second_order_adjacent_vertices(const unsigned int n) const
void set_neighbor(const unsigned int i, Elem *n)
void build_shellface_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &shellface_list, std::vector< boundary_id_type > &bc_id_list) const
double pow(double a, int b)
unsigned int which_child_am_i(const Elem *e) const
SimpleRange< NodeRefIter > node_ref_range()
virtual const Elem * elem_ptr(const dof_id_type i) const =0
const Elem * neighbor_ptr(unsigned int i) const
void remove_side(const Elem *elem, const unsigned short int side)
virtual unsigned int n_vertices() const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
subdomain_id_type subdomain_id() const
A 3D tetrahedral element with 10 nodes.
const Node * node_ptr(const unsigned int i) const
void build_edge_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &edge_list, std::vector< boundary_id_type > &bc_id_list) const
void make_nodes_parallel_consistent(MeshBase &)
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
virtual unsigned short int second_order_adjacent_vertex(const unsigned int n, const unsigned int v) const
void add_shellface(const dof_id_type elem, const unsigned short int shellface, const boundary_id_type id)
unsigned int mesh_dimension() const
virtual std::unique_ptr< FunctionBase< Output > > clone() const =0
A 3D tetrahedral element with 4 nodes.
IntRange< unsigned short > node_index_range() const
virtual const Node & node_ref(const dof_id_type i) const
virtual const Point & point(const dof_id_type i) const =0
virtual dof_id_type max_node_id() const =0
virtual dof_id_type n_elem() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
processor_id_type processor_id() const
processor_id_type processor_id() const
virtual ElemType type() const =0
long double min(long double a, double b)
A geometric point in (x,y,z) space.
dof_id_type node_id(const unsigned int i) const
const Point & point(const unsigned int i) const
virtual dof_id_type n_nodes() const =0
void add_edge(const dof_id_type elem, const unsigned short int edge, const boundary_id_type id)
std::vector< boundary_id_type > edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const
const RemoteElem * remote_elem