60 namespace Generation {
71 const unsigned int nx,
88 return i + j*(2*nx+1);
92 libmesh_error_msg(
"ERROR: Unrecognized 2D element type.");
103 const unsigned int nx,
104 const unsigned int ny,
105 const unsigned int i,
106 const unsigned int j,
107 const unsigned int k)
115 return i + (nx+1)*(j + k*(ny+1));
128 return i + (2*nx+1)*(j + k*(2*ny+1));
132 libmesh_error_msg(
"ERROR: Unrecognized element type.");
178 for (
unsigned dir=0; dir<3; ++dir)
182 for (std::size_t i=0; i<
_cosines[dir].size(); ++i)
200 virtual std::unique_ptr<FunctionBase<Real>>
clone ()
const override 202 return libmesh_make_unique<GaussLobattoRedistributionFunction>(*this);
216 for (
unsigned dir=0; dir<3; ++dir)
223 Real integer_part_f = 0;
224 const Real fractional_part = std::modf(float_index, &integer_part_f);
226 const int integer_part = int(integer_part_f);
231 int index = int(round(float_index));
252 (1.0 - 2./3.*
_cosines[dir][integer_part] - 1./3.*
_cosines[dir][integer_part+1]);
261 (1.0 - 1./3.*
_cosines[dir][integer_part] - 2./3.*
_cosines[dir][integer_part+1]);
265 libmesh_error_msg(
"Cannot redistribute node: " << p);
274 const Real )
override 276 libmesh_not_implemented();
297 const unsigned int nx,
298 const unsigned int ny,
299 const unsigned int nz,
304 const bool gauss_lobatto_grid)
306 START_LOG(
"build_cube()",
"MeshTools::Generation");
315 using namespace MeshTools::Generation::Private;
324 mesh.set_mesh_dimension(3);
325 mesh.set_spatial_dimension(3);
329 mesh.set_mesh_dimension(2);
330 mesh.set_spatial_dimension(2);
334 mesh.set_mesh_dimension(1);
335 mesh.set_spatial_dimension(1);
340 mesh.set_mesh_dimension(0);
341 mesh.set_spatial_dimension(0);
344 switch (
mesh.mesh_dimension())
350 libmesh_assert_equal_to (nx, 0);
351 libmesh_assert_equal_to (ny, 0);
352 libmesh_assert_equal_to (nz, 0);
370 libmesh_assert_not_equal_to (nx, 0);
371 libmesh_assert_equal_to (ny, 0);
372 libmesh_assert_equal_to (nz, 0);
373 libmesh_assert_less (xmin, xmax);
383 mesh.reserve_elem (nx);
388 libmesh_error_msg(
"ERROR: Unrecognized 1D element type.");
397 mesh.reserve_nodes(nx+1);
403 mesh.reserve_nodes(2*nx+1);
409 mesh.reserve_nodes(3*nx+1);
414 libmesh_error_msg(
"ERROR: Unrecognized 1D element type.");
420 unsigned int node_id = 0;
426 for (
unsigned int i=0; i<=nx; i++)
427 mesh.add_point (
Point(static_cast<Real>(i)/nx, 0, 0), node_id++);
434 for (
unsigned int i=0; i<=2*nx; i++)
435 mesh.add_point (
Point(static_cast<Real>(i)/(2*nx), 0, 0), node_id++);
441 for (
unsigned int i=0; i<=3*nx; i++)
442 mesh.add_point (
Point(static_cast<Real>(i)/(3*nx), 0, 0), node_id++);
448 libmesh_error_msg(
"ERROR: Unrecognized 1D element type.");
458 for (
unsigned int i=0; i<nx; i++)
462 elem =
mesh.add_elem (elem);
477 for (
unsigned int i=0; i<nx; i++)
481 elem =
mesh.add_elem (elem);
497 for (
unsigned int i=0; i<nx; i++)
501 elem =
mesh.add_elem (elem);
517 libmesh_error_msg(
"ERROR: Unrecognized 1D element type.");
521 if (gauss_lobatto_grid)
523 GaussLobattoRedistributionFunction func(nx, xmin, xmax);
528 for (
unsigned int p=0; p<
mesh.n_nodes(); p++)
529 mesh.node_ref(p)(0) = (
mesh.node_ref(p)(0))*(xmax-xmin) + xmin;
556 libmesh_assert_not_equal_to (nx, 0);
557 libmesh_assert_not_equal_to (ny, 0);
558 libmesh_assert_equal_to (nz, 0);
559 libmesh_assert_less (xmin, xmax);
560 libmesh_assert_less (ymin, ymax);
571 mesh.reserve_elem (nx*ny);
578 mesh.reserve_elem (2*nx*ny);
583 libmesh_error_msg(
"ERROR: Unrecognized 2D element type.");
596 mesh.reserve_nodes( (nx+1)*(ny+1) );
604 mesh.reserve_nodes( (2*nx+1)*(2*ny+1) );
610 libmesh_error_msg(
"ERROR: Unrecognized 2D element type.");
618 unsigned int node_id = 0;
625 for (
unsigned int j=0; j<=ny; j++)
626 for (
unsigned int i=0; i<=nx; i++)
627 mesh.add_point (
Point(static_cast<Real>(i)/static_cast<Real>(nx),
628 static_cast<Real>(j)/static_cast<Real>(ny),
638 for (
unsigned int j=0; j<=(2*ny); j++)
639 for (
unsigned int i=0; i<=(2*nx); i++)
640 mesh.add_point (
Point(static_cast<Real>(i)/static_cast<Real>(2*nx),
641 static_cast<Real>(j)/static_cast<Real>(2*ny),
649 libmesh_error_msg(
"ERROR: Unrecognized 2D element type.");
658 unsigned int elem_id = 0;
665 for (
unsigned int j=0; j<ny; j++)
666 for (
unsigned int i=0; i<nx; i++)
670 elem =
mesh.add_elem (elem);
695 for (
unsigned int j=0; j<ny; j++)
696 for (
unsigned int i=0; i<nx; i++)
701 elem =
mesh.add_elem (elem);
716 elem =
mesh.add_elem (elem);
736 for (
unsigned int j=0; j<(2*ny); j += 2)
737 for (
unsigned int i=0; i<(2*nx); i += 2)
740 static_cast<Elem *>(
new Quad8) :
743 elem =
mesh.add_elem (elem);
775 for (
unsigned int j=0; j<(2*ny); j += 2)
776 for (
unsigned int i=0; i<(2*nx); i += 2)
781 elem =
mesh.add_elem (elem);
799 elem =
mesh.add_elem (elem);
820 libmesh_error_msg(
"ERROR: Unrecognized 2D element type.");
827 if (gauss_lobatto_grid)
829 GaussLobattoRedistributionFunction func(nx, xmin, xmax,
835 for (
unsigned int p=0; p<
mesh.n_nodes(); p++)
837 mesh.node_ref(p)(0) = (
mesh.node_ref(p)(0))*(xmax-xmin) + xmin;
838 mesh.node_ref(p)(1) = (
mesh.node_ref(p)(1))*(ymax-ymin) + ymin;
871 libmesh_assert_not_equal_to (nx, 0);
872 libmesh_assert_not_equal_to (ny, 0);
873 libmesh_assert_not_equal_to (nz, 0);
874 libmesh_assert_less (xmin, xmax);
875 libmesh_assert_less (ymin, ymax);
876 libmesh_assert_less (zmin, zmax);
893 mesh.reserve_elem(nx*ny*nz);
901 mesh.reserve_elem(2*nx*ny*nz);
906 libmesh_error_msg(
"ERROR: Unrecognized 3D element type.");
920 mesh.reserve_nodes( (nx+1)*(ny+1)*(nz+1) );
938 mesh.reserve_nodes( (2*nx+1)*(2*ny+1)*(2*nz+1) );
943 libmesh_error_msg(
"ERROR: Unrecognized 3D element type.");
950 unsigned int node_id = 0;
957 for (
unsigned int k=0; k<=nz; k++)
958 for (
unsigned int j=0; j<=ny; j++)
959 for (
unsigned int i=0; i<=nx; i++)
960 mesh.add_point(
Point(static_cast<Real>(i)/static_cast<Real>(nx),
961 static_cast<Real>(j)/static_cast<Real>(ny),
962 static_cast<Real>(k)/static_cast<Real>(nz)), node_id++);
977 for (
unsigned int k=0; k<=(2*nz); k++)
978 for (
unsigned int j=0; j<=(2*ny); j++)
979 for (
unsigned int i=0; i<=(2*nx); i++)
980 mesh.add_point(
Point(static_cast<Real>(i)/static_cast<Real>(2*nx),
981 static_cast<Real>(j)/static_cast<Real>(2*ny),
982 static_cast<Real>(k)/static_cast<Real>(2*nz)), node_id++);
989 libmesh_error_msg(
"ERROR: Unrecognized 3D element type.");
996 unsigned int elem_id = 0;
1002 for (
unsigned int k=0; k<nz; k++)
1003 for (
unsigned int j=0; j<ny; j++)
1004 for (
unsigned int i=0; i<nx; i++)
1008 elem =
mesh.add_elem (elem);
1020 boundary_info.
add_side(elem, 0, 0);
1023 boundary_info.
add_side(elem, 5, 5);
1026 boundary_info.
add_side(elem, 1, 1);
1029 boundary_info.
add_side(elem, 3, 3);
1032 boundary_info.
add_side(elem, 4, 4);
1035 boundary_info.
add_side(elem, 2, 2);
1045 for (
unsigned int k=0; k<nz; k++)
1046 for (
unsigned int j=0; j<ny; j++)
1047 for (
unsigned int i=0; i<nx; i++)
1052 elem =
mesh.add_elem (elem);
1063 boundary_info.
add_side(elem, 3, 4);
1066 boundary_info.
add_side(elem, 1, 1);
1069 boundary_info.
add_side(elem, 0, 0);
1072 boundary_info.
add_side(elem, 4, 5);
1077 elem =
mesh.add_elem (elem);
1088 boundary_info.
add_side(elem, 1, 2);
1091 boundary_info.
add_side(elem, 2, 3);
1094 boundary_info.
add_side(elem, 0, 0);
1097 boundary_info.
add_side(elem, 4, 5);
1115 for (
unsigned int k=0; k<(2*nz); k += 2)
1116 for (
unsigned int j=0; j<(2*ny); j += 2)
1117 for (
unsigned int i=0; i<(2*nx); i += 2)
1120 static_cast<Elem *>(
new Hex20) :
1123 elem =
mesh.add_elem (elem);
1159 boundary_info.
add_side(elem, 0, 0);
1162 boundary_info.
add_side(elem, 5, 5);
1165 boundary_info.
add_side(elem, 1, 1);
1168 boundary_info.
add_side(elem, 3, 3);
1171 boundary_info.
add_side(elem, 4, 4);
1174 boundary_info.
add_side(elem, 2, 2);
1185 for (
unsigned int k=0; k<(2*nz); k += 2)
1186 for (
unsigned int j=0; j<(2*ny); j += 2)
1187 for (
unsigned int i=0; i<(2*nx); i += 2)
1191 static_cast<Elem *>(
new Prism15) :
1194 elem =
mesh.add_elem (elem);
1220 boundary_info.
add_side(elem, 3, 4);
1223 boundary_info.
add_side(elem, 1, 1);
1226 boundary_info.
add_side(elem, 0, 0);
1229 boundary_info.
add_side(elem, 4, 5);
1234 static_cast<Elem *>(
new Prism15) :
1237 elem =
mesh.add_elem (elem);
1263 boundary_info.
add_side(elem, 1, 2);
1266 boundary_info.
add_side(elem, 2, 3);
1269 boundary_info.
add_side(elem, 0, 0);
1272 boundary_info.
add_side(elem, 4, 5);
1283 libmesh_error_msg(
"ERROR: Unrecognized 3D element type.");
1291 if (gauss_lobatto_grid)
1293 GaussLobattoRedistributionFunction func(nx, xmin, xmax,
1300 for (
unsigned int p=0; p<
mesh.n_nodes(); p++)
1302 mesh.node_ref(p)(0) = (
mesh.node_ref(p)(0))*(xmax-xmin) + xmin;
1303 mesh.node_ref(p)(1) = (
mesh.node_ref(p)(1))*(ymax-ymin) + ymin;
1304 mesh.node_ref(p)(2) = (
mesh.node_ref(p)(2))*(zmax-zmin) + zmin;
1317 if ((type ==
TET4) ||
1324 std::vector<Elem *> new_elements;
1327 new_elements.reserve(24*
mesh.n_elem());
1329 new_elements.reserve(6*
mesh.n_elem());
1332 for (
auto & base_hex :
mesh.element_ptr_range())
1335 Node * apex_node = base_hex->node_ptr(26);
1338 std::vector<boundary_id_type> ids;
1340 for (
auto s : base_hex->side_index_range())
1346 libmesh_assert(ids.size() <= 1);
1352 std::unique_ptr<Elem>
side = base_hex->build_side_ptr(s);
1357 for (
unsigned int sub_tet=0; sub_tet<4; ++sub_tet)
1359 new_elements.push_back(
new Tet4 );
1360 Elem * sub_elem = new_elements.back();
1363 sub_elem->
set_node(2) =
side->node_ptr(sub_tet==3 ? 0 : sub_tet+1 );
1370 boundary_info.
add_side(sub_elem, 0, b_id);
1377 new_elements.push_back(
new Pyramid5);
1378 Elem * sub_elem = new_elements.back();
1394 boundary_info.
add_side(sub_elem, 4, b_id);
1401 for (
auto & elem :
mesh.element_ptr_range())
1403 boundary_info.
remove(elem);
1404 mesh.delete_elem(elem);
1409 n_new = cast_int<dof_id_type>(new_elements.size());
1412 new_elements[i]->set_id(i);
1413 mesh.add_elem(new_elements[i]);
1421 mesh.all_second_order();
1424 mesh.all_second_order(
false);
1447 libmesh_error_msg(
"Unknown dimension " <<
mesh.mesh_dimension());
1450 STOP_LOG(
"build_cube()",
"MeshTools::Generation");
1455 mesh.prepare_for_use (
false);
1462 const bool gauss_lobatto_grid)
1474 gauss_lobatto_grid);
1479 const unsigned int nx,
1482 const bool gauss_lobatto_grid)
1494 gauss_lobatto_grid);
1500 const unsigned int nx,
1501 const unsigned int ny,
1505 const bool gauss_lobatto_grid)
1518 gauss_lobatto_grid);
1529 #ifndef LIBMESH_ENABLE_AMR 1537 libmesh_error_msg(
"Building a circle/sphere only works with AMR.");
1544 const unsigned int nr,
1546 const unsigned int n_smooth,
1549 libmesh_assert_greater (rad, 0.);
1552 START_LOG(
"build_sphere()",
"MeshTools::Generation");
1558 unsigned char orig_mesh_dimension =
1581 libmesh_error_msg(
"build_sphere(): Please specify a mesh dimension or a valid ElemType (EDGE{2,3,4}, TRI3, QUAD4, HEX{8,27})");
1589 const Sphere sphere (cent, rad);
1613 unsigned node_id = 0;
1617 const Real sqrt_2 = std::sqrt(2.);
1618 const Real rad_2 = .25*rad;
1619 const Real rad_sqrt_2 = rad/sqrt_2;
1622 std::vector<Node *> nodes(8);
1625 nodes[0] =
mesh.
add_point (Point(-rad_2,-rad_2, 0.), node_id++);
1628 nodes[1] =
mesh.
add_point (Point( rad_2,-rad_2, 0.), node_id++);
1631 nodes[2] =
mesh.
add_point (Point( rad_2, rad_2, 0.), node_id++);
1634 nodes[3] =
mesh.
add_point (Point(-rad_2, rad_2, 0.), node_id++);
1637 nodes[4] =
mesh.
add_point (Point(-rad_sqrt_2,-rad_sqrt_2, 0.), node_id++);
1640 nodes[5] =
mesh.
add_point (Point( rad_sqrt_2,-rad_sqrt_2, 0.), node_id++);
1643 nodes[6] =
mesh.
add_point (Point( rad_sqrt_2, rad_sqrt_2, 0.), node_id++);
1646 nodes[7] =
mesh.
add_point (Point(-rad_sqrt_2, rad_sqrt_2, 0.), node_id++);
1654 elem0->set_node(1) = nodes[1];
1655 elem0->set_node(2) = nodes[2];
1656 elem0->set_node(3) = nodes[3];
1663 elem1->set_node(1) = nodes[0];
1664 elem1->set_node(2) = nodes[3];
1665 elem1->set_node(3) = nodes[7];
1672 elem2->set_node(1) = nodes[5];
1673 elem2->set_node(2) = nodes[1];
1674 elem2->set_node(3) = nodes[0];
1681 elem3->set_node(1) = nodes[5];
1682 elem3->set_node(2) = nodes[6];
1683 elem3->set_node(3) = nodes[2];
1690 elem4->set_node(1) = nodes[2];
1691 elem4->set_node(2) = nodes[6];
1692 elem4->set_node(3) = nodes[7];
1699 Real t = 0.5 * (1 + std::sqrt(5.0));
1700 Real s = rad / std::sqrt(1 + t*t);
1719 static const unsigned int idx1 [6] = {11, 5, 1, 7, 10, 11};
1720 static const unsigned int idx2 [6] = {9, 4, 2, 6, 8, 9};
1721 static const unsigned int idx3 [6] = {1, 5, 11, 10, 7, 1};
1723 for (
unsigned int i = 0; i < 5; ++i)
1763 if (!((type ==
HEX8) || (type ==
HEX27)))
1767 libmesh_error_msg(
"Error: Only HEX8/27 currently supported.");
1774 r_med = (0.125*std::sqrt(2.)+0.5)*rad;
1777 std::vector<Node *> nodes(16);
1783 unsigned node_id = 0;
1786 nodes[0] =
mesh.
add_point (Point(-r_small,-r_small, -r_small), node_id++);
1787 nodes[1] =
mesh.
add_point (Point( r_small,-r_small, -r_small), node_id++);
1788 nodes[2] =
mesh.
add_point (Point( r_small, r_small, -r_small), node_id++);
1789 nodes[3] =
mesh.
add_point (Point(-r_small, r_small, -r_small), node_id++);
1790 nodes[4] =
mesh.
add_point (Point(-r_small,-r_small, r_small), node_id++);
1791 nodes[5] =
mesh.
add_point (Point( r_small,-r_small, r_small), node_id++);
1792 nodes[6] =
mesh.
add_point (Point( r_small, r_small, r_small), node_id++);
1793 nodes[7] =
mesh.
add_point (Point(-r_small, r_small, r_small), node_id++);
1796 nodes[8] =
mesh.
add_point (Point(-r_med,-r_med, -r_med), node_id++);
1797 nodes[9] =
mesh.
add_point (Point( r_med,-r_med, -r_med), node_id++);
1798 nodes[10] =
mesh.
add_point (Point( r_med, r_med, -r_med), node_id++);
1799 nodes[11] =
mesh.
add_point (Point(-r_med, r_med, -r_med), node_id++);
1800 nodes[12] =
mesh.
add_point (Point(-r_med,-r_med, r_med), node_id++);
1801 nodes[13] =
mesh.
add_point (Point( r_med,-r_med, r_med), node_id++);
1802 nodes[14] =
mesh.
add_point (Point( r_med, r_med, r_med), node_id++);
1803 nodes[15] =
mesh.
add_point (Point(-r_med, r_med, r_med), node_id++);
1810 elem0->set_node(1) = nodes[1];
1811 elem0->set_node(2) = nodes[2];
1812 elem0->set_node(3) = nodes[3];
1813 elem0->set_node(4) = nodes[4];
1814 elem0->set_node(5) = nodes[5];
1815 elem0->set_node(6) = nodes[6];
1816 elem0->set_node(7) = nodes[7];
1823 elem1->set_node(1) = nodes[9];
1824 elem1->set_node(2) = nodes[10];
1825 elem1->set_node(3) = nodes[11];
1826 elem1->set_node(4) = nodes[0];
1827 elem1->set_node(5) = nodes[1];
1828 elem1->set_node(6) = nodes[2];
1829 elem1->set_node(7) = nodes[3];
1836 elem2->set_node(1) = nodes[9];
1837 elem2->set_node(2) = nodes[1];
1838 elem2->set_node(3) = nodes[0];
1839 elem2->set_node(4) = nodes[12];
1840 elem2->set_node(5) = nodes[13];
1841 elem2->set_node(6) = nodes[5];
1842 elem2->set_node(7) = nodes[4];
1849 elem3->set_node(1) = nodes[9];
1850 elem3->set_node(2) = nodes[10];
1851 elem3->set_node(3) = nodes[2];
1852 elem3->set_node(4) = nodes[5];
1853 elem3->set_node(5) = nodes[13];
1854 elem3->set_node(6) = nodes[14];
1855 elem3->set_node(7) = nodes[6];
1862 elem4->set_node(1) = nodes[2];
1863 elem4->set_node(2) = nodes[10];
1864 elem4->set_node(3) = nodes[11];
1865 elem4->set_node(4) = nodes[7];
1866 elem4->set_node(5) = nodes[6];
1867 elem4->set_node(6) = nodes[14];
1868 elem4->set_node(7) = nodes[15];
1875 elem5->set_node(1) = nodes[0];
1876 elem5->set_node(2) = nodes[3];
1877 elem5->set_node(3) = nodes[11];
1878 elem5->set_node(4) = nodes[12];
1879 elem5->set_node(5) = nodes[4];
1880 elem5->set_node(6) = nodes[7];
1881 elem5->set_node(7) = nodes[15];
1888 elem6->set_node(1) = nodes[5];
1889 elem6->set_node(2) = nodes[6];
1890 elem6->set_node(3) = nodes[7];
1891 elem6->set_node(4) = nodes[12];
1892 elem6->set_node(5) = nodes[13];
1893 elem6->set_node(6) = nodes[14];
1894 elem6->set_node(7) = nodes[15];
1910 MeshRefinement mesh_refinement (
mesh);
1913 for (
unsigned int r=0; r<nr; r++)
1915 mesh_refinement.uniformly_refine(1);
1918 for (
auto s : elem->side_index_range())
1921 std::unique_ptr<Elem>
side(elem->build_side_ptr(s));
1924 for (
auto n :
side->node_index_range())
1926 sphere.closest_point(
side->point(n));
1939 if ((type ==
TRI6) || (type ==
TRI3))
1953 bool full_ordered = !((type==
QUAD8) || (type==
HEX20));
1958 for (
auto s : elem->side_index_range())
1959 if (elem->neighbor_ptr(s) ==
nullptr)
1961 std::unique_ptr<Elem>
side(elem->build_side_ptr(s));
1964 for (
auto n :
side->node_index_range())
1966 sphere.closest_point(
side->point(n));
1972 LaplaceMeshSmoother smoother(
mesh);
1973 smoother.smooth(n_smooth);
1977 for (
auto s : elem->side_index_range())
1978 if (!elem->neighbor_ptr(s))
1979 boundary_info.
add_side(elem, s, 0);
1981 STOP_LOG(
"build_sphere()",
"MeshTools::Generation");
1988 #endif // #ifndef LIBMESH_ENABLE_AMR 1994 const unsigned int nz,
1998 if (!cross_section.
n_elem())
2001 START_LOG(
"build_extrusion()",
"MeshTools::Generation");
2006 #ifdef LIBMESH_ENABLE_UNIQUE_ID 2010 unsigned int order = 1;
2032 std::vector<boundary_id_type> ids_to_copy;
2036 for (
unsigned int k=0; k != order*nz+1; ++k)
2040 (extrusion_vector * k / nz / order),
2041 node->id() + (k * orig_nodes),
2042 node->processor_id());
2044 #ifdef LIBMESH_ENABLE_UNIQUE_ID 2050 orig_unique_ids + (k-1)*(orig_nodes + orig_elem) + node->id();
2055 cross_section_boundary_info.
boundary_ids(node, ids_to_copy);
2056 boundary_info.
add_node(new_node, ids_to_copy);
2060 const std::set<boundary_id_type> & side_ids =
2064 0 : cast_int<boundary_id_type>(*side_ids.rbegin() + 1);
2069 cross_section.
comm().
max(next_side_id);
2073 const ElemType etype = elem->type();
2076 libmesh_assert (!elem->parent());
2078 for (
unsigned int k=0; k != nz; ++k)
2085 new_elem =
new Quad4;
2100 new_elem =
new Quad9;
2170 new_elem =
new Hex8;
2193 new_elem =
new Hex27;
2235 libmesh_not_implemented();
2240 new_elem->
set_id(elem->id() + (k * orig_elem));
2243 #ifdef LIBMESH_ENABLE_UNIQUE_ID 2249 orig_unique_ids + (k-1)*(orig_nodes + orig_elem) + orig_nodes + elem->id();
2254 if (!elem_subdomain)
2264 for (
auto s : elem->side_index_range())
2266 cross_section_boundary_info.
boundary_ids(elem, s, ids_to_copy);
2268 if (new_elem->
dim() == 3)
2275 cast_int<unsigned short>(s+1),
2284 libmesh_assert_less(s, 2);
2285 const unsigned short sidemap[2] = {3, 1};
2286 boundary_info.
add_side(new_elem, sidemap[s], ids_to_copy);
2292 boundary_info.
add_side(new_elem, 0, next_side_id);
2298 const unsigned short top_id = new_elem->
dim() == 3 ?
2299 cast_int<unsigned short>(elem->n_sides()+1) : 2;
2302 cast_int<boundary_id_type>(next_side_id+1));
2307 STOP_LOG(
"build_extrusion()",
"MeshTools::Generation");
2316 #ifdef LIBMESH_HAVE_TRIANGLE 2320 const unsigned int nx,
2321 const unsigned int ny,
2325 const std::vector<TriangleInterface::Hole*> * holes)
2328 libmesh_assert_greater_equal (nx, 1);
2329 libmesh_assert_greater_equal (ny, 1);
2330 libmesh_assert_less (xmin, xmax);
2331 libmesh_assert_less (ymin, ymax);
2342 const Real delta_x = (xmax-xmin) / static_cast<Real>(nx);
2343 const Real delta_y = (ymax-ymin) / static_cast<Real>(ny);
2346 for (
unsigned int p=0; p<=nx; ++p)
2350 for (
unsigned int p=1; p<ny; ++p)
2354 for (
unsigned int p=0; p<=nx; ++p)
2358 for (
unsigned int p=1; p<ny; ++p)
2362 libmesh_assert_equal_to (
mesh.
n_nodes(), 2*(nx+ny));
2368 t.
desired_area() = 0.5 * (xmax-xmin)*(ymax-ymin) /
static_cast<Real>(nx*ny);
2372 if (holes !=
nullptr)
2382 for (
auto s : elem->side_index_range())
2383 if (elem->neighbor_ptr(s) ==
nullptr)
2385 std::unique_ptr<const Elem>
side (elem->build_side_ptr(s));
2391 Point side_midpoint= 0.5f*(
side->point(0) +
side->point(1) );
2402 if (std::fabs(side_midpoint(1) - ymin) <
TOLERANCE)
2406 else if (std::fabs(side_midpoint(0) - xmax) <
TOLERANCE)
2410 else if (std::fabs(side_midpoint(1) - ymax) <
TOLERANCE)
2414 else if (std::fabs(side_midpoint(0) - xmin) <
TOLERANCE)
2426 #endif // LIBMESH_HAVE_TRIANGLE
A 2D triangular element with 3 nodes.
unique_id_type & set_unique_id()
virtual void reserve_nodes(const dof_id_type nn)=0
const std::set< boundary_id_type > & get_side_boundary_ids() const
virtual Node *& set_node(const unsigned int i)
A geometric point in (x,y,z) space associated with a DOF.
virtual unique_id_type parallel_max_unique_id() const =0
std::string & nodeset_name(boundary_id_type id)
const unsigned int invalid_uint
A geometric object representing a sphere.
A 2D quadrilateral element with 4 nodes.
A 3D hexahedral element with 8 nodes.
A 3D prismatic element with 6 nodes.
void resize(const unsigned int n)
A 3D hexahedral element with 20 nodes.
void remove(const Node *node)
The base class for all geometric element types.
unique_id_type unique_id() const
A 2D quadrilateral element with 8 nodes.
const Parallel::Communicator & comm() const
static const Real TOLERANCE
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
const BoundaryInfo & get_boundary_info() const
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
A 2D triangular element with 6 nodes.
std::vector< boundary_id_type > boundary_ids(const Node *node) const
virtual element_iterator elements_begin()=0
void attach_hole_list(const std::vector< Hole *> *holes)
virtual bool is_serial() const
void add_node(const Node *node, const boundary_id_type id)
static const boundary_id_type invalid_id
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual void all_second_order(const bool full_ordered=true)=0
Base class for Replicated and Distributed meshes.
virtual Elem * add_elem(Elem *e)=0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
virtual element_iterator elements_end()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
Used by the Mesh to keep track of boundary nodes and elements.
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
void set_mesh_dimension(unsigned char d)
A 1D geometric element with 3 nodes.
TriangulationType & triangulation_type()
void set_neighbor(const unsigned int i, Elem *n)
A 2D quadrilateral element with 9 nodes.
std::string & sideset_name(boundary_id_type id)
A zero-dimensional geometric entity implementing the Elem interface.
A 3D prismatic element with 15 nodes.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A 3D hexahedral element with 27 nodes.
subdomain_id_type subdomain_id() const
virtual unsigned short dim() const =0
A 3D prismatic element with 18 nodes.
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
A 1D geometric element with 2 nodes.
unsigned int mesh_dimension() const
A 1D geometric element with 4 nodes.
A 3D tetrahedral element with 4 nodes.
virtual void delete_remote_elements()
virtual subdomain_id_type get_subdomain_for_layer(const Elem *old_elem, unsigned int layer)=0
virtual dof_id_type n_elem() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
Base class for functors that can be evaluated at a point and (optionally) time.
A 3D pyramid element with 5 nodes.
processor_id_type processor_id() const
A geometric point in (x,y,z) space.
virtual void reserve_elem(const dof_id_type ne)=0
virtual dof_id_type n_nodes() const =0
const RemoteElem * remote_elem