libMesh
Loading...
Searching...
No Matches
mesh_input.C
Go to the documentation of this file.
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>
13
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>
22
23#include "test_comm.h"
24#include "libmesh_cppunit.h"
25
26#include <regex>
27
28using namespace libMesh;
29
30
32 const Parameters&,
33 const std::string&,
34 const std::string&)
35{
36 const Real & x = p(0);
37 const Real & y = p(1);
38
39 return 6*x + 60*y;
40}
41
42
44 const Parameters&,
45 const std::string&,
46 const std::string&)
47{
48 const Real & x = p(0);
49 const Real & y = p(1);
50
51 return sin(x) + cos(y);
52}
53
54constexpr int added_sides_nxyz[] = {2,2,2};
55
57 const Parameters & param,
58 const std::string &,
59 const std::string &)
60{
61 const Real & x = p(0);
62 const Real & y = p(1);
63 const Real & z = p(2);
64
65 short facedim = param.have_parameter<short>("face") ?
66 param.get<short>("face") : -1;
67
68 // What face are we on?
69 auto is_on_face = [facedim](Real r, short rdim) {
70 if (facedim == rdim)
71 return true;
72 if (facedim >= 0)
73 return false;
74 const Real numerator = r * added_sides_nxyz[rdim];
75 return (std::abs(numerator - std::round(numerator)) <
77 };
78
79
80
81 // x/y/z components of a div-free flux,
82 // curl([x^2yz, xy^2z, xyz])
83 if (is_on_face(x, 0))
84 {
85 libmesh_assert(!is_on_face(y, 1));
86 libmesh_assert(!is_on_face(z, 2));
87 return (x*z-x*y*y);
88 }
89 if (is_on_face(y, 1))
90 {
91 libmesh_assert(!is_on_face(z, 2));
92 return (x*x*y-y*z);
93 }
94
95 libmesh_assert(is_on_face(z, 2));
96 return (y*y*z-x*x*z);
97}
98
99
100class MeshInputTest : public CppUnit::TestCase {
101public:
103
104#if LIBMESH_DIM > 1
105#ifdef LIBMESH_HAVE_VTK
111#endif
112
113#ifdef LIBMESH_HAVE_EXODUS_API
122#if LIBMESH_DIM > 2
125#endif
126#ifndef LIBMESH_USE_COMPLEX_NUMBERS
129
130 // Eventually this will support complex numbers.
132#endif // !LIBMESH_USE_COMPLEX_NUMBERS
133
138 // CPPUNIT_TEST( testExodusDiscWriteAddedSidesEdgeDisc ); // need is_on_face fixes
139 // CPPUNIT_TEST( testExodusDiscWriteAddedSidesEdgeDisc ); // need is_on_face fixes
144 // CPPUNIT_TEST( testExodusWriteAddedSidesTriDisc ); // Need aligned faces
145 // CPPUNIT_TEST( testExodusDiscWriteAddedSidesTriDisc ); // Need aligned faces
150 // CPPUNIT_TEST( testExodusWriteAddedSidesQuadDisc ); // need is_on_face fixes
151 // CPPUNIT_TEST( testExodusDiscWriteAddedSidesQuadDisc ); // need is_on_face fixes
152 // CPPUNIT_TEST( testExodusWriteAddedSidesTetC0 ); // BROKEN!?! WHY!?!
153 // CPPUNIT_TEST( testExodusDiscWriteAddedSidesTetC0 ); // BROKEN!?! WHY!?!
154 // CPPUNIT_TEST( testExodusWriteAddedSidesTetDisc );
155 // CPPUNIT_TEST( testExodusDiscWriteAddedSidesTetDisc );
162
167
172#endif // LIBMESH_HAVE_EXODUS_API
173
174#if defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API)
177
182
185#ifndef LIBMESH_USE_COMPLEX_NUMBERS
188#endif // !LIBMESH_USE_COMPLEX_NUMBERS
189#endif // defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API)
190
191#ifdef LIBMESH_HAVE_GZSTREAM
201#endif // LIBMESH_HAVE_GZSTREAM
202#endif // LIBMESH_DIM > 1
203 //
204#if LIBMESH_DIM > 1
207#endif
208
209#if LIBMESH_DIM > 2
212
214
215#ifdef LIBMESH_HAVE_TETGEN
217#endif
218#endif
219
221
222private:
223
224public:
225 void setUp()
226 {}
227
228 void tearDown()
229 {}
230
231#ifdef LIBMESH_HAVE_VTK
233 {
234 LOG_UNIT_TEST;
235
236 // Come up with some crazy numbering. Make all the new ids higher
237 // than the existing ids so we don't have to worry about conflicts
238 // while renumbering.
239 dof_id_type start_id;
240
241 // first scope: write file
242 {
244 mesh.allow_renumbering(false);
245 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
246
247 start_id = mesh.max_elem_id();
248
249 // Use a separate container that won't invalidate iterators when
250 // we renumber
251 std::set<Elem *> elements {mesh.elements_begin(), mesh.elements_end()};
252 for (Elem * elem : elements)
253 {
254 const Point center = elem->vertex_average();
255 const int xn = int(center(0)*3);
256 const int yn = int(center(1)*3);
257 const dof_id_type new_id = start_id + yn*5 + xn;
258 mesh.renumber_elem(elem->id(), new_id);
259 }
260
261 // Explicit writer object here to be absolutely sure we get VTK
262 VTKIO vtk(mesh);
263 vtk.write("read_elem_ids_test.pvtu");
264 }
265
266 // Make sure that the writing is done before the reading starts.
267 TestCommWorld->barrier();
268
269 // second scope: read file
270 {
272 mesh.allow_renumbering(false);
273
274 mesh.read("read_elem_ids_test.pvtu");
276
277 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), dof_id_type(16));
278 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(9));
279
280 for (const auto & elem : mesh.element_ptr_range())
281 {
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);
287 }
288 }
289 }
290
292 {
293 LOG_UNIT_TEST;
294
295 // first scope: write file
296 {
298 mesh.allow_renumbering(false);
299 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
300
301 for (const auto & elem : mesh.element_ptr_range())
302 {
303 const Point center = elem->vertex_average();
304 const int xn = int(center(0)*3);
305 const int yn = int(center(1)*3);
306 const subdomain_id_type new_id = yn*4 + xn;
307 elem->subdomain_id() = new_id;
308 }
309
310 // Explicit writer object here to be absolutely sure we get VTK
311 VTKIO vtk(mesh);
312 vtk.write("read_sbd_ids_test.pvtu");
313 }
314
315 // Make sure that the writing is done before the reading starts.
316 TestCommWorld->barrier();
317
318 // second scope: read file
319 {
321 mesh.allow_renumbering(false);
322
323 mesh.read("read_sbd_ids_test.pvtu");
325
326 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), dof_id_type(16));
327 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(9));
328
329 for (const auto & elem : mesh.element_ptr_range())
330 {
331 const Point center = elem->vertex_average();
332 const int xn = int(center(0)*3);
333 const int yn = int(center(1)*3);
334 const subdomain_id_type expected_id = yn*4 + xn;
335 CPPUNIT_ASSERT_EQUAL(elem->subdomain_id(), expected_id);
336 }
337 }
338 }
339
340 // Shared checks for a mesh that should contain exactly the hexagonal
341 // prism polyhedron (12 vertices, 8 faces -- two hexagons and six
342 // quads) written to meshes/hex_prism_polyhedron.{pvtu,_0.vtu}.
344 {
345 CPPUNIT_ASSERT_EQUAL(dof_id_type(1), mesh.n_elem());
346
347 // The element may live on a single processor when the mesh is
348 // distributed, so guard the checks accordingly.
349 const Elem * elem = mesh.query_elem_ptr(0);
350 bool found_elem = elem;
351 mesh.comm().max(found_elem);
352 CPPUNIT_ASSERT(found_elem);
353
354 if (!elem)
355 return;
356
357 CPPUNIT_ASSERT_EQUAL(C0POLYHEDRON, elem->type());
358 CPPUNIT_ASSERT_EQUAL(12u, elem->n_vertices());
359 CPPUNIT_ASSERT_EQUAL(8u, elem->n_sides());
360
361 // The file has no libmesh_node_id array, so libMesh node ids match
362 // the VTK point ordering, i.e. the coordinates we wrote out.
363 LIBMESH_ASSERT_FP_EQUAL(6.0, elem->volume(), TOLERANCE);
364
365 // Collect the faces (as node-id sets) and compare against the faces
366 // that were written to the file, independent of any reordering the
367 // C0Polyhedron may do to its sides.
368 std::set<std::set<dof_id_type>> faces;
369 for (auto s : elem->side_index_range())
370 {
371 std::set<dof_id_type> face;
372 for (const auto n : elem->nodes_on_side(s))
373 face.insert(elem->node_id(n));
374 faces.insert(std::move(face));
375 }
376
377 const std::set<std::set<dof_id_type>> expected_faces =
378 { {0, 1, 2, 3, 4, 5},
379 {0, 1, 7, 6},
380 {1, 2, 8, 7},
381 {2, 3, 9, 8},
382 {3, 4, 10, 9},
383 {4, 5, 11, 10},
384 {5, 0, 6, 11},
385 {6, 7, 8, 9, 10, 11} };
386
387 CPPUNIT_ASSERT(faces == expected_faces);
388 }
389
391 {
392 LOG_UNIT_TEST;
393
394 // This .pvtu (+ piece) file contains a single VTK_POLYHEDRON cell.
395 // VTKIO::read() sniffs the file's actual root element to tell a
396 // parallel PUnstructuredGrid (.pvtu) descriptor from a plain serial
397 // UnstructuredGrid (.vtu) file and uses the matching reader class --
398 // see testVTKReadPolyhedraSerial below for the latter.
400 // Without this, prepare_for_use()'s default renumbering can reassign
401 // node ids (by local element-traversal order rather than preserving
402 // the ids we read), which would invalidate the "ids match VTK point
403 // ordering" assumption checkHexPrismPolyhedron() relies on.
404 mesh.allow_renumbering(false);
405 mesh.read("meshes/hex_prism_polyhedron.pvtu");
407
409 }
410
411 // The same polyhedron, read directly from the underlying serial
412 // UnstructuredGrid piece file rather than its .pvtu descriptor. This
413 // is a perfectly valid, common thing to hand a mesh reader -- many
414 // external tools write only this form, with no parallel wrapper -- but
415 // VTKIO::read() briefly lost the ability to read it at all: a Jan 2024
416 // change to add .pvtu support replaced the serial reader class instead
417 // of adding the parallel one alongside it, silently regressing plain
418 // .vtu files to fail (which is what caused this CI failure in the
419 // first place). This is the regression test for that.
421 {
422 LOG_UNIT_TEST;
423
425 mesh.allow_renumbering(false);
426 mesh.read("meshes/hex_prism_polyhedron_0.vtu");
428
430 }
431
432 // A file that isn't a VTK XML file at all (wrong format entirely, or a
433 // corrupted/truncated download) should be rejected clearly rather than
434 // being handed to vtkXMLFileReadTester/the VTK XML readers and failing
435 // in some less legible way. We reuse an existing, unrelated mesh
436 // fixture here rather than adding a new one; any non-VTK-XML file
437 // demonstrates this code path.
438 //
439 // We construct VTKIO directly here rather than going through
440 // mesh.read(), which would dispatch via NameBasedIO's rank-0-reads/
441 // then-broadcast pattern: throwing out of that on rank 0 before the
442 // broadcast would leave every other rank blocked on a broadcast that
443 // never arrives. Every rank hits this same, rank-independent error
444 // when calling VTKIO::read() directly, so there's no such hazard here.
446 {
447 LOG_UNIT_TEST;
448
449#ifdef LIBMESH_ENABLE_EXCEPTIONS
451 VTKIO vtk(mesh);
452 CPPUNIT_ASSERT_THROW_MESSAGE
453 ("Non-VTK-XML file not detected",
454 vtk.read("meshes/circle.msh"),
456#endif
457 }
458#endif // LIBMESH_HAVE_VTK
459
460
461#ifdef LIBMESH_HAVE_EXODUS_API
462
464 bool set_unique_ids,
465 const std::vector<unique_id_type> & expected_unique_ids)
466 {
467 // This test requires that libmesh is compiled with unique_ids enabled
468#ifdef LIBMESH_ENABLE_UNIQUE_ID
469 {
471 ExodusII_IO exii(mesh);
472
473 // Set Node/Elem unique ids based on the node/elem_num_map
474 exii.set_unique_ids_from_maps(set_unique_ids);
475
476 // Read the mesh
477 exii.read("meshes/nontrivial_node_num_map.exo");
478
479 // Verify the results.
480 for (auto i : index_range(expected_unique_ids))
481 {
482 // Debugging:
483 // libMesh::out << "unique_id for node " << i
484 // << " = " << mesh.node_ptr(i)->unique_id()
485 // << std::endl;
486
487 CPPUNIT_ASSERT_EQUAL(mesh.node_ptr(i)->unique_id(), expected_unique_ids[i]);
488 }
489 }
490#else
491 // Prevent compiler warnings about unused variables when
492 // unique_ids are not enabled.
493 libmesh_ignore(set_unique_ids, expected_unique_ids);
494#endif // LIBMESH_ENABLE_UNIQUE_ID
495 } // end testExodusSetNodeUniqueIdsFromMaps_implementation()
496
497
498
500 {
501 LOG_UNIT_TEST;
502
503 // node_num_map = 1, 3, 9, 8, 2, 5, 7, 6, 4
504 // The input is a (zero-based) version of the node_num_map as it
505 // exists in the file.
507 /*set_unique_ids=*/true,
508 /*expected_unique_ids=*/{0, 2, 8, 7, 1, 4, 6, 5, 3});
509
510 // The input is the (zero-based) _position_ of the (one-based) id
511 // "i" in the node_num_map, as it exists in the file. For example,
512 // zero-based Node id 3 corresponds to one-based Node id 4, which
513 // appears in (zero-based) position 8 in the node_num_map, hence:
514 // 3 -> 8, etc.
516 /*set_unique_ids=*/false,
517 /*expected_unique_ids=*/{0, 4, 1, 8, 5, 7, 6, 3, 2});
518 }
519
521 bool set_unique_ids,
522 const std::vector<unique_id_type> & expected_unique_ids)
523 {
524 // This test requires that libmesh is compiled with unique_ids enabled
525#ifdef LIBMESH_ENABLE_UNIQUE_ID
526 {
528 ExodusII_IO exii(mesh);
529
530 // Set Node/Elem unique ids based on the node/elem_num_map
531 exii.set_unique_ids_from_maps(set_unique_ids);
532
533 // Read the mesh
534 exii.read("meshes/nontrivial_elem_num_map.exo");
535
536 // Verify the results.
537 auto expected_it = expected_unique_ids.begin();
538 for (const auto & elem : mesh.element_ptr_range())
539 {
540 // Debugging:
541 // libMesh::out << "unique_id for Elem " << elem->id()
542 // << " = " << elem->unique_id()
543 // << std::endl;
544
545 CPPUNIT_ASSERT_EQUAL(elem->unique_id(), *expected_it++);
546 }
547 }
548#else
549 // Prevent compiler warnings about unused variables when
550 // unique_ids are not enabled.
551 libmesh_ignore(set_unique_ids, expected_unique_ids);
552#endif // LIBMESH_ENABLE_UNIQUE_ID
553 }
554
556 {
557 LOG_UNIT_TEST;
558
559 // The mesh used in this test has a non-trivial elem_num_map with
560 // a non-contiguous numbering that has a "gap" at the beginning
561 // and is also missing "16":
562 // elem_num_map = 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
563 // 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
564 // 45, 46 ;
565 {
566 // When we assign (zero-based) elem_num_map entries as unique_ids, the
567 // unique_ids are just a zero-based version of the entries above.
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 /*set_unique_ids=*/true, expected_unique_ids);
573 }
574
575 {
576 // When libmesh assigns unique_ids, all the Nodes (50) are
577 // numbered first, so the first Elem is assigned a unique_id of
578 // 50 and the rest are sequential from there.
579 std::vector<unique_id_type> expected_unique_ids(/*size=*/35);
580 std::iota(expected_unique_ids.begin(), expected_unique_ids.end(), /*start=*/50);
582 /*set_unique_ids=*/false, expected_unique_ids);
583 }
584 }
585
587 {
588 LOG_UNIT_TEST;
589
590 // first scope: write file
591 {
593 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
594 ExodusII_IO exii(mesh);
595 mesh.write("read_header_test.e");
596 }
597
598 // Make sure that the writing is done before the reading starts.
599 TestCommWorld->barrier();
600
601 // second scope: read header
602 // Note: The header information is read from file on processor 0
603 // and then broadcast to the other procs, so with this test we are
604 // checking both that the header information is read correctly and
605 // that it is correctly communicated to other procs.
606 {
608 ExodusII_IO exii(mesh);
609 ExodusHeaderInfo header_info = exii.read_header("read_header_test.e");
610
611 // Make sure the header information is as expected.
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);
615 CPPUNIT_ASSERT_EQUAL(header_info.num_elem_blk, 1);
616 CPPUNIT_ASSERT_EQUAL(header_info.num_node_sets, 4);
617 CPPUNIT_ASSERT_EQUAL(header_info.num_side_sets, 4);
618 CPPUNIT_ASSERT_EQUAL(header_info.num_edge_blk, 0);
619 CPPUNIT_ASSERT_EQUAL(header_info.num_edge, 0);
620 }
621 }
622
624 {
625 LOG_UNIT_TEST;
626
628 ExodusII_IO exii(mesh);
629
630 if (mesh.processor_id() == 0)
631 exii.read("meshes/mesh_with_low_order_edge_blocks.e");
632
635
636 // Check that we see the boundary ids we expect
638
639 // On a ReplicatedMesh, check that the number of edge boundary
640 // conditions is as expected. The real test is that we can read
641 // this file in at all. Prior to the changes in #3491, the Exodus
642 // reader threw an exception while trying to read this mesh.
643 if (mesh.is_serial())
644 {
645 // Mesh has 26 boundary ids total (including edge and side ids).
646 // ss_prop1 = 200, 201 ;
647 // ed_prop1 = 8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009, 8010,
648 // 8011, 9001, 9002, 9003, 9004, 9005, 9006, 9007, 9008, 9009, 9010,
649 // 9011, 9012 ;
650 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(26), bi.n_boundary_ids());
651
652 // We can binary_search() the build_edge_list() which is sorted
653 // in lexicographical order before it's returned.
654 auto edge_list = bi.build_edge_list();
655
656 // Search for some tuples we expect to be present
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)));
659
660 // And make sure we don't have entries we shouldn't have
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)));
663 }
664 }
665
667 {
668 LOG_UNIT_TEST;
669
671
672 // Block here so we trigger exii destructor early; I thought I
673 // might have had a bug in there at one point
674 {
675 ExodusII_IO exii(mesh);
676 // IGA Exodus meshes require ExodusII 8 or higher
677 if (exii.get_exodus_version() < 800)
678 return;
679
680 if (mesh.processor_id() == 0)
681 exii.read("meshes/Cube_With_Sidesets.e");
682
683 }
684
687
688 // 5^3 spline nodes + 7^3 Rational Bezier nodes
689 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(468));
690 // 5^3 spline elements + 3^3 Rational Bezier elements
691 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(152));
692
693 // Check that we see the boundary ids we expect
695
696 // On a ReplicatedMesh, we should see all 6 boundary ids on each processor
697 if (mesh.is_serial())
698 CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(6), bi.n_boundary_ids());
699
700 // On any mesh, we should see each id on *some* processor
701 {
702 const std::set<boundary_id_type> & bc_ids = bi.get_boundary_ids();
703 // CoreForm gave me a file with 1-based numbering! (faints)
704 for (boundary_id_type i = 1 ; i != 7; ++i)
705 {
706 bool has_bcid = bc_ids.count(i);
707 mesh.comm().max(has_bcid);
708 CPPUNIT_ASSERT(has_bcid);
709 }
710 }
711
712 // Indexed by bcid-1, because we count from 0, like God and
713 // Dijkstra intended!
714 std::vector<int> side_counts(6, 0);
715
716 // Map from our side numbers to the file's BCIDs
717 const boundary_id_type libmesh_side_to_bcid[] = {1, 4, 6, 3, 5, 2};
718
719 for (const auto & elem : mesh.active_local_element_ptr_range())
720 {
721 if (elem->type() == NODEELEM)
722 continue;
723
724 for (unsigned short side=0; side<elem->n_sides(); side++)
725 {
726 if (elem->neighbor_ptr(side))
727 CPPUNIT_ASSERT_EQUAL(bi.n_boundary_ids(elem, side), 0u);
728 else
729 {
730 CPPUNIT_ASSERT_EQUAL(bi.n_boundary_ids(elem, side), 1u);
731 std::vector<boundary_id_type> bids;
732 bi.boundary_ids(elem, side, bids);
733 side_counts[bids[0]-1]++;
734 CPPUNIT_ASSERT_EQUAL(libmesh_side_to_bcid[side], bids[0]);
735 }
736 }
737 }
738
739 for (auto bc_count : side_counts)
740 {
741 // We should have 3^2 sides with each id
742 mesh.comm().sum(bc_count);
743 CPPUNIT_ASSERT_EQUAL(bc_count, 9);
744 }
745
746 // Test a write when we're done reading; I was getting weirdness
747 // from NetCDF at this point in a Moose output test.
748 {
749 ExodusII_IO exii(mesh);
750
751 exii.write("Cube_With_Sidesets_out.e");
752 }
753 }
754
755
756 template <typename MeshType, typename IOType>
757 void testCopyNodalSolutionImpl (const std::string & filename)
758 {
759 {
760 MeshType mesh(*TestCommWorld);
761
763 System &sys = es.add_system<System> ("SimpleSystem");
764 sys.add_variable("n", FIRST, LAGRANGE);
765
767 3, 3,
768 0., 1., 0., 1.);
769
770 es.init();
772
773 IOType meshoutput(mesh);
774
775 meshoutput.write_equation_systems(filename, es);
776 }
777
778 {
779 MeshType mesh(*TestCommWorld);
780 mesh.allow_renumbering(false);
781 IOType meshinput(mesh);
782
783 // Avoid getting Nemesis solution values mixed up
784 if (meshinput.is_parallel_format())
785 {
787 }
788
790 System &sys = es.add_system<System> ("SimpleSystem");
791 sys.add_variable("testn", FIRST, LAGRANGE);
792
793 if (mesh.processor_id() == 0 || meshinput.is_parallel_format())
794 meshinput.read(filename);
795 if (!meshinput.is_parallel_format())
798
799 es.init();
800
801 // Read the solution e into variable teste.
802 //
803 // With complex numbers, we'll only bother reading the real
804 // part.
805#ifdef LIBMESH_USE_COMPLEX_NUMBERS
806 meshinput.copy_nodal_solution(sys, "testn", "r_n");
807#else
808 meshinput.copy_nodal_solution(sys, "testn", "n");
809#endif
810
811 // Exodus only handles double precision
812 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
813
814 for (Real x = 0; x < 1 + TOLERANCE; x += Real(1.L/3.L))
815 for (Real y = 0; y < 1 + TOLERANCE; y += Real(1.L/3.L))
816 {
817 Point p(x,y);
818 LIBMESH_ASSERT_NUMBERS_EQUAL
819 (sys.point_value(0,p), 6*x+60*y, exotol);
820 }
821 }
822 }
823
824
826 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,ExodusII_IO>("repl_with_nodal_soln.e"); }
827
829 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,ExodusII_IO>("dist_with_nodal_soln.e"); }
830
831#if defined(LIBMESH_HAVE_NEMESIS_API)
833 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<ReplicatedMesh,Nemesis_IO>("repl_with_nodal_soln.nem"); }
834
836 { LOG_UNIT_TEST; testCopyNodalSolutionImpl<DistributedMesh,Nemesis_IO>("dist_with_nodal_soln.nem"); }
837#endif
838
839
840 template <typename MeshType, typename IOType>
841 void testCopyElementSolutionImpl (const std::string & filename)
842 {
843 {
844 MeshType mesh(*TestCommWorld);
845
847 System &sys = es.add_system<System> ("SimpleSystem");
848 sys.add_variable("e", CONSTANT, MONOMIAL);
849 sys.add_variable("e_no_p", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
850 sys.add_variable("e_xyz", FEType(CONSTANT, XYZ));
851
853 3, 3,
854 0., 1., 0., 1.);
855
856 es.init();
858
859 IOType meshinput(mesh);
860
861 // Don't try to write element data as nodal data
862 std::set<std::string> sys_list;
863 meshinput.write_equation_systems(filename, es, &sys_list);
864
865 // Just write it as element data
866 meshinput.write_element_data(es);
867 }
868
869 {
870 MeshType mesh(*TestCommWorld);
871 mesh.allow_renumbering(false);
872 IOType meshinput(mesh);
873
874 // Avoid getting Nemesis solution values mixed up
875 if (meshinput.is_parallel_format())
876 {
878 }
879
881 System &sys = es.add_system<System> ("SimpleSystem");
882 sys.add_variable("teste", CONSTANT, MONOMIAL);
883 sys.add_variable("teste_no_p", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
884 sys.add_variable("teste_xyz", FEType(CONSTANT, XYZ));
885
886 if (mesh.processor_id() == 0 || meshinput.is_parallel_format())
887 meshinput.read(filename);
888 if (!meshinput.is_parallel_format())
891
892 es.init();
893
894 // Read the solution e into variable teste.
895 //
896 // With complex numbers, we'll only bother reading the real
897 // part.
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");
902#else
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");
906#endif
907
908 // Exodus only handles double precision
909 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
910
911 for (Real x = Real(1.L/6.L); x < 1; x += Real(1.L/3.L))
912 for (Real y = Real(1.L/6.L); y < 1; y += Real(1.L/3.L))
913 {
914 Point p(x,y);
915 LIBMESH_ASSERT_NUMBERS_EQUAL
916 (sys.point_value(0,p), 6*x+60*y, exotol);
917 LIBMESH_ASSERT_NUMBERS_EQUAL
918 (sys.point_value(1,p), 6*x+60*y, exotol);
919 LIBMESH_ASSERT_NUMBERS_EQUAL
920 (sys.point_value(2,p), 6*x+60*y, exotol);
921 }
922 }
923 }
924
925
927 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,ExodusII_IO>("repl_with_elem_soln.e"); }
928
930 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,ExodusII_IO>("dist_with_elem_soln.e"); }
931
932
933 // Tests that a FIRST order discontinuous MONOMIAL variable can be
934 // written as elemental Exodus data (via the opt-in
935 // write_discontinuous_elemental_data()) and read back. Since
936 // six_x_plus_sixty_y is linear and the mesh elements are uniform
937 // squares, the exact quadrature average over each element equals
938 // the function's value at that element's centroid, so we can reuse
939 // the centroid-evaluation check from testCopyElementSolutionImpl
940 // without needing to hand-compute the expected quadrature average.
942 {
943 LOG_UNIT_TEST;
944
945 const std::string filename("repl_with_high_order_elem_soln.e");
946
947 {
949
951 System &sys = es.add_system<System> ("SimpleSystem");
952 sys.add_variable("e", FIRST, MONOMIAL);
953
955 3, 3,
956 0., 1., 0., 1.);
957
958 es.init();
960
961 ExodusII_IO meshinput(mesh);
963
964 std::set<std::string> sys_list;
965 meshinput.write_equation_systems(filename, es, &sys_list);
966 meshinput.write_element_data(es);
967 }
968
969 {
971 mesh.allow_renumbering(false);
972 ExodusII_IO meshinput(mesh);
973
975 System &sys = es.add_system<System> ("SimpleSystem");
976 sys.add_variable("teste", CONSTANT, MONOMIAL);
977
978 if (mesh.processor_id() == 0)
979 meshinput.read(filename);
982
983 es.init();
984
985#ifdef LIBMESH_USE_COMPLEX_NUMBERS
986 meshinput.copy_elemental_solution(sys, "teste", "r_e");
987#else
988 meshinput.copy_elemental_solution(sys, "teste", "e");
989#endif
990
991 // Exodus only handles double precision
992 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
993
994 for (Real x = Real(1.L/6.L); x < 1; x += Real(1.L/3.L))
995 for (Real y = Real(1.L/6.L); y < 1; y += Real(1.L/3.L))
996 {
997 Point p(x,y);
998 LIBMESH_ASSERT_NUMBERS_EQUAL
999 (sys.point_value(0,p), 6*x+60*y, exotol);
1000 }
1001 }
1002 }
1003
1004
1005#if defined(LIBMESH_HAVE_NEMESIS_API)
1007 { LOG_UNIT_TEST; testCopyElementSolutionImpl<ReplicatedMesh,Nemesis_IO>("repl_with_elem_soln.nem"); }
1008
1010 { LOG_UNIT_TEST; testCopyElementSolutionImpl<DistributedMesh,Nemesis_IO>("dist_with_elem_soln.nem"); }
1011
1012
1013 // This tests that a single-element mesh solution makes it through all of the API to write out a
1014 // set of Nemesis files. When this executes in parallel, there are ((number of processors) - 1)
1015 // subdomains with zero elements and therefore nothing to write, but the API should handle this.
1016 template <typename MeshType, typename IOType>
1017 void testSingleElementImpl(const std::string & filename)
1018 {
1019 {
1020 // Generate a single 1x1 square element mesh
1021 MeshType mesh(*TestCommWorld);
1023
1025 auto & sys = es.add_system<System>("SimpleSystem");
1026 sys.add_variable("e", CONSTANT, MONOMIAL);
1027
1028 // Set an arbitrary solution for the single element DOF
1029 es.init();
1030 sys.project_solution(six_x_plus_sixty_y, nullptr, es.parameters);
1031
1032 // Write the solution to Nemesis file(s) - only proc 0 should have anything to write!
1033 Nemesis_IO nem_io(mesh);
1034 std::set<std::string> sys_list;
1035 nem_io.write_equation_systems(filename, es, &sys_list);
1036 nem_io.write_element_data(es);
1037 }
1038
1039 // If we can read and copy the correct element value back into the mesh, we know the Nemesis
1040 // file(s) were written properly.
1041 {
1042 MeshType mesh(*TestCommWorld);
1043 mesh.allow_renumbering(false);
1045 auto & sys = es.add_system<System>("SimpleSystem");
1046 sys.add_variable("teste", CONSTANT, MONOMIAL);
1047
1048 Nemesis_IO nem_io(mesh);
1049 if (mesh.processor_id() == 0 || nem_io.is_parallel_format())
1050 nem_io.read(filename);
1051
1053 es.init();
1054
1055#ifdef LIBMESH_USE_COMPLEX_NUMBERS
1056 nem_io.copy_elemental_solution(sys, "teste", "r_e");
1057#else
1058 nem_io.copy_elemental_solution(sys, "teste", "e");
1059#endif
1060
1061 // The result should be '\frac{6 + 60}{2} = 33' at all points in the element domain
1062 CPPUNIT_ASSERT_EQUAL(int(sys.solution->size()), 1);
1063 CPPUNIT_ASSERT_EQUAL(libmesh_real(sys.point_value(0, Point(0.5, 0.5))), Real(33));
1064 }
1065 }
1066
1067
1069 { LOG_UNIT_TEST; testSingleElementImpl<ReplicatedMesh,Nemesis_IO>("repl_with_single_elem.nem"); }
1070
1072 { LOG_UNIT_TEST; testSingleElementImpl<DistributedMesh,Nemesis_IO>("dist_with_single_elem.nem"); }
1073#endif //defined(LIBMESH_HAVE_NEMESIS_API)
1074
1075
1076#ifndef LIBMESH_USE_COMPLEX_NUMBERS
1077 // So this tester runs through pretty much the same process as 'testCopyElementSolutionImpl()'
1078 // except for a CONSTANT MONOMIAL_VEC variable. It mainly serves as a test for writing elemental
1079 // vector variables to elements in ExodusII files, and is not actually a test for reading and
1080 // copying an elemental solution.
1081 template <typename MeshType, typename IOType>
1082 void testCopyElementVectorImpl(const std::string & filename)
1083 {
1084 {
1085 MeshType mesh(*TestCommWorld);
1086
1088
1089 // We need a mesh.spatial_dimension() *before* adding a
1090 // vector-valued variable, so add_variable() can figure out how
1091 // many components it needs.
1093 3, 3,
1094 0., 1., 0., 1.);
1095
1096 System & sys = es.add_system<System> ("SimpleSystem");
1097 auto e_var = sys.add_variable("e", CONSTANT, MONOMIAL_VEC);
1098 auto e_no_p_var = sys.add_variable("e_no_p",
1100
1101 es.init();
1102
1103 // Here, we're going to manually set up the solution because the 'project_solution()' and
1104 // 'project_vector()' methods don't work so well with CONSTANT MONOMIAL_VEC variables. They
1105 // each lead to an error downstream asserting positive-definiteness when Cholesky decomposing.
1106 // Interestingly, the error is only invoked for CONSTANT MONOMIAL_VEC, and not, e.g.,
1107 // CONSTANT MONOMIAL nor FIRST LAGRANGE_VEC.
1108 //
1109 // Anyways, the important thing here is that we test the ExodusII and Nemesis writers, how
1110 // the solution is set is hardly important, and we're pretty much following the same
1111 // philosophy as the 'test2DProjectVectorFE()' unit tester in 'systems_test.C'
1112 Parameters params;
1113 for (const auto & elem : mesh.active_local_element_ptr_range())
1114 {
1115 const Point & p = elem->vertex_average();
1116
1117 // Set the x-component with the value from 'six_x_plus_sixty_y()' and the y-component
1118 // with that from 'sin_x_plus_cos_y()' at the element centroid (vertex average)
1119 sys.current_local_solution->set(
1120 elem->dof_number(sys.number(), e_var, 0), six_x_plus_sixty_y(p, params, "", ""));
1121 sys.current_local_solution->set(
1122 elem->dof_number(sys.number(), e_var, 1), sin_x_plus_cos_y(p, params, "", ""));
1123 sys.current_local_solution->set(
1124 elem->dof_number(sys.number(), e_no_p_var, 0), six_x_plus_sixty_y(p, params, "", ""));
1125 sys.current_local_solution->set(
1126 elem->dof_number(sys.number(), e_no_p_var, 1), sin_x_plus_cos_y(p, params, "", ""));
1127 }
1128
1129 // After setting values, we need to assemble
1130 sys.current_local_solution->close();
1131
1132 IOType meshinput(mesh);
1133
1134 // Don't try to write element data as nodal data
1135 std::set<std::string> sys_list;
1136 meshinput.write_equation_systems(filename, es, &sys_list);
1137
1138 // Just write it as element data
1139 meshinput.write_element_data(es);
1140 }
1141
1142 {
1143 MeshType mesh(*TestCommWorld);
1144 mesh.allow_renumbering(false);
1145 IOType meshinput(mesh);
1146
1147 // Avoid getting Nemesis solution values mixed up
1148 if (meshinput.is_parallel_format())
1149 {
1151 }
1152
1154 System & sys = es.add_system<System> ("SimpleSystem");
1155
1156 // We have to read the CONSTANT MONOMIAL_VEC var "e" into separate CONSTANT MONOMIAL vars
1157 // "e_x" and "e_y" because 'copy_elemental_solution()' currently doesn't support vectors.
1158 // Again, this isn't a test for reading/copying an elemental vector solution, only writing.
1159 sys.add_variable("teste_x", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1160 sys.add_variable("teste_y", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1161 sys.add_variable("teste_no_p_x", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1162 sys.add_variable("teste_no_p_y", FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1163
1164 if (mesh.processor_id() == 0 || meshinput.is_parallel_format())
1165 meshinput.read(filename);
1166 if (!meshinput.is_parallel_format())
1169
1170 es.init();
1171
1172 // Read the solution e_x and e_y into variable teste_x and teste_y, respectively.
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");
1177
1178 // Exodus only handles double precision
1179 Real exotol = std::max(TOLERANCE*TOLERANCE, Real(1e-12));
1180
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))
1183 {
1184 Point p(x,y);
1185 LIBMESH_ASSERT_NUMBERS_EQUAL
1186 (sys.point_value(0,p), 6*x+60*y, exotol);
1187 LIBMESH_ASSERT_NUMBERS_EQUAL
1188 (sys.point_value(1,p), sin(x)+cos(y), exotol);
1189 LIBMESH_ASSERT_NUMBERS_EQUAL
1190 (sys.point_value(2,p), 6*x+60*y, exotol);
1191 LIBMESH_ASSERT_NUMBERS_EQUAL
1192 (sys.point_value(3,p), sin(x)+cos(y), exotol);
1193 }
1194 }
1195 }
1196
1198 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh, ExodusII_IO>("repl_with_elem_vec.e"); }
1199
1201 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,ExodusII_IO>("dist_with_elem_vec.e"); }
1202
1203#if defined(LIBMESH_HAVE_NEMESIS_API)
1205 { LOG_UNIT_TEST; testCopyElementVectorImpl<ReplicatedMesh,Nemesis_IO>("repl_with_elem_vec.nem"); }
1206
1208 { LOG_UNIT_TEST; testCopyElementVectorImpl<DistributedMesh,Nemesis_IO>("dist_with_elem_vec.nem"); }
1209#endif
1210
1211
1213 {
1214 LOG_UNIT_TEST;
1215
1216 const Real scalar_value = 42.;
1217 const Real xyz_value = 84.;
1218 const std::vector<Real> vector_values = {10., 20., 30.};
1219
1220 // first scope: write file
1221 {
1223
1225 System & sys = es.add_system<System> ("SimpleSystem");
1226 sys.add_variable("u", FIRST, L2_LAGRANGE);
1227 const auto c_var =
1229 const auto xyz_var =
1230 sys.add_variable("xyz", FEType(CONSTANT, XYZ));
1231 const auto vec_var =
1233
1235 (mesh, 2, 2, 2, 0., 1., 0., 1., 0., 1., HEX8);
1236
1237 es.init();
1238
1239 // Set solution u^e_i = i, for the ith vertex of a given element e.
1240 const DofMap & dof_map = sys.get_dof_map();
1241 std::vector<dof_id_type> dof_indices;
1242 for (const auto & elem : mesh.element_ptr_range())
1243 {
1244 dof_map.dof_indices(elem, dof_indices, /*var_id=*/0);
1245 for (unsigned int i=0; i<dof_indices.size(); ++i)
1246 sys.solution->set(dof_indices[i], i);
1247
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);
1250 for (auto comp : index_range(vector_values))
1251 sys.solution->set(elem->dof_number(sys.number(),
1252 vec_var,
1253 cast_int<unsigned int>(comp)),
1254 vector_values[comp]);
1255 }
1256 sys.solution->close();
1257
1258 // Now write to file.
1259 ExodusII_IO exii(mesh);
1260
1261 // Don't try to write element data as averaged nodal data.
1262 std::set<std::string> sys_list;
1263 exii.write_equation_systems("elemental_from_nodal.e", es, &sys_list);
1264
1265 // Write one elemental data field per vertex value.
1266 sys_list = {"SimpleSystem"};
1267
1269 (es, &sys_list, /*var_suffix=*/"_elem_corner_");
1270 } // end first scope
1271
1272 // second scope: read values back in, verify they are correct.
1273 {
1274 std::vector<std::string> file_var_names =
1275 {"u_elem_corner_0",
1276 "u_elem_corner_1",
1277 "u_elem_corner_2",
1278 "u_elem_corner_3",
1279 "c",
1280 "xyz",
1281 "vec_x",
1282 "vec_y",
1283 "vec_z"};
1284 std::vector<Real> expected_values =
1285 {0., 1., 2., 3.,
1286 scalar_value, xyz_value, vector_values[0], vector_values[1], vector_values[2]};
1287
1288 // copy_elemental_solution currently requires ReplicatedMesh
1290 mesh.allow_renumbering(false);
1291
1293 System & sys = es.add_system<System> ("SimpleSystem");
1294 for (auto i : index_range(file_var_names))
1295 sys.add_variable(file_var_names[i], FEType(CONSTANT, MONOMIAL).set_p_refinement(false));
1296
1297 ExodusII_IO exii(mesh);
1298
1299 if (mesh.processor_id() == 0)
1300 exii.read("elemental_from_nodal.e");
1303
1304 es.init();
1305
1306 for (auto i : index_range(file_var_names))
1308 (sys, sys.variable_name(i), file_var_names[i]);
1309
1310 // Check that the values we read back in are as expected.
1311 for (const auto & elem : mesh.active_element_ptr_range())
1312 for (auto i : index_range(file_var_names))
1313 {
1314 Real read_val = sys.point_value(i, elem->vertex_average());
1315 LIBMESH_ASSERT_FP_EQUAL
1316 (expected_values[i], read_val, TOLERANCE*TOLERANCE);
1317 }
1318 } // end second scope
1319 } // end testExodusWriteElementDataFromDiscontinuousNodalData
1320
1321#endif // !LIBMESH_USE_COMPLEX_NUMBERS
1322
1323
1325 (Number (*exact_sol)(const Point &, const Parameters &, const
1326 std::string &, const std::string &),
1327 const ElemType elem_type,
1328 const Order order,
1329 const bool write_discontinuous = false,
1330 const std::vector<FEType> earlier_vars = {},
1331 const std::vector<FEType> later_vars = {})
1332 {
1333 constexpr unsigned int nx = added_sides_nxyz[0],
1334 ny = added_sides_nxyz[1],
1335 nz = added_sides_nxyz[2];
1336
1337 const unsigned int dim = Elem::type_to_dim_map[elem_type];
1338 const bool is_tensor = (Elem::build(elem_type)->n_sides() == dim * 2);
1339
1340 // Figure out how many fake and true elements to expect
1341 dof_id_type n_fake_elem = 0;
1342 dof_id_type n_true_elem = 0;
1343
1344 dof_id_type n_fake_nodes = 0;
1345 dof_id_type n_true_nodes = 0;
1346
1347 const std::string filename =
1348 "side_discontinuous_"+Utility::enum_to_string<ElemType>(elem_type)+(write_discontinuous?"_disc":"")+".e";
1349
1350 // first scope: write file
1351 {
1352 Mesh mesh(*TestCommWorld);
1353
1355 System & sys = es.add_system<System> ("SimpleSystem");
1356 int varnum = 1;
1357 for (auto vartype : earlier_vars)
1358 sys.add_variable("earlier_"+std::to_string(varnum++), vartype);
1359
1360 sys.add_variable("u", order, SIDE_HIERARCHIC);
1361
1362 varnum = 1;
1363 for (auto vartype : later_vars)
1364 sys.add_variable("later_"+std::to_string(varnum++), vartype);
1365
1366 if (dim == 3)
1368 (mesh, nx, ny, nz, 0., 1., 0., 1., 0., 1., elem_type);
1369 else if (dim == 2)
1371 (mesh, nx, ny, 0., 1., 0., 1., elem_type);
1372 else
1374 (mesh, nx, 0., 1., elem_type);
1375
1376 n_true_elem = mesh.n_elem();
1377 n_true_nodes = mesh.n_nodes();
1378 CPPUNIT_ASSERT_LESS(n_true_nodes, n_true_elem); // Ne < Nn
1379
1380 const unsigned int our_ny = dim>1 ? ny : 1;
1381 const unsigned int our_nz = dim>2 ? nz : 1;
1382
1383 dof_id_type min_n_elem = nx * our_ny * our_nz;
1384 CPPUNIT_ASSERT_LESSEQUAL(n_true_elem, min_n_elem); // "backwards" API...
1385
1386 for (const auto & elem : mesh.active_local_element_ptr_range())
1387 {
1388 for (auto s : make_range(elem->n_sides()))
1389 if (!elem->neighbor_ptr(s) || elem->neighbor_ptr(s)->id() < elem->id())
1390 {
1391 ++n_fake_elem;
1392 auto side = elem->build_side_ptr(s);
1393 n_fake_nodes += side->n_nodes();
1394 }
1395 }
1396 mesh.comm().sum(n_fake_elem);
1397 mesh.comm().sum(n_fake_nodes);
1398
1399 const dof_id_type expected_fakes = [elem_type]() {
1400 switch (elem_type)
1401 {
1402 case EDGE3:
1403 return nx+1;
1404 case TRI6:
1405 return 3*nx*ny + nx + ny;
1406 case QUAD8:
1407 case QUAD9:
1408 return 2*nx*ny + nx + ny;
1409 case TET14:
1410 return 48*nx*ny*nz + 4*(nx*ny+nx*nz+ny*nz);
1411 case HEX27:
1412 return 3*nx*ny*nz + nx*ny + nx*nz + ny*nz;
1413 default:
1414 libmesh_error();
1415 }
1416 } (); // Invoke anonymous lambda
1417
1418 CPPUNIT_ASSERT_EQUAL(n_fake_elem, expected_fakes); // "backwards" API...
1419
1420 es.init();
1421 sys.project_solution(exact_sol, nullptr,
1422 es.parameters);
1423
1424 // Set solution u^e_i = i, for the ith vertex of a given element e.
1425
1426 // Now write to file.
1427 ExodusII_IO exii(mesh);
1428 exii.write_added_sides(true);
1429
1430 if (write_discontinuous)
1431 exii.write_discontinuous_equation_systems(filename, es);
1432 else
1433 exii.write_equation_systems(filename, es);
1434 } // end first scope
1435
1436 // second scope: read file, verify extra elements exist
1437 {
1438 Mesh mesh(*TestCommWorld);
1439 mesh.allow_renumbering(false);
1440 ExodusII_IO exii(mesh);
1441
1442 if (mesh.processor_id() == 0)
1443 exii.read(filename);
1446
1447 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), n_true_elem + n_fake_elem);
1448 if (write_discontinuous)
1449 {
1450 const dof_id_type nodes_per_elem = Elem::build(elem_type)->n_nodes();
1451 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(),
1452 n_true_elem*nodes_per_elem + n_fake_nodes);
1453 }
1454 else
1455 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), n_true_nodes + n_fake_nodes);
1456
1458 System & sys = es.add_system<System> ("SimpleSystem");
1459 // Read back into a LAGRANGE variable for testing; we still
1460 // can't use Exodus for a proper restart.
1461 sys.add_variable("ul", SECOND);
1462 es.init();
1463
1464 const DofMap & dof_map = sys.get_dof_map();
1465
1466#ifdef LIBMESH_USE_COMPLEX_NUMBERS
1467 exii.copy_nodal_solution(sys, "ul", "r_u");
1468#else
1469 exii.copy_nodal_solution(sys, "ul", "u");
1470#endif
1471
1472 dof_id_type n_side_nodes = 0;
1473 const std::string nullstr;
1474 const std::string facestr = "face";
1475
1476 // Debugging this in parallel is tricky. Let's make sure that
1477 // if we have a failure on one rank we see it on all the others
1478 // and we can go on to other tests.
1479#ifdef LIBMESH_ENABLE_EXCEPTIONS
1480 bool threw_exception = false;
1481 try
1482#endif // LIBMESH_ENABLE_EXCEPTIONS
1483 {
1484 for (const auto & elem : mesh.active_local_element_ptr_range())
1485 {
1486 // Just look at side elements, not interiors
1487 if (elem->dim() == dim)
1488 continue;
1489
1490 std::vector<dof_id_type> dof_indices;
1491 dof_map.dof_indices(elem, dof_indices, 0);
1492
1493 // Find what face direction we're looking at, to
1494 // disambiguate when testing against a discontinuous
1495 // function, since we're evaluating on nodes that overlap
1496 // multiple faces
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)
1502 return Point
1503 (elem->point(1)(1)-elem->point(0)(1),
1504 elem->point(0)(0)-elem->point(1)(0));
1505 else
1506 return Point(1);
1507 } (); // Invoke anonymous lambda
1508
1509 short faceval = -1;
1510 if (is_tensor)
1511 {
1512 if (std::abs(normal(0)) > TOLERANCE)
1513 {
1514 faceval = 0;
1515 libmesh_assert_less(std::abs(normal(1)), TOLERANCE);
1516 libmesh_assert_less(std::abs(normal(2)), TOLERANCE);
1517 }
1518 else if (std::abs(normal(1)) > TOLERANCE)
1519 {
1520 faceval = 1;
1521 libmesh_assert_less(std::abs(normal(2)), TOLERANCE);
1522 }
1523 else
1524 {
1525 faceval = 2;
1526 libmesh_assert_greater(std::abs(normal(2)), TOLERANCE);
1527 }
1528 libmesh_assert_greater_equal(faceval, 0);
1529 es.parameters.set<short>(facestr) = faceval;
1530 }
1531
1532 for (auto i : index_range(dof_indices))
1533 {
1534 const Point node_pt = elem->point(i);
1535 const Real nodal_coef =
1536 libmesh_real((*sys.current_local_solution)(dof_indices[i]));
1537 const Real exact_val =
1538 libmesh_real(exact_sol
1539 (node_pt, es.parameters, nullstr,
1540 nullstr));
1541 LIBMESH_ASSERT_FP_EQUAL
1542 (nodal_coef, exact_val,
1543 std::max(Real(2),nodal_coef+exact_val)*
1544 TOLERANCE*std::sqrt(TOLERANCE));
1545 ++n_side_nodes;
1546 }
1547 }
1548 }
1549#ifdef LIBMESH_ENABLE_EXCEPTIONS
1550 catch (...)
1551 {
1552 threw_exception = true;
1553 TestCommWorld->max(threw_exception);
1554 throw;
1555 }
1556 if (!threw_exception)
1557 TestCommWorld->max(threw_exception);
1558 CPPUNIT_ASSERT(!threw_exception);
1559#endif // LIBMESH_ENABLE_EXCEPTIONS
1560
1561 TestCommWorld->sum(n_side_nodes);
1562 CPPUNIT_ASSERT_EQUAL(n_side_nodes, n_fake_nodes);
1563 } // end second scope
1564 } // end testExodusWriteAddedSides
1565
1571
1577
1583
1589
1594
1599
1605
1611
1617
1623
1628
1633
1639
1645
1651
1657
1662
1667
1673
1679
1684
1689
1695
1701
1707
1713
1718
1723
1724#endif // LIBMESH_HAVE_EXODUS_API
1725
1726
1727#if defined(LIBMESH_HAVE_EXODUS_API) && defined(LIBMESH_HAVE_NEMESIS_API)
1728 template <typename MeshType>
1730 {
1731 // first scope: write file
1732 {
1733 MeshType mesh(*TestCommWorld);
1734 MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.);
1735 mesh.write("test_nemesis_read.nem");
1736 }
1737
1738 // Make sure that the writing is done before the reading starts.
1739 TestCommWorld->barrier();
1740
1741 // second scope: read file
1742 {
1743 MeshType mesh(*TestCommWorld);
1744 Nemesis_IO nem(mesh);
1745
1746 nem.read("test_nemesis_read.nem");
1748 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(9));
1749 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(16));
1750 }
1751 }
1752
1754 { LOG_UNIT_TEST; testNemesisReadImpl<ReplicatedMesh>(); }
1755
1757 { LOG_UNIT_TEST; testNemesisReadImpl<DistributedMesh>(); }
1758#endif
1759
1760
1762 {
1763 auto locator = mesh.sub_point_locator();
1764
1765 for (auto & elem : mesh.element_ptr_range())
1766 {
1767 Point master_pt = {}; // center, for tensor product elements
1768
1769 // But perturb it to try and trigger any mapping weirdness
1770 if (elem->dim() > 0)
1771 master_pt(0) = 0.25;
1772
1773 if (elem->dim() > 1)
1774 master_pt(1) = -0.25;
1775
1776 if (elem->dim() > 2)
1777 master_pt(2) = 0.75;
1778
1779 Point physical_pt = FEMap::map(elem->dim(), elem, master_pt);
1780
1781 Point inverse_pt = FEMap::inverse_map(elem->dim(), elem,
1782 physical_pt);
1783
1784 CPPUNIT_ASSERT((inverse_pt-master_pt).norm() < TOLERANCE);
1785
1786 CPPUNIT_ASSERT(elem->contains_point(physical_pt));
1787
1788 // We only want to find elements in the same block
1789 std::set<subdomain_id_type> my_subdomain { elem->subdomain_id() };
1790
1791 // We can *still* have overlapping NodeElem from a slit mesh
1792 // input file; better check them all
1793 std::set<const Elem * > located_elems;
1794 (*locator)(physical_pt, located_elems, &my_subdomain);
1795
1796 CPPUNIT_ASSERT(located_elems.count(elem));
1797 }
1798 }
1799
1800
1801
1803 {
1804 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
1806
1807 unsigned char weight_index = mesh.default_mapping_data();
1808
1809 bool found_the_quad = false;
1810
1811 for (auto & elem : mesh.element_ptr_range())
1812 {
1813 if (elem->type() == NODEELEM)
1814 continue;
1815
1816 CPPUNIT_ASSERT_EQUAL(elem->type(), QUAD9);
1817 found_the_quad = true;
1818
1819 for (unsigned int n=0; n != 9; ++n)
1820 CPPUNIT_ASSERT_EQUAL
1821 (elem->node_ref(n).get_extra_datum<Real>(weight_index),
1822 Real(0.75));
1823
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());
1833#if LIBMESH_DIM > 2
1834 for (unsigned int v=0; v != 4; ++v)
1835 CPPUNIT_ASSERT_EQUAL(elem->point(v)(2), Real(0));
1836#endif
1837 }
1838
1839 TestCommWorld->max(found_the_quad);
1840 CPPUNIT_ASSERT(found_the_quad);
1841
1843 }
1844
1845
1846 void testAbaqusRead (const std::string & fname,
1847 dof_id_type n_elem,
1849 {
1851
1852 AbaqusIO abaqus(mesh);
1853
1854 if (mesh.processor_id() == 0)
1855 abaqus.read(fname);
1857
1859
1860 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), n_elem);
1861 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), n_nodes);
1862 }
1863
1864
1866 {
1867 LOG_UNIT_TEST;
1868 testAbaqusRead("meshes/tensile_sample_test1.inp.gz", 728, 1166);
1869 }
1870
1871
1873 {
1874 LOG_UNIT_TEST;
1875 testAbaqusRead("meshes/poly_sample_test2.inp.gz", 1280, 1625);
1876 }
1877
1878
1880 {
1881 LOG_UNIT_TEST;
1882
1884
1885 DynaIO dyna(mesh);
1886
1887 if (mesh.processor_id() == 0)
1888 dyna.read("meshes/1_quad.bxt.gz");
1890
1892
1893 // We have 1 QUAD9 finite element, attached via a trivial map to 9
1894 // spline Node+NodeElem objects
1895 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(10));
1896 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(18));
1897
1899 }
1900
1902 {
1903 LOG_UNIT_TEST;
1904
1906
1907 GmshIO gmsh_io(mesh);
1908
1909#ifdef LIBMESH_ENABLE_EXCEPTIONS
1910 std::string what = "";
1911 try
1912 {
1913 if (mesh.processor_id() == 0)
1914 gmsh_io.read("meshes/block.msh");
1915 }
1916 catch (libMesh::LogicError & e)
1917 {
1918 what = e.what();
1919 }
1920
1921 TestCommWorld->broadcast(what);
1922 std::regex msg_regex("outside entity physical bounding box");
1923 CPPUNIT_ASSERT(std::regex_search(what, msg_regex));
1924#endif
1925 }
1926
1928 {
1929 LOG_UNIT_TEST;
1930
1932
1933 GmshIO gmsh_io(mesh);
1934
1935 if (mesh.processor_id() == 0)
1936 gmsh_io.read("meshes/circle.msh");
1938
1939 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(14));
1940 }
1941
1943 {
1944 LOG_UNIT_TEST;
1945
1947
1948 GmshIO gmsh_io(mesh);
1949
1950 if (mesh.processor_id() == 0)
1951 gmsh_io.read("meshes/bcid_overlap.msh");
1953
1954 CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().get_sideset_name_map().size(),
1955 std::size_t(2));
1956 CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().sideset_name(1),
1957 std::string("srfBC4A"));
1958 CPPUNIT_ASSERT_EQUAL(mesh.get_boundary_info().sideset_name(2),
1959 std::string("srfBC4B"));
1960 CPPUNIT_ASSERT_EQUAL(mesh.get_subdomain_name_map().size(),
1961 std::size_t(2));
1962 CPPUNIT_ASSERT_EQUAL(mesh.subdomain_name(1),
1963 std::string("volBC3A"));
1964 CPPUNIT_ASSERT_EQUAL(mesh.subdomain_name(2),
1965 std::string("volBC3B"));
1966 }
1967
1969 {
1970 LOG_UNIT_TEST;
1971
1973
1974 STLIO stl_io(mesh);
1975
1976 if (mesh.processor_id() == 0)
1977 stl_io.read("meshes/Cluster_34.stl");
1979
1980 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(40));
1981 }
1982
1984 {
1985 LOG_UNIT_TEST;
1986
1988
1989 STLIO stl_io(mesh);
1990
1991 if (mesh.processor_id() == 0)
1992 stl_io.read("meshes/engraving.stl");
1994
1995 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(426));
1996 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), dof_id_type(215));
1997 }
1998
2000 {
2001#ifdef LIBMESH_HAVE_TETGEN
2002 LOG_UNIT_TEST;
2003
2005
2006 TetGenIO tetgen_io(mesh);
2007
2008 if (mesh.processor_id() == 0)
2009 tetgen_io.read("meshes/tetgen_one_tet10.ele");
2011
2013
2014 // Mesh should contain 1 TET10 finite element
2015 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(1));
2016 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(10));
2017
2018 // Element should have TET10 reference element volume
2019 const Elem * const elem = mesh.query_elem_ptr(0);
2020
2021 // On a serial mesh we have every element everywhere
2022 if (mesh.is_serial())
2023 CPPUNIT_ASSERT(elem);
2024 else
2025 {
2026 bool have_elem = elem;
2027 mesh.comm().max(have_elem);
2028 CPPUNIT_ASSERT(have_elem);
2029 }
2030
2031 if (elem)
2032 {
2033 const Real vol = elem->volume();
2034 LIBMESH_ASSERT_FP_EQUAL(vol, 1./6, TOLERANCE*TOLERANCE);
2035 }
2036#endif
2037 }
2038
2040 {
2041 LOG_UNIT_TEST;
2042
2044
2045 DynaIO dyna(mesh, /* keep_spline_nodes = */ false);
2046
2047 if (mesh.processor_id() == 0)
2048 dyna.read("meshes/1_quad.bxt.gz");
2050
2052
2053 // We have 1 QUAD9 finite element
2054 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(1));
2055 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(9));
2056
2058 }
2059
2060
2062 {
2063 LOG_UNIT_TEST;
2064
2066
2067 DynaIO dyna(mesh);
2068 if (mesh.processor_id() == 0)
2069 dyna.read("meshes/25_quad.bxt.gz");
2071
2073
2074 // We have 5^2 QUAD9 elements, with 11^2 nodes,
2075 // tied to 49 Node/NodeElem spline nodes
2076 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), static_cast<dof_id_type>(25+49));
2077 CPPUNIT_ASSERT_EQUAL(mesh.n_nodes(), static_cast<dof_id_type>(121+49));
2078
2079 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
2081
2082 unsigned char weight_index = mesh.default_mapping_data();
2083
2084 for (const auto & elem : mesh.active_element_ptr_range())
2085 {
2086 if (elem->type() == NODEELEM)
2087 continue;
2088 LIBMESH_ASSERT_FP_EQUAL(Real(0.04), elem->volume(), TOLERANCE);
2089
2090 for (unsigned int n=0; n != 9; ++n)
2091 CPPUNIT_ASSERT_EQUAL
2092 (elem->node_ref(n).get_extra_datum<Real>(weight_index),
2093 Real(1.0));
2094
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))
2098 n_neighbors++;
2099 Point c = elem->vertex_average();
2100
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++;
2105
2106 CPPUNIT_ASSERT_EQUAL(n_neighbors, n_neighbors_expected);
2107 }
2108
2110
2111#ifdef LIBMESH_HAVE_SOLVER
2112#ifdef LIBMESH_ENABLE_CONSTRAINTS
2113 // Now test whether we can assign the desired constraint equations
2115 System & sys = es.add_system<LinearImplicitSystem>("test");
2116 sys.add_variable("u", SECOND); // to match QUAD9
2117 es.init();
2118
2119 // We should have a constraint on every FE dof
2120 CPPUNIT_ASSERT_EQUAL(sys.get_dof_map().n_constrained_dofs(), static_cast<dof_id_type>(121));
2121#endif // LIBMESH_ENABLE_CONSTRAINTS
2122#endif // LIBMESH_HAVE_SOLVER
2123 }
2124
2125 void testProjectionRegression(MeshBase & mesh, std::array<Real, 4> expected_norms)
2126 {
2127 int order = 0;
2128 for (const auto elem : mesh.element_ptr_range())
2129 order = std::max(order, int(elem->default_order()));
2130 TestCommWorld->max(order);
2131 CPPUNIT_ASSERT (order > 0);
2132
2133 // Let's test that IGA constraints are preserved (in a relative
2134 // sense) when we clone a mesh.
2135 std::unique_ptr<MeshBase> mesh_clone = mesh.clone();
2136 CPPUNIT_ASSERT(*mesh_clone == mesh);
2137
2139 System &sys = es.add_system<System> ("SimpleSystem");
2140 sys.add_variable("n", Order(order), RATIONAL_BERNSTEIN);
2141
2142 es.init();
2143
2145
2146 // Make this easy to tweak in the future
2147 const Real my_tolerance = TOLERANCE;
2148
2149 // Calculate some norms, skipping the spline points, and compare
2150 // to regression standard values
2151 std::set<unsigned int> skip_dimensions {0};
2152 const Real L2_norm =
2153 sys.calculate_norm(*sys.solution, 0, L2, &skip_dimensions);
2154// std::cout.precision(16);
2155// std::cout << "L2_norm = " << L2_norm << std::endl;
2156 LIBMESH_ASSERT_FP_EQUAL(L2_norm, expected_norms[0], my_tolerance);
2157 const Real Linf_norm =
2158 sys.calculate_norm(*sys.solution, 0, L_INF, &skip_dimensions);
2159// std::cout << "Linf_norm = " << Linf_norm << std::endl;
2160 LIBMESH_ASSERT_FP_EQUAL(Linf_norm, expected_norms[1], my_tolerance);
2161 const Real H1_norm =
2162 sys.calculate_norm(*sys.solution, 0, H1_SEMINORM, &skip_dimensions);
2163// std::cout << "H1_norm = " << H1_norm << std::endl;
2164 LIBMESH_ASSERT_FP_EQUAL(H1_norm, expected_norms[2], my_tolerance);
2165 const Real W1inf_norm =
2166 sys.calculate_norm(*sys.solution, 0, W1_INF_SEMINORM, &skip_dimensions);
2167// std::cout << "W1inf_norm = " << W1inf_norm << std::endl;
2168 // W1_inf seems more sensitive to FP error...
2169 LIBMESH_ASSERT_FP_EQUAL(W1inf_norm, expected_norms[3], 10*my_tolerance);
2170 }
2171
2172 void testDynaFileMappings (const std::string & filename, std::array<Real, 4> expected_norms)
2173 {
2175
2176 DynaIO dyna(mesh);
2177 if (mesh.processor_id() == 0)
2178 dyna.read(filename);
2180
2182
2183 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
2185
2186 // Useful when trying out different projection functions
2187 // std::cout << filename << ":" << std::endl;
2188
2190
2191 testProjectionRegression(mesh, expected_norms);
2192 }
2193
2195 {
2196 LOG_UNIT_TEST;
2197
2198 testDynaFileMappings("meshes/PressurizedCyl_Patch6_256Elem.bxt.gz",
2199 // Regression values for sin_x_plus_cos_y
2200 {{0.9639857809698268, 1.839870171669186,
2201 0.7089812562241862, 1.306121188539059}});
2202 }
2203
2205 {
2206 LOG_UNIT_TEST;
2207
2208 testDynaFileMappings("meshes/BlockWithHole_Patch9.bxt.gz",
2209 // Regression values for sin_x_plus_cos_y
2210 {{3.22612556930183, 1.97405365384733,
2211 2.53376235803176, 1.41374070517223}});
2212 }
2213
2215 {
2216 LOG_UNIT_TEST;
2217
2218 testDynaFileMappings("meshes/PlateWithHole_Patch8.bxt.gz",
2219 // Regression values for sin_x_plus_cos_y
2220 {{2.2812154374012, 1.974049990211937,
2221 1.791640772215248, 1.413679237529376}});
2222 }
2223
2225 {
2226 LOG_UNIT_TEST;
2227
2228 testDynaFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.bxt.gz",
2229 // Regression values for sin_x_plus_cos_y
2230 {{0.963612880188165, 1.82329452603503,
2231 0.707998701597943, 1.31399222566683}});
2232 }
2233
2234 void testExodusFileMappings (const std::string & filename,
2235 std::array<Real, 4> expected_norms,
2236 bool use_disc_bex = false)
2237 {
2239
2240 ExodusII_IO exii(mesh);
2241 // IGA Exodus meshes require ExodusII 8 or higher
2242 if (exii.get_exodus_version() < 800)
2243 return;
2244
2245 // This should default to false
2246 if (use_disc_bex)
2247 exii.set_discontinuous_bex(true);
2248
2249 if (mesh.processor_id() == 0)
2250 exii.read(filename);
2252
2254
2255 CPPUNIT_ASSERT_EQUAL(mesh.default_mapping_type(),
2257
2259
2260 testProjectionRegression(mesh, expected_norms);
2261
2262 // Test a write when we're done reading; I was getting weirdness
2263 // from NetCDF at this point in a Moose output test.
2264 {
2265 ExodusII_IO exii(mesh);
2266
2267 exii.write("exodus_file_mapping_out.e");
2268 }
2269
2270#ifdef LIBMESH_HAVE_VTK
2271 {
2272 VTKIO vtkout(mesh);
2273
2274 vtkout.write("vtk_file_mapping_out.pvtu");
2275 }
2276#endif
2277 }
2278
2280 {
2281 LOG_UNIT_TEST;
2282
2283 testExodusFileMappings("meshes/PlateWithHole_Patch8.e",
2284 // Regression values for sin_x_plus_cos_y
2285 {{2.2812154374012, 1.974049990211937,
2286 1.791640772215248, 1.413679237529376}});
2287 }
2288
2290 {
2291 LOG_UNIT_TEST;
2292
2293 testExodusFileMappings("meshes/two_quads_two_blocks.e",
2294 // Regression values for sin_x_plus_cos_y
2295 {{2.03496953073072, 1.97996853164955,
2296 1.18462134113435, 1.03085301158959}});
2297 }
2299 {
2300 LOG_UNIT_TEST;
2301
2302 testExodusFileMappings("meshes/two_element_iga_in.e",
2303 // Regression values for sin_x_plus_cos_y
2304 {{1.26865962862531, 1.42562070158386,
2305 1.54905363492342, 1.29782906548366}});
2306 }
2307
2309 {
2310 LOG_UNIT_TEST;
2311
2312 testExodusFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.e",
2313 {{0.963612880188165, 1.82329452603503,
2314 0.707998701597943, 1.31399222566683}});
2315 }
2316
2318 {
2319 LOG_UNIT_TEST;
2320
2321 testExodusFileMappings("meshes/PlateWithHole_Patch8.e",
2322 // Regression values for sin_x_plus_cos_y
2323 //
2324 // These are *not* the same as for the continuous plate, because
2325 // we do the C^TKCx=C^Tf trick to pull back projections to the
2326 // spline nodes, and the pseudoinverse here minimizes the error in
2327 // a discretization-dependent norm, not in a Sobolev norm. For
2328 // these coarse meshes, our Sobolev norms can end up being ~0.1%
2329 // different.
2330 {{2.28234312456534, 1.97439548757586,
2331 1.79290449809266, 1.41075128955985}},
2332 true);
2333 }
2334
2336 {
2337 LOG_UNIT_TEST;
2338
2339 testExodusFileMappings("meshes/two_quads_two_blocks.e",
2340 // Regression values for sin_x_plus_cos_y
2341 {{2.03496953073072, 1.97996853164955,
2342 1.18462134113435, 1.03085301158959}},
2343 true);
2344 }
2346 {
2347 LOG_UNIT_TEST;
2348
2349 testExodusFileMappings("meshes/two_element_iga_in.e",
2350 // Regression values for sin_x_plus_cos_y
2351 {{1.26877626663365, 1.42553698909339,
2352 1.54810114917177, 1.29792704408979}},
2353 true);
2354 }
2355
2357 {
2358 LOG_UNIT_TEST;
2359
2360 testExodusFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.e",
2361 {{0.963855209590556, 1.8234396424318,
2362 0.708286572453382, 1.31468940958327}},
2363 true);
2364 }
2365};
2366
unsigned int dim
void ErrorVector unsigned int
void testAbaqusReadSecond()
void testExodusSetNodeUniqueIdsFromMaps()
Definition mesh_input.C:499
void testDynaNoSplines()
CPPUNIT_TEST(testDynaFileMappingsBlockWithHole)
CPPUNIT_TEST(testExodusFileMappingsTwoBlocks)
void testExodusDiscWriteAddedSidesHexC0()
void testGmshBCIDOverlap()
CPPUNIT_TEST(testNemesisReadDistributed)
CPPUNIT_TEST(testNemesisCopyNodalSolutionReplicated)
void testBadGmsh()
void testExodusDiscWriteAddedSidesTriDisc()
void testExodusWriteElementDataFromDiscontinuousNodalData()
void testNemesisCopyElementVectorReplicated()
void testVTKPreserveSubdomainIds()
Definition mesh_input.C:291
void testExodusWriteAddedSidesTetC0()
void testExodusWriteAddedSidesQuadC0()
void testExodusIGASidesets()
Definition mesh_input.C:666
void testExodusWriteAddedSidesEdgeDisc()
void testExodusFileMappingsPlateWithHole()
CPPUNIT_TEST(testExodusFileMappingsCyl3d)
void testAbaqusReadFirst()
void testVTKReadPolyhedraSerial()
Definition mesh_input.C:420
void testVTKReadNotAnXMLFile()
Definition mesh_input.C:445
void testExodusDiscWriteAddedSidesTetDisc()
CPPUNIT_TEST(testExodusDiscWriteAddedSidesTriC0)
void testExodusCopyElementVectorReplicated()
void testExodusDiscWriteAddedSidesMixedEdgeC0()
CPPUNIT_TEST(testGmshBCIDOverlap)
CPPUNIT_TEST(testExodusDiscCyl3d)
void testNemesisCopyNodalSolutionReplicated()
Definition mesh_input.C:832
CPPUNIT_TEST(testNemesisSingleElementReplicated)
CPPUNIT_TEST(testNemesisCopyElementSolutionDistributed)
void testExodusWriteAddedSides(Number(*exact_sol)(const Point &, const Parameters &, const std::string &, const std::string &), const ElemType elem_type, const Order order, const bool write_discontinuous=false, const std::vector< FEType > earlier_vars={}, const std::vector< FEType > later_vars={})
void testSingleElementImpl(const std::string &filename)
CPPUNIT_TEST(testAbaqusReadFirst)
void testGoodSTL()
void testExodusDiscWriteAddedSidesEdgeC0()
void testExodusDiscTwoElemIGA()
CPPUNIT_TEST(testExodusDiscWriteAddedSidesHexC0)
CPPUNIT_TEST(testExodusWriteAddedSidesMixedEdgeC0)
CPPUNIT_TEST(testExodusSetElemUniqueIdsFromMaps)
void testDynaFileMappingsBlockWithHole()
void testGoodGmsh()
void testNemesisSingleElementReplicated()
void testExodusCopyElementSolutionReplicated()
Definition mesh_input.C:926
void testNemesisReadImpl()
void testDynaReadPatch()
CPPUNIT_TEST(testExodusWriteAddedSidesTriC0)
CPPUNIT_TEST(testExodusDiscTwoBlocks)
CPPUNIT_TEST(testGoodGmsh)
void testNemesisSingleElementDistributed()
void testExodusCopyElementSolutionDistributed()
Definition mesh_input.C:929
void testCopyNodalSolutionImpl(const std::string &filename)
Definition mesh_input.C:757
CPPUNIT_TEST(testVTKReadPolyhedraSerial)
void testExodusCopyNodalSolutionDistributed()
Definition mesh_input.C:828
void testExodusReadHeader()
Definition mesh_input.C:586
void testExodusWriteAddedSidesMixedEdgeC0()
CPPUNIT_TEST(testNemesisSingleElementDistributed)
CPPUNIT_TEST(testExodusCopyElementVectorDistributed)
CPPUNIT_TEST(testVTKReadNotAnXMLFile)
void testExodusSetElemUniqueIdsFromMaps()
Definition mesh_input.C:555
void testExodusFileMappingsCyl3d()
CPPUNIT_TEST(testGoodSTL)
void testNemesisCopyElementSolutionDistributed()
void testExodusDiscTwoBlocks()
void testExodusDiscWriteAddedSidesQuadC0()
void helperTestingDynaQuad(const MeshBase &mesh)
void testExodusDiscWriteAddedSidesMixedTriC0()
CPPUNIT_TEST(testDynaFileMappingsCyl3d)
void testCopyElementSolutionImpl(const std::string &filename)
Definition mesh_input.C:841
void testExodusDiscWriteAddedSidesMixedHexC0()
CPPUNIT_TEST(testExodusDiscTwoElemIGA)
void checkHexPrismPolyhedron(MeshBase &mesh)
Definition mesh_input.C:343
void testExodusDiscWriteAddedSidesMixedQuadC0()
void testDynaFileMappingsCyl3d()
void testExodusFileMappings(const std::string &filename, std::array< Real, 4 > expected_norms, bool use_disc_bex=false)
void testExodusWriteAddedSidesQuadDisc()
void testExodusWriteAddedSidesMixedTriC0()
void testExodusWriteAddedSidesTetDisc()
CPPUNIT_TEST(testLowOrderEdgeBlocks)
void testNemesisReadDistributed()
CPPUNIT_TEST(testNemesisCopyNodalSolutionDistributed)
void testExodusDiscWriteAddedSidesQuadDisc()
CPPUNIT_TEST(testNemesisCopyElementSolutionReplicated)
CPPUNIT_TEST(testExodusCopyHighOrderElementSolution)
void testVTKPreserveElemIds()
Definition mesh_input.C:232
CPPUNIT_TEST(testExodusFileMappingsPlateWithHole)
CPPUNIT_TEST(testExodusWriteAddedSidesHexC0)
void testExodusWriteAddedSidesMixedHexC0()
CPPUNIT_TEST(testDynaReadPatch)
void testLowOrderEdgeBlocks()
Definition mesh_input.C:623
void testDynaFileMappingsFEMEx5()
void testExodusDiscWriteAddedSidesTetC0()
void testCopyElementVectorImpl(const std::string &filename)
CPPUNIT_TEST(testExodusWriteAddedSidesMixedTriC0)
void testMasterCenters(const MeshBase &mesh)
void testNemesisCopyElementSolutionReplicated()
void testExodusSetNodeUniqueIdsFromMaps_implementation(bool set_unique_ids, const std::vector< unique_id_type > &expected_unique_ids)
Definition mesh_input.C:463
void testDynaFileMappingsPlateWithHole()
CPPUNIT_TEST(testExodusDiscWriteAddedSidesMixedHexC0)
CPPUNIT_TEST(testVTKReadPolyhedra)
CPPUNIT_TEST(testExodusWriteAddedSidesMixedHexC0)
void testExodusCopyElementVectorDistributed()
CPPUNIT_TEST(testExodusCopyElementVectorReplicated)
CPPUNIT_TEST(testExodusCopyElementSolutionReplicated)
void testAbaqusRead(const std::string &fname, dof_id_type n_elem, dof_id_type n_nodes)
CPPUNIT_TEST(testAbaqusReadSecond)
CPPUNIT_TEST(testExodusWriteAddedSidesQuadC0)
CPPUNIT_TEST(testExodusIGASidesets)
CPPUNIT_TEST(testExodusDiscWriteAddedSidesMixedQuadC0)
CPPUNIT_TEST(testExodusWriteAddedSidesMixedQuadC0)
void testNemesisReadReplicated()
void testExodusWriteAddedSidesHexC0()
void testExodusFileMappingsTwoBlocks()
void testTetgenIO()
CPPUNIT_TEST(testDynaFileMappingsFEMEx5)
void testExodusWriteAddedSidesMixedQuadC0()
CPPUNIT_TEST(testExodusFileMappingsTwoElemIGA)
CPPUNIT_TEST(testExodusCopyElementSolutionDistributed)
void testExodusWriteAddedSidesTriDisc()
void testNemesisCopyNodalSolutionDistributed()
Definition mesh_input.C:835
void testGoodSTLBinary()
void testExodusDiscPlateWithHole()
CPPUNIT_TEST(testExodusDiscWriteAddedSidesQuadC0)
CPPUNIT_TEST(testExodusSetNodeUniqueIdsFromMaps)
void testVTKReadPolyhedra()
Definition mesh_input.C:390
void testExodusWriteAddedSidesHexDisc()
CPPUNIT_TEST(testExodusCopyNodalSolutionReplicated)
CPPUNIT_TEST(testGoodSTLBinary)
CPPUNIT_TEST(testExodusWriteAddedSidesEdgeC0)
CPPUNIT_TEST(testTetgenIO)
CPPUNIT_TEST(testExodusReadHeader)
void testExodusSetElemUniqueIdsFromMaps_implementation(bool set_unique_ids, const std::vector< unique_id_type > &expected_unique_ids)
Definition mesh_input.C:520
CPPUNIT_TEST(testNemesisCopyElementVectorDistributed)
void testNemesisCopyElementVectorDistributed()
CPPUNIT_TEST(testExodusDiscWriteAddedSidesEdgeC0)
void testExodusDiscWriteAddedSidesTriC0()
void testExodusCopyNodalSolutionReplicated()
Definition mesh_input.C:825
void testExodusFileMappingsTwoElemIGA()
CPPUNIT_TEST(testNemesisCopyElementVectorReplicated)
CPPUNIT_TEST(testBadGmsh)
void testExodusWriteAddedSidesEdgeC0()
void testExodusDiscWriteAddedSidesHexDisc()
void testDynaFileMappings(const std::string &filename, std::array< Real, 4 > expected_norms)
CPPUNIT_TEST(testExodusCopyNodalSolutionDistributed)
void testExodusDiscWriteAddedSidesEdgeDisc()
CPPUNIT_TEST(testDynaReadElem)
CPPUNIT_TEST(testExodusDiscPlateWithHole)
void testExodusDiscCyl3d()
void testProjectionRegression(MeshBase &mesh, std::array< Real, 4 > expected_norms)
LIBMESH_CPPUNIT_TEST_SUITE(MeshInputTest)
CPPUNIT_TEST(testExodusDiscWriteAddedSidesMixedTriC0)
CPPUNIT_TEST(testVTKPreserveSubdomainIds)
CPPUNIT_TEST(testDynaNoSplines)
void testExodusWriteAddedSidesTriC0()
void testExodusCopyHighOrderElementSolution()
Definition mesh_input.C:941
CPPUNIT_TEST(testExodusDiscWriteAddedSidesHexDisc)
CPPUNIT_TEST(testExodusWriteAddedSidesHexDisc)
CPPUNIT_TEST(testDynaFileMappingsPlateWithHole)
CPPUNIT_TEST(testExodusWriteElementDataFromDiscontinuousNodalData)
void testDynaReadElem()
void tearDown()
Definition mesh_input.C:228
CPPUNIT_TEST(testNemesisReadReplicated)
CPPUNIT_TEST(testVTKPreserveElemIds)
CPPUNIT_TEST(testExodusDiscWriteAddedSidesMixedEdgeC0)
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.
Definition abaqus_io.h:42
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.
Definition abaqus_io.C:227
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.
Definition dof_map.h:181
dof_id_type n_constrained_dofs() const
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition dof_map.C:2203
unique_id_type unique_id() const
Definition dof_object.h:849
Reading and writing meshes in (a subset of) LS-DYNA format.
Definition dyna_io.h:53
virtual void read(const std::string &name) override
Reads in a mesh in the Dyna format from the ASCII file given by name.
Definition dyna_io.C:139
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual unsigned int n_vertices() const =0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:382
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...
Definition elem.h:649
virtual Real volume() const
Definition elem.C:3865
virtual ElemType type() const =0
virtual unsigned int n_sides() const =0
dof_id_type node_id(const unsigned int i) const
Definition elem.h:2605
IntRange< unsigned short > side_index_range() const
Definition elem.h:2848
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.
This class is used as both an external data structure for passing around Exodus file header informati...
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition exodusII_io.h:53
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)
Definition fe_map.C:1954
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)
Definition fe_map.C:1512
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
FEType set_p_refinement(bool p) &
"Fluent API" for constructing a non-default p_refinement, for easier compatibility between non-InfFE ...
Definition fe_type.h:298
Reading and writing meshes in the Gmsh format.
Definition gmsh_io.h:53
virtual void read(const std::string &name) override
Reads in a mesh in the Gmsh *.msh format from the ASCII file given by name.
Definition gmsh_io.C:149
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.
Definition mesh_base.h:81
virtual bool is_serial() const
Definition mesh_base.h:357
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
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.
Definition mesh_base.h:1359
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition mesh_base.h:1930
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.
Definition mesh_base.C:824
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 ...
Definition mesh_base.h:938
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)
Definition mesh_base.C:1902
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
Definition mesh_base.h:956
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition mesh_base.C:1848
void skip_noncritical_partitioning(bool skip)
If true is passed in then the elements on this mesh will no longer be (re)partitioned,...
Definition mesh_base.h:1415
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...
bool is_parallel_format() const
Returns true iff this mesh file format and input class are parallelized, so that all processors can r...
Definition mesh_input.h:87
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 ...
Definition mesh_output.C:31
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
The Nemesis_IO class implements reading parallel meshes in the Nemesis file format from Sandia Nation...
Definition nemesis_io.h:54
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.
Definition nemesis_io.C:215
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...
Definition parameters.h:75
bool have_parameter(std::string_view) const
Definition parameters.h:420
const T & get(std::string_view) const
Definition parameters.h:451
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
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.
Definition stl_io.h:47
virtual void read(const std::string &mesh_file) override
This method implements reading a mesh from a specified file.
Definition stl_io.C:165
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
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.
Definition system.h:1667
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2219
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.
Definition system.C:1344
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition system.h:1655
const std::string & variable_name(const unsigned int i) const
Definition system.C:2679
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition system.C:1511
const DofMap & get_dof_map() const
Definition system.h:2417
unsigned int number() const
Definition system.h:2393
This class implements reading and writing meshes in the TetGen format.
Definition tetgen_io.h:49
virtual void read(const std::string &) override
This method implements reading a mesh from a specified file in TetGen format.
Definition tetgen_io.C:36
This class implements reading and writing meshes in the VTK format.
Definition vtk_io.h:62
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.
Definition vtk_io.C:258
Communicator * TestCommWorld
MeshBase & mesh
Number six_x_plus_sixty_y(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition mesh_input.C:31
CPPUNIT_TEST_SUITE_REGISTRATION(MeshInputTest)
constexpr int added_sides_nxyz[]
Definition mesh_input.C:54
Number sin_x_plus_cos_y(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition mesh_input.C:43
Number designed_for_side_elems(const Point &p, const Parameters &param, const std::string &, const std::string &)
Definition mesh_input.C:56
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
void build_line(UnstructuredMesh &mesh, const unsigned int nx, const Real xmin=0., const Real xmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 1D meshes.
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
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...
Definition int_range.h:153
ElemType
Defines an enum for geometric element types.
int8_t boundary_id_type
Definition id_types.h:51
void libmesh_ignore(const Args &...)
@ RATIONAL_BERNSTEIN_MAP
libmesh_assert(ctx)
LIBMESH_DEVICE_INLINE T libmesh_real(T a)
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67
@ RATIONAL_BERNSTEIN
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...
Definition int_range.h:176
const dof_id_type n_nodes
Definition tecplot_io.C:67