libMesh
Loading...
Searching...
No Matches
vector_value_test.C
Go to the documentation of this file.
1#include <libmesh/vector_value.h>
2
3#include "type_vector_test.h"
4
5#include <type_traits>
6
7
8using namespace libMesh;
9
10#define VECTORVALUETEST \
11 TYPEVECTORTEST \
12 CPPUNIT_TEST( testScalarInit ); \
13
14class RealVectorValueTest : public TypeVectorTestBase<VectorValue<Real>> {
15public:
19 this->libmesh_suite_name = "TypeVectorTest";
20 else
21 this->libmesh_suite_name = "RealVectorValueTest";
22 }
23
25
26 VECTORVALUETEST
27
29};
30
31class NumberVectorValueTest : public TypeVectorTestBase<VectorValue<Number>> {
32public:
35 this->libmesh_suite_name = "NumberVectorValueTest";
36 }
37
39
40 VECTORVALUETEST
41
43};
44
45class ComplexVectorValueTest : public TypeVectorTestBase<VectorValue<Complex>> {
46public:
49 this->libmesh_suite_name = "ComplexVectorValueTest";
50 }
51
53
54 VECTORVALUETEST
55
57};
58
59class VectorCompareTypesTest : public CppUnit::TestCase {
60public:
62
64
66
67private:
68 template <typename T, typename T2>
70 average(const T & val1, const T2 & val2)
71 {
72 return (val1 + val2) / 2;
73 }
74
75public:
76 void
78 {
79 LOG_UNIT_TEST;
80
83
84 [[maybe_unused]] auto ftype = fvec * 1;
85 [[maybe_unused]] auto dtype = dvec * 1;
86
87 {
88 bool assertion = std::is_same<decltype(ftype), TypeVector<float>>::value;
89 CPPUNIT_ASSERT(assertion);
90 }
91 {
92 bool assertion = std::is_same<decltype(dtype), TypeVector<double>>::value;
93 CPPUNIT_ASSERT(assertion);
94 }
95 {
96 bool assertion = std::is_same<decltype(average(ftype, ftype)), TypeVector<float>>::value;
97 CPPUNIT_ASSERT(assertion);
98 }
99 {
100 bool assertion = std::is_same<decltype(average(ftype, dtype)), TypeVector<double>>::value;
101 CPPUNIT_ASSERT(assertion);
102 }
103 {
104 bool assertion = std::is_same<decltype(average(fvec, fvec)), VectorValue<float>>::value;
105 CPPUNIT_ASSERT(assertion);
106 }
107 {
108 bool assertion = std::is_same<decltype(average(fvec, dvec)), VectorValue<double>>::value;
109 CPPUNIT_ASSERT(assertion);
110 }
111 {
112 bool assertion = std::is_same<decltype(average(fvec, dtype)), VectorValue<double>>::value;
113 CPPUNIT_ASSERT(assertion);
114 }
115 {
116 bool assertion = std::is_same<decltype(average(ftype, dvec)), VectorValue<double>>::value;
117 CPPUNIT_ASSERT(assertion);
118 }
119#ifdef LIBMESH_HAVE_METAPHYSICL
120 {
121 typedef typename MetaPhysicL::ReplaceAlgebraicType<
122 std::vector<double>,
124 typename MetaPhysicL::ValueType<std::vector<double>>::type>::type>::type
125 ReplacedType;
126 constexpr bool assertion =
127 std::is_same<ReplacedType, std::vector<VectorValue<double>>>::value;
128 CPPUNIT_ASSERT(assertion);
129 }
130 {
131 typedef typename MetaPhysicL::ReplaceAlgebraicType<
132 std::vector<VectorValue<double>>,
134 typename MetaPhysicL::ValueType<std::vector<VectorValue<double>>>::type>::type>::type
135 ReplacedType;
136 constexpr bool assertion =
137 std::is_same<ReplacedType, std::vector<TensorValue<double>>>::value;
138 CPPUNIT_ASSERT(assertion);
139 }
140#endif
141 }
142};
143
144
CPPUNIT_TEST_SUITE(ComplexVectorValueTest)
VECTORVALUETEST CPPUNIT_TEST_SUITE_END()
VECTORVALUETEST CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST_SUITE(NumberVectorValueTest)
CPPUNIT_TEST_SUITE(RealVectorValueTest)
VECTORVALUETEST CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST(testCompareTypes)
LIBMESH_CPPUNIT_TEST_SUITE(VectorCompareTypesTest)
CompareTypes< T, T2 >::supertype average(const T &val1, const T2 &val2)
bool summarized_logs_enabled()
Definition perf_log.h:210
This class defines a vector in LIBMESH_DIM dimensional space of type T.
Definition type_vector.h:63
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
libMesh::PerfLog * unitlog
Definition driver.C:220
The libMesh namespace provides an interface to certain functionality in the library.
std::complex< Real > Complex
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CPPUNIT_TEST_SUITE_REGISTRATION(RealVectorValueTest)
static const bool value
Definition xdr_io.C:55