libMesh
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ExodusC0PolygonTest Class Reference
Inheritance diagram for ExodusC0PolygonTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (ExodusC0PolygonTest)
 
 CPPUNIT_TEST (test_write_and_read_pentagon)
 
 CPPUNIT_TEST_SUITE_END ()
 
void build_pentagon (Mesh &mesh)
 
void test_write_and_read_pentagon ()
 

Detailed Description

Definition at line 113 of file exodus_test.C.

Member Function Documentation

◆ build_pentagon()

void ExodusC0PolygonTest::build_pentagon ( Mesh mesh)
inline

Definition at line 122 of file exodus_test.C.

123 {
124 const std::vector<Point> points =
125 { {0, 0}, {1, 0}, {1.5, 0.5}, {1, 1}, {0, 1} };
126
127 for (auto p : index_range(points))
128 mesh.add_point(points[p], /*id=*/p);
129
130 std::unique_ptr<Elem> polygon =
131 std::make_unique<C0Polygon>(cast_int<unsigned int>(points.size()));
132 for (auto i : index_range(points))
133 polygon->set_node(i, mesh.node_ptr(i));
134
135 polygon->set_id() = 0;
136 Elem *elem = mesh.add_elem(std::move(polygon));
137 elem->subdomain_id() = 1;
139 }
This is the base class from which all geometric element types are derived.
Definition elem.h:96
subdomain_id_type subdomain_id() const
Definition elem.h:2591
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 Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
MeshBase & mesh
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

References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::index_range(), mesh, libMesh::MeshBase::node_ptr(), libMesh::MeshBase::prepare_for_use(), and libMesh::Elem::subdomain_id().

Referenced by test_write_and_read_pentagon().

◆ CPPUNIT_TEST()

ExodusC0PolygonTest::CPPUNIT_TEST ( test_write_and_read_pentagon  )

◆ CPPUNIT_TEST_SUITE_END()

ExodusC0PolygonTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

ExodusC0PolygonTest::LIBMESH_CPPUNIT_TEST_SUITE ( ExodusC0PolygonTest  )

◆ test_write_and_read_pentagon()

void ExodusC0PolygonTest::test_write_and_read_pentagon ( )
inline

Definition at line 141 of file exodus_test.C.

142 {
143 LOG_UNIT_TEST;
144
145 Mesh mesh(*TestCommWorld);
146 this->build_pentagon(mesh);
147
148 {
149 ExodusII_IO exii(mesh);
150 exii.write("write_exodus_C0POLYGON.e");
151 }
152
153 Mesh input_mesh(*TestCommWorld);
154 ExodusII_IO exii_input(input_mesh);
155 if (input_mesh.processor_id() == 0)
156 exii_input.read("write_exodus_C0POLYGON.e");
157
158 MeshCommunication().broadcast(input_mesh);
159 input_mesh.prepare_for_use();
160
161 CPPUNIT_ASSERT_EQUAL(cast_int<dof_id_type>(1), input_mesh.n_elem());
162
163 const Elem *elem = input_mesh.query_elem_ptr(0);
164 bool found_elem = elem;
165 input_mesh.comm().max(found_elem);
166 CPPUNIT_ASSERT(found_elem);
167
168 if (!elem)
169 return;
170
171 CPPUNIT_ASSERT_EQUAL(C0POLYGON, elem->type());
172 CPPUNIT_ASSERT_EQUAL(5u, elem->n_nodes());
173
174 for (auto i : make_range(5))
175 CPPUNIT_ASSERT_EQUAL(cast_int<dof_id_type>(i), elem->node_id(i));
176 }
void build_pentagon(Mesh &mesh)
virtual unsigned int n_nodes() const =0
virtual ElemType type() const =0
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition exodusII_io.h:53
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...
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
Tnew cast_int(Told oldvar)
uint8_t dof_id_type
Definition id_types.h:67
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

References libMesh::MeshCommunication::broadcast(), build_pentagon(), libMesh::C0POLYGON, libMesh::ParallelObject::comm(), libMesh::make_range(), libMesh::Parallel::Communicator::max(), mesh, libMesh::DistributedMesh::n_elem(), libMesh::Elem::n_nodes(), libMesh::Elem::node_id(), libMesh::MeshBase::prepare_for_use(), libMesh::ParallelObject::processor_id(), libMesh::DistributedMesh::query_elem_ptr(), libMesh::ExodusII_IO::read(), TestCommWorld, libMesh::Elem::type(), and libMesh::ExodusII_IO::write().


The documentation for this class was generated from the following file: