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>
12#include <libmesh/cell_c0polyhedron.h>
14#include <libmesh/abaqus_io.h>
15#include <libmesh/dyna_io.h>
16#include <libmesh/exodusII_io.h>
17#include <libmesh/gmsh_io.h>
18#include <libmesh/nemesis_io.h>
19#include <libmesh/stl_io.h>
20#include <libmesh/vtk_io.h>
21#include <libmesh/tetgen_io.h>
36 const Real & x = p(0);
37 const Real & y = p(1);
48 const Real & x = p(0);
49 const Real & y = p(1);
51 return sin(x) + cos(y);
61 const Real & x = p(0);
62 const Real & y = p(1);
63 const Real & z = p(2);
66 param.
get<
short>(
"face") : -1;
69 auto is_on_face = [facedim](
Real r,
short rdim) {
75 return (std::abs(numerator - std::round(numerator)) <
105#ifdef LIBMESH_HAVE_VTK
113#ifdef LIBMESH_HAVE_EXODUS_API
126#ifndef LIBMESH_USE_COMPLEX_NUMBERS
174#if defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API)
185#ifndef LIBMESH_USE_COMPLEX_NUMBERS
191#ifdef LIBMESH_HAVE_GZSTREAM
215#ifdef LIBMESH_HAVE_TETGEN
231#ifdef LIBMESH_HAVE_VTK
251 std::set<Elem *> elements {
mesh.elements_begin(),
mesh.elements_end()};
252 for (
Elem * elem : elements)
254 const Point center = elem->vertex_average();
255 const int xn =
int(center(0)*3);
256 const int yn =
int(center(1)*3);
263 vtk.
write(
"read_elem_ids_test.pvtu");
274 mesh.
read(
"read_elem_ids_test.pvtu");
280 for (
const auto & elem :
mesh.element_ptr_range())
282 const Point center = elem->vertex_average();
283 const int xn =
int(center(0)*3);
284 const int yn =
int(center(1)*3);
285 const dof_id_type expected_id = start_id + yn*5 + xn;
286 CPPUNIT_ASSERT_EQUAL(elem->id(), expected_id);
301 for (
const auto & elem :
mesh.element_ptr_range())
303 const Point center = elem->vertex_average();
304 const int xn =
int(center(0)*3);
305 const int yn =
int(center(1)*3);
307 elem->subdomain_id() = new_id;
312 vtk.
write(
"read_sbd_ids_test.pvtu");
323 mesh.
read(
"read_sbd_ids_test.pvtu");
329 for (
const auto & elem :
mesh.element_ptr_range())
331 const Point center = elem->vertex_average();
332 const int xn =
int(center(0)*3);
333 const int yn =
int(center(1)*3);
335 CPPUNIT_ASSERT_EQUAL(elem->subdomain_id(), expected_id);
350 bool found_elem = elem;
352 CPPUNIT_ASSERT(found_elem);
358 CPPUNIT_ASSERT_EQUAL(12u, elem->
n_vertices());
359 CPPUNIT_ASSERT_EQUAL(8u, elem->
n_sides());
368 std::set<std::set<dof_id_type>> faces;
371 std::set<dof_id_type> face;
374 faces.insert(std::move(face));
377 const std::set<std::set<dof_id_type>> expected_faces =
378 { {0, 1, 2, 3, 4, 5},
385 {6, 7, 8, 9, 10, 11} };
387 CPPUNIT_ASSERT(faces == expected_faces);
405 mesh.
read(
"meshes/hex_prism_polyhedron.pvtu");
426 mesh.
read(
"meshes/hex_prism_polyhedron_0.vtu");
449#ifdef LIBMESH_ENABLE_EXCEPTIONS
452 CPPUNIT_ASSERT_THROW_MESSAGE
453 (
"Non-VTK-XML file not detected",
454 vtk.
read(
"meshes/circle.msh"),
461#ifdef LIBMESH_HAVE_EXODUS_API
465 const std::vector<unique_id_type> & expected_unique_ids)
468#ifdef LIBMESH_ENABLE_UNIQUE_ID
477 exii.
read(
"meshes/nontrivial_node_num_map.exo");
508 {0, 2, 8, 7, 1, 4, 6, 5, 3});
517 {0, 4, 1, 8, 5, 7, 6, 3, 2});
522 const std::vector<unique_id_type> & expected_unique_ids)
525#ifdef LIBMESH_ENABLE_UNIQUE_ID
534 exii.
read(
"meshes/nontrivial_elem_num_map.exo");
537 auto expected_it = expected_unique_ids.begin();
538 for (
const auto & elem :
mesh.element_ptr_range())
545 CPPUNIT_ASSERT_EQUAL(elem->unique_id(), *expected_it++);
568 std::vector<unique_id_type> expected_unique_ids = {
569 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
570 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
572 true, expected_unique_ids);
579 std::vector<unique_id_type> expected_unique_ids(35);
580 std::iota(expected_unique_ids.begin(), expected_unique_ids.end(), 50);
582 false, expected_unique_ids);
612 CPPUNIT_ASSERT_EQUAL(std::string(header_info.
title.data()), std::string(
"read_header_test.e"));
613 CPPUNIT_ASSERT_EQUAL(header_info.
num_dim, 2);
614 CPPUNIT_ASSERT_EQUAL(header_info.
num_elem, 9);
619 CPPUNIT_ASSERT_EQUAL(header_info.
num_edge, 0);
631 exii.
read(
"meshes/mesh_with_low_order_edge_blocks.e");
650 CPPUNIT_ASSERT_EQUAL(
static_cast<std::size_t
>(26), bi.
n_boundary_ids());
657 CPPUNIT_ASSERT(std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(4, 1, 8007)));
658 CPPUNIT_ASSERT(std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(10, 6, 8001)));
661 CPPUNIT_ASSERT(!std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(1, 8, 8009)));
662 CPPUNIT_ASSERT(!std::binary_search(edge_list.begin(), edge_list.end(), std::make_tuple(2, 10, 9011)));
681 exii.
read(
"meshes/Cube_With_Sidesets.e");
698 CPPUNIT_ASSERT_EQUAL(
static_cast<std::size_t
>(6), bi.
n_boundary_ids());
706 bool has_bcid = bc_ids.count(i);
708 CPPUNIT_ASSERT(has_bcid);
714 std::vector<int> side_counts(6, 0);
719 for (
const auto & elem :
mesh.active_local_element_ptr_range())
724 for (
unsigned short side=0; side<elem->n_sides(); side++)
726 if (elem->neighbor_ptr(side))
731 std::vector<boundary_id_type> bids;
733 side_counts[bids[0]-1]++;
734 CPPUNIT_ASSERT_EQUAL(libmesh_side_to_bcid[side], bids[0]);
739 for (
auto bc_count : side_counts)
743 CPPUNIT_ASSERT_EQUAL(bc_count, 9);
751 exii.
write(
"Cube_With_Sidesets_out.e");
756 template <
typename MeshType,
typename IOType>
773 IOType meshoutput(
mesh);
775 meshoutput.write_equation_systems(filename, es);
781 IOType meshinput(
mesh);
784 if (meshinput.is_parallel_format())
794 meshinput.read(filename);
795 if (!meshinput.is_parallel_format())
805#ifdef LIBMESH_USE_COMPLEX_NUMBERS
806 meshinput.copy_nodal_solution(sys,
"testn",
"r_n");
808 meshinput.copy_nodal_solution(sys,
"testn",
"n");
818 LIBMESH_ASSERT_NUMBERS_EQUAL
826 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,ExodusII_IO>(
"repl_with_nodal_soln.e"); }
829 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,ExodusII_IO>(
"dist_with_nodal_soln.e"); }
831#if defined(LIBMESH_HAVE_NEMESIS_API)
833 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_nodal_soln.nem"); }
836 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,Nemesis_IO>(
"dist_with_nodal_soln.nem"); }
840 template <
typename MeshType,
typename IOType>
859 IOType meshinput(
mesh);
862 std::set<std::string> sys_list;
863 meshinput.write_equation_systems(filename, es, &sys_list);
866 meshinput.write_element_data(es);
872 IOType meshinput(
mesh);
875 if (meshinput.is_parallel_format())
887 meshinput.read(filename);
888 if (!meshinput.is_parallel_format())
898#ifdef LIBMESH_USE_COMPLEX_NUMBERS
899 meshinput.copy_elemental_solution(sys,
"teste",
"r_e");
900 meshinput.copy_elemental_solution(sys,
"teste_no_p",
"r_e_no_p");
901 meshinput.copy_elemental_solution(sys,
"teste_xyz",
"r_e_xyz");
903 meshinput.copy_elemental_solution(sys,
"teste",
"e");
904 meshinput.copy_elemental_solution(sys,
"teste_no_p",
"e_no_p");
905 meshinput.copy_elemental_solution(sys,
"teste_xyz",
"e_xyz");
915 LIBMESH_ASSERT_NUMBERS_EQUAL
917 LIBMESH_ASSERT_NUMBERS_EQUAL
919 LIBMESH_ASSERT_NUMBERS_EQUAL
927 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,ExodusII_IO>(
"repl_with_elem_soln.e"); }
930 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,ExodusII_IO>(
"dist_with_elem_soln.e"); }
945 const std::string filename(
"repl_with_high_order_elem_soln.e");
964 std::set<std::string> sys_list;
979 meshinput.
read(filename);
985#ifdef LIBMESH_USE_COMPLEX_NUMBERS
998 LIBMESH_ASSERT_NUMBERS_EQUAL
1005#if defined(LIBMESH_HAVE_NEMESIS_API)
1007 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_elem_soln.nem"); }
1010 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,Nemesis_IO>(
"dist_with_elem_soln.nem"); }
1016 template <
typename MeshType,
typename IOType>
1034 std::set<std::string> sys_list;
1050 nem_io.
read(filename);
1055#ifdef LIBMESH_USE_COMPLEX_NUMBERS
1062 CPPUNIT_ASSERT_EQUAL(
int(sys.solution->size()), 1);
1069 { LOG_UNIT_TEST; testSingleElementImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_single_elem.nem"); }
1072 { LOG_UNIT_TEST; testSingleElementImpl<DistributedMesh,Nemesis_IO>(
"dist_with_single_elem.nem"); }
1076#ifndef LIBMESH_USE_COMPLEX_NUMBERS
1081 template <
typename MeshType,
typename IOType>
1113 for (
const auto & elem :
mesh.active_local_element_ptr_range())
1115 const Point & p = elem->vertex_average();
1132 IOType meshinput(
mesh);
1135 std::set<std::string> sys_list;
1136 meshinput.write_equation_systems(filename, es, &sys_list);
1139 meshinput.write_element_data(es);
1145 IOType meshinput(
mesh);
1148 if (meshinput.is_parallel_format())
1165 meshinput.read(filename);
1166 if (!meshinput.is_parallel_format())
1173 meshinput.copy_elemental_solution(sys,
"teste_x",
"e_x");
1174 meshinput.copy_elemental_solution(sys,
"teste_y",
"e_y");
1175 meshinput.copy_elemental_solution(sys,
"teste_no_p_x",
"e_no_p_x");
1176 meshinput.copy_elemental_solution(sys,
"teste_no_p_y",
"e_no_p_y");
1181 for (
Real x =
Real(1.L/6.L); x < 1; x +=
Real(1.L/3.L))
1182 for (
Real y =
Real(1.L/6.L); y < 1; y +=
Real(1.L/3.L))
1185 LIBMESH_ASSERT_NUMBERS_EQUAL
1187 LIBMESH_ASSERT_NUMBERS_EQUAL
1189 LIBMESH_ASSERT_NUMBERS_EQUAL
1191 LIBMESH_ASSERT_NUMBERS_EQUAL
1198 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh, ExodusII_IO>(
"repl_with_elem_vec.e"); }
1201 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,ExodusII_IO>(
"dist_with_elem_vec.e"); }
1203#if defined(LIBMESH_HAVE_NEMESIS_API)
1205 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh,Nemesis_IO>(
"repl_with_elem_vec.nem"); }
1208 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,Nemesis_IO>(
"dist_with_elem_vec.nem"); }
1216 const Real scalar_value = 42.;
1217 const Real xyz_value = 84.;
1218 const std::vector<Real> vector_values = {10., 20., 30.};
1229 const auto xyz_var =
1231 const auto vec_var =
1235 (
mesh, 2, 2, 2, 0., 1., 0., 1., 0., 1.,
HEX8);
1241 std::vector<dof_id_type> dof_indices;
1242 for (
const auto & elem :
mesh.element_ptr_range())
1245 for (
unsigned int i=0; i<dof_indices.size(); ++i)
1246 sys.
solution->set(dof_indices[i], i);
1248 sys.
solution->set(elem->dof_number(sys.
number(), c_var, 0), scalar_value);
1249 sys.
solution->set(elem->dof_number(sys.
number(), xyz_var, 0), xyz_value);
1253 cast_int<unsigned int>(comp)),
1254 vector_values[comp]);
1262 std::set<std::string> sys_list;
1266 sys_list = {
"SimpleSystem"};
1269 (es, &sys_list,
"_elem_corner_");
1274 std::vector<std::string> file_var_names =
1284 std::vector<Real> expected_values =
1286 scalar_value, xyz_value, vector_values[0], vector_values[1], vector_values[2]};
1300 exii.
read(
"elemental_from_nodal.e");
1311 for (
const auto & elem :
mesh.active_element_ptr_range())
1315 LIBMESH_ASSERT_FP_EQUAL
1326 std::string &,
const std::string &),
1329 const bool write_discontinuous =
false,
1330 const std::vector<FEType> earlier_vars = {},
1331 const std::vector<FEType> later_vars = {})
1338 const bool is_tensor = (
Elem::build(elem_type)->n_sides() ==
dim * 2);
1347 const std::string filename =
1348 "side_discontinuous_"+Utility::enum_to_string<ElemType>(elem_type)+(write_discontinuous?
"_disc":
"")+
".e";
1357 for (
auto vartype : earlier_vars)
1358 sys.add_variable(
"earlier_"+
std::to_string(varnum++), vartype);
1363 for (
auto vartype : later_vars)
1364 sys.add_variable(
"later_"+
std::to_string(varnum++), vartype);
1368 (
mesh, nx, ny, nz, 0., 1., 0., 1., 0., 1., elem_type);
1371 (
mesh, nx, ny, 0., 1., 0., 1., elem_type);
1374 (
mesh, nx, 0., 1., elem_type);
1378 CPPUNIT_ASSERT_LESS(n_true_nodes, n_true_elem);
1380 const unsigned int our_ny =
dim>1 ? ny : 1;
1381 const unsigned int our_nz =
dim>2 ? nz : 1;
1384 CPPUNIT_ASSERT_LESSEQUAL(n_true_elem, min_n_elem);
1386 for (
const auto & elem :
mesh.active_local_element_ptr_range())
1389 if (!elem->neighbor_ptr(s) || elem->neighbor_ptr(s)->id() < elem->id())
1392 auto side = elem->build_side_ptr(s);
1393 n_fake_nodes += side->n_nodes();
1399 const dof_id_type expected_fakes = [elem_type]() {
1405 return 3*nx*ny + nx + ny;
1408 return 2*nx*ny + nx + ny;
1410 return 48*nx*ny*nz + 4*(nx*ny+nx*nz+ny*nz);
1412 return 3*nx*ny*nz + nx*ny + nx*nz + ny*nz;
1418 CPPUNIT_ASSERT_EQUAL(n_fake_elem, expected_fakes);
1428 exii.write_added_sides(
true);
1430 if (write_discontinuous)
1431 exii.write_discontinuous_equation_systems(filename, es);
1433 exii.write_equation_systems(filename, es);
1443 exii.read(filename);
1447 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), n_true_elem + n_fake_elem);
1448 if (write_discontinuous)
1452 n_true_elem*nodes_per_elem + n_fake_nodes);
1455 CPPUNIT_ASSERT_EQUAL(
mesh.
n_nodes(), n_true_nodes + n_fake_nodes);
1466#ifdef LIBMESH_USE_COMPLEX_NUMBERS
1467 exii.copy_nodal_solution(sys,
"ul",
"r_u");
1469 exii.copy_nodal_solution(sys,
"ul",
"u");
1473 const std::string nullstr;
1474 const std::string facestr =
"face";
1479#ifdef LIBMESH_ENABLE_EXCEPTIONS
1480 bool threw_exception =
false;
1484 for (
const auto & elem :
mesh.active_local_element_ptr_range())
1487 if (elem->dim() ==
dim)
1490 std::vector<dof_id_type> dof_indices;
1497 const Point normal = [elem](){
1498 if (elem->dim() == 2)
1499 return Point((elem->point(1) - elem->point(0)).cross
1500 (elem->point(2) - elem->point(0)));
1501 else if (elem->dim() == 1)
1503 (elem->point(1)(1)-elem->point(0)(1),
1504 elem->point(0)(0)-elem->point(1)(0));
1515 libmesh_assert_less(std::abs(normal(1)),
TOLERANCE);
1516 libmesh_assert_less(std::abs(normal(2)),
TOLERANCE);
1518 else if (std::abs(normal(1)) >
TOLERANCE)
1521 libmesh_assert_less(std::abs(normal(2)),
TOLERANCE);
1526 libmesh_assert_greater(std::abs(normal(2)),
TOLERANCE);
1528 libmesh_assert_greater_equal(faceval, 0);
1529 es.parameters.set<
short>(facestr) = faceval;
1534 const Point node_pt = elem->point(i);
1535 const Real nodal_coef =
1537 const Real exact_val =
1539 (node_pt, es.parameters, nullstr,
1541 LIBMESH_ASSERT_FP_EQUAL
1542 (nodal_coef, exact_val,
1543 std::max(
Real(2),nodal_coef+exact_val)*
1549#ifdef LIBMESH_ENABLE_EXCEPTIONS
1552 threw_exception =
true;
1556 if (!threw_exception)
1558 CPPUNIT_ASSERT(!threw_exception);
1562 CPPUNIT_ASSERT_EQUAL(n_side_nodes, n_fake_nodes);
1727#if defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API)
1728 template <
typename MeshType>
1746 nem.
read(
"test_nemesis_read.nem");
1754 { LOG_UNIT_TEST; testNemesisReadImpl<ReplicatedMesh>(); }
1757 { LOG_UNIT_TEST; testNemesisReadImpl<DistributedMesh>(); }
1765 for (
auto & elem :
mesh.element_ptr_range())
1767 Point master_pt = {};
1770 if (elem->dim() > 0)
1771 master_pt(0) = 0.25;
1773 if (elem->dim() > 1)
1774 master_pt(1) = -0.25;
1776 if (elem->dim() > 2)
1777 master_pt(2) = 0.75;
1784 CPPUNIT_ASSERT((inverse_pt-master_pt).norm() <
TOLERANCE);
1786 CPPUNIT_ASSERT(elem->contains_point(physical_pt));
1789 std::set<subdomain_id_type> my_subdomain { elem->subdomain_id() };
1793 std::set<const Elem * > located_elems;
1794 (*locator)(physical_pt, located_elems, &my_subdomain);
1796 CPPUNIT_ASSERT(located_elems.count(elem));
1809 bool found_the_quad =
false;
1811 for (
auto & elem :
mesh.element_ptr_range())
1816 CPPUNIT_ASSERT_EQUAL(elem->type(),
QUAD9);
1817 found_the_quad =
true;
1819 for (
unsigned int n=0; n != 9; ++n)
1820 CPPUNIT_ASSERT_EQUAL
1821 (elem->node_ref(n).get_extra_datum<
Real>(weight_index),
1824 CPPUNIT_ASSERT_EQUAL(elem->point(0)(0),
Real(0.5));
1825 CPPUNIT_ASSERT_EQUAL(elem->point(0)(1),
Real(0.5));
1826 CPPUNIT_ASSERT_EQUAL(elem->point(1)(0),
Real(1.5));
1827 CPPUNIT_ASSERT_EQUAL(elem->point(1)(1),
Real(0.5));
1828 CPPUNIT_ASSERT_EQUAL(elem->point(2)(0),
Real(1.5));
1829 CPPUNIT_ASSERT_EQUAL(elem->point(2)(1),
Real(1.5));
1830 CPPUNIT_ASSERT_EQUAL(elem->point(3)(0),
Real(0.5));
1831 CPPUNIT_ASSERT_EQUAL(elem->point(3)(1),
Real(1.5));
1832 CPPUNIT_ASSERT(elem->has_affine_map());
1834 for (
unsigned int v=0; v != 4; ++v)
1835 CPPUNIT_ASSERT_EQUAL(elem->point(v)(2),
Real(0));
1840 CPPUNIT_ASSERT(found_the_quad);
1888 dyna.
read(
"meshes/1_quad.bxt.gz");
1909#ifdef LIBMESH_ENABLE_EXCEPTIONS
1910 std::string what =
"";
1914 gmsh_io.
read(
"meshes/block.msh");
1922 std::regex msg_regex(
"outside entity physical bounding box");
1923 CPPUNIT_ASSERT(std::regex_search(what, msg_regex));
1936 gmsh_io.
read(
"meshes/circle.msh");
1951 gmsh_io.
read(
"meshes/bcid_overlap.msh");
1957 std::string(
"srfBC4A"));
1959 std::string(
"srfBC4B"));
1963 std::string(
"volBC3A"));
1965 std::string(
"volBC3B"));
1977 stl_io.
read(
"meshes/Cluster_34.stl");
1992 stl_io.
read(
"meshes/engraving.stl");
2001#ifdef LIBMESH_HAVE_TETGEN
2009 tetgen_io.
read(
"meshes/tetgen_one_tet10.ele");
2023 CPPUNIT_ASSERT(elem);
2026 bool have_elem = elem;
2028 CPPUNIT_ASSERT(have_elem);
2048 dyna.
read(
"meshes/1_quad.bxt.gz");
2069 dyna.
read(
"meshes/25_quad.bxt.gz");
2084 for (
const auto & elem :
mesh.active_element_ptr_range())
2088 LIBMESH_ASSERT_FP_EQUAL(
Real(0.04), elem->volume(),
TOLERANCE);
2090 for (
unsigned int n=0; n != 9; ++n)
2091 CPPUNIT_ASSERT_EQUAL
2092 (elem->node_ref(n).get_extra_datum<
Real>(weight_index),
2095 unsigned int n_neighbors = 0, n_neighbors_expected = 2;
2096 for (
unsigned int side=0; side != 4; ++side)
2097 if (elem->neighbor_ptr(side))
2099 Point c = elem->vertex_average();
2101 if (c(0) > 0.2 && c(0) < 0.8)
2102 n_neighbors_expected++;
2103 if (c(1) > 0.2 && c(1) < 0.8)
2104 n_neighbors_expected++;
2106 CPPUNIT_ASSERT_EQUAL(n_neighbors, n_neighbors_expected);
2111#ifdef LIBMESH_HAVE_SOLVER
2112#ifdef LIBMESH_ENABLE_CONSTRAINTS
2128 for (
const auto elem :
mesh.element_ptr_range())
2129 order = std::max(order,
int(elem->default_order()));
2131 CPPUNIT_ASSERT (order > 0);
2135 std::unique_ptr<MeshBase> mesh_clone =
mesh.
clone();
2136 CPPUNIT_ASSERT(*mesh_clone ==
mesh);
2151 std::set<unsigned int> skip_dimensions {0};
2152 const Real L2_norm =
2156 LIBMESH_ASSERT_FP_EQUAL(L2_norm, expected_norms[0], my_tolerance);
2157 const Real Linf_norm =
2160 LIBMESH_ASSERT_FP_EQUAL(Linf_norm, expected_norms[1], my_tolerance);
2161 const Real H1_norm =
2164 LIBMESH_ASSERT_FP_EQUAL(H1_norm, expected_norms[2], my_tolerance);
2165 const Real W1inf_norm =
2169 LIBMESH_ASSERT_FP_EQUAL(W1inf_norm, expected_norms[3], 10*my_tolerance);
2178 dyna.
read(filename);
2200 {{0.9639857809698268, 1.839870171669186,
2201 0.7089812562241862, 1.306121188539059}});
2210 {{3.22612556930183, 1.97405365384733,
2211 2.53376235803176, 1.41374070517223}});
2220 {{2.2812154374012, 1.974049990211937,
2221 1.791640772215248, 1.413679237529376}});
2230 {{0.963612880188165, 1.82329452603503,
2231 0.707998701597943, 1.31399222566683}});
2235 std::array<Real, 4> expected_norms,
2236 bool use_disc_bex =
false)
2250 exii.
read(filename);
2267 exii.
write(
"exodus_file_mapping_out.e");
2270#ifdef LIBMESH_HAVE_VTK
2274 vtkout.
write(
"vtk_file_mapping_out.pvtu");
2285 {{2.2812154374012, 1.974049990211937,
2286 1.791640772215248, 1.413679237529376}});
2295 {{2.03496953073072, 1.97996853164955,
2296 1.18462134113435, 1.03085301158959}});
2304 {{1.26865962862531, 1.42562070158386,
2305 1.54905363492342, 1.29782906548366}});
2313 {{0.963612880188165, 1.82329452603503,
2314 0.707998701597943, 1.31399222566683}});
2330 {{2.28234312456534, 1.97439548757586,
2331 1.79290449809266, 1.41075128955985}},
2341 {{2.03496953073072, 1.97996853164955,
2342 1.18462134113435, 1.03085301158959}},
2351 {{1.26877626663365, 1.42553698909339,
2352 1.54810114917177, 1.29792704408979}},
2361 {{0.963855209590556, 1.8234396424318,
2362 0.708286572453382, 1.31468940958327}},
void ErrorVector unsigned int
void max(const T &r, T &o, Request &req) const
The AbaqusIO class is a preliminary implementation for reading Abaqus mesh files in ASCII format.
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
std::size_t n_boundary_ids() const
std::string & sideset_name(boundary_id_type id)
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.
const std::set< boundary_id_type > & get_boundary_ids() const
std::vector< BCTuple > build_edge_list() const
Create a list of (element_id, edge_id, boundary_id) tuples for all relevant edges.
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
This class handles the numbering of degrees of freedom on a mesh.
dof_id_type n_constrained_dofs() const
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
unique_id_type unique_id() const
Reading and writing meshes in (a subset of) LS-DYNA format.
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 base class from which all geometric element types are derived.
virtual unsigned int n_vertices() const =0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
virtual std::vector< unsigned int > nodes_on_side(const unsigned int) const =0
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...
virtual Real volume() const
virtual ElemType type() const =0
virtual unsigned int n_sides() const =0
dof_id_type node_id(const unsigned int i) const
IntRange< unsigned short > side_index_range() const
This is the EquationSystems class.
Parameters parameters
Data structure holding arbitrary parameters.
virtual void init()
Initialize all the systems.
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 ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
virtual void write(const std::string &fname) override
This method implements writing a mesh to a specified file.
ExodusHeaderInfo read_header(const std::string &name)
Read only the header information, instead of the entire mesh.
void write_discontinuous_elemental_data(bool allow_hi_order_elemental)
Set to true (false is the default) to allow elemental output of higher-order discontinuous (non-CONST...
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.
static int get_exodus_version()
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,...
void set_unique_ids_from_maps(bool val)
If true, this flag enforces the following behaviors:
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...
void write_element_data(const EquationSystems &es)
Write out element solution.
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.
void set_discontinuous_bex(bool disc_bex)
Set to true (false is the default) to generate independent nodes for every Bezier Extraction element ...
static Point map(const unsigned int dim, const Elem *elem, const Point &reference_point)
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)
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
FEType set_p_refinement(bool p) &
"Fluent API" for constructing a non-default p_refinement, for easier compatibility between non-InfFE ...
Reading and writing meshes in the Gmsh format.
virtual void read(const std::string &name) override
Reads in a mesh in the Gmsh *.msh format from the ASCII file given by name.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
This is the MeshBase class.
virtual bool is_serial() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual dof_id_type n_elem() const =0
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 allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
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.
virtual void write(const std::string &name) const =0
virtual std::unique_ptr< MeshBase > clone() const =0
Virtual "copy constructor".
virtual dof_id_type n_nodes() const =0
ElemMappingType default_mapping_type() const
Returns the default master space to physical space mapping basis functions to be used on newly added ...
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.
virtual dof_id_type max_elem_id() const =0
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
std::string & subdomain_name(subdomain_id_type id)
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
std::unique_ptr< PointLocatorBase > sub_point_locator() const
void skip_noncritical_partitioning(bool skip)
If true is passed in then the elements on this mesh will no longer be (re)partitioned,...
This is the MeshCommunication class.
void broadcast(MeshBase &) const
This method takes a mesh (which is assumed to reside on processor 0) and broadcasts it to all the oth...
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 ...
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
The Nemesis_IO class implements reading parallel meshes in the Nemesis file format from Sandia Nation...
void write_element_data(const EquationSystems &es)
Write out element solution in parallel, without localizing the solution vector.
virtual void read(const std::string &base_filename) override
Implements reading the mesh from several different files.
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...
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
This class provides the ability to map between arbitrary, user-defined strings and several data types...
bool have_parameter(std::string_view) const
const T & get(std::string_view) const
A Point defines a location in LIBMESH_DIM dimensional Real space.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
This class implements reading and writing triangle meshes in the STL format.
virtual void read(const std::string &mesh_file) override
This method implements reading a mesh from a specified file.
Manages consistently variables, degrees of freedom, and coefficient vectors.
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.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
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.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
const std::string & variable_name(const unsigned int i) const
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
const DofMap & get_dof_map() const
unsigned int number() const
This class implements reading and writing meshes in the TetGen format.
virtual void read(const std::string &) override
This method implements reading a mesh from a specified file in TetGen format.
This class implements reading and writing meshes in the VTK format.
virtual void write(const std::string &) override
Output the mesh without solutions to a .pvtu file.
virtual void read(const std::string &) override
This method implements reading a mesh from a specified file in VTK format.
Communicator * TestCommWorld
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
ElemType
Defines an enum for geometric element types.
void libmesh_ignore(const Args &...)
LIBMESH_DEVICE_INLINE T libmesh_real(T a)
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
const dof_id_type n_nodes