libMesh
Loading...
Searching...
No Matches
mesh_deletions.C
Go to the documentation of this file.
1#include <libmesh/distributed_mesh.h>
2#include <libmesh/elem.h>
3#include "libmesh/enum_partitioner_type.h"
4#include <libmesh/mesh_generation.h>
5#include <libmesh/parallel.h>
6#include <libmesh/partitioner.h>
7#include <libmesh/replicated_mesh.h>
8
9#include "test_comm.h"
10#include "libmesh_cppunit.h"
11
12using namespace libMesh;
13
14class MeshDeletionsTest : public CppUnit::TestCase {
19public:
21
22#if LIBMESH_DIM > 1
25#endif
26
28
29protected:
30
31public:
32 void setUp()
33 {
34 }
35
36 void tearDown()
37 {
38 }
39
41 {
42 LOG_UNIT_TEST;
43
44 // Let's not trust Metis or Parmetis to give us a replicable test
45 // case.
47
49 3, 3,
50 0., 1.,
51 0., 1.,
52 QUAD4);
53
54 std::vector<std::vector<int>> deletions =
55 {{1, 2, 4}, {0, 3}, {0, 2}, {1}};
56 dof_id_type n_elem = 9;
57 for (auto deletionset : deletions)
58 {
59 for (int e : deletionset)
60 {
61 --n_elem;
62 Elem * elem = mesh.query_elem_ptr(e);
63 if (elem)
64 {
65 elem->remove_links_to_me();
66 mesh.delete_elem(elem);
67 }
68 }
69
71
72 CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), n_elem);
73 }
74 }
75
77 {
78 LOG_UNIT_TEST;
81 }
82
84 {
85 LOG_UNIT_TEST;
88 }
89};
90
void testDeleteElem(UnstructuredMesh &mesh)
CPPUNIT_TEST(testDeleteElemDistributed)
void testDeleteElemReplicated()
CPPUNIT_TEST(testDeleteElemReplicated)
LIBMESH_CPPUNIT_TEST_SUITE(MeshDeletionsTest)
This test ensures operations like delete_elem don't cause problems with later mesh preparation.
void testDeleteElemDistributed()
The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical fu...
This is the base class from which all geometric element types are derived.
Definition elem.h:96
void remove_links_to_me()
Resets this element's neighbors' appropriate neighbor pointers and its parent's and children's approp...
Definition elem.C:1648
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each partitioning.
Definition mesh_base.h:165
virtual dof_id_type n_elem() const =0
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 delete_elem(Elem *e)=0
Removes element e from the mesh.
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
static std::unique_ptr< Partitioner > build(const PartitionerType solver_package)
Builds a Partitioner of the type specified by partitioner_type.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
The UnstructuredMesh class is derived from the MeshBase class.
Communicator * TestCommWorld
MeshBase & mesh
CPPUNIT_TEST_SUITE_REGISTRATION(MeshDeletionsTest)
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.
The libMesh namespace provides an interface to certain functionality in the library.
uint8_t dof_id_type
Definition id_types.h:67