preprocessor now filters debug output

This commit is contained in:
2025-05-28 15:27:00 +02:00
parent e2167fb75b
commit f510d0a39a
39 changed files with 375 additions and 14 deletions
+20
View File
@@ -11,14 +11,20 @@ namespace generator {
std::function<double(double)> function1D(json_t* object) {
if (json_object_by_path(object, {"Constant"})) {
#ifdef debug_level2
DEBUG_LEVEL_2("Creating function1d: constant.");
#endif
double constant =
json_double(json_object_by_path(object, {"Constant", "constant"}));
#ifdef debug_level3
DEBUG_LEVEL_3("with constant: " + std::to_string(constant));
#endif
return D1ToD1::Constant(constant);
} else if (json_object_by_path(object, {"PiecewiseLinear"})) {
#ifdef debug_level2
DEBUG_LEVEL_2("Creating function1d: PiecewiseLinear.");
#endif
std::vector<double> x_values = json_vector(
json_object_by_path(object, {"PiecewiseLinear", {"xValues"}}));
std::vector<double> y_values = json_vector(
@@ -31,11 +37,15 @@ std::function<double(double)> function1D(json_t* object) {
return D1ToD1::PiecewiseLinear(x_values, y_values);
} else if (json_object_by_path(object, {"PiecewiseLinearFromFile"})) {
#ifdef debug_level2
DEBUG_LEVEL_2("Creating function1d: PiecewiseLinear from file.");
#endif
std::string absolute_filename = readAbsoluteFilename(
json_object_by_path(object, {"PiecewiseLinearFromFile", "PathToH5"}));
#ifdef debug_level3
DEBUG_LEVEL_3("with filename: " + absolute_filename);
#endif
Hdf5Reader reader(absolute_filename);
std::string x_values_key = json_string(
@@ -53,7 +63,9 @@ std::function<double(double)> function1D(json_t* object) {
double prefactor = json_double(json_object_by_path(
object, {"PiecewiseLinearFromFile", {"prefactor"}}));
#ifdef debug_level3
DEBUG_LEVEL_3("with prefactor: " + std::to_string(prefactor));
#endif
for (int i = 0; i < y_values.size(); ++i) {
y_values[i] = y_values[i] * prefactor;
@@ -61,7 +73,9 @@ std::function<double(double)> function1D(json_t* object) {
return D1ToD1::PiecewiseLinear(x_values, y_values);
} else if (json_object_by_path(object, {"Product"})) {
#ifdef debug_level2
DEBUG_LEVEL_2("Creating function1d: Product.");
#endif
json_t* function_array = json_object_by_path(object, {"Product"});
std::vector<std::function<double(double)>> functions;
size_t index;
@@ -72,7 +86,9 @@ std::function<double(double)> function1D(json_t* object) {
return D1ToD1::Product(functions);
} else if (json_object_by_path(object, {"Exponential"})) {
#ifdef debug_level2
DEBUG_LEVEL_2("Creating function1d: Exponential.");
#endif
double prefactor = json_double(json_object_by_path(
object, {"Exponential", {"prefactor"}}));
double scale = json_double(json_object_by_path(
@@ -86,12 +102,16 @@ std::function<double(double)> function1D(json_t* object) {
std::function<double(double, double, double)> function3D(json_t* object) {
if (json_object_by_path(object, {"Constant3D"})) {
#ifdef debug_level2
DEBUG_LEVEL_2("Creating function3d: Constant3D.");
#endif
double constant =
json_double(json_object_by_path(object, {"Constant3D", "constant"}));
return D3ToD1::Constant(constant);
} else if (json_object_by_path(object, {"Product"})) {
#ifdef debug_level2
DEBUG_LEVEL_2("Creating function3d: Product.");
#endif
std::function<double(double)> fi =
function1D(json_object_by_path(object, {"Product", "fi"}));
std::function<double(double)> fj =