libMesh
Loading...
Searching...
No Matches
stored_range_test.C
Go to the documentation of this file.
1#include <libmesh/elem_range.h>
2#include <libmesh/replicated_mesh.h>
3#include <libmesh/mesh_generation.h>
4
5#include "test_comm.h"
6#include "libmesh_cppunit.h"
7
8using namespace libMesh;
9
10class StoredRangeTest : public CppUnit::TestCase {
11
12public:
14#if LIBMESH_DIM > 1
16#endif
18
19public:
20 void setUp() {}
21
22 void tearDown() {}
23
30 {
31 LOG_UNIT_TEST;
32
33 // Every processor needs every element
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 }
61};
62
LIBMESH_CPPUNIT_TEST_SUITE(StoredRangeTest)
void testEquality()
Ranges are equal when they hold the same objects in the same order.
CPPUNIT_TEST(testEquality)
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.
const_iterator begin() const
Beginning of the range.
const_iterator end() const
End of the range.
Communicator * TestCommWorld
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.
The libMesh namespace provides an interface to certain functionality in the library.
CPPUNIT_TEST_SUITE_REGISTRATION(StoredRangeTest)