commit 1b7695ed04152e1775329cb8fb8b4fe4690a689b
parent b975623d49983fc9553a5bda14165ce00c191f86
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Wed, 9 Mar 2022 17:03:25 +0100
Cope with changes in stardis-green.h
Diffstat:
4 files changed, 89 insertions(+), 98 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -56,7 +56,7 @@ configure_file(${GREEN_SOURCE_DIR}/green-version.h.in
###############################################################################
find_package(RCMake 0.4 REQUIRED)
find_package(RSys 0.9 REQUIRED)
-find_package(Stardis 0.8 REQUIRED)
+find_package(stardis-green-types 4 REQUIRED)
find_package(OpenMP 2.0 REQUIRED)
if(MSVC)
find_package(MuslGetopt REQUIRED)
diff --git a/src/green-compute.c b/src/green-compute.c
@@ -96,7 +96,10 @@ check_green_table_variables_use
/* Ambient ID is description_count */
ASSERT(id <= green->header.description_count);
ASSERT(id == green->header.description_count
- || DESC_HOLDS_T(green->descriptions[id].type));
+ || green->descriptions[id].type == GREEN_MAT_SOLID
+ || green->descriptions[id].type == GREEN_MAT_FLUID
+ || green->descriptions[id].type == GREEN_BOUND_H
+ || green->descriptions[id].type == GREEN_BOUND_T);
if(sample->header.at_initial)
green->table[id].initial_T_weight++;
else
@@ -106,14 +109,15 @@ check_green_table_variables_use
const double w = sample->pw_weights[j];
id = sample->pw_ids[j];
ASSERT(id < green->header.description_count);
- ASSERT(DESC_IS_MEDIUM(green->descriptions[id].type));
+ ASSERT(green->descriptions[id].type == GREEN_MAT_SOLID
+ || green->descriptions[id].type == GREEN_MAT_FLUID);
green->table[id].other_weight += w;
}
FOR_EACH(j, 0, sample->header.fx_count) {
const double w = sample->fx_weights[j];
id = sample->fx_ids[j];
ASSERT(id < green->header.description_count);
- ASSERT(DESC_IS_F(green->descriptions[id].type));
+ ASSERT(green->descriptions[id].type == GREEN_BOUND_F);
green->table[id].other_weight += w;
}
}
@@ -173,73 +177,75 @@ build_green_table
FOR_EACH(i, 0, green->header.description_count) {
struct green_description* desc = green->descriptions + i;
- if(DESC_IS_T(desc->type)) {
- MK_VAR("%s.T", desc->d.t_boundary);
- ERR(str_set(&green->table[i].imposed_T_name, buf));
- ASSERT(desc->d.t_boundary.imposed_temperature >= 0);
- green->table[i].imposed_T_value = desc->d.t_boundary.imposed_temperature;
- green->table[i].imposed_T_defined = 1;
- INSERT(i, imposed_T);
- }
- else if(DESC_IS_H(desc->type)) {
- MK_VAR("%s.T", desc->d.h_boundary);
- ERR(str_set(&green->table[i].imposed_T_name, buf));
- ASSERT(desc->d.h_boundary.imposed_temperature >= 0);
- green->table[i].imposed_T_value = desc->d.h_boundary.imposed_temperature;
- green->table[i].imposed_T_defined = 1;
- INSERT(i, imposed_T);
- }
- else if(DESC_IS_F(desc->type)) {
- MK_VAR("%s.F", desc->d.f_boundary);
- ERR(str_set(&green->table[i].other_name, buf));
- green->table[i].other_value = desc->d.f_boundary.imposed_flux;
- green->table[i].other_defined = 1;
- INSERT(i, other);
- }
- else if(desc->type == GREEN_MAT_SOLID) {
- MK_VAR("%s.T", desc->d.solid);
- ERR(str_set(&green->table[i].imposed_T_name, buf));
- green->table[i].imposed_T_value = desc->d.solid.imposed_temperature;
- green->table[i].imposed_T_defined = 1;
- if(green->table[i].imposed_T_value < 0)
- green->table[i].imposed_T_unknown = 1;
- INSERT(i, imposed_T);
- MK_VAR("%s.Tinit", desc->d.solid);
- ERR(str_set(&green->table[i].initial_T_name, buf));
- green->table[i].initial_T_value = desc->d.solid.initial_temperature;
- green->table[i].initial_T_defined = 1;
- if(green->table[i].initial_T_value < 0)
- green->table[i].initial_T_unknown = 1;
- INSERT(i, initial_T);
- MK_VAR("%s.VP", desc->d.solid);
- ERR(str_set(&green->table[i].other_name, buf));
- green->table[i].other_value = desc->d.solid.volumic_power;
- green->table[i].other_defined = 1;
- INSERT(i, other);
- }
- else if(desc->type == GREEN_MAT_FLUID) {
- MK_VAR("%s.T", desc->d.fluid);
- ERR(str_set(&green->table[i].imposed_T_name, buf));
- green->table[i].imposed_T_value = desc->d.fluid.imposed_temperature;
- green->table[i].imposed_T_defined = 1;
- if(green->table[i].imposed_T_value < 0)
- green->table[i].imposed_T_unknown = 1;
- INSERT(i, imposed_T);
- MK_VAR("%s.Tinit", desc->d.fluid);
- ERR(str_set(&green->table[i].initial_T_name, buf));
- green->table[i].initial_T_value = desc->d.fluid.initial_temperature;
- green->table[i].initial_T_defined = 1;
- if(green->table[i].initial_T_value < 0)
- green->table[i].initial_T_unknown = 1;
- INSERT(i, initial_T);
- }
- else if(DESC_IS_CONNECTION(desc->type)) {
- /* No variables here */
- }
- else { /*Corrupted file??? */
- logger_print(green->logger, LOG_ERROR, "Invalid description type.\n");
- res = RES_BAD_ARG;
- goto error;
+ switch(desc->type) {
+ case GREEN_BOUND_T:
+ MK_VAR("%s.T", desc->d.t_boundary);
+ ERR(str_set(&green->table[i].imposed_T_name, buf));
+ ASSERT(desc->d.t_boundary.imposed_temperature >= 0);
+ green->table[i].imposed_T_value = desc->d.t_boundary.imposed_temperature;
+ green->table[i].imposed_T_defined = 1;
+ INSERT(i, imposed_T);
+ break;
+ case GREEN_BOUND_H:
+ MK_VAR("%s.T", desc->d.h_boundary);
+ ERR(str_set(&green->table[i].imposed_T_name, buf));
+ ASSERT(desc->d.h_boundary.imposed_temperature >= 0);
+ green->table[i].imposed_T_value = desc->d.h_boundary.imposed_temperature;
+ green->table[i].imposed_T_defined = 1;
+ INSERT(i, imposed_T);
+ break;
+ case GREEN_BOUND_F:
+ MK_VAR("%s.F", desc->d.f_boundary);
+ ERR(str_set(&green->table[i].other_name, buf));
+ green->table[i].other_value = desc->d.f_boundary.imposed_flux;
+ green->table[i].other_defined = 1;
+ INSERT(i, other);
+ break;
+ case GREEN_MAT_SOLID:
+ MK_VAR("%s.T", desc->d.solid);
+ ERR(str_set(&green->table[i].imposed_T_name, buf));
+ green->table[i].imposed_T_value = desc->d.solid.imposed_temperature;
+ green->table[i].imposed_T_defined = 1;
+ if(green->table[i].imposed_T_value < 0)
+ green->table[i].imposed_T_unknown = 1;
+ INSERT(i, imposed_T);
+ MK_VAR("%s.Tinit", desc->d.solid);
+ ERR(str_set(&green->table[i].initial_T_name, buf));
+ green->table[i].initial_T_value = desc->d.solid.initial_temperature;
+ green->table[i].initial_T_defined = 1;
+ if(green->table[i].initial_T_value < 0)
+ green->table[i].initial_T_unknown = 1;
+ INSERT(i, initial_T);
+ MK_VAR("%s.VP", desc->d.solid);
+ ERR(str_set(&green->table[i].other_name, buf));
+ green->table[i].other_value = desc->d.solid.volumic_power;
+ green->table[i].other_defined = 1;
+ INSERT(i, other);
+ break;
+ case GREEN_MAT_FLUID:
+ MK_VAR("%s.T", desc->d.fluid);
+ ERR(str_set(&green->table[i].imposed_T_name, buf));
+ green->table[i].imposed_T_value = desc->d.fluid.imposed_temperature;
+ green->table[i].imposed_T_defined = 1;
+ if(green->table[i].imposed_T_value < 0)
+ green->table[i].imposed_T_unknown = 1;
+ INSERT(i, imposed_T);
+ MK_VAR("%s.Tinit", desc->d.fluid);
+ ERR(str_set(&green->table[i].initial_T_name, buf));
+ green->table[i].initial_T_value = desc->d.fluid.initial_temperature;
+ green->table[i].initial_T_defined = 1;
+ if(green->table[i].initial_T_value < 0)
+ green->table[i].initial_T_unknown = 1;
+ INSERT(i, initial_T);
+ break;
+ case GREEN_SOLID_SOLID_CONNECT:
+ case GREEN_SOLID_FLUID_CONNECT:
+ /* No variables here */
+ break;
+ default:
+ logger_print(green->logger, LOG_ERROR, "Invalid description type.\n");
+ res = RES_BAD_ARG;
+ goto error;
}
}
/* Ambient ID is description_count */
@@ -290,9 +296,10 @@ green_compute_1
unsigned id = sample->header.sample_end_description_id;
ASSERT(id <= green->header.description_count); /* Ambient ID is description_count */
ASSERT(id == green->header.description_count
- || DESC_IS_T(green->descriptions[id].type)
- || DESC_IS_H(green->descriptions[id].type)
- || DESC_IS_MEDIUM(green->descriptions[id].type));
+ || (green->descriptions[id].type == GREEN_BOUND_T)
+ || (green->descriptions[id].type == GREEN_BOUND_H)
+ || (green->descriptions[id].type == GREEN_MAT_SOLID)
+ || (green->descriptions[id].type == GREEN_MAT_FLUID));
if(sample->header.at_initial) {
ASSERT(green->table[id].initial_T_defined
&& !green->table[id].initial_T_unknown);
@@ -307,7 +314,8 @@ green_compute_1
const double w = sample->pw_weights[j];
id = sample->pw_ids[j];
ASSERT(id < green->header.description_count);
- ASSERT(DESC_IS_MEDIUM(green->descriptions[id].type));
+ ASSERT(green->descriptions[id].type == GREEN_MAT_SOLID
+ || green->descriptions[id].type == GREEN_MAT_FLUID);
ASSERT(green->table[id].other_defined && !green->table[id].other_unknown);
Ti += w * settings[id].other_value;
}
@@ -315,7 +323,7 @@ green_compute_1
const double w = sample->fx_weights[j];
id = sample->fx_ids[j];
ASSERT(id < green->header.description_count);
- ASSERT(DESC_IS_F(green->descriptions[id].type));
+ ASSERT(green->descriptions[id].type == GREEN_BOUND_F);
ASSERT(green->table[id].other_defined && !green->table[id].other_unknown);
Ti += w * settings[id].other_value;
}
diff --git a/src/green-output.c b/src/green-output.c
@@ -405,7 +405,7 @@ dump_green_info
FOR_EACH(i, 0, green->header.description_count) {
const struct green_description* desc = green->descriptions + i;
const struct green_t_boundary* bd;
- if(desc->type != GREEN_BOUND_T_FOR_SOLID) continue;
+ if(desc->type != GREEN_BOUND_T) continue;
if(!local_count) {
fprintf(stream, "<h2>T boundaries for solids</h2>\n");
fprintf(stream, "<table>\n");
@@ -429,7 +429,7 @@ dump_green_info
FOR_EACH(i, 0, green->header.description_count) {
const struct green_description* desc = green->descriptions + i;
const struct green_h_boundary* bd;
- if(desc->type != GREEN_BOUND_H_FOR_SOLID) continue;
+ if(desc->type != GREEN_BOUND_H) continue;
if(!local_count) {
fprintf(stream, "<h2>H boundaries for solids</h2>\n");
fprintf(stream, "<table>\n");
@@ -458,7 +458,7 @@ dump_green_info
FOR_EACH(i, 0, green->header.description_count) {
const struct green_description* desc = green->descriptions + i;
const struct green_h_boundary* bd;
- if(desc->type != GREEN_BOUND_H_FOR_FLUID) continue;
+ if(desc->type != GREEN_BOUND_H) continue;
if(!local_count) {
fprintf(stream, "<h2>H boundaries for fluids</h2>\n");
fprintf(stream, "<table>\n");
@@ -488,7 +488,7 @@ dump_green_info
FOR_EACH(i, 0, green->header.description_count) {
const struct green_description* desc = green->descriptions + i;
const struct green_f_boundary* bd;
- if(desc->type != GREEN_BOUND_F_FOR_SOLID) continue;
+ if(desc->type != GREEN_BOUND_F) continue;
if(!local_count) {
fprintf(stream, "<h2>F boundaries for solids</h2>\n");
fprintf(stream, "<table>\n");
diff --git a/src/green-types.h b/src/green-types.h
@@ -22,7 +22,7 @@
#include <rsys/dynamic_array.h>
#include <rsys/dynamic_array_char.h>
#include <rsys/dynamic_array_str.h>
-#include <stardis-green.h>
+#include <stardis/stardis-green-types.h>
#include <string.h>
#include <omp.h>
@@ -298,21 +298,4 @@ green_read_settings
(struct green* green,
const char* in_name);
-#define DESC_IS_MEDIUM(D) \
- ((D) == GREEN_MAT_SOLID || (D) == GREEN_MAT_FLUID)
-#define DESC_IS_H(D) \
- ((D) == GREEN_BOUND_H_FOR_SOLID || (D) == GREEN_BOUND_H_FOR_FLUID)
-#define DESC_IS_T(D) \
- ((D) == GREEN_BOUND_T_FOR_SOLID)
-#define DESC_IS_F(D) \
- ((D) == GREEN_BOUND_F_FOR_SOLID)
-#define DESC_IS_SF(D) \
- ((D) == GREEN_SOLID_FLUID_CONNECT)
-#define DESC_IS_SS(D) \
- ((D) == GREEN_SOLID_SOLID_CONNECT)
-#define DESC_IS_CONNECTION(D) \
- (DESC_IS_SS(D) || DESC_IS_SF(D))
-#define DESC_HOLDS_T(D) \
- (DESC_IS_MEDIUM(D) || DESC_IS_H(D) || DESC_IS_T(D))
-
#endif /* GREEN_TYPES_H */