commit 58ad56309088d1ea5b0572f874e58e65ec041c01
parent ea0cd087cef266cffc5eaa2af1cd5b4fb419e83d
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 27 Jan 2025 17:06:34 +0100
Create stardis description for mode 1 buildings
Diffstat:
3 files changed, 166 insertions(+), 14 deletions(-)
diff --git a/src/cg_city.c b/src/cg_city.c
@@ -446,19 +446,27 @@ create_city
res = RES_IO_ERR;
goto error;
}
- fprintf(city->set_vars,
- "#!/bin/sh\n"
- "\n"
- GENERIC_WALL_VARS
- GENERIC_FLOOR_VARS
- GENERIC_ROOF_VARS
- GENERIC_GROUND_VARS
- GENERIC_CAVITY_VARS
- GENERIC_SFC_VARS
- GENERIC_B_WALL_VARS
- GENERIC_B_ROOF_VARS
- GENERIC_B_GROUND_VARS
- );
+ fprintf(city->set_vars, "#!/bin/sh\n\n");
+ fprintf(city->set_vars, GENERIC_INTERNAL_INSULATION_VARS);
+ fprintf(city->set_vars, GENERIC_GROUND_VARS);
+ fprintf(city->set_vars, GENERIC_B_GROUND_VARS);
+ fprintf(city->set_vars, GENERIC_WALL_VARS);
+ fprintf(city->set_vars, GENERIC_FLOOR_VARS);
+ fprintf(city->set_vars, GENERIC_INTERMEDIATE_FLOOR_VARS);
+ fprintf(city->set_vars, GENERIC_ROOF_VARS);
+ fprintf(city->set_vars, GENERIC_FOUNDATION_VARS);
+ fprintf(city->set_vars, GENERIC_INTERNAL_INSULATION_VARS);
+ fprintf(city->set_vars, GENERIC_EXTERNAL_INSULATION_VARS);
+ fprintf(city->set_vars, GENERIC_ROOF_INSULATION_VARS);
+ fprintf(city->set_vars, GENERIC_FLOOR_INSULATION_VARS);
+ fprintf(city->set_vars, GENERIC_GLAZING_VARS);
+ fprintf(city->set_vars, GENERIC_CAVITY_VARS);
+ fprintf(city->set_vars, GENERIC_ATTIC_CAVITY_VARS);
+ fprintf(city->set_vars, GENERIC_HABITABLE_CAVITY_VARS);
+ fprintf(city->set_vars, GENERIC_CRAWLSPACE_CAVITY_VARS);
+ fprintf(city->set_vars, GENERIC_SFC_VARS);
+ fprintf(city->set_vars, GENERIC_B_WALL_VARS);
+ fprintf(city->set_vars, GENERIC_B_ROOF_VARS);
ground_init(allocator, &city->ground);
ERR(vertex_denoiser_create(allocator, pow(10, -(CLIPPER_PRECISON+2)),
diff --git a/src/cg_construction_mode_1.c b/src/cg_construction_mode_1.c
@@ -27,6 +27,7 @@
#include "cg_construction_mode.h"
#include "cg_construction_mode_1.h"
#include "cg_vertex_denoiser.h"
+#include "cg_stardis_model.h"
#include <rsys/rsys.h>
#include <rsys/str.h>
@@ -1894,16 +1895,39 @@ export_stl_cmode_1
struct scad_geometry** list = NULL;
struct mem_allocator* allocator = NULL;
struct city* city;
+ struct building* building;
struct vertex_denoiser* denoiser;
+ FILE* model = NULL;
+ FILE* vars = NULL;
+ fpos_t model_pos, vars_pos;
+ long model_count = 0;
+ const char* n;
+ static int fst = 1;
if(!cad) {
res = RES_BAD_ARG;
goto error;
}
- city = data_cad->building->city;
+ building = data_cad->building;
+ city = building->city;
allocator = city->allocator;
denoiser = city->denoiser;
+ model = city->stardis_model;
+ vars = city->set_vars;
+
+ if(!fst) fprintf(model, "\n");
+ fst = 0;
+ fprintf(model,
+ "# Building '%s' construction mode 1, dataset '%s', %g m tall\n",
+ str_cget(&building->name), str_cget(&building->dataset_name),
+ building->total_height);
+ fgetpos(model, &model_pos);
+ fprintf(vars,
+ "\n# Building '%s' construction mode 1, dataset '%s', %g m tall\n",
+ str_cget(&building->name), str_cget(&building->dataset_name),
+ building->total_height);
+ fgetpos(vars, &vars_pos);
if(darray_geometries_size_get(&data_cad->adj_walls) == 0) {
/* wall export */
@@ -1971,64 +1995,92 @@ export_stl_cmode_1
binary));
}
+ STARDIS_SOLID(wall);
+
+ if(data_cad->external_insulation) {
+ STARDIS_SOLID(external_insulation);
+ }
+
/* floor export */
ERR(stl_export_denoised_geometry(denoiser, data_cad->floor,
Scad_force_normals_outward, binary));
+ STARDIS_SOLID(floor);
+
/* roof export */
ERR(stl_export_denoised_geometry(denoiser, data_cad->roof,
Scad_force_normals_outward, binary));
+ STARDIS_SOLID(roof);
+
/* foundation export */
if(data_cad->foundation) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->foundation,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(foundation);
}
/* glass export */
if(data_cad->glazing) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->glazing,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(glazing);
}
/* intermediate floor export*/
if(data_cad->intermediate_floor) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->intermediate_floor,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(intermediate_floor);
}
/* internal insulation export*/
if(data_cad->internal_insulation) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->internal_insulation,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(internal_insulation);
}
/* roof insulation export*/
if(data_cad->roof_insulation) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->roof_insulation,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(roof_insulation);
}
/* floor insulation export*/
if(data_cad->floor_insulation) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->floor_insulation,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(floor_insulation);
}
/* attic cavity export*/
if(data_cad->attic_cavity) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->attic_cavity,
Scad_force_normals_outward, binary));
+
+ STARDIS_FLUID(attic_cavity);
}
/* habitable cavity export*/
ERR(stl_export_denoised_geometry(denoiser, data_cad->habitable_cavity,
Scad_force_normals_outward, binary));
+ STARDIS_FLUID(habitable_cavity);
+
/* crawlspace cavity export*/
if(data_cad->crawlspace_cavity) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->crawlspace_cavity,
Scad_force_normals_outward, binary));
+
+ STARDIS_FLUID(crawlspace_cavity);
}
/* boundary export*/
@@ -2036,6 +2088,9 @@ export_stl_cmode_1
struct scad_geometry* b = darray_geometries_data_get(&data_cad->boundary)[i];
ERR(stl_export_denoised_geometry(denoiser, b, Scad_keep_normals_unchanged,
binary));
+
+ ERR(scad_geometry_get_name(b, &n));
+ STARDIS_H_BOUND_2(SFC, n);
}
/* connections export*/
@@ -2043,12 +2098,18 @@ export_stl_cmode_1
struct scad_geometry* c = darray_geometries_data_get(&data_cad->connection)[i];
ERR(stl_export_denoised_geometry(denoiser, c, Scad_keep_normals_unchanged,
binary));
+
+ ERR(scad_geometry_get_name(c, &n));
+ STARDIS_SFC_2(SFC, n);
}
/* ground/building connection export*/
ERR(stl_export_denoised_geometry(denoiser, data_cad->ground_connection,
Scad_keep_normals_unchanged, binary));
+ /* No need to describe solid-solid connections until there is a contact
+ * resistance */
+
exit:
for(j = 0; j < common_n; j++) {
if(list[j]) SCAD(geometry_ref_put(list[j]));
@@ -2065,6 +2126,19 @@ error:
"Internal error '"__FILE__"': creating STL for building '%s'.\n",
str_cget(&data_cad->building->name));
}
+ /* Reset stardis model file */
+ if(model) {
+ long l;
+ fsetpos(model, &model_pos);
+ for(l = 0; l < model_count; l += 40)
+ fprintf(model, " \n");
+ fprintf(model, "# Building '%s' construction cancelled\n",
+ str_cget(&building->name));
+ }
+ if(vars) {
+ fprintf(vars, "# Building '%s' construction cancelled\n",
+ str_cget(&building->name));
+ }
goto exit;
}
diff --git a/src/cg_stardis_model.h b/src/cg_stardis_model.h
@@ -222,6 +222,16 @@
"export floor_T_IMPOSED=UNKNOWN\n" \
"export floor_POWER=0\n"
+#define GENERIC_INTERMEDIATE_FLOOR_VARS \
+ "# Generic INTERMEDIATE FLOOR properties.\n" \
+ "export intermediate_floor_LAMBDA=1.5\n" \
+ "export intermediate_floor_RHO=2300\n" \
+ "export intermediate_floor_CP=2500\n" \
+ "export intermediate_floor_DELTA=AUTO\n" \
+ "export intermediate_floor_TINIT=273\n" \
+ "export intermediate_floor_T_IMPOSED=UNKNOWN\n" \
+ "export intermediate_floor_POWER=0\n"
+
#define GENERIC_ROOF_VARS \
"# Generic ROOF properties.\n" \
"export roof_LAMBDA=1.5\n" \
@@ -232,6 +242,66 @@
"export roof_T_IMPOSED=UNKNOWN\n" \
"export roof_POWER=0\n"
+#define GENERIC_FOUNDATION_VARS \
+ "# Generic FOUNDATION properties.\n" \
+ "export foundation_LAMBDA=1.5\n" \
+ "export foundation_RHO=2300\n" \
+ "export foundation_CP=2500\n" \
+ "export foundation_DELTA=AUTO\n" \
+ "export foundation_TINIT=273\n" \
+ "export foundation_T_IMPOSED=UNKNOWN\n" \
+ "export foundation_POWER=0\n"
+
+#define GENERIC_GLAZING_VARS \
+ "# Generic GLAZING properties.\n" \
+ "export glazing_LAMBDA=1\n" \
+ "export glazing_RHO=2500\n" \
+ "export glazing_CP=720\n" \
+ "export glazing_DELTA=AUTO\n" \
+ "export glazing_TINIT=273\n" \
+ "export glazing_T_IMPOSED=UNKNOWN\n" \
+ "export glazing_POWER=0\n"
+
+#define GENERIC_INTERNAL_INSULATION_VARS \
+ "# Generic INTERNAL INSULATION properties.\n" \
+ "export internal_insulation_LAMBDA=0.05\n" \
+ "export internal_insulation_RHO=18\n" \
+ "export internal_insulation_CP=1000\n" \
+ "export internal_insulation_DELTA=AUTO\n" \
+ "export internal_insulation_TINIT=273\n" \
+ "export internal_insulation_T_IMPOSED=UNKNOWN\n" \
+ "export internal_insulation_POWER=0\n"
+
+#define GENERIC_EXTERNAL_INSULATION_VARS \
+ "# Generic EXTERNAL INSULATION properties.\n" \
+ "export external_insulation_LAMBDA=0.05\n" \
+ "export external_insulation_RHO=18\n" \
+ "export external_insulation_CP=1000\n" \
+ "export external_insulation_DELTA=AUTO\n" \
+ "export external_insulation_TINIT=273\n" \
+ "export external_insulation_T_IMPOSED=UNKNOWN\n" \
+ "export external_insulation_POWER=0\n"
+
+#define GENERIC_ROOF_INSULATION_VARS \
+ "# Generic ROOF INSULATION properties.\n" \
+ "export roof_insulation_LAMBDA=0.05\n" \
+ "export roof_insulation_RHO=18\n" \
+ "export roof_insulation_CP=1000\n" \
+ "export roof_insulation_DELTA=AUTO\n" \
+ "export roof_insulation_TINIT=273\n" \
+ "export roof_insulation_T_IMPOSED=UNKNOWN\n" \
+ "export roof_insulation_POWER=0\n"
+
+#define GENERIC_FLOOR_INSULATION_VARS \
+ "# Generic FLOOR INSULATION properties.\n" \
+ "export floor_insulation_LAMBDA=0.05\n" \
+ "export floor_insulation_RHO=18\n" \
+ "export floor_insulation_CP=1000\n" \
+ "export floor_insulation_DELTA=AUTO\n" \
+ "export floor_insulation_TINIT=273\n" \
+ "export floor_insulation_T_IMPOSED=UNKNOWN\n" \
+ "export floor_insulation_POWER=0\n"
+
#define GENERIC_CAVITY_VARS \
"# Generic FLUID CAVITY properties.\n" \
"export cavity_RHO=1.25\n" \