preCICE v3.1.2
Loading...
Searching...
No Matches
ValidationMacros.hpp
Go to the documentation of this file.
1#pragma once
2
9//
10// MESH VALIDATION
11//
12
17#include "utils/stacktrace.hpp"
18#define PRECICE_VALIDATE_MESH_NAME_IMPL(name) \
19 PRECICE_CHECK(_accessor->hasMesh(name), \
20 "The mesh named \"{}\" is unknown to preCICE.{}", \
21 name, _accessor->hintForMesh(name));
22
27#define PRECICE_REQUIRE_MESH_USE_IMPL(name) \
28 PRECICE_VALIDATE_MESH_NAME_IMPL(name) \
29 PRECICE_CHECK(_accessor->isMeshUsed(name), \
30 "This participant does not use the mesh \"{0}\", but attempted to access it. " \
31 "Please define a <provide-mesh name=\"{0}\" /> or <receive-mesh name=\"{0}\" from=\"...\" /> " \
32 "tag in the configuration of participant \" {1}.", \
33 name, _accessorName);
34
39#define PRECICE_REQUIRE_MESH_PROVIDE_IMPL(name) \
40 PRECICE_REQUIRE_MESH_USE_IMPL(name) \
41 PRECICE_CHECK(_accessor->isMeshProvided(name), \
42 "This participant does not provide Mesh \"{0}\", but attempted to modify it. " \
43 "Please add a provide-mesh tag as follows <provide-mesh name=\"{0}\" />.", \
44 name);
45
50#define PRECICE_REQUIRE_MESH_MODIFY_IMPL(name) \
51 PRECICE_REQUIRE_MESH_PROVIDE_IMPL(name) \
52 PRECICE_CHECK(!_meshLock.check(name), \
53 "This participant attempted to modify the Mesh \"{}\" while locked. " \
54 "Mesh modification is only allowed before calling initialize().", \
55 name);
56
60#define PRECICE_VALIDATE_MESH_NAME(name) \
61 do { \
62 PRECICE_VALIDATE_MESH_NAME_IMPL(name) \
63 } while (false)
64
68#define PRECICE_REQUIRE_MESH_USE(name) \
69 do { \
70 PRECICE_REQUIRE_MESH_USE_IMPL(name) \
71 } while (false)
72
76#define PRECICE_REQUIRE_MESH_PROVIDE(name) \
77 do { \
78 PRECICE_REQUIRE_MESH_PROVIDE_IMPL(name) \
79 } while (false)
80
84#define PRECICE_REQUIRE_MESH_MODIFY(name) \
85 do { \
86 PRECICE_REQUIRE_MESH_MODIFY_IMPL(name) \
87 } while (false)
88
89//
90// DATA VALIDATION
91//
92
97#define PRECICE_VALIDATE_DATA_NAME_IMPL(mesh, data) \
98 PRECICE_CHECK(_accessor->hasData(mesh, data), \
99 "The given data \"{}\" is unknown to preCICE mesh \"{}\".{}", data, mesh, _accessor->hintForMeshData(mesh, data));
100
105#define PRECICE_REQUIRE_DATA_READ_IMPL(mesh, data) \
106 PRECICE_VALIDATE_DATA_NAME_IMPL(mesh, data) \
107 PRECICE_CHECK((_accessor->isDataRead(mesh, data)), \
108 "This participant does not use Data \"{0}\", but attempted to read it. " \
109 "Please extend the configuration of participant \"{1}\" by defining <read-data mesh=\"{2}\" name=\"{0}\" />.", \
110 data, _accessorName, mesh);
111
116#define PRECICE_REQUIRE_DATA_WRITE_IMPL(mesh, data) \
117 PRECICE_VALIDATE_DATA_NAME_IMPL(mesh, data) \
118 PRECICE_CHECK((_accessor->isDataWrite(mesh, data)), \
119 "This participant does not use Data \"{0}\", but attempted to write it. " \
120 "Please extend the configuration of participant \"{1}\" by defining <write-data mesh=\"{2}\" name=\"{0}\" />.", \
121 data, _accessorName, mesh);
122
126#define PRECICE_VALIDATE_DATA_NAME(mesh, data) \
127 do { \
128 PRECICE_VALIDATE_DATA_NAME_IMPL(mesh, data) \
129 } while (false)
130
134#define PRECICE_REQUIRE_DATA_READ(mesh, data) \
135 do { \
136 PRECICE_REQUIRE_DATA_READ_IMPL(mesh, data) \
137 } while (false)
138
142#define PRECICE_REQUIRE_DATA_WRITE(mesh, data) \
143 do { \
144 PRECICE_REQUIRE_DATA_WRITE_IMPL(mesh, data) \
145 } while (false)
146
147//
148// DATA VALUE VALIDATION
149//
150#ifdef NDEBUG
151
152#define PRECICE_VALIDATE_DATA(data, size) \
153 { \
154 }
155#else // NDEBUG
156
157#define PRECICE_VALIDATE_DATA(data, size) \
158 PRECICE_CHECK(std::all_of(data, data + size, [](double val) { return std::isfinite(val); }), "One of the given data values is either plus or minus infinity or NaN.");
159
160#endif
161
162#define PRECICE_EXPERIMENTAL_API() \
163 PRECICE_CHECK(_allowsExperimental, "You called the API function \"{}\", which is part of the experimental API. " \
164 "You may unlock the full API by specifying <precice-configuration experimental=\"true\" ... > in the configuration. " \
165 "Please be aware that experimental features may change in any future version (even minor or bugfix).", \
166 __func__)