FrictionQPotFEM 0.23.3
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1
7#ifndef FRICTIONQPOTFEM_CONFIG_H
8#define FRICTIONQPOTFEM_CONFIG_H
9
10#include <algorithm>
11#include <string>
12#include <xtensor/xtensor.hpp>
13
17#define Q(x) #x
18#define QUOTE(x) Q(x)
19
20#define FRICTIONQPOTFEM_ASSERT_IMPL(expr, file, line) \
21 if (!(expr)) { \
22 throw std::runtime_error( \
23 std::string(file) + ':' + std::to_string(line) + \
24 ": assertion failed (" #expr ") \n\t"); \
25 }
26
27#define FRICTIONQPOTFEM_WIP_IMPL(expr, file, line) \
28 if (!(expr)) { \
29 throw std::out_of_range( \
30 std::string(file) + ':' + std::to_string(line) + \
31 ": assertion failed (" #expr ") \n\t"); \
32 }
33
34#define FRICTIONQPOTFEM_WARNING_IMPL(message, file, line) \
35 std::cout << std::string(file) + ':' + std::to_string(line) + ": " message ") \n\t";
36
59#ifdef FRICTIONQPOTFEM_ENABLE_ASSERT
60#define FRICTIONQPOTFEM_ASSERT(expr) FRICTIONQPOTFEM_ASSERT_IMPL(expr, __FILE__, __LINE__)
61#else
62#define FRICTIONQPOTFEM_ASSERT(expr)
63#endif
64
70#define FRICTIONQPOTFEM_REQUIRE(expr) FRICTIONQPOTFEM_ASSERT_IMPL(expr, __FILE__, __LINE__)
71
77#define FRICTIONQPOTFEM_WIP(expr) FRICTIONQPOTFEM_WIP_IMPL(expr, __FILE__, __LINE__)
78
88#ifdef FRICTIONQPOTFEM_DISABLE_WARNING
89#define FRICTIONQPOTFEM_WARNING(message)
90#else
91#define FRICTIONQPOTFEM_WARNING(message) FRICTIONQPOTFEM_WARNING_IMPL(message, __FILE__, __LINE__)
92#endif
93
103#ifdef FRICTIONQPOTFEM_ENABLE_WARNING_PYTHON
104#define FRICTIONQPOTFEM_WARNING_PYTHON(message) \
105 FRICTIONQPOTFEM_WARNING_IMPL(message, __FILE__, __LINE__)
106#else
107#define FRICTIONQPOTFEM_WARNING_PYTHON(message)
108#endif
109
131#ifndef FRICTIONQPOTFEM_VERSION
132#define FRICTIONQPOTFEM_VERSION "@PROJECT_VERSION@"
133#endif
134
140
144namespace array_type {
145
146#ifdef FRICTIONQPOTFEM_USE_XTENSOR_PYTHON
147
151template <typename T, size_t N>
152using tensor = xt::pytensor<T, N>;
153
154#else
155
159template <typename T, size_t N>
160using tensor = xt::xtensor<T, N>;
161
162#endif
163
164} // namespace array_type
165
166namespace detail {
167
168inline std::string unquote(const std::string& arg)
169{
170 std::string ret = arg;
171 ret.erase(std::remove(ret.begin(), ret.end(), '\"'), ret.end());
172 return ret;
173}
174
175} // namespace detail
176
181inline std::string version()
182{
183 return detail::unquote(std::string(QUOTE(FRICTIONQPOTFEM_VERSION)));
184}
185
186} // namespace FrictionQPotFEM
187
188#endif
xt::xtensor< T, N > tensor
Fixed (static) rank array.
Definition: config.h:160
Friction simulations based on a disorder potential energy landscape and the finite element method.
Definition: config.h:139
std::string version()
Return version string, e.g.
Definition: config.h:181
#define FRICTIONQPOTFEM_VERSION
Current version.
Definition: config.h:132