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 );
115 CPPUNIT_TEST( testExodusSetNodeUniqueIdsFromMaps );
116 CPPUNIT_TEST( testExodusSetElemUniqueIdsFromMaps );
118 CPPUNIT_TEST( testExodusIGASidesets );
119 CPPUNIT_TEST( testLowOrderEdgeBlocks );
121 #ifndef LIBMESH_USE_COMPLEX_NUMBERS 122 CPPUNIT_TEST( testExodusCopyElementVectorDistributed );
123 CPPUNIT_TEST( testExodusCopyElementVectorReplicated );
126 CPPUNIT_TEST( testExodusWriteElementDataFromDiscontinuousNodalData );
127 #endif // !LIBMESH_USE_COMPLEX_NUMBERS 129 CPPUNIT_TEST( testExodusWriteAddedSidesEdgeC0 );
130 CPPUNIT_TEST( testExodusDiscWriteAddedSidesEdgeC0 );
131 CPPUNIT_TEST( testExodusWriteAddedSidesMixedEdgeC0 );
132 CPPUNIT_TEST( testExodusDiscWriteAddedSidesMixedEdgeC0 );
135 CPPUNIT_TEST( testExodusWriteAddedSidesTriC0 );
136 CPPUNIT_TEST( testExodusDiscWriteAddedSidesTriC0 );
137 CPPUNIT_TEST( testExodusWriteAddedSidesMixedTriC0 );
138 CPPUNIT_TEST( testExodusDiscWriteAddedSidesMixedTriC0 );
141 CPPUNIT_TEST( testExodusWriteAddedSidesQuadC0 );
142 CPPUNIT_TEST( testExodusDiscWriteAddedSidesQuadC0 );
143 CPPUNIT_TEST( testExodusWriteAddedSidesMixedQuadC0 );
144 CPPUNIT_TEST( testExodusDiscWriteAddedSidesMixedQuadC0 );
151 CPPUNIT_TEST( testExodusWriteAddedSidesHexC0 );
152 CPPUNIT_TEST( testExodusDiscWriteAddedSidesHexC0 );
153 CPPUNIT_TEST( testExodusWriteAddedSidesMixedHexC0 );
154 CPPUNIT_TEST( testExodusDiscWriteAddedSidesMixedHexC0 );
155 CPPUNIT_TEST( testExodusWriteAddedSidesHexDisc );
156 CPPUNIT_TEST( testExodusDiscWriteAddedSidesHexDisc );
158 CPPUNIT_TEST( testExodusFileMappingsPlateWithHole);
159 CPPUNIT_TEST( testExodusFileMappingsTwoBlocks);
160 CPPUNIT_TEST( testExodusFileMappingsTwoElemIGA);
161 CPPUNIT_TEST( testExodusFileMappingsCyl3d);
163 CPPUNIT_TEST( testExodusDiscPlateWithHole);
164 CPPUNIT_TEST( testExodusDiscTwoBlocks);
165 CPPUNIT_TEST( testExodusDiscTwoElemIGA);
166 CPPUNIT_TEST( testExodusDiscCyl3d);
167 #endif // LIBMESH_HAVE_EXODUS_API 169 #if defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API) 170 CPPUNIT_TEST( testNemesisReadReplicated );
171 CPPUNIT_TEST( testNemesisReadDistributed );
173 CPPUNIT_TEST( testNemesisCopyNodalSolutionDistributed );
174 CPPUNIT_TEST( testNemesisCopyNodalSolutionReplicated );
175 CPPUNIT_TEST( testNemesisCopyElementSolutionDistributed );
176 CPPUNIT_TEST( testNemesisCopyElementSolutionReplicated );
178 CPPUNIT_TEST( testNemesisSingleElementDistributed );
179 CPPUNIT_TEST( testNemesisSingleElementReplicated );
180 #ifndef LIBMESH_USE_COMPLEX_NUMBERS 181 CPPUNIT_TEST( testNemesisCopyElementVectorDistributed );
182 CPPUNIT_TEST( testNemesisCopyElementVectorReplicated );
183 #endif // !LIBMESH_USE_COMPLEX_NUMBERS 184 #endif // defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API) 186 #ifdef LIBMESH_HAVE_GZSTREAM 187 CPPUNIT_TEST( testAbaqusReadFirst );
188 CPPUNIT_TEST( testAbaqusReadSecond );
189 CPPUNIT_TEST( testDynaReadElem );
190 CPPUNIT_TEST( testDynaNoSplines );
191 CPPUNIT_TEST( testDynaReadPatch );
192 CPPUNIT_TEST( testDynaFileMappingsFEMEx5);
193 CPPUNIT_TEST( testDynaFileMappingsBlockWithHole);
194 CPPUNIT_TEST( testDynaFileMappingsPlateWithHole);
195 CPPUNIT_TEST( testDynaFileMappingsCyl3d);
196 #endif // LIBMESH_HAVE_GZSTREAM 197 #endif // LIBMESH_DIM > 1 200 CPPUNIT_TEST( testBadGmsh );
201 CPPUNIT_TEST( testGoodGmsh );
205 CPPUNIT_TEST( testGoodSTL );
206 CPPUNIT_TEST( testGoodSTLBinary );
208 CPPUNIT_TEST( testGmshBCIDOverlap );
210 #ifdef LIBMESH_HAVE_TETGEN 211 CPPUNIT_TEST( testTetgenIO );
215 CPPUNIT_TEST_SUITE_END();
226 #ifdef LIBMESH_HAVE_VTK 246 std::set<Elem *> elements {
mesh.elements_begin(),
mesh.elements_end()};
247 for (
Elem * elem : elements)
249 const Point center = elem->vertex_average();
250 const int xn =
int(center(0)*3);
251 const int yn =
int(center(1)*3);
258 vtk.
write(
"read_elem_ids_test.pvtu");
269 mesh.
read(
"read_elem_ids_test.pvtu");
275 for (
const auto & elem :
mesh.element_ptr_range())
277 const Point center = elem->vertex_average();
278 const int xn =
int(center(0)*3);
279 const int yn =
int(center(1)*3);
280 const dof_id_type expected_id = start_id + yn*5 + xn;
281 CPPUNIT_ASSERT_EQUAL(elem->id(), expected_id);
296 for (
const auto & elem :
mesh.element_ptr_range())
298 const Point center = elem->vertex_average();
299 const int xn =
int(center(0)*3);
300 const int yn =
int(center(1)*3);
302 elem->subdomain_id() = new_id;
307 vtk.
write(
"read_sbd_ids_test.pvtu");
318 mesh.
read(
"read_sbd_ids_test.pvtu");
324 for (
const auto & elem :
mesh.element_ptr_range())
326 const Point center = elem->vertex_average();
327 const int xn =
int(center(0)*3);
328 const int yn =
int(center(1)*3);
330 CPPUNIT_ASSERT_EQUAL(elem->subdomain_id(), expected_id);
334 #endif // LIBMESH_HAVE_VTK 337 #ifdef LIBMESH_HAVE_EXODUS_API 341 const std::vector<unique_id_type> & expected_unique_ids)
344 #ifdef LIBMESH_ENABLE_UNIQUE_ID 353 exii.
read(
"meshes/nontrivial_node_num_map.exo");
370 #endif // LIBMESH_ENABLE_UNIQUE_ID 382 this->testExodusSetNodeUniqueIdsFromMaps_implementation(
384 {0, 2, 8, 7, 1, 4, 6, 5, 3});
391 this->testExodusSetNodeUniqueIdsFromMaps_implementation(
393 {0, 4, 1, 8, 5, 7, 6, 3, 2});
398 const std::vector<unique_id_type> & expected_unique_ids)
401 #ifdef LIBMESH_ENABLE_UNIQUE_ID 410 exii.
read(
"meshes/nontrivial_elem_num_map.exo");
413 auto expected_it = expected_unique_ids.begin();
414 for (
const auto & elem :
mesh.element_ptr_range())
421 CPPUNIT_ASSERT_EQUAL(elem->unique_id(), *expected_it++);
428 #endif // LIBMESH_ENABLE_UNIQUE_ID 444 std::vector<unique_id_type> expected_unique_ids = {
445 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
446 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
447 this->testExodusSetElemUniqueIdsFromMaps_implementation(
448 true, expected_unique_ids);
455 std::vector<unique_id_type> expected_unique_ids(35);
456 std::iota(expected_unique_ids.begin(), expected_unique_ids.end(), 50);
457 this->testExodusSetElemUniqueIdsFromMaps_implementation(
458 false, expected_unique_ids);
488 CPPUNIT_ASSERT_EQUAL(std::string(header_info.
title.data()), std::string(
"read_header_test.e"));
489 CPPUNIT_ASSERT_EQUAL(header_info.
num_dim, 2);
490 CPPUNIT_ASSERT_EQUAL(header_info.
num_elem, 9);
495 CPPUNIT_ASSERT_EQUAL(header_info.
num_edge, 0);
507 exii.
read(
"meshes/mesh_with_low_order_edge_blocks.e");
526 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(26), bi.
n_boundary_ids());
533 CPPUNIT_ASSERT(std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(4, 1, 8007)));
534 CPPUNIT_ASSERT(std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(10, 6, 8001)));
537 CPPUNIT_ASSERT(!std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(1, 8, 8009)));
538 CPPUNIT_ASSERT(!std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(2, 10, 9011)));
557 exii.
read(
"meshes/Cube_With_Sidesets.e");
574 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(6), bi.
n_boundary_ids());
582 bool has_bcid = bc_ids.count(i);
584 CPPUNIT_ASSERT(has_bcid);
590 std::vector<int> side_counts(6, 0);
595 for (
const auto & elem :
mesh.active_local_element_ptr_range())
600 for (
unsigned short side=0; side<elem->n_sides(); side++)
602 if (elem->neighbor_ptr(side))
607 std::vector<boundary_id_type> bids;
609 side_counts[bids[0]-1]++;
610 CPPUNIT_ASSERT_EQUAL(libmesh_side_to_bcid[side], bids[0]);
615 for (
auto bc_count : side_counts)
619 CPPUNIT_ASSERT_EQUAL(bc_count, 9);
627 exii.
write(
"Cube_With_Sidesets_out.e");
632 template <
typename MeshType,
typename IOType>
649 IOType meshoutput(
mesh);
651 meshoutput.write_equation_systems(filename, es);
657 IOType meshinput(
mesh);
660 if (meshinput.is_parallel_format())
670 meshinput.read(filename);
671 if (!meshinput.is_parallel_format())
681 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 682 meshinput.copy_nodal_solution(sys,
"testn",
"r_n");
684 meshinput.copy_nodal_solution(sys,
"testn",
"n");
694 LIBMESH_ASSERT_NUMBERS_EQUAL
702 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,ExodusII_IO>(
"repl_with_nodal_soln.e"); }
705 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,ExodusII_IO>(
"dist_with_nodal_soln.e"); }
707 #if defined(LIBMESH_HAVE_NEMESIS_API) 709 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_nodal_soln.nem"); }
712 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,Nemesis_IO>(
"dist_with_nodal_soln.nem"); }
716 template <
typename MeshType,
typename IOType>
733 IOType meshinput(
mesh);
736 std::set<std::string> sys_list;
737 meshinput.write_equation_systems(filename, es, &sys_list);
740 meshinput.write_element_data(es);
746 IOType meshinput(
mesh);
749 if (meshinput.is_parallel_format())
759 meshinput.read(filename);
760 if (!meshinput.is_parallel_format())
770 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 771 meshinput.copy_elemental_solution(sys,
"teste",
"r_e");
773 meshinput.copy_elemental_solution(sys,
"teste",
"e");
783 LIBMESH_ASSERT_NUMBERS_EQUAL
791 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,ExodusII_IO>(
"repl_with_elem_soln.e"); }
794 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,ExodusII_IO>(
"dist_with_elem_soln.e"); }
796 #if defined(LIBMESH_HAVE_NEMESIS_API) 798 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_elem_soln.nem"); }
801 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,Nemesis_IO>(
"dist_with_elem_soln.nem"); }
807 template <
typename MeshType,
typename IOType>
825 std::set<std::string> sys_list;
841 nem_io.
read(filename);
846 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 853 CPPUNIT_ASSERT_EQUAL(
int(sys.solution->size()), 1);
860 { LOG_UNIT_TEST; testSingleElementImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_single_elem.nem"); }
863 { LOG_UNIT_TEST; testSingleElementImpl<DistributedMesh,Nemesis_IO>(
"dist_with_single_elem.nem"); }
864 #endif //defined(LIBMESH_HAVE_NEMESIS_API) 867 #ifndef LIBMESH_USE_COMPLEX_NUMBERS 872 template <
typename MeshType,
typename IOType>
898 for (
const auto & elem :
mesh.active_local_element_ptr_range())
900 const Point & p = elem->vertex_average();
913 IOType meshinput(
mesh);
916 std::set<std::string> sys_list;
917 meshinput.write_equation_systems(filename, es, &sys_list);
920 meshinput.write_element_data(es);
926 IOType meshinput(
mesh);
929 if (meshinput.is_parallel_format())
944 meshinput.read(filename);
945 if (!meshinput.is_parallel_format())
952 meshinput.copy_elemental_solution(sys,
"teste_x",
"e_x");
953 meshinput.copy_elemental_solution(sys,
"teste_y",
"e_y");
962 LIBMESH_ASSERT_NUMBERS_EQUAL
964 LIBMESH_ASSERT_NUMBERS_EQUAL
971 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh, ExodusII_IO>(
"repl_with_elem_vec.e"); }
974 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,ExodusII_IO>(
"dist_with_elem_vec.e"); }
976 #if defined(LIBMESH_HAVE_NEMESIS_API) 978 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_elem_vec.nem"); }
981 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,Nemesis_IO>(
"dist_with_elem_vec.nem"); }
998 (
mesh, 2, 2, 2, 0., 1., 0., 1., 0., 1.,
HEX8);
1004 std::vector<dof_id_type> dof_indices;
1005 for (
const auto & elem :
mesh.element_ptr_range())
1008 for (
unsigned int i=0; i<dof_indices.size(); ++i)
1009 sys.
solution->set(dof_indices[i], i);
1017 std::set<std::string> sys_list;
1021 sys_list = {
"SimpleSystem"};
1024 (es, &sys_list,
"_elem_corner_");
1029 std::vector<std::string> file_var_names =
1034 std::vector<Real> expected_values = {0., 1., 2., 3.};
1048 exii.
read(
"elemental_from_nodal.e");
1059 for (
const auto & elem :
mesh.active_element_ptr_range())
1063 LIBMESH_ASSERT_FP_EQUAL
1069 #endif // !LIBMESH_USE_COMPLEX_NUMBERS 1072 void testExodusWriteAddedSides
1074 std::string &,
const std::string &),
1077 const bool write_discontinuous =
false,
1078 const std::vector<FEType> earlier_vars = {},
1079 const std::vector<FEType> later_vars = {})
1086 const bool is_tensor = (
Elem::build(elem_type)->n_sides() ==
dim * 2);
1095 const std::string filename =
1096 "side_discontinuous_"+Utility::enum_to_string<ElemType>(elem_type)+(write_discontinuous?
"_disc":
"")+
".e";
1105 for (
auto vartype : earlier_vars)
1106 sys.
add_variable(
"earlier_"+std::to_string(varnum++), vartype);
1111 for (
auto vartype : later_vars)
1112 sys.
add_variable(
"later_"+std::to_string(varnum++), vartype);
1116 (
mesh, nx, ny, nz, 0., 1., 0., 1., 0., 1., elem_type);
1119 (
mesh, nx, ny, 0., 1., 0., 1., elem_type);
1122 (
mesh, nx, 0., 1., elem_type);
1126 CPPUNIT_ASSERT_LESS(n_true_nodes, n_true_elem);
1128 const unsigned int our_ny =
dim>1 ? ny : 1;
1129 const unsigned int our_nz =
dim>2 ? nz : 1;
1132 CPPUNIT_ASSERT_LESSEQUAL(n_true_elem, min_n_elem);
1134 for (
const auto & elem :
mesh.active_local_element_ptr_range())
1137 if (!elem->neighbor_ptr(s) || elem->neighbor_ptr(s)->id() < elem->id())
1140 auto side = elem->build_side_ptr(s);
1141 n_fake_nodes += side->n_nodes();
1147 const dof_id_type expected_fakes = [elem_type]() {
1153 return 3*nx*ny + nx + ny;
1156 return 2*nx*ny + nx + ny;
1158 return 48*nx*ny*nz + 4*(nx*ny+nx*nz+ny*nz);
1160 return 3*nx*ny*nz + nx*ny + nx*nz + ny*nz;
1166 CPPUNIT_ASSERT_EQUAL(n_fake_elem, expected_fakes);
1176 exii.write_added_sides(
true);
1178 if (write_discontinuous)
1179 exii.write_discontinuous_equation_systems(filename, es);
1181 exii.write_equation_systems(filename, es);
1191 exii.read(filename);
1195 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), n_true_elem + n_fake_elem);
1196 if (write_discontinuous)
1200 n_true_elem*nodes_per_elem + n_fake_nodes);
1203 CPPUNIT_ASSERT_EQUAL(
mesh.
n_nodes(), n_true_nodes + n_fake_nodes);
1214 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 1215 exii.copy_nodal_solution(sys,
"ul",
"r_u");
1217 exii.copy_nodal_solution(sys,
"ul",
"u");
1221 const std::string nullstr;
1222 const std::string facestr =
"face";
1227 #ifdef LIBMESH_ENABLE_EXCEPTIONS 1228 bool threw_exception =
false;
1230 #endif // LIBMESH_ENABLE_EXCEPTIONS 1232 for (
const auto & elem :
mesh.active_local_element_ptr_range())
1235 if (elem->dim() ==
dim)
1238 std::vector<dof_id_type> dof_indices;
1245 const Point normal = [elem](){
1246 if (elem->dim() == 2)
1247 return Point((elem->point(1) - elem->point(0)).cross
1248 (elem->point(2) - elem->point(0)));
1249 else if (elem->dim() == 1)
1251 (elem->point(1)(1)-elem->point(0)(1),
1252 elem->point(0)(0)-elem->point(1)(0));
1263 libmesh_assert_less(std::abs(normal(1)),
TOLERANCE);
1264 libmesh_assert_less(std::abs(normal(2)),
TOLERANCE);
1266 else if (std::abs(normal(1)) >
TOLERANCE)
1269 libmesh_assert_less(std::abs(normal(2)),
TOLERANCE);
1274 libmesh_assert_greater(std::abs(normal(2)),
TOLERANCE);
1276 libmesh_assert_greater_equal(faceval, 0);
1277 es.parameters.set<
short>(facestr) = faceval;
1282 const Point node_pt = elem->point(i);
1283 const Real nodal_coef =
1285 const Real exact_val =
1287 (node_pt, es.parameters, nullstr,
1289 LIBMESH_ASSERT_FP_EQUAL
1290 (nodal_coef, exact_val,
1291 std::max(
Real(2),nodal_coef+exact_val)*
1297 #ifdef LIBMESH_ENABLE_EXCEPTIONS 1300 threw_exception =
true;
1304 if (!threw_exception)
1306 CPPUNIT_ASSERT(!threw_exception);
1307 #endif // LIBMESH_ENABLE_EXCEPTIONS 1310 CPPUNIT_ASSERT_EQUAL(n_side_nodes, n_fake_nodes);
1472 #endif // LIBMESH_HAVE_EXODUS_API 1475 #if defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API) 1476 template <
typename MeshType>
1494 nem.
read(
"test_nemesis_read.nem");
1502 { LOG_UNIT_TEST; testNemesisReadImpl<ReplicatedMesh>(); }
1505 { LOG_UNIT_TEST; testNemesisReadImpl<DistributedMesh>(); }
1513 for (
auto & elem :
mesh.element_ptr_range())
1515 Point master_pt = {};
1518 if (elem->dim() > 0)
1519 master_pt(0) = 0.25;
1521 if (elem->dim() > 1)
1522 master_pt(1) = -0.25;
1524 if (elem->dim() > 2)
1525 master_pt(2) = 0.75;
1534 CPPUNIT_ASSERT(elem->contains_point(physical_pt));
1537 std::set<subdomain_id_type> my_subdomain { elem->subdomain_id() };
1541 std::set<const Elem * > located_elems;
1542 (*locator)(physical_pt, located_elems, &my_subdomain);
1544 CPPUNIT_ASSERT(located_elems.count(elem));
1557 bool found_the_quad =
false;
1559 for (
auto & elem :
mesh.element_ptr_range())
1564 CPPUNIT_ASSERT_EQUAL(elem->type(),
QUAD9);
1565 found_the_quad =
true;
1567 for (
unsigned int n=0; n != 9; ++n)
1568 CPPUNIT_ASSERT_EQUAL
1569 (elem->node_ref(n).get_extra_datum<
Real>(weight_index),
1572 CPPUNIT_ASSERT_EQUAL(elem->point(0)(0),
Real(0.5));
1573 CPPUNIT_ASSERT_EQUAL(elem->point(0)(1),
Real(0.5));
1574 CPPUNIT_ASSERT_EQUAL(elem->point(1)(0),
Real(1.5));
1575 CPPUNIT_ASSERT_EQUAL(elem->point(1)(1),
Real(0.5));
1576 CPPUNIT_ASSERT_EQUAL(elem->point(2)(0),
Real(1.5));
1577 CPPUNIT_ASSERT_EQUAL(elem->point(2)(1),
Real(1.5));
1578 CPPUNIT_ASSERT_EQUAL(elem->point(3)(0),
Real(0.5));
1579 CPPUNIT_ASSERT_EQUAL(elem->point(3)(1),
Real(1.5));
1580 CPPUNIT_ASSERT(elem->has_affine_map());
1582 for (
unsigned int v=0; v != 4; ++v)
1583 CPPUNIT_ASSERT_EQUAL(elem->point(v)(2),
Real(0));
1588 CPPUNIT_ASSERT(found_the_quad);
1590 testMasterCenters(
mesh);
1616 testAbaqusRead(
"meshes/tensile_sample_test1.inp.gz", 728, 1166);
1623 testAbaqusRead(
"meshes/poly_sample_test2.inp.gz", 1280, 1625);
1636 dyna.
read(
"meshes/1_quad.bxt.gz");
1646 helperTestingDynaQuad(
mesh);
1657 #ifdef LIBMESH_ENABLE_EXCEPTIONS 1658 std::string what =
"";
1662 gmsh_io.
read(
"meshes/block.msh");
1670 std::regex msg_regex(
"outside entity physical bounding box");
1671 CPPUNIT_ASSERT(std::regex_search(what, msg_regex));
1684 gmsh_io.
read(
"meshes/circle.msh");
1699 gmsh_io.
read(
"meshes/bcid_overlap.msh");
1705 std::string(
"srfBC4A"));
1707 std::string(
"srfBC4B"));
1711 std::string(
"volBC3A"));
1713 std::string(
"volBC3B"));
1725 stl_io.
read(
"meshes/Cluster_34.stl");
1740 stl_io.
read(
"meshes/engraving.stl");
1749 #ifdef LIBMESH_HAVE_TETGEN 1757 tetgen_io.
read(
"meshes/tetgen_one_tet10.ele");
1771 CPPUNIT_ASSERT(elem);
1774 bool have_elem = elem;
1776 CPPUNIT_ASSERT(have_elem);
1796 dyna.
read(
"meshes/1_quad.bxt.gz");
1805 helperTestingDynaQuad(
mesh);
1817 dyna.
read(
"meshes/25_quad.bxt.gz");
1832 for (
const auto & elem :
mesh.active_element_ptr_range())
1836 LIBMESH_ASSERT_FP_EQUAL(
Real(0.04), elem->volume(),
TOLERANCE);
1838 for (
unsigned int n=0; n != 9; ++n)
1839 CPPUNIT_ASSERT_EQUAL
1840 (elem->node_ref(n).get_extra_datum<
Real>(weight_index),
1843 unsigned int n_neighbors = 0, n_neighbors_expected = 2;
1844 for (
unsigned int side=0; side != 4; ++side)
1845 if (elem->neighbor_ptr(side))
1847 Point c = elem->vertex_average();
1849 if (c(0) > 0.2 && c(0) < 0.8)
1850 n_neighbors_expected++;
1851 if (c(1) > 0.2 && c(1) < 0.8)
1852 n_neighbors_expected++;
1854 CPPUNIT_ASSERT_EQUAL(n_neighbors, n_neighbors_expected);
1857 testMasterCenters(
mesh);
1859 #ifdef LIBMESH_HAVE_SOLVER 1860 #ifdef LIBMESH_ENABLE_CONSTRAINTS 1869 #endif // LIBMESH_ENABLE_CONSTRAINTS 1870 #endif // LIBMESH_HAVE_SOLVER 1876 for (
const auto elem :
mesh.element_ptr_range())
1877 order = std::max(order,
int(elem->default_order()));
1879 CPPUNIT_ASSERT (order > 0);
1883 std::unique_ptr<MeshBase> mesh_clone =
mesh.
clone();
1884 CPPUNIT_ASSERT(*mesh_clone ==
mesh);
1899 std::set<unsigned int> skip_dimensions {0};
1900 const Real L2_norm =
1904 LIBMESH_ASSERT_FP_EQUAL(L2_norm, expected_norms[0], my_tolerance);
1905 const Real Linf_norm =
1908 LIBMESH_ASSERT_FP_EQUAL(Linf_norm, expected_norms[1], my_tolerance);
1909 const Real H1_norm =
1912 LIBMESH_ASSERT_FP_EQUAL(H1_norm, expected_norms[2], my_tolerance);
1913 const Real W1inf_norm =
1917 LIBMESH_ASSERT_FP_EQUAL(W1inf_norm, expected_norms[3], 10*my_tolerance);
1926 dyna.
read(filename);
1937 testMasterCenters(
mesh);
1939 testProjectionRegression(
mesh, expected_norms);
1946 testDynaFileMappings(
"meshes/PressurizedCyl_Patch6_256Elem.bxt.gz",
1948 {{0.9639857809698268, 1.839870171669186,
1949 0.7089812562241862, 1.306121188539059}});
1956 testDynaFileMappings(
"meshes/BlockWithHole_Patch9.bxt.gz",
1958 {{3.22612556930183, 1.97405365384733,
1959 2.53376235803176, 1.41374070517223}});
1966 testDynaFileMappings(
"meshes/PlateWithHole_Patch8.bxt.gz",
1968 {{2.2812154374012, 1.974049990211937,
1969 1.791640772215248, 1.413679237529376}});
1976 testDynaFileMappings(
"meshes/PressurizedCyl3d_Patch1_8Elem.bxt.gz",
1978 {{0.963612880188165, 1.82329452603503,
1979 0.707998701597943, 1.31399222566683}});
1983 std::array<Real, 4> expected_norms,
1984 bool use_disc_bex =
false)
1998 exii.
read(filename);
2006 testMasterCenters(
mesh);
2008 testProjectionRegression(
mesh, expected_norms);
2015 exii.
write(
"exodus_file_mapping_out.e");
2018 #ifdef LIBMESH_HAVE_VTK 2022 vtkout.
write(
"vtk_file_mapping_out.pvtu");
2031 testExodusFileMappings(
"meshes/PlateWithHole_Patch8.e",
2033 {{2.2812154374012, 1.974049990211937,
2034 1.791640772215248, 1.413679237529376}});
2041 testExodusFileMappings(
"meshes/two_quads_two_blocks.e",
2043 {{2.03496953073072, 1.97996853164955,
2044 1.18462134113435, 1.03085301158959}});
2050 testExodusFileMappings(
"meshes/two_element_iga_in.e",
2052 {{1.26865962862531, 1.42562070158386,
2053 1.54905363492342, 1.29782906548366}});
2060 testExodusFileMappings(
"meshes/PressurizedCyl3d_Patch1_8Elem.e",
2061 {{0.963612880188165, 1.82329452603503,
2062 0.707998701597943, 1.31399222566683}});
2069 testExodusFileMappings(
"meshes/PlateWithHole_Patch8.e",
2078 {{2.28234312456534, 1.97439548757586,
2079 1.79290449809266, 1.41075128955985}},
2087 testExodusFileMappings(
"meshes/two_quads_two_blocks.e",
2089 {{2.03496953073072, 1.97996853164955,
2090 1.18462134113435, 1.03085301158959}},
2097 testExodusFileMappings(
"meshes/two_element_iga_in.e",
2099 {{1.26877626663365, 1.42553698909339,
2100 1.54810114917177, 1.29792704408979}},
2108 testExodusFileMappings(
"meshes/PressurizedCyl3d_Patch1_8Elem.e",
2109 {{0.963855209590556, 1.8234396424318,
2110 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.
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...
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
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 created (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.
unique_id_type unique_id() const
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.
virtual bool is_serial() const
void libmesh_ignore(const Args &...)
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 set_unique_ids_from_maps(bool val)
If true, this flag enforces the following behaviors:
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...
std::vector< BCTuple > build_edge_list() const
Create a list of (element_id, edge_id, boundary_id) tuples for all relevant edges.
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)
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int >> variable_numbers=std::nullopt) const
Projects arbitrary functions onto the current solution.
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.
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.
virtual const Node * node_ptr(const dof_id_type i) const =0
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