1 #include <libmesh/distributed_mesh.h> 2 #include <libmesh/dof_map.h> 3 #include <libmesh/equation_systems.h> 4 #include <libmesh/linear_implicit_system.h> 5 #include <libmesh/mesh.h> 6 #include <libmesh/mesh_communication.h> 7 #include <libmesh/mesh_generation.h> 8 #include <libmesh/numeric_vector.h> 9 #include <libmesh/replicated_mesh.h> 10 #include <libmesh/enum_norm_type.h> 11 #include <libmesh/enum_to_string.h> 13 #include <libmesh/abaqus_io.h> 14 #include <libmesh/dyna_io.h> 15 #include <libmesh/exodusII_io.h> 16 #include <libmesh/gmsh_io.h> 17 #include <libmesh/nemesis_io.h> 18 #include <libmesh/stl_io.h> 19 #include <libmesh/vtk_io.h> 20 #include <libmesh/tetgen_io.h> 35 const Real & x = p(0);
36 const Real & y = p(1);
47 const Real & x = p(0);
48 const Real & y = p(1);
50 return sin(x) + cos(y);
60 const Real & x = p(0);
61 const Real & y = p(1);
62 const Real & z = p(2);
65 param.
get<
short>(
"face") : -1;
68 auto is_on_face = [facedim](
Real r,
short rdim) {
74 return (std::abs(numerator - std::round(numerator)) <
104 #ifdef LIBMESH_HAVE_VTK 105 CPPUNIT_TEST( testVTKPreserveElemIds );
106 CPPUNIT_TEST( testVTKPreserveSubdomainIds );
109 #ifdef LIBMESH_HAVE_EXODUS_API 110 CPPUNIT_TEST( testExodusCopyNodalSolutionDistributed );
111 CPPUNIT_TEST( testExodusCopyElementSolutionDistributed );
112 CPPUNIT_TEST( testExodusCopyNodalSolutionReplicated );
113 CPPUNIT_TEST( testExodusCopyElementSolutionReplicated );
114 CPPUNIT_TEST( testExodusReadHeader );
116 CPPUNIT_TEST( testExodusIGASidesets );
117 CPPUNIT_TEST( testLowOrderEdgeBlocks );
119 #ifndef LIBMESH_USE_COMPLEX_NUMBERS 120 CPPUNIT_TEST( testExodusCopyElementVectorDistributed );
121 CPPUNIT_TEST( testExodusCopyElementVectorReplicated );
124 CPPUNIT_TEST( testExodusWriteElementDataFromDiscontinuousNodalData );
125 #endif // !LIBMESH_USE_COMPLEX_NUMBERS 127 CPPUNIT_TEST( testExodusWriteAddedSidesEdgeC0 );
128 CPPUNIT_TEST( testExodusDiscWriteAddedSidesEdgeC0 );
129 CPPUNIT_TEST( testExodusWriteAddedSidesMixedEdgeC0 );
130 CPPUNIT_TEST( testExodusDiscWriteAddedSidesMixedEdgeC0 );
133 CPPUNIT_TEST( testExodusWriteAddedSidesTriC0 );
134 CPPUNIT_TEST( testExodusDiscWriteAddedSidesTriC0 );
135 CPPUNIT_TEST( testExodusWriteAddedSidesMixedTriC0 );
136 CPPUNIT_TEST( testExodusDiscWriteAddedSidesMixedTriC0 );
139 CPPUNIT_TEST( testExodusWriteAddedSidesQuadC0 );
140 CPPUNIT_TEST( testExodusDiscWriteAddedSidesQuadC0 );
141 CPPUNIT_TEST( testExodusWriteAddedSidesMixedQuadC0 );
142 CPPUNIT_TEST( testExodusDiscWriteAddedSidesMixedQuadC0 );
149 CPPUNIT_TEST( testExodusWriteAddedSidesHexC0 );
150 CPPUNIT_TEST( testExodusDiscWriteAddedSidesHexC0 );
151 CPPUNIT_TEST( testExodusWriteAddedSidesMixedHexC0 );
152 CPPUNIT_TEST( testExodusDiscWriteAddedSidesMixedHexC0 );
153 CPPUNIT_TEST( testExodusWriteAddedSidesHexDisc );
154 CPPUNIT_TEST( testExodusDiscWriteAddedSidesHexDisc );
156 CPPUNIT_TEST( testExodusFileMappingsPlateWithHole);
157 CPPUNIT_TEST( testExodusFileMappingsTwoBlocks);
158 CPPUNIT_TEST( testExodusFileMappingsTwoElemIGA);
159 CPPUNIT_TEST( testExodusFileMappingsCyl3d);
161 CPPUNIT_TEST( testExodusDiscPlateWithHole);
162 CPPUNIT_TEST( testExodusDiscTwoBlocks);
163 CPPUNIT_TEST( testExodusDiscTwoElemIGA);
164 CPPUNIT_TEST( testExodusDiscCyl3d);
165 #endif // LIBMESH_HAVE_EXODUS_API 167 #if defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API) 168 CPPUNIT_TEST( testNemesisReadReplicated );
169 CPPUNIT_TEST( testNemesisReadDistributed );
171 CPPUNIT_TEST( testNemesisCopyNodalSolutionDistributed );
172 CPPUNIT_TEST( testNemesisCopyNodalSolutionReplicated );
173 CPPUNIT_TEST( testNemesisCopyElementSolutionDistributed );
174 CPPUNIT_TEST( testNemesisCopyElementSolutionReplicated );
176 CPPUNIT_TEST( testNemesisSingleElementDistributed );
177 CPPUNIT_TEST( testNemesisSingleElementReplicated );
178 #ifndef LIBMESH_USE_COMPLEX_NUMBERS 179 CPPUNIT_TEST( testNemesisCopyElementVectorDistributed );
180 CPPUNIT_TEST( testNemesisCopyElementVectorReplicated );
181 #endif // !LIBMESH_USE_COMPLEX_NUMBERS 182 #endif // defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API) 184 #ifdef LIBMESH_HAVE_GZSTREAM 185 CPPUNIT_TEST( testAbaqusReadFirst );
186 CPPUNIT_TEST( testAbaqusReadSecond );
187 CPPUNIT_TEST( testDynaReadElem );
188 CPPUNIT_TEST( testDynaNoSplines );
189 CPPUNIT_TEST( testDynaReadPatch );
190 CPPUNIT_TEST( testDynaFileMappingsFEMEx5);
191 CPPUNIT_TEST( testDynaFileMappingsBlockWithHole);
192 CPPUNIT_TEST( testDynaFileMappingsPlateWithHole);
193 CPPUNIT_TEST( testDynaFileMappingsCyl3d);
194 #endif // LIBMESH_HAVE_GZSTREAM 195 #endif // LIBMESH_DIM > 1 198 CPPUNIT_TEST( testBadGmsh );
199 CPPUNIT_TEST( testGoodGmsh );
203 CPPUNIT_TEST( testGoodSTL );
204 CPPUNIT_TEST( testGoodSTLBinary );
206 CPPUNIT_TEST( testGmshBCIDOverlap );
208 #ifdef LIBMESH_HAVE_TETGEN 209 CPPUNIT_TEST( testTetgenIO );
213 CPPUNIT_TEST_SUITE_END();
224 #ifdef LIBMESH_HAVE_VTK 244 std::set<Elem *> elements {
mesh.elements_begin(),
mesh.elements_end()};
245 for (
Elem * elem : elements)
247 const Point center = elem->vertex_average();
248 const int xn =
int(center(0)*3);
249 const int yn =
int(center(1)*3);
256 vtk.
write(
"read_elem_ids_test.pvtu");
267 mesh.
read(
"read_elem_ids_test.pvtu");
273 for (
const auto & elem :
mesh.element_ptr_range())
275 const Point center = elem->vertex_average();
276 const int xn =
int(center(0)*3);
277 const int yn =
int(center(1)*3);
278 const dof_id_type expected_id = start_id + yn*5 + xn;
279 CPPUNIT_ASSERT_EQUAL(elem->id(), expected_id);
294 for (
const auto & elem :
mesh.element_ptr_range())
296 const Point center = elem->vertex_average();
297 const int xn =
int(center(0)*3);
298 const int yn =
int(center(1)*3);
300 elem->subdomain_id() = new_id;
305 vtk.
write(
"read_sbd_ids_test.pvtu");
316 mesh.
read(
"read_sbd_ids_test.pvtu");
322 for (
const auto & elem :
mesh.element_ptr_range())
324 const Point center = elem->vertex_average();
325 const int xn =
int(center(0)*3);
326 const int yn =
int(center(1)*3);
328 CPPUNIT_ASSERT_EQUAL(elem->subdomain_id(), expected_id);
332 #endif // LIBMESH_HAVE_VTK 335 #ifdef LIBMESH_HAVE_EXODUS_API 362 CPPUNIT_ASSERT_EQUAL(std::string(header_info.
title.data()), std::string(
"read_header_test.e"));
363 CPPUNIT_ASSERT_EQUAL(header_info.
num_dim, 2);
364 CPPUNIT_ASSERT_EQUAL(header_info.
num_elem, 9);
369 CPPUNIT_ASSERT_EQUAL(header_info.
num_edge, 0);
381 exii.
read(
"meshes/mesh_with_low_order_edge_blocks.e");
400 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(26), bi.
n_boundary_ids());
407 CPPUNIT_ASSERT(std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(4, 1, 8007)));
408 CPPUNIT_ASSERT(std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(10, 6, 8001)));
411 CPPUNIT_ASSERT(!std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(1, 8, 8009)));
412 CPPUNIT_ASSERT(!std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(2, 10, 9011)));
431 exii.
read(
"meshes/Cube_With_Sidesets.e");
448 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(6), bi.
n_boundary_ids());
456 bool has_bcid = bc_ids.count(i);
458 CPPUNIT_ASSERT(has_bcid);
464 std::vector<int> side_counts(6, 0);
469 for (
const auto & elem :
mesh.active_local_element_ptr_range())
474 for (
unsigned short side=0; side<elem->n_sides(); side++)
476 if (elem->neighbor_ptr(side))
481 std::vector<boundary_id_type> bids;
483 side_counts[bids[0]-1]++;
484 CPPUNIT_ASSERT_EQUAL(libmesh_side_to_bcid[side], bids[0]);
489 for (
auto bc_count : side_counts)
493 CPPUNIT_ASSERT_EQUAL(bc_count, 9);
501 exii.
write(
"Cube_With_Sidesets_out.e");
506 template <
typename MeshType,
typename IOType>
523 IOType meshoutput(
mesh);
525 meshoutput.write_equation_systems(filename, es);
530 IOType meshinput(
mesh);
533 if (meshinput.is_parallel_format())
544 meshinput.read(filename);
545 if (!meshinput.is_parallel_format())
555 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 556 meshinput.copy_nodal_solution(sys,
"testn",
"r_n");
558 meshinput.copy_nodal_solution(sys,
"testn",
"n");
568 LIBMESH_ASSERT_NUMBERS_EQUAL
576 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,ExodusII_IO>(
"repl_with_nodal_soln.e"); }
579 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,ExodusII_IO>(
"dist_with_nodal_soln.e"); }
581 #if defined(LIBMESH_HAVE_NEMESIS_API) 583 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_nodal_soln.nem"); }
586 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,Nemesis_IO>(
"dist_with_nodal_soln.nem"); }
590 template <
typename MeshType,
typename IOType>
607 IOType meshinput(
mesh);
610 std::set<std::string> sys_list;
611 meshinput.write_equation_systems(filename, es, &sys_list);
614 meshinput.write_element_data(es);
619 IOType meshinput(
mesh);
622 if (meshinput.is_parallel_format())
633 meshinput.read(filename);
634 if (!meshinput.is_parallel_format())
644 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 645 meshinput.copy_elemental_solution(sys,
"teste",
"r_e");
647 meshinput.copy_elemental_solution(sys,
"teste",
"e");
657 LIBMESH_ASSERT_NUMBERS_EQUAL
665 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,ExodusII_IO>(
"repl_with_elem_soln.e"); }
668 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,ExodusII_IO>(
"dist_with_elem_soln.e"); }
670 #if defined(LIBMESH_HAVE_NEMESIS_API) 672 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_elem_soln.nem"); }
675 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,Nemesis_IO>(
"dist_with_elem_soln.nem"); }
681 template <
typename MeshType,
typename IOType>
699 std::set<std::string> sys_list;
714 nem_io.
read(filename);
719 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 726 CPPUNIT_ASSERT_EQUAL(
int(sys.solution->size()), 1);
733 { LOG_UNIT_TEST; testSingleElementImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_single_elem.nem"); }
736 { LOG_UNIT_TEST; testSingleElementImpl<DistributedMesh,Nemesis_IO>(
"dist_with_single_elem.nem"); }
737 #endif //defined(LIBMESH_HAVE_NEMESIS_API) 740 #ifndef LIBMESH_USE_COMPLEX_NUMBERS 745 template <
typename MeshType,
typename IOType>
771 for (
const auto & elem :
mesh.active_local_element_ptr_range())
773 const Point & p = elem->vertex_average();
786 IOType meshinput(
mesh);
789 std::set<std::string> sys_list;
790 meshinput.write_equation_systems(filename, es, &sys_list);
793 meshinput.write_element_data(es);
798 IOType meshinput(
mesh);
801 if (meshinput.is_parallel_format())
817 meshinput.read(filename);
818 if (!meshinput.is_parallel_format())
825 meshinput.copy_elemental_solution(sys,
"teste_x",
"e_x");
826 meshinput.copy_elemental_solution(sys,
"teste_y",
"e_y");
835 LIBMESH_ASSERT_NUMBERS_EQUAL
837 LIBMESH_ASSERT_NUMBERS_EQUAL
844 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh, ExodusII_IO>(
"repl_with_elem_vec.e"); }
847 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,ExodusII_IO>(
"dist_with_elem_vec.e"); }
849 #if defined(LIBMESH_HAVE_NEMESIS_API) 851 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_elem_vec.nem"); }
854 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,Nemesis_IO>(
"dist_with_elem_vec.nem"); }
871 (
mesh, 2, 2, 2, 0., 1., 0., 1., 0., 1.,
HEX8);
877 std::vector<dof_id_type> dof_indices;
878 for (
const auto & elem :
mesh.element_ptr_range())
881 for (
unsigned int i=0; i<dof_indices.size(); ++i)
882 sys.
solution->set(dof_indices[i], i);
890 std::set<std::string> sys_list;
894 sys_list = {
"SimpleSystem"};
897 (es, &sys_list,
"_elem_corner_");
902 std::vector<std::string> file_var_names =
907 std::vector<Real> expected_values = {0., 1., 2., 3.};
920 exii.
read(
"elemental_from_nodal.e");
931 for (
const auto & elem :
mesh.active_element_ptr_range())
935 LIBMESH_ASSERT_FP_EQUAL
941 #endif // !LIBMESH_USE_COMPLEX_NUMBERS 944 void testExodusWriteAddedSides
946 std::string &,
const std::string &),
949 const bool write_discontinuous =
false,
950 const std::vector<FEType> earlier_vars = {},
951 const std::vector<FEType> later_vars = {})
958 const bool is_tensor = (
Elem::build(elem_type)->n_sides() ==
dim * 2);
967 const std::string filename =
968 "side_discontinuous_"+Utility::enum_to_string<ElemType>(elem_type)+(write_discontinuous?
"_disc":
"")+
".e";
977 for (
auto vartype : earlier_vars)
978 sys.
add_variable(
"earlier_"+std::to_string(varnum++), vartype);
983 for (
auto vartype : later_vars)
984 sys.
add_variable(
"later_"+std::to_string(varnum++), vartype);
988 (
mesh, nx, ny, nz, 0., 1., 0., 1., 0., 1., elem_type);
991 (
mesh, nx, ny, 0., 1., 0., 1., elem_type);
994 (
mesh, nx, 0., 1., elem_type);
998 CPPUNIT_ASSERT_LESS(n_true_nodes, n_true_elem);
1000 const unsigned int our_ny =
dim>1 ? ny : 1;
1001 const unsigned int our_nz =
dim>2 ? nz : 1;
1004 CPPUNIT_ASSERT_LESSEQUAL(n_true_elem, min_n_elem);
1006 for (
const auto & elem :
mesh.active_local_element_ptr_range())
1009 if (!elem->neighbor_ptr(s) || elem->neighbor_ptr(s)->id() < elem->id())
1012 auto side = elem->build_side_ptr(s);
1013 n_fake_nodes += side->n_nodes();
1019 const dof_id_type expected_fakes = [elem_type]() {
1025 return 3*nx*ny + nx + ny;
1028 return 2*nx*ny + nx + ny;
1030 return 48*nx*ny*nz + 4*(nx*ny+nx*nz+ny*nz);
1032 return 3*nx*ny*nz + nx*ny + nx*nz + ny*nz;
1038 CPPUNIT_ASSERT_EQUAL(n_fake_elem, expected_fakes);
1048 exii.write_added_sides(
true);
1050 if (write_discontinuous)
1051 exii.write_discontinuous_equation_systems(filename, es);
1053 exii.write_equation_systems(filename, es);
1064 exii.read(filename);
1068 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), n_true_elem + n_fake_elem);
1069 if (write_discontinuous)
1073 n_true_elem*nodes_per_elem + n_fake_nodes);
1076 CPPUNIT_ASSERT_EQUAL(
mesh.
n_nodes(), n_true_nodes + n_fake_nodes);
1087 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 1088 exii.copy_nodal_solution(sys,
"ul",
"r_u");
1090 exii.copy_nodal_solution(sys,
"ul",
"u");
1094 const std::string nullstr;
1095 const std::string facestr =
"face";
1100 #ifdef LIBMESH_ENABLE_EXCEPTIONS 1101 bool threw_exception =
false;
1103 #endif // LIBMESH_ENABLE_EXCEPTIONS 1105 for (
const auto & elem :
mesh.active_local_element_ptr_range())
1108 if (elem->dim() ==
dim)
1111 std::vector<dof_id_type> dof_indices;
1118 const Point normal = [elem](){
1119 if (elem->dim() == 2)
1120 return Point((elem->point(1) - elem->point(0)).cross
1121 (elem->point(2) - elem->point(0)));
1122 else if (elem->dim() == 1)
1124 (elem->point(1)(1)-elem->point(0)(1),
1125 elem->point(0)(0)-elem->point(1)(0));
1136 libmesh_assert_less(std::abs(normal(1)),
TOLERANCE);
1137 libmesh_assert_less(std::abs(normal(2)),
TOLERANCE);
1139 else if (std::abs(normal(1)) >
TOLERANCE)
1142 libmesh_assert_less(std::abs(normal(2)),
TOLERANCE);
1147 libmesh_assert_greater(std::abs(normal(2)),
TOLERANCE);
1149 libmesh_assert_greater_equal(faceval, 0);
1150 es.parameters.set<
short>(facestr) = faceval;
1155 const Point node_pt = elem->point(i);
1156 const Real nodal_coef =
1158 const Real exact_val =
1160 (node_pt, es.parameters, nullstr,
1162 LIBMESH_ASSERT_FP_EQUAL
1163 (nodal_coef, exact_val,
1164 std::max(
Real(2),nodal_coef+exact_val)*
1170 #ifdef LIBMESH_ENABLE_EXCEPTIONS 1173 threw_exception =
true;
1177 if (!threw_exception)
1179 CPPUNIT_ASSERT(!threw_exception);
1180 #endif // LIBMESH_ENABLE_EXCEPTIONS 1183 CPPUNIT_ASSERT_EQUAL(n_side_nodes, n_fake_nodes);
1345 #endif // LIBMESH_HAVE_EXODUS_API 1348 #if defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API) 1349 template <
typename MeshType>
1367 nem.
read(
"test_nemesis_read.nem");
1375 { LOG_UNIT_TEST; testNemesisReadImpl<ReplicatedMesh>(); }
1378 { LOG_UNIT_TEST; testNemesisReadImpl<DistributedMesh>(); }
1386 for (
auto & elem :
mesh.element_ptr_range())
1388 Point master_pt = {};
1391 if (elem->dim() > 0)
1392 master_pt(0) = 0.25;
1394 if (elem->dim() > 1)
1395 master_pt(1) = -0.25;
1397 if (elem->dim() > 2)
1398 master_pt(2) = 0.75;
1407 CPPUNIT_ASSERT(elem->contains_point(physical_pt));
1410 std::set<subdomain_id_type> my_subdomain { elem->subdomain_id() };
1414 std::set<const Elem * > located_elems;
1415 (*locator)(physical_pt, located_elems, &my_subdomain);
1417 CPPUNIT_ASSERT(located_elems.count(elem));
1430 bool found_the_quad =
false;
1432 for (
auto & elem :
mesh.element_ptr_range())
1437 CPPUNIT_ASSERT_EQUAL(elem->type(),
QUAD9);
1438 found_the_quad =
true;
1440 for (
unsigned int n=0; n != 9; ++n)
1441 CPPUNIT_ASSERT_EQUAL
1442 (elem->node_ref(n).get_extra_datum<
Real>(weight_index),
1445 CPPUNIT_ASSERT_EQUAL(elem->point(0)(0),
Real(0.5));
1446 CPPUNIT_ASSERT_EQUAL(elem->point(0)(1),
Real(0.5));
1447 CPPUNIT_ASSERT_EQUAL(elem->point(1)(0),
Real(1.5));
1448 CPPUNIT_ASSERT_EQUAL(elem->point(1)(1),
Real(0.5));
1449 CPPUNIT_ASSERT_EQUAL(elem->point(2)(0),
Real(1.5));
1450 CPPUNIT_ASSERT_EQUAL(elem->point(2)(1),
Real(1.5));
1451 CPPUNIT_ASSERT_EQUAL(elem->point(3)(0),
Real(0.5));
1452 CPPUNIT_ASSERT_EQUAL(elem->point(3)(1),
Real(1.5));
1453 CPPUNIT_ASSERT(elem->has_affine_map());
1455 for (
unsigned int v=0; v != 4; ++v)
1456 CPPUNIT_ASSERT_EQUAL(elem->point(v)(2),
Real(0));
1461 CPPUNIT_ASSERT(found_the_quad);
1463 testMasterCenters(
mesh);
1489 testAbaqusRead(
"meshes/tensile_sample_test1.inp.gz", 728, 1166);
1496 testAbaqusRead(
"meshes/poly_sample_test2.inp.gz", 1280, 1625);
1509 dyna.
read(
"meshes/1_quad.bxt.gz");
1519 helperTestingDynaQuad(
mesh);
1530 #ifdef LIBMESH_ENABLE_EXCEPTIONS 1531 std::string what =
"";
1535 gmsh_io.
read(
"meshes/block.msh");
1543 std::regex msg_regex(
"outside entity physical bounding box");
1544 CPPUNIT_ASSERT(std::regex_search(what, msg_regex));
1557 gmsh_io.
read(
"meshes/circle.msh");
1572 gmsh_io.
read(
"meshes/bcid_overlap.msh");
1578 std::string(
"srfBC4A"));
1580 std::string(
"srfBC4B"));
1584 std::string(
"volBC3A"));
1586 std::string(
"volBC3B"));
1598 stl_io.
read(
"meshes/Cluster_34.stl");
1613 stl_io.
read(
"meshes/engraving.stl");
1622 #ifdef LIBMESH_HAVE_TETGEN 1630 tetgen_io.
read(
"meshes/tetgen_one_tet10.ele");
1644 CPPUNIT_ASSERT(elem);
1647 bool have_elem = elem;
1649 CPPUNIT_ASSERT(have_elem);
1669 dyna.
read(
"meshes/1_quad.bxt.gz");
1678 helperTestingDynaQuad(
mesh);
1690 dyna.
read(
"meshes/25_quad.bxt.gz");
1705 for (
const auto & elem :
mesh.active_element_ptr_range())
1709 LIBMESH_ASSERT_FP_EQUAL(
Real(0.04), elem->volume(),
TOLERANCE);
1711 for (
unsigned int n=0; n != 9; ++n)
1712 CPPUNIT_ASSERT_EQUAL
1713 (elem->node_ref(n).get_extra_datum<
Real>(weight_index),
1716 unsigned int n_neighbors = 0, n_neighbors_expected = 2;
1717 for (
unsigned int side=0; side != 4; ++side)
1718 if (elem->neighbor_ptr(side))
1720 Point c = elem->vertex_average();
1722 if (c(0) > 0.2 && c(0) < 0.8)
1723 n_neighbors_expected++;
1724 if (c(1) > 0.2 && c(1) < 0.8)
1725 n_neighbors_expected++;
1727 CPPUNIT_ASSERT_EQUAL(n_neighbors, n_neighbors_expected);
1730 testMasterCenters(
mesh);
1732 #ifdef LIBMESH_HAVE_SOLVER 1733 #ifdef LIBMESH_ENABLE_CONSTRAINTS 1742 #endif // LIBMESH_ENABLE_CONSTRAINTS 1743 #endif // LIBMESH_HAVE_SOLVER 1749 for (
const auto elem :
mesh.element_ptr_range())
1750 order = std::max(order,
int(elem->default_order()));
1752 CPPUNIT_ASSERT (order > 0);
1756 std::unique_ptr<MeshBase> mesh_clone =
mesh.
clone();
1757 CPPUNIT_ASSERT(*mesh_clone ==
mesh);
1772 std::set<unsigned int> skip_dimensions {0};
1773 const Real L2_norm =
1777 LIBMESH_ASSERT_FP_EQUAL(L2_norm, expected_norms[0], my_tolerance);
1778 const Real Linf_norm =
1781 LIBMESH_ASSERT_FP_EQUAL(Linf_norm, expected_norms[1], my_tolerance);
1782 const Real H1_norm =
1785 LIBMESH_ASSERT_FP_EQUAL(H1_norm, expected_norms[2], my_tolerance);
1786 const Real W1inf_norm =
1790 LIBMESH_ASSERT_FP_EQUAL(W1inf_norm, expected_norms[3], 10*my_tolerance);
1799 dyna.
read(filename);
1810 testMasterCenters(
mesh);
1812 testProjectionRegression(
mesh, expected_norms);
1819 testDynaFileMappings(
"meshes/PressurizedCyl_Patch6_256Elem.bxt.gz",
1821 {{0.9639857809698268, 1.839870171669186,
1822 0.7089812562241862, 1.306121188539059}});
1829 testDynaFileMappings(
"meshes/BlockWithHole_Patch9.bxt.gz",
1831 {{3.22612556930183, 1.97405365384733,
1832 2.53376235803176, 1.41374070517223}});
1839 testDynaFileMappings(
"meshes/PlateWithHole_Patch8.bxt.gz",
1841 {{2.2812154374012, 1.974049990211937,
1842 1.791640772215248, 1.413679237529376}});
1849 testDynaFileMappings(
"meshes/PressurizedCyl3d_Patch1_8Elem.bxt.gz",
1851 {{0.963612880188165, 1.82329452603503,
1852 0.707998701597943, 1.31399222566683}});
1856 std::array<Real, 4> expected_norms,
1857 bool use_disc_bex =
false)
1871 exii.
read(filename);
1879 testMasterCenters(
mesh);
1881 testProjectionRegression(
mesh, expected_norms);
1888 exii.
write(
"exodus_file_mapping_out.e");
1891 #ifdef LIBMESH_HAVE_VTK 1895 vtkout.
write(
"vtk_file_mapping_out.pvtu");
1904 testExodusFileMappings(
"meshes/PlateWithHole_Patch8.e",
1906 {{2.2812154374012, 1.974049990211937,
1907 1.791640772215248, 1.413679237529376}});
1914 testExodusFileMappings(
"meshes/two_quads_two_blocks.e",
1916 {{2.03496953073072, 1.97996853164955,
1917 1.18462134113435, 1.03085301158959}});
1923 testExodusFileMappings(
"meshes/two_element_iga_in.e",
1925 {{1.26865962862531, 1.42562070158386,
1926 1.54905363492342, 1.29782906548366}});
1933 testExodusFileMappings(
"meshes/PressurizedCyl3d_Patch1_8Elem.e",
1934 {{0.963612880188165, 1.82329452603503,
1935 0.707998701597943, 1.31399222566683}});
1942 testExodusFileMappings(
"meshes/PlateWithHole_Patch8.e",
1951 {{2.28234312456534, 1.97439548757586,
1952 1.79290449809266, 1.41075128955985}},
1960 testExodusFileMappings(
"meshes/two_quads_two_blocks.e",
1962 {{2.03496953073072, 1.97996853164955,
1963 1.18462134113435, 1.03085301158959}},
1970 testExodusFileMappings(
"meshes/two_element_iga_in.e",
1972 {{1.26877626663365, 1.42553698909339,
1973 1.54810114917177, 1.29792704408979}},
1981 testExodusFileMappings(
"meshes/PressurizedCyl3d_Patch1_8Elem.e",
1982 {{0.963855209590556, 1.8234396424318,
1983 0.708286572453382, 1.31468940958327}},
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.
ElemType
Defines an enum for geometric element types.
virtual void read(const std::string &name) override
Reads in a mesh in the Dyna format from the ASCII file given by name.
This is the EquationSystems class.
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false)=0
Interfaces for reading/writing a mesh to/from a file.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
Reading and writing meshes in the Gmsh format.
Order
defines an enum for polynomial orders.
bool have_parameter(std::string_view) const
virtual void read(const std::string &base_filename) override
Implements reading the mesh from several different files.
Reading and writing meshes in (a subset of) LS-DYNA format.
virtual void read(const std::string &) override
This method implements reading a mesh from a specified file in TetGen format.
std::unique_ptr< PointLocatorBase > sub_point_locator() const
This class implements reading and writing triangle meshes in the STL format.
The AbaqusIO class is a preliminary implementation for reading Abaqus mesh files in ASCII format...
This class provides the ability to map between arbitrary, user-defined strings and several data types...
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use...
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
libMesh::Parallel::Communicator * TestCommWorld
static constexpr Real TOLERANCE
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly ecreated (or read) mesh for use.
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
virtual void read(const std::string &mesh_file) override
This method implements reading a mesh from a specified file.
This is the base class from which all geometric element types are derived.
virtual void write(const std::string &) override
Output the mesh without solutions to a .pvtu file.
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
void skip_noncritical_partitioning(bool skip)
If true is passed in then the elements on this mesh will no longer be (re)partitioned, and the nodes on this mesh will only be repartitioned if they are found "orphaned" via coarsening or other removal of the last element responsible for their node/element processor id consistency.
const Parallel::Communicator & comm() const
void boundary_ids(const Node *node, std::vector< boundary_id_type > &vec_to_fill) const
Fills a user-provided std::vector with the boundary ids associated with Node node.
This class implements reading and writing meshes in the TetGen format.
The libMesh namespace provides an interface to certain functionality in the library.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
This class implements reading and writing meshes in the VTK format.
virtual std::unique_ptr< MeshBase > clone() const =0
Virtual "copy constructor".
This is the MeshBase class.
std::size_t n_boundary_ids() const
ElemMappingType default_mapping_type() const
Returns the default master space to physical space mapping basis functions to be used on newly added ...
This class handles the numbering of degrees of freedom on a mesh.
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
virtual bool is_serial() const
const dof_id_type n_nodes
unsigned int number() const
const T & get(std::string_view) const
This is the MeshCommunication class.
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
The Nemesis_IO class implements reading parallel meshes in the Nemesis file format from Sandia Nation...
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
virtual void write_equation_systems(const std::string &fname, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Writes out the solution for no specific time or timestep.
Manages consistently variables, degrees of freedom, and coefficient vectors.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
void write_element_data(const EquationSystems &es)
Write out element solution in parallel, without localizing the solution vector.
virtual dof_id_type max_elem_id() const =0
void copy_elemental_solution(System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
If we read in a elemental solution while reading in a mesh, we can attempt to copy that elemental sol...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
const std::string & variable_name(const unsigned int i) const
std::string & subdomain_name(subdomain_id_type id)
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
std::string & sideset_name(boundary_id_type id)
virtual void write(const std::string &name) const =0
const std::set< boundary_id_type > & get_boundary_ids() const
static int get_exodus_version()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
dof_id_type n_constrained_dofs() const
virtual void renumber_elem(dof_id_type old_id, dof_id_type new_id)=0
Changes the id of element old_id, both by changing elem(old_id)->id() and by moving elem(old_id) in t...
void max(const T &r, T &o, Request &req) const
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
virtual void write(const std::string &fname) override
This method implements writing a mesh to a specified file.
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
Creates a list of element numbers, edges, and boundary ids for those edges.
static Point map(const unsigned int dim, const Elem *elem, const Point &reference_point)
void broadcast(MeshBase &) const
Finds all the processors that may contain elements that neighbor my elements.
void copy_elemental_solution(System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
If we read in a elemental solution while reading in a mesh, we can attempt to copy that elemental sol...
virtual Real volume() const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Parameters parameters
Data structure holding arbitrary parameters.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
ExodusHeaderInfo read_header(const std::string &name)
Read only the header information, instead of the entire mesh.
void write_element_data_from_discontinuous_nodal_data(const EquationSystems &es, const std::set< std::string > *system_names=nullptr, const std::string &var_suffix="_elem_node_")
Similar to the function above, but instead of only handling (CONSTANT, MONOMIAL) data, writes out a general discontinuous solution field, e.g.
void set_discontinuous_bex(bool disc_bex)
Set to true (false is the default) to generate independent nodes for every Bezier Extraction element ...
virtual void init()
Initialize all the systems.
virtual void read(const std::string &name) override
Reads in a mesh in the Gmsh *.msh format from the ASCII file given by name.
virtual dof_id_type n_elem() const =0
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
processor_id_type processor_id() const
const DofMap & get_dof_map() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
void ErrorVector unsigned int
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
virtual dof_id_type n_nodes() const =0