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

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (StoredRangeTest)
 
 CPPUNIT_TEST (testEquality)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testEquality ()
 Ranges are equal when they hold the same objects in the same order.
 

Detailed Description

Definition at line 10 of file stored_range_test.C.

Member Function Documentation

◆ CPPUNIT_TEST()

StoredRangeTest::CPPUNIT_TEST ( testEquality  )

◆ CPPUNIT_TEST_SUITE_END()

StoredRangeTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

StoredRangeTest::LIBMESH_CPPUNIT_TEST_SUITE ( StoredRangeTest  )

◆ setUp()

void StoredRangeTest::setUp ( )
inline

Definition at line 20 of file stored_range_test.C.

20{}

◆ tearDown()

void StoredRangeTest::tearDown ( )
inline

Definition at line 22 of file stored_range_test.C.

22{}

◆ testEquality()

void StoredRangeTest::testEquality ( )
inline

Ranges are equal when they hold the same objects in the same order.

A range compares equal to a range over a copy of its objects, wherever the two are stored, including when one range begins where the other ends.

Definition at line 29 of file stored_range_test.C.

30 {
31 LOG_UNIT_TEST;
32
33 // Every processor needs every element
34 ReplicatedMesh mesh(*TestCommWorld);
36
37 std::vector<const Elem *> all(mesh.elements_begin(), mesh.elements_end());
38 std::vector<const Elem *> copy(all);
39 std::vector<const Elem *> fewer(all.begin(), all.end() - 1);
40 std::vector<const Elem *> reversed(all.rbegin(), all.rend());
41
42 const ConstElemRange all_range(&all), copy_range(&copy), fewer_range(&fewer),
43 reversed_range(&reversed);
44
45 CPPUNIT_ASSERT(all_range == copy_range);
46 CPPUNIT_ASSERT(!(all_range == fewer_range));
47 CPPUNIT_ASSERT(!(fewer_range == all_range));
48 CPPUNIT_ASSERT(!(all_range == reversed_range));
49
50 // Two copies of the same objects, stored back to back
51 std::vector<const Elem *> twice(all);
52 twice.insert(twice.end(), all.begin(), all.end());
53 const ConstElemRange twice_range(&twice);
54 const auto middle = twice_range.begin() + all.size();
55 const ConstElemRange first_half(twice_range, twice_range.begin(), middle),
56 second_half(twice_range, middle, twice_range.end());
57
58 CPPUNIT_ASSERT(first_half == second_half);
59 CPPUNIT_ASSERT(second_half == first_half);
60 }
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
The StoredRange class defines a contiguous, divisible set of objects.
MeshBase & mesh
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.

References libMesh::StoredRange< iterator_type, object_type >::begin(), libMesh::MeshTools::Generation::build_square(), libMesh::StoredRange< iterator_type, object_type >::end(), mesh, and TestCommWorld.


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