commit bba8d9e38b87722c9264c15ae75377ba030f8402
parent d2b920a1e8fa81d12c68d5bc9b209a513c8e869a
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 10 Jan 2022 18:37:12 +0100
Further splitting too large files
Diffstat:
28 files changed, 964 insertions(+), 606 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -124,16 +124,21 @@ set(SDIS_FILES_SRC
stardis-description.c
stardis-fluid.c
stardis-fluid-prog.c
+ stardis-fbound.c
stardis-fbound-prog.c
+ stardis-hbound.c
stardis-hbound-prog.c
stardis-intface.c
stardis-main.c
stardis-output.c
stardis-parsing.c
+ stardis-sfconnect.c
stardis-sfconnect-prog.c
+ stardis-ssconnect.c
stardis-ssconnect-prog.c
stardis-solid.c
stardis-solid-prog.c
+ stardis-tbound.c
stardis-tbound-prog.c)
set(SDIS_FILES_INC_API
@@ -147,15 +152,20 @@ set(SDIS_FILES_INC
stardis-default.h.in
stardis-fluid.h
stardis-fluid-prog.h
+ stardis-fbound.h
stardis-fbound-prog.h
+ stardis-hbound.h
stardis-hbound-prog.h
stardis-intface.h
stardis-output.h
stardis-parsing.h
+ stardis-sfconnect.h
stardis-sfconnect-prog.h
+ stardis-ssconnect.h
stardis-ssconnect-prog.h
stardis-solid.h
stardis-solid-prog.h
+ stardis-tbound.h
stardis-tbound-prog.h
stardis-version.h.in)
diff --git a/src/stardis-app.c b/src/stardis-app.c
@@ -14,19 +14,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "stardis-app.h"
+#include "stardis-args.h"
#include "stardis-description.h"
-#include "stardis-output.h"
+#include "stardis-default.h"
+#include "stardis-parsing.h"
#include "stardis-compute.h"
#include "stardis-intface.h"
-#include "stardis-fluid.h"
#include "stardis-solid.h"
+#include "stardis-fluid.h"
#include <star/senc3d.h>
#include <star/sg3d_sencXd_helper.h>
#include <star/sg3d_sdisXd_helper.h>
#include <rsys/str.h>
-#include <rsys/text_reader.h>
#include <rsys/logger.h>
#include <rsys/double2.h>
#include <rsys/double3.h>
@@ -39,64 +40,6 @@ static const struct counts COUNTS_NULL = COUNTS_NULL__;
/*******************************************************************************
* Local Functions
******************************************************************************/
-static res_T
-read_model
- (const struct darray_str* model_files,
- struct stardis* stardis)
-{
- res_T res = RES_OK;
- const struct str* files = NULL;
- size_t i;
- FILE* f = NULL;
- struct txtrdr* txtrdr = NULL;
-
- ASSERT(model_files && stardis);
- files = darray_str_cdata_get(model_files);
- FOR_EACH(i, 0, darray_str_size_get(model_files)) {
- const char* name = str_cget(files + i);
- f = fopen(name, "r");
- if(!f) {
- logger_print(stardis->logger, LOG_ERROR,
- "Cannot open model file '%s'\n",
- name);
- res = RES_IO_ERR;
- goto error;
- }
- txtrdr_stream(stardis->allocator, f, name, '#', &txtrdr);
- for(;;) {
- char* line;
- ERR(txtrdr_read_line(txtrdr));
- line = txtrdr_get_line(txtrdr);
- if(!line) break;
- ERR(process_model_line(name, line, stardis));
- }
- txtrdr_ref_put(txtrdr);
- txtrdr = NULL;
- fclose(f);
- f = NULL;
- }
- if(stardis->scale_factor <= 0)
- stardis->scale_factor = STARDIS_DEFAULT_SCALE_FACTOR;
- logger_print(stardis->logger, LOG_OUTPUT,
- "Scaling factor is %g\n", stardis->scale_factor);
- logger_print(stardis->logger, LOG_OUTPUT,
- "Trad is %g, Trad reference is %g\n", stardis->trad, stardis->trad_ref);
- stardis->t_range[0] = MMIN(stardis->t_range[0], stardis->trad_ref);
- stardis->t_range[1] = MMAX(stardis->t_range[1], stardis->trad_ref);
- logger_print(stardis->logger, LOG_OUTPUT,
- "System T range is [%g %g]\n", SPLIT2(stardis->t_range));
- logger_print(stardis->logger, LOG_OUTPUT,
- "Picard order is %u\n", stardis->picard_order);
-
- ASSERT(!f && !txtrdr);
-exit:
- return res;
-error:
- if(f) fclose(f);
- if(txtrdr) txtrdr_ref_put(txtrdr);
- goto exit;
-}
-
static struct sdis_interface*
geometry_get_interface
(const size_t itri, void* ctx)
@@ -465,6 +408,14 @@ stardis_release
}
}
+unsigned
+allocate_stardis_medium_id
+ (struct stardis* stardis)
+{
+ ASSERT(stardis);
+ return stardis->next_medium_id++;
+}
+
res_T
init_enclosures
(struct stardis* stardis)
@@ -642,3 +593,109 @@ end:
}
#undef COUNT_SIDE
+
+res_T
+init_geometry
+ (struct logger* logger,
+ struct mem_allocator* allocator,
+ const int verbose,
+ struct geometry* geom)
+{
+ res_T res = RES_OK;
+ struct sg3d_device* sg3d_dev = NULL;
+
+ ASSERT(allocator && geom);
+
+ geom->sg3d = NULL;
+ darray_interface_ptrs_init(allocator, &geom->interfaces);
+ darray_interface_ptrs_init(allocator, &geom->interf_bytrg);
+ ERR(sg3d_device_create(logger, allocator, verbose, &sg3d_dev));
+ ERR(sg3d_geometry_create(sg3d_dev, &geom->sg3d));
+
+exit:
+ if(sg3d_dev) SG3D(device_ref_put(sg3d_dev));
+ return res;
+error:
+ release_geometry(geom);
+ goto exit;
+}
+
+void
+release_geometry
+ (struct geometry* geom)
+{
+ size_t i;
+ struct sdis_interface
+ ** intf = darray_interface_ptrs_data_get(&geom->interfaces);
+ if(geom->sg3d) SG3D(geometry_ref_put(geom->sg3d));
+ for(i = 0; i < darray_interface_ptrs_size_get(&geom->interfaces); ++i)
+ SDIS(interface_ref_put(intf[i]));
+ darray_interface_ptrs_release(&geom->interfaces);
+ darray_interface_ptrs_release(&geom->interf_bytrg);
+}
+
+void
+init_camera
+ (struct mem_allocator* alloc, struct camera* cam)
+{
+ ASSERT(alloc && cam);
+ d3(cam->pos, STARDIS_DEFAULT_RENDERING_POS);
+ d3(cam->tgt, STARDIS_DEFAULT_RENDERING_TGT);
+ d3(cam->up, STARDIS_DEFAULT_RENDERING_UP);
+ cam->fmt = STARDIS_DEFAULT_RENDERING_OUTPUT_FILE_FMT;
+ cam->fov = STARDIS_DEFAULT_RENDERING_FOV;
+ cam->spp = STARDIS_DEFAULT_RENDERING_SPP;
+ cam->img_width = STARDIS_DEFAULT_RENDERING_IMG_WIDTH;
+ cam->img_height = STARDIS_DEFAULT_RENDERING_IMG_HEIGHT;
+ d2(cam->time_range, STARDIS_DEFAULT_RENDERING_TIME);
+ cam->auto_look_at = 1;
+ str_init(alloc, &cam->file_name);
+}
+
+void
+release_camera
+ (struct camera* cam)
+{
+ ASSERT(cam);
+ str_release(&cam->file_name);
+}
+
+void
+log_err_fn
+ (const char* msg, void* ctx)
+{
+ ASSERT(msg);
+ (void)ctx;
+#ifdef OS_WINDOWS
+ fprintf(stderr, "error: %s", msg);
+#else
+ fprintf(stderr, "\x1b[31merror:\x1b[0m %s", msg);
+#endif
+}
+
+void
+log_warn_fn
+ (const char* msg, void* ctx)
+{
+ ASSERT(msg);
+ (void)ctx;
+#ifdef OS_WINDOWS
+ fprintf(stderr, "warning: %s", msg);
+#else
+ fprintf(stderr, "\x1b[33mwarning:\x1b[0m %s", msg);
+#endif
+}
+
+void
+log_prt_fn
+ (const char* msg, void* ctx)
+{
+ ASSERT(msg);
+ (void)ctx;
+#ifdef OS_WINDOWS
+ fprintf(stderr, "message: %s", msg);
+#else
+ fprintf(stderr, "\x1b[32moutput:\x1b[0m %s", msg);
+#endif
+}
+
diff --git a/src/stardis-app.h b/src/stardis-app.h
@@ -16,54 +16,37 @@
#ifndef STARDIS_APP_H
#define STARDIS_APP_H
-#include "stardis-args.h"
#include "stardis-description.h"
-#include "stardis-parsing.h"
-#include "stardis-default.h"
-#include "stardis-solid.h"
-#include "stardis-fluid.h"
-#include "stardis-prog.h"
-#include <star/sstl.h>
#include <star/sg3d.h>
#include <rsys/rsys.h>
-#include <rsys/float3.h>
#include <rsys/double2.h>
#include <rsys/double3.h>
#include <rsys/dynamic_array_size_t.h>
+#include <rsys/dynamic_array_uint.h>
#include <rsys/dynamic_array.h>
#include <rsys/str.h>
#include <sdis.h>
-#include <limits.h>
-#include <stdarg.h>
-
/* Forward declarations */
struct logger;
struct mem_allocator;
struct sdis_medium;
+struct args;
+struct solid;
+struct fluid;
+
/* Utility macros */
#define ERR(Expr) if((res = (Expr)) != RES_OK) goto error; else (void)0
-#define STR_APPEND_PRINTF(Accum, Fmt, Args) \
-{ \
- struct str tmp; \
- str_init((Accum)->allocator, &tmp); \
- res = str_printf(&tmp, Fmt COMMA_##Args LIST_##Args); \
- if(res == RES_OK) res = str_append((Accum), str_cget(&tmp)); \
- str_release(&tmp); \
- if(res != RES_OK) goto error; \
-} (void)0
-
-
-#define VFATAL(Fmt, Args) \
- { \
- fprintf(stderr, Fmt COMMA_##Args LIST_##Args); \
- ASSERT(0); \
- abort(); \
+#define VFATAL(Fmt, Args) \
+ { \
+ fprintf(stderr, Fmt COMMA_##Args LIST_##Args); \
+ ASSERT(0); \
+ abort(); \
} (void)0
@@ -133,44 +116,16 @@ struct geometry {
struct darray_interface_ptrs interfaces;
};
-static INLINE void
-release_geometry(struct geometry* geom)
-{
- size_t i;
- struct sdis_interface
- ** intf = darray_interface_ptrs_data_get(&geom->interfaces);
- if(geom->sg3d) SG3D(geometry_ref_put(geom->sg3d));
- for(i = 0; i < darray_interface_ptrs_size_get(&geom->interfaces); ++i)
- SDIS(interface_ref_put(intf[i]));
- darray_interface_ptrs_release(&geom->interfaces);
- darray_interface_ptrs_release(&geom->interf_bytrg);
-}
+void
+release_geometry
+ (struct geometry* geom);
-static INLINE res_T
+res_T
init_geometry
(struct logger* logger,
struct mem_allocator* allocator,
const int verbose,
- struct geometry* geom)
-{
- res_T res = RES_OK;
- struct sg3d_device* sg3d_dev = NULL;
-
- ASSERT(allocator && geom);
-
- geom->sg3d = NULL;
- darray_interface_ptrs_init(allocator, &geom->interfaces);
- darray_interface_ptrs_init(allocator, &geom->interf_bytrg);
- ERR(sg3d_device_create(logger, allocator, verbose, &sg3d_dev));
- ERR(sg3d_geometry_create(sg3d_dev, &geom->sg3d));
-
-exit:
- if(sg3d_dev) SG3D(device_ref_put(sg3d_dev));
- return res;
-error:
- release_geometry(geom);
- goto exit;
-}
+ struct geometry* geom);
/******************************************************************************/
enum stardis_output_fmt {
@@ -191,63 +146,21 @@ struct camera {
struct str file_name;
};
-static INLINE void
-init_camera(struct mem_allocator* alloc, struct camera* cam) {
- ASSERT(alloc && cam);
- d3(cam->pos, STARDIS_DEFAULT_RENDERING_POS);
- d3(cam->tgt, STARDIS_DEFAULT_RENDERING_TGT);
- d3(cam->up, STARDIS_DEFAULT_RENDERING_UP);
- cam->fmt = STARDIS_DEFAULT_RENDERING_OUTPUT_FILE_FMT;
- cam->fov = STARDIS_DEFAULT_RENDERING_FOV;
- cam->spp = STARDIS_DEFAULT_RENDERING_SPP;
- cam->img_width = STARDIS_DEFAULT_RENDERING_IMG_WIDTH;
- cam->img_height = STARDIS_DEFAULT_RENDERING_IMG_HEIGHT;
- d2(cam->time_range, STARDIS_DEFAULT_RENDERING_TIME);
- cam->auto_look_at = 1;
- str_init(alloc, &cam->file_name);
-}
+void
+init_camera
+ (struct mem_allocator* alloc, struct camera* cam);
-static INLINE void
-release_camera(struct camera* cam) {
- ASSERT(cam);
- str_release(&cam->file_name);
-}
+void
+release_camera(struct camera* cam);
-static INLINE void
-log_err_fn(const char* msg, void* ctx)
-{
- ASSERT(msg);
- (void)ctx;
-#ifdef OS_WINDOWS
- fprintf(stderr, "error: %s", msg);
-#else
- fprintf(stderr, "\x1b[31merror:\x1b[0m %s", msg);
-#endif
-}
+void
+log_err_fn(const char* msg, void* ctx);
-static INLINE void
-log_warn_fn(const char* msg, void* ctx)
-{
- ASSERT(msg);
- (void)ctx;
-#ifdef OS_WINDOWS
- fprintf(stderr, "warning: %s", msg);
-#else
- fprintf(stderr, "\x1b[33mwarning:\x1b[0m %s", msg);
-#endif
-}
+void
+log_warn_fn(const char* msg, void* ctx);
-static INLINE void
-log_prt_fn(const char* msg, void* ctx)
-{
- ASSERT(msg);
- (void)ctx;
-#ifdef OS_WINDOWS
- fprintf(stderr, "message: %s", msg);
-#else
- fprintf(stderr, "\x1b[32moutput:\x1b[0m %s", msg);
-#endif
-}
+void
+log_prt_fn(const char* msg, void* ctx);
struct counts {
unsigned smed_count, fmed_count, tbound_count, hbound_count,
@@ -315,12 +228,9 @@ struct stardis {
int verbose;
};
-static INLINE unsigned
-allocate_stardis_medium_id(struct stardis* stardis)
-{
- ASSERT(stardis);
- return stardis->next_medium_id++;
-}
+unsigned
+allocate_stardis_medium_id
+ (struct stardis* stardis);
res_T
stardis_init
diff --git a/src/stardis-args.c b/src/stardis-args.c
@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define _POSIX_C_SOURCE 200809L /* strdup */
+#include "stardis-args.h"
#include "stardis-parsing.h"
#include "stardis-app.h"
#include "stardis-default.h"
diff --git a/src/stardis-args.h b/src/stardis-args.h
@@ -25,7 +25,6 @@ struct camera;
struct logger;
struct mem_allocator;
struct stardis;
-struct dummies;
enum stardis_mode {
/* Ordered so that print_multiple_modes() prints in alphabetical order */
diff --git a/src/stardis-compute.c b/src/stardis-compute.c
@@ -14,13 +14,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "stardis-app.h"
+#include "stardis-args.h"
#include "stardis-description.h"
#include "stardis-output.h"
#include "stardis-compute.h"
+#include "stardis-parsing.h"
+#include "stardis-default.h"
#include "stardis-fluid.h"
#include "stardis-fluid-prog.h"
#include "stardis-solid.h"
#include "stardis-solid-prog.h"
+#include "stardis-sfconnect.h"
+#include "stardis-ssconnect.h"
#include <sdis.h>
#include <sdis_version.h>
diff --git a/src/stardis-description.c b/src/stardis-description.c
@@ -13,16 +13,22 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "stardis-app.h"
#include "stardis-description.h"
#include "stardis-prog.h"
#include "stardis-solid.h"
#include "stardis-solid-prog.h"
#include "stardis-fluid.h"
#include "stardis-fluid-prog.h"
+#include "stardis-hbound.h"
#include "stardis-hbound-prog.h"
+#include "stardis-tbound.h"
#include "stardis-tbound-prog.h"
+#include "stardis-fbound.h"
#include "stardis-fbound-prog.h"
+#include "stardis-sfconnect.h"
#include "stardis-sfconnect-prog.h"
+#include "stardis-ssconnect.h"
#include "stardis-ssconnect-prog.h"
#include <rsys/rsys.h>
@@ -33,271 +39,6 @@
#include <limits.h>
-/* Utility macros */
-#define ERR(Expr) if((res = (Expr)) != RES_OK) goto error; else (void)0
-
-res_T
-init_h
- (struct mem_allocator* allocator,
- struct h_boundary** dst)
-{
- res_T res = RES_OK;
- int str_initialized = 0;
- ASSERT(allocator && dst && *dst == NULL);
- *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
- if(! *dst) {
- res = RES_MEM_ERR;
- goto error;
- }
- str_init(allocator, &(*dst)->name);
- str_initialized = 1;
- (*dst)->imposed_temperature = -1;
- (*dst)->mat_id = UINT_MAX;
-end:
- return res;
-error:
- if(str_initialized) str_release(&(*dst)->name);
- if(*dst) MEM_RM(allocator, *dst);
- goto end;
-}
-
-void
-release_h_boundary
- (struct h_boundary* bound,
- struct mem_allocator* allocator)
-{
- ASSERT(bound && allocator);
- str_release(&bound->name);
- if(bound->possible_external_fluid)
- release_fluid(bound->possible_external_fluid, allocator);
- MEM_RM(allocator, bound);
-}
-
-res_T
-str_print_h_boundary
- (struct str* str,
- const struct description* desc)
-{
- res_T res = RES_OK;
- const struct h_boundary* b;
- ASSERT(str && desc && DESC_IS_H(desc));
- b = desc->d.h_boundary;
- ERR(str_append_printf(str,
- "H boundary for %s '%s': ref_temperature=%g emissivity=%g specular_fraction=%g "
- "hc=%g T=%g (using medium %u as external medium)",
- (desc->type == DESC_BOUND_H_FOR_SOLID ? "solid" : "fluid"),
- str_cget(&b->name), b->ref_temperature, b->emissivity,
- b->specular_fraction, b->hc, b->imposed_temperature, b->mat_id));
-end:
- return res;
-error:
- goto end;
-}
-
-res_T
-init_t
- (struct mem_allocator* allocator,
- struct t_boundary** dst)
-{
- res_T res = RES_OK;
- int str_initialized = 0;
- ASSERT(allocator && dst && *dst == NULL);
- *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
- if(! *dst) {
- res = RES_MEM_ERR;
- goto error;
- }
- str_init(allocator, &(*dst)->name);
- str_initialized = 1;
- (*dst)->imposed_temperature = -1;
- (*dst)->mat_id = UINT_MAX;
-end:
- return res;
-error:
- if(str_initialized) str_release(&(*dst)->name);
- if(*dst) MEM_RM(allocator, *dst);
- goto end;
-}
-
-void
-release_t_boundary
- (struct t_boundary* bound,
- struct mem_allocator* allocator)
-{
- ASSERT(bound && allocator);
- str_release(&bound->name);
- MEM_RM(allocator, bound);
-}
-
-res_T
-str_print_t_boundary
- (struct str* str,
- const struct t_boundary* b)
-{
- res_T res = RES_OK;
- ASSERT(str && b);
- ERR(str_append_printf(str,
- "T boundary for solid '%s': T=%g (using medium %u as external medium)",
- str_cget(&b->name), b->imposed_temperature, b->mat_id));
-end:
- return res;
-error:
- goto end;
-}
-
-res_T
-init_f
- (struct mem_allocator* allocator,
- struct f_boundary** dst)
-{
- res_T res = RES_OK;
- int str_initialized = 0;
- ASSERT(allocator && dst && *dst == NULL);
- *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
- if(! *dst) {
- res = RES_MEM_ERR;
- goto error;
- }
- str_init(allocator, &(*dst)->name);
- str_initialized = 1;
- (*dst)->mat_id = UINT_MAX;
- (*dst)->imposed_flux = -1;
-end:
- return res;
-error:
- if(str_initialized) str_release(&(*dst)->name);
- if(*dst) MEM_RM(allocator, *dst);
- goto end;
-}
-
-void
-release_f_boundary
- (struct f_boundary* bound,
- struct mem_allocator* allocator)
-{
- ASSERT(bound && allocator);
- str_release(&bound->name);
- MEM_RM(allocator, bound);
-}
-
-res_T
-str_print_f_boundary
- (struct str* str,
- const struct f_boundary* b)
-{
- res_T res = RES_OK;
- ASSERT(str && b);
- ERR(str_append_printf(str,
- "F boundary for SOLID '%s': flux=%g (using medium %u as external medium)",
- str_cget(&b->name), b->imposed_flux, b->mat_id));
-end:
- return res;
-error:
- goto end;
-}
-
-void
-release_sf_connect
- (struct solid_fluid_connect* connect,
- struct mem_allocator* allocator)
-{
- ASSERT(connect && allocator);
- str_release(&connect->name);
- MEM_RM(allocator, connect);
-}
-
-res_T
-init_sf
- (struct mem_allocator* allocator,
- struct solid_fluid_connect** dst)
-{
- res_T res = RES_OK;
- int str_initialized = 0;
- ASSERT(allocator && dst && *dst == NULL);
- *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
- if(! *dst) {
- res = RES_MEM_ERR;
- goto error;
- }
- str_init(allocator, &(*dst)->name);
- str_initialized = 1;
- (*dst)->connection_id = UINT_MAX;
-end:
- return res;
-error:
- if(str_initialized) str_release(&(*dst)->name);
- if(*dst) MEM_RM(allocator, *dst);
- goto end;
-}
-
-res_T
-str_print_sf_connect
- (struct str* str,
- const struct solid_fluid_connect* c)
-{
- res_T res = RES_OK;
- ASSERT(str && c);
- ERR(str_append_printf(str,
- "Solid-Fluid connection '%s': "
- "ref_temperature=%g emissivity=%g, specular_fraction=%g hc=%g",
- str_cget(&c->name),
- c->ref_temperature, c->emissivity, c->specular_fraction, c->hc));
-end:
- return res;
-error:
- goto end;
-}
-
-void
-release_ss_connect
- (struct solid_solid_connect* connect,
- struct mem_allocator* allocator)
-{
- ASSERT(connect && allocator);
- str_release(&connect->name);
- MEM_RM(allocator, connect);
-}
-
-res_T
-init_ss
- (struct mem_allocator* allocator,
- struct solid_solid_connect** dst)
-{
- res_T res = RES_OK;
- int str_initialized = 0;
- ASSERT(allocator && dst && *dst == NULL);
- *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
- if(! *dst) {
- res = RES_MEM_ERR;
- goto error;
- }
- str_init(allocator, &(*dst)->name);
- str_initialized = 1;
- (*dst)->connection_id = UINT_MAX;
-end:
- return res;
-error:
- if(str_initialized) str_release(&(*dst)->name);
- if(*dst) MEM_RM(allocator, *dst);
- goto end;
-}
-
-res_T
-str_print_ss_connect
- (struct str* str,
- const struct solid_solid_connect* c)
-{
- res_T res = RES_OK;
- ASSERT(str && c);
- ERR(str_append_printf(str,
- "Solid-Solid connection '%s': contact resistance=%g",
- str_cget(&c->name), c->tcr));
-end:
- return res;
-error:
- goto end;
-}
-
res_T
init_description
(struct mem_allocator* alloc,
diff --git a/src/stardis-description.h b/src/stardis-description.h
@@ -122,120 +122,6 @@ struct description {
};
/******************************************************************************/
-
-struct h_boundary {
- struct str name;
- double ref_temperature;
- double emissivity;
- double specular_fraction;
- double hc;
- double imposed_temperature;
- unsigned mat_id;
- struct fluid* possible_external_fluid; /* if H for solid */
-};
-
-res_T
-init_h
- (struct mem_allocator* allocator,
- struct h_boundary** dst);
-
-void
-release_h_boundary
- (struct h_boundary* bound,
- struct mem_allocator* allocator);
-
-res_T
-str_print_h_boundary
- (struct str* str,
- const struct description* desc);
-
-struct t_boundary {
- struct str name;
- double imposed_temperature;
- unsigned mat_id;
-};
-
-res_T
-init_t
- (struct mem_allocator* allocator,
- struct t_boundary** dst);
-
-void
-release_t_boundary
- (struct t_boundary* bound,
- struct mem_allocator* allocator);
-
-res_T
-str_print_t_boundary
- (struct str* str,
- const struct t_boundary* b);
-
-struct f_boundary {
- struct str name;
- double imposed_flux;
- unsigned mat_id;
-};
-
-res_T
-init_f
- (struct mem_allocator* allocator,
- struct f_boundary** dst);
-
-void
-release_f_boundary
- (struct f_boundary* bound,
- struct mem_allocator* allocator);
-
-res_T
-str_print_f_boundary
- (struct str* str,
- const struct f_boundary* b);
-
-struct solid_fluid_connect {
- struct str name;
- double ref_temperature;
- double emissivity;
- double specular_fraction;
- double hc;
- unsigned connection_id;
-};
-
-void
-release_sf_connect
- (struct solid_fluid_connect* connect,
- struct mem_allocator* allocator);
-
-res_T
-init_sf
- (struct mem_allocator* allocator,
- struct solid_fluid_connect** dst);
-
-res_T
-str_print_sf_connect
- (struct str* str,
- const struct solid_fluid_connect* c);
-
-struct solid_solid_connect {
- struct str name;
- double tcr;
- unsigned connection_id;
-};
-
-void
-release_ss_connect
- (struct solid_solid_connect* connect,
- struct mem_allocator* allocator);
-
-res_T
-init_ss
- (struct mem_allocator* allocator,
- struct solid_solid_connect** dst);
-
-res_T
-str_print_ss_connect
- (struct str* str,
- const struct solid_solid_connect* c);
-
res_T
init_description
(struct mem_allocator* alloc,
diff --git a/src/stardis-fbound.c b/src/stardis-fbound.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "stardis-app.h"
+#include "stardis-fbound.h"
+#include "stardis-fluid.h"
+#include "stardis-intface.h"
+
+#include <rsys/rsys.h>
+#include <rsys/mem_allocator.h>
+#include <rsys/str.h>
+
+#include <sdis.h>
+
+#include <limits.h>
+
+/*******************************************************************************
+ * Public Functions
+ ******************************************************************************/
+res_T
+init_f_boundary
+ (struct mem_allocator* allocator,
+ struct f_boundary** dst)
+{
+ res_T res = RES_OK;
+ int str_initialized = 0;
+ ASSERT(allocator && dst && *dst == NULL);
+ *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
+ if(! *dst) {
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ str_init(allocator, &(*dst)->name);
+ str_initialized = 1;
+ (*dst)->mat_id = UINT_MAX;
+ (*dst)->imposed_flux = -1;
+end:
+ return res;
+error:
+ if(str_initialized) str_release(&(*dst)->name);
+ if(*dst) MEM_RM(allocator, *dst);
+ goto end;
+}
+
+void
+release_f_boundary
+ (struct f_boundary* bound,
+ struct mem_allocator* allocator)
+{
+ ASSERT(bound && allocator);
+ str_release(&bound->name);
+ MEM_RM(allocator, bound);
+}
+
+res_T
+str_print_f_boundary
+ (struct str* str,
+ const struct f_boundary* bound)
+{
+ res_T res = RES_OK;
+ ASSERT(str && bound);
+ ERR(str_append_printf(str,
+ "F boundary for SOLID '%s': flux=%g (using medium %u as external medium)",
+ str_cget(&bound->name), bound->imposed_flux, bound->mat_id));
+end:
+ return res;
+error:
+ goto end;
+}
+
diff --git a/src/stardis-fbound.h b/src/stardis-fbound.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SDIS_FBOUND_H
+#define SDIS_FBOUND_H
+
+#include <rsys/rsys.h>
+#include <rsys/str.h>
+
+struct mem_allocator;
+
+/*******************************************************************************
+ * F boundary type
+ ******************************************************************************/
+struct f_boundary {
+ struct str name;
+ double imposed_flux;
+ unsigned mat_id;
+};
+
+res_T
+init_f_boundary
+ (struct mem_allocator* allocator,
+ struct f_boundary** dst);
+
+void
+release_f_boundary
+ (struct f_boundary* bound,
+ struct mem_allocator* allocator);
+
+res_T
+str_print_f_boundary
+ (struct str* str,
+ const struct f_boundary* bound);
+
+#endif
diff --git a/src/stardis-fluid-prog.c b/src/stardis-fluid-prog.c
@@ -16,7 +16,6 @@
#include "stardis-fluid-prog.h"
#include "stardis-app.h"
#include "stardis-prog.h"
-#include "stardis-compute.h"
#include "stardis-app.h"
#include <rsys/mem_allocator.h>
@@ -187,9 +186,10 @@ str_print_fluid_prog(struct str* str, const struct fluid_prog* f)
{
res_T res = RES_OK;
ASSERT(str && f);
- STR_APPEND_PRINTF(str, "programmed fluid '%s': lib='%s', args=[%s]",
- ARG3( str_cget(&f->name), str_cget(&f->prog_name), str_cget(&f->args) ) );
- STR_APPEND_PRINTF(str, " (it is medium %u)", ARG1( f->fluid_id ) );
+ ERR(str_append_printf(str,
+ "programmed fluid '%s': lib='%s', args=[%s] (it is medium %u)",
+ str_cget(&f->name), str_cget(&f->prog_name), str_cget(&f->args),
+ f->fluid_id));
end:
return res;
error:
diff --git a/src/stardis-fluid.c b/src/stardis-fluid.c
@@ -14,7 +14,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "stardis-fluid.h"
-#include "stardis-compute.h"
#include "stardis-app.h"
#include <sdis.h>
@@ -153,15 +152,15 @@ str_print_fluid(struct str* str, const struct fluid* f)
{
res_T res = RES_OK;
ASSERT(str && f);
- STR_APPEND_PRINTF(str, "Fluid '%s': rho=%g cp=%g",
- ARG3( str_cget(&f->name), f->rho, f->cp ) );
+ ERR(str_append_printf(str, "Fluid '%s': rho=%g cp=%g",
+ str_cget(&f->name), f->rho, f->cp));
if(f->tinit >= 0) {
- STR_APPEND_PRINTF(str, " Tinit=%g", ARG1( f->tinit ) );
+ ERR(str_append_printf(str, " Tinit=%g", f->tinit));
}
if(f->imposed_temperature >= 0) {
- STR_APPEND_PRINTF(str, " Temp=%g", ARG1( f->imposed_temperature ) );
+ ERR(str_append_printf(str, " Temp=%g", f->imposed_temperature));
}
- STR_APPEND_PRINTF(str, " (it is medium %u)", ARG1( f->fluid_id ) );
+ ERR(str_append_printf(str, " (it is medium %u)", f->fluid_id));
end:
return res;
error:
diff --git a/src/stardis-hbound-prog.h b/src/stardis-hbound-prog.h
@@ -21,7 +21,6 @@
#include "stardis-prog.h"
-struct stardis;
struct mem_allocator;
struct fluid_prog;
struct description;
@@ -53,24 +52,19 @@ struct h_boundary_prog {
};
res_T
-create_solver_h_boundary_prog
- (struct stardis* stardis,
- const struct h_boundary_prog* h_boundary_props);
-
-res_T
init_h_boundary_prog
(struct mem_allocator* allocator,
struct h_boundary_prog** dst);
void
release_h_boundary_prog
- (struct h_boundary_prog* fluid,
+ (struct h_boundary_prog* bound,
struct mem_allocator* allocator);
res_T
str_print_h_boundary_prog
(struct str* str,
- const struct description* s);
+ const struct description* bound);
double
h_bound_prog_get_hmax
diff --git a/src/stardis-hbound.c b/src/stardis-hbound.c
@@ -0,0 +1,88 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "stardis-app.h"
+#include "stardis-hbound.h"
+#include "stardis-fluid.h"
+#include "stardis-intface.h"
+
+#include <rsys/rsys.h>
+#include <rsys/mem_allocator.h>
+#include <rsys/str.h>
+
+#include <sdis.h>
+
+#include <limits.h>
+
+/*******************************************************************************
+ * Public Functions
+ ******************************************************************************/
+res_T
+init_h_boundary
+ (struct mem_allocator* allocator,
+ struct h_boundary** dst)
+{
+ res_T res = RES_OK;
+ int str_initialized = 0;
+ ASSERT(allocator && dst && *dst == NULL);
+ *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
+ if(! *dst) {
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ str_init(allocator, &(*dst)->name);
+ str_initialized = 1;
+ (*dst)->imposed_temperature = -1;
+ (*dst)->mat_id = UINT_MAX;
+end:
+ return res;
+error:
+ if(str_initialized) str_release(&(*dst)->name);
+ if(*dst) MEM_RM(allocator, *dst);
+ goto end;
+}
+
+void
+release_h_boundary
+ (struct h_boundary* bound,
+ struct mem_allocator* allocator)
+{
+ ASSERT(bound && allocator);
+ str_release(&bound->name);
+ if(bound->possible_external_fluid)
+ release_fluid(bound->possible_external_fluid, allocator);
+ MEM_RM(allocator, bound);
+}
+
+res_T
+str_print_h_boundary
+ (struct str* str,
+ const struct description* desc)
+{
+ res_T res = RES_OK;
+ const struct h_boundary* b;
+ ASSERT(str && desc && DESC_IS_H(desc));
+ b = desc->d.h_boundary;
+ ERR(str_append_printf(str,
+ "H boundary for %s '%s': ref_temperature=%g emissivity=%g specular_fraction=%g "
+ "hc=%g T=%g (using medium %u as external medium)",
+ (desc->type == DESC_BOUND_H_FOR_SOLID ? "solid" : "fluid"),
+ str_cget(&b->name), b->ref_temperature, b->emissivity,
+ b->specular_fraction, b->hc, b->imposed_temperature, b->mat_id));
+end:
+ return res;
+error:
+ goto end;
+}
diff --git a/src/stardis-hbound.h b/src/stardis-hbound.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SDIS_HBOUND_H
+#define SDIS_HBOUND_H
+
+#include <rsys/rsys.h>
+#include <rsys/str.h>
+
+#include "stardis-prog.h"
+
+struct mem_allocator;
+struct fluid;
+struct description;
+
+/*******************************************************************************
+ * H boundary type
+ ******************************************************************************/
+struct h_boundary {
+ struct str name;
+ double ref_temperature;
+ double emissivity;
+ double specular_fraction;
+ double hc;
+ double imposed_temperature;
+ unsigned mat_id;
+ struct fluid* possible_external_fluid; /* if H for solid */
+};
+
+res_T
+init_h_boundary
+ (struct mem_allocator* allocator,
+ struct h_boundary** dst);
+
+void
+release_h_boundary
+ (struct h_boundary* bound,
+ struct mem_allocator* allocator);
+
+res_T
+str_print_h_boundary
+ (struct str* str,
+ const struct description* desc);
+
+#endif
diff --git a/src/stardis-intface.c b/src/stardis-intface.c
@@ -18,10 +18,15 @@
#include "stardis-compute.h"
#include "stardis-output.h"
#include "stardis-solid.h"
+#include "stardis-hbound.h"
#include "stardis-hbound-prog.h"
+#include "stardis-tbound.h"
#include "stardis-tbound-prog.h"
+#include "stardis-fbound.h"
#include "stardis-fbound-prog.h"
+#include "stardis-ssconnect.h"
#include "stardis-ssconnect-prog.h"
+#include "stardis-sfconnect.h"
#include "stardis-sfconnect-prog.h"
#include "stardis-prog.h"
diff --git a/src/stardis-main.c b/src/stardis-main.c
@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "stardis-app.h"
+#include "stardis-args.h"
#include "stardis-parsing.h"
#include "stardis-output.h"
#include "stardis-compute.h"
diff --git a/src/stardis-output.c b/src/stardis-output.c
@@ -15,17 +15,23 @@
#define _POSIX_C_SOURCE 200112L /* snprintf */
#include "stardis-output.h"
+#include "stardis-args.h"
#include "stardis-compute.h"
#include "stardis-fluid.h"
#include "stardis-solid.h"
+#include "stardis-hbound.h"
+#include "stardis-tbound.h"
+#include "stardis-fbound.h"
+#include "stardis-ssconnect.h"
+#include "stardis-sfconnect.h"
#include "stardis-intface.h"
#include "stardis-app.h"
#include <sdis.h>
+#include<star/ssp.h>
#include<star/senc3d.h>
#include<star/sg3d.h>
-#include<star/ssp.h>
#include <rsys/math.h>
#include <rsys/mem_allocator.h>
diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c
@@ -16,11 +16,17 @@
#define _POSIX_C_SOURCE 200809L /* strdup */
#include "stardis-parsing.h"
#include "stardis-app.h"
+#include "stardis-args.h"
#include "stardis-description.h"
+#include "stardis-hbound.h"
#include "stardis-hbound-prog.h"
+#include "stardis-tbound.h"
#include "stardis-tbound-prog.h"
+#include "stardis-fbound.h"
#include "stardis-fbound-prog.h"
+#include "stardis-sfconnect.h"
#include "stardis-sfconnect-prog.h"
+#include "stardis-ssconnect.h"
#include "stardis-ssconnect-prog.h"
#include "stardis-fluid-prog.h"
#include "stardis-fluid.h"
@@ -33,6 +39,7 @@
#include <rsys/double3.h>
#include <sdis_version.h>
#include <rsys/logger.h>
+#include <rsys/text_reader.h>
#include <rsys/library.h>
#include <stdlib.h>
@@ -186,7 +193,7 @@ read_sides_and_files
"File '%s' included %lu degenerated triangles (removed)\n",
tk, (unsigned long)c);
ERR(str_printf(&str, "Degenerated triangles IDs: %u", ids[0]));
- FOR_EACH(n, 1, c) { STR_APPEND_PRINTF(&str, ", %u", ARG1( ids[n] ) ); }
+ FOR_EACH(n, 1, c) { ERR(str_append_printf(&str, ", %u", ids[n])); }
logger_print(stardis->logger, LOG_OUTPUT, "%s\n", str_cget(&str));
darray_uint_clear(°enerated);
}
@@ -337,7 +344,7 @@ process_h
sz = darray_descriptions_size_get(&stardis->descriptions);
ERR(darray_descriptions_resize(&stardis->descriptions, sz+1));
desc = darray_descriptions_data_get(&stardis->descriptions) + sz;
- ERR(init_h(stardis->allocator, &desc->d.h_boundary));
+ ERR(init_h_boundary(stardis->allocator, &desc->d.h_boundary));
h_boundary = desc->d.h_boundary;
desc->type = type;
@@ -633,7 +640,7 @@ process_t
sz = darray_descriptions_size_get(&stardis->descriptions);
ERR(darray_descriptions_resize(&stardis->descriptions, sz + 1));
desc = darray_descriptions_data_get(&stardis->descriptions) + sz;
- ERR(init_t(stardis->allocator, &desc->d.t_boundary));
+ ERR(init_t_boundary(stardis->allocator, &desc->d.t_boundary));
t_boundary = desc->d.t_boundary;
desc->type = DESC_BOUND_T_FOR_SOLID;
@@ -795,7 +802,7 @@ process_flx
sz = darray_descriptions_size_get(&stardis->descriptions);
ERR(darray_descriptions_resize(&stardis->descriptions, sz + 1));
desc = darray_descriptions_data_get(&stardis->descriptions) + sz;
- ERR(init_f(stardis->allocator, &desc->d.f_boundary));
+ ERR(init_f_boundary(stardis->allocator, &desc->d.f_boundary));
f_boundary = desc->d.f_boundary;
desc->type = DESC_BOUND_F_FOR_SOLID;
@@ -953,7 +960,7 @@ process_sfc
sz = darray_descriptions_size_get(&stardis->descriptions);
ERR(darray_descriptions_resize(&stardis->descriptions, sz + 1));
desc = darray_descriptions_data_get(&stardis->descriptions) + sz;
- ERR(init_sf(stardis->allocator, &desc->d.sf_connect));
+ ERR(init_sf_connect(stardis->allocator, &desc->d.sf_connect));
sf_connect = desc->d.sf_connect;
desc->type = DESC_SOLID_FLUID_CONNECT;
@@ -1180,7 +1187,7 @@ process_ssc
sz = darray_descriptions_size_get(&stardis->descriptions);
ERR(darray_descriptions_resize(&stardis->descriptions, sz + 1));
desc = darray_descriptions_data_get(&stardis->descriptions) + sz;
- ERR(init_ss(stardis->allocator, &desc->d.ss_connect));
+ ERR(init_ss_connect(stardis->allocator, &desc->d.ss_connect));
ss_connect = desc->d.ss_connect;
desc->type = DESC_SOLID_SOLID_CONNECT;
@@ -1959,19 +1966,30 @@ error:
}
/* Read medium or boundary line; should be one of:
- * SOLID Name lambda rho cp delta Tinit Timposed volumic_power STL_filenames
+ * SOLID Name lambda rho cp delta Tinit Timposed volumic_power STL_sides_filenames
* FLUID Name rho cp Tinit Timposed STL_filenames
- * H_BOUNDARY_FOR_SOLID Name ref_temperature emissivity specular_fraction hc T_env STL_filenames
+ * H_BOUNDARY_FOR_SOLID Name ref_temperature emissivity specular_fraction hc T_env STL_sides_filenames
* H_BOUNDARY_FOR_FLUID Name ref_temperature emissivity specular_fraction hc T_env STL_filenames
* T_BOUNDARY_FOR_SOLID Name T STL_filenames
* F_BOUNDARY_FOR_SOLID Name F STL_filenames
* SOLID_FLUID_CONNECTION Name ref_temperature emissivity specular_fraction hc STL_filenames
+ *
+ * SOLID_PROG Name Libray STL_sides_filenames [ PROG_PARAMS ... ]
+ * SOLID_PROG Name Libray STL_sides_filenames [ PROG_PARAMS ... ]
+ * H_BOUNDARY_FOR_SOLID_PROG Name Libray STL_filenames [ PROG_PARAMS ... ]
+ * H_BOUNDARY_FOR_FLUID_PROG Name Libray STL_filenames [ PROG_PARAMS ... ]
+ * T_BOUNDARY_FOR_SOLID_PROG Name Libray STL_filenames [ PROG_PARAMS ... ]
+ * F_BOUNDARY_FOR_SOLID_PROG Name Libray STL_filenames [ PROG_PARAMS ... ]
+ * SOLID_FLUID_CONNECTION_PROG Name Libray STL_filenames [ PROG_PARAMS ... ]
+ * SOLID_SOLID_CONNECTION_PROG Name Libray STL_filenames [ PROG_PARAMS ... ]
+ *
* SCALE scale_factor
* TRAD Trad Trad_ref
*
- * STL_filenames = { { FRONT | BACK | BOTH } STL_filename }+
+ * STL_sides_filenames = { { FRONT | BACK | BOTH } STL_filename }+
+ * STL_filenames = { STL_filename }+
*/
-res_T
+static res_T
process_model_line
(const char* file_name,
char* line,
@@ -2040,6 +2058,10 @@ error:
goto end;
}
+/*******************************************************************************
+ * Public Functions
+ ******************************************************************************/
+
res_T
get_dummy_solid_id
(struct stardis* stardis,
@@ -2105,3 +2127,62 @@ end:
error:
goto end;
}
+
+res_T
+read_model
+ (const struct darray_str* model_files,
+ struct stardis* stardis)
+{
+ res_T res = RES_OK;
+ const struct str* files = NULL;
+ size_t i;
+ FILE* f = NULL;
+ struct txtrdr* txtrdr = NULL;
+
+ ASSERT(model_files && stardis);
+ files = darray_str_cdata_get(model_files);
+ FOR_EACH(i, 0, darray_str_size_get(model_files)) {
+ const char* name = str_cget(files + i);
+ f = fopen(name, "r");
+ if(!f) {
+ logger_print(stardis->logger, LOG_ERROR,
+ "Cannot open model file '%s'\n",
+ name);
+ res = RES_IO_ERR;
+ goto error;
+ }
+ txtrdr_stream(stardis->allocator, f, name, '#', &txtrdr);
+ for(;;) {
+ char* line;
+ ERR(txtrdr_read_line(txtrdr));
+ line = txtrdr_get_line(txtrdr);
+ if(!line) break;
+ ERR(process_model_line(name, line, stardis));
+ }
+ txtrdr_ref_put(txtrdr);
+ txtrdr = NULL;
+ fclose(f);
+ f = NULL;
+ }
+ if(stardis->scale_factor <= 0)
+ stardis->scale_factor = STARDIS_DEFAULT_SCALE_FACTOR;
+ logger_print(stardis->logger, LOG_OUTPUT,
+ "Scaling factor is %g\n", stardis->scale_factor);
+ logger_print(stardis->logger, LOG_OUTPUT,
+ "Trad is %g, Trad reference is %g\n", stardis->trad, stardis->trad_ref);
+ stardis->t_range[0] = MMIN(stardis->t_range[0], stardis->trad_ref);
+ stardis->t_range[1] = MMAX(stardis->t_range[1], stardis->trad_ref);
+ logger_print(stardis->logger, LOG_OUTPUT,
+ "System T range is [%g %g]\n", SPLIT2(stardis->t_range));
+ logger_print(stardis->logger, LOG_OUTPUT,
+ "Picard order is %u\n", stardis->picard_order);
+
+ ASSERT(!f && !txtrdr);
+exit:
+ return res;
+error:
+ if(f) fclose(f);
+ if(txtrdr) txtrdr_ref_put(txtrdr);
+ goto exit;
+}
+
diff --git a/src/stardis-parsing.h b/src/stardis-parsing.h
@@ -56,12 +56,6 @@ add_geom_ctx_position
void* context);
res_T
-process_model_line
- (const char* file_name,
- char* line,
- struct stardis* stardis);
-
-res_T
get_dummy_solid_id
(struct stardis* stardis,
unsigned* id);
@@ -71,4 +65,9 @@ get_dummy_fluid_id
(struct stardis* stardis,
unsigned* id);
+res_T
+read_model
+ (const struct darray_str* model_files,
+ struct stardis* stardis);
+
#endif /*ARGS_H*/
diff --git a/src/stardis-sfconnect.c b/src/stardis-sfconnect.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "stardis-app.h"
+#include "stardis-sfconnect.h"
+
+#include <rsys/rsys.h>
+#include <rsys/mem_allocator.h>
+#include <rsys/str.h>
+
+#include <sdis.h>
+
+#include <limits.h>
+
+/*******************************************************************************
+ * Public Functions
+ ******************************************************************************/
+res_T
+init_sf_connect
+ (struct mem_allocator* allocator,
+ struct solid_fluid_connect** dst)
+{
+ res_T res = RES_OK;
+ int str_initialized = 0;
+ ASSERT(allocator && dst && *dst == NULL);
+ *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
+ if(! *dst) {
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ str_init(allocator, &(*dst)->name);
+ str_initialized = 1;
+ (*dst)->connection_id = UINT_MAX;
+end:
+ return res;
+error:
+ if(str_initialized) str_release(&(*dst)->name);
+ if(*dst) MEM_RM(allocator, *dst);
+ goto end;
+}
+
+void
+release_sf_connect
+ (struct solid_fluid_connect* connect,
+ struct mem_allocator* allocator)
+{
+ ASSERT(connect && allocator);
+ str_release(&connect->name);
+ MEM_RM(allocator, connect);
+}
+
+res_T
+str_print_sf_connect
+ (struct str* str,
+ const struct solid_fluid_connect* connect)
+{
+ res_T res = RES_OK;
+ ASSERT(str && connect);
+ ERR(str_append_printf(str,
+ "Solid-Fluid connection '%s': "
+ "ref_temperature=%g emissivity=%g, specular_fraction=%g hc=%g",
+ str_cget(&connect->name),
+ connect->ref_temperature, connect->emissivity, connect->specular_fraction,
+ connect->hc));
+end:
+ return res;
+error:
+ goto end;
+}
+
diff --git a/src/stardis-sfconnect.h b/src/stardis-sfconnect.h
@@ -0,0 +1,52 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SDIS_SF_CONNECT_H
+#define SDIS_SF_CONNECT_H
+
+#include <rsys/rsys.h>
+#include <rsys/str.h>
+
+struct mem_allocator;
+
+/*******************************************************************************
+ * Solid-Fluid connection type
+ ******************************************************************************/
+
+struct solid_fluid_connect {
+ struct str name;
+ double ref_temperature;
+ double emissivity;
+ double specular_fraction;
+ double hc;
+ unsigned connection_id;
+};
+
+res_T
+init_sf_connect
+ (struct mem_allocator* allocator,
+ struct solid_fluid_connect** dst);
+
+void
+release_sf_connect
+ (struct solid_fluid_connect* connect,
+ struct mem_allocator* allocator);
+
+res_T
+str_print_sf_connect
+ (struct str* str,
+ const struct solid_fluid_connect* connect);
+
+#endif
diff --git a/src/stardis-solid-prog.c b/src/stardis-solid-prog.c
@@ -15,7 +15,6 @@
#include "stardis-solid-prog.h"
#include "stardis-prog.h"
-#include "stardis-compute.h"
#include "stardis-app.h"
#include <rsys/mem_allocator.h>
@@ -189,9 +188,10 @@ str_print_solid_prog(struct str* str, const struct solid_prog* f)
{
res_T res = RES_OK;
ASSERT(str && f);
- STR_APPEND_PRINTF(str, "programmed solid '%s': lib='%s', args=[%s]",
- ARG3( str_cget(&f->name), str_cget(&f->prog_name), str_cget(&f->args) ) );
- STR_APPEND_PRINTF(str, " (it is medium %u)", ARG1( f->solid_id ) );
+ ERR(str_append_printf(str,
+ "programmed solid '%s': lib='%s', args=[%s] (it is medium %u)",
+ str_cget(&f->name), str_cget(&f->prog_name), str_cget(&f->args),
+ f->solid_id));
end:
return res;
error:
diff --git a/src/stardis-solid.c b/src/stardis-solid.c
@@ -14,7 +14,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "stardis-solid.h"
-#include "stardis-compute.h"
#include "stardis-app.h"
#include <sdis.h>
@@ -203,18 +202,18 @@ str_print_solid(struct str* str, const struct solid* s)
{
res_T res = RES_OK;
ASSERT(str && s);
- STR_APPEND_PRINTF(str, "Solid '%s': lambda=%g rho=%g cp=%g delta=%g",
- ARG5( str_cget(&s->name), s->lambda, s->rho, s->cp, s->delta ) );
+ ERR(str_append_printf(str, "Solid '%s': lambda=%g rho=%g cp=%g delta=%g",
+ str_cget(&s->name), s->lambda, s->rho, s->cp, s->delta));
if(s->vpower != 0) {
- STR_APPEND_PRINTF(str, " VPower=%g", ARG1( s->vpower ) );
+ ERR(str_append_printf(str, " VPower=%g", s->vpower));
}
if(s->tinit >= 0) {
- STR_APPEND_PRINTF(str, " Tinit=%g", ARG1( s->tinit ) );
+ ERR(str_append_printf(str, " Tinit=%g", s->tinit));
}
if(s->imposed_temperature >= 0) {
- STR_APPEND_PRINTF(str, " Temp=%g", ARG1( s->imposed_temperature ) );
+ ERR(str_append_printf(str, " Temp=%g", s->imposed_temperature));
}
- STR_APPEND_PRINTF(str, " (it is medium %u)", ARG1( s->solid_id ) );
+ ERR(str_append_printf(str, " (it is medium %u)", s->solid_id));
end:
return res;
error:
diff --git a/src/stardis-ssconnect.c b/src/stardis-ssconnect.c
@@ -0,0 +1,79 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "stardis-app.h"
+#include "stardis-ssconnect.h"
+
+#include <rsys/rsys.h>
+#include <rsys/mem_allocator.h>
+#include <rsys/str.h>
+
+#include <sdis.h>
+
+#include <limits.h>
+
+/*******************************************************************************
+ * Public Functions
+ ******************************************************************************/
+res_T
+init_ss_connect
+ (struct mem_allocator* allocator,
+ struct solid_solid_connect** dst)
+{
+ res_T res = RES_OK;
+ int str_initialized = 0;
+ ASSERT(allocator && dst && *dst == NULL);
+ *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
+ if(! *dst) {
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ str_init(allocator, &(*dst)->name);
+ str_initialized = 1;
+ (*dst)->connection_id = UINT_MAX;
+end:
+ return res;
+error:
+ if(str_initialized) str_release(&(*dst)->name);
+ if(*dst) MEM_RM(allocator, *dst);
+ goto end;
+}
+
+void
+release_ss_connect
+ (struct solid_solid_connect* connect,
+ struct mem_allocator* allocator)
+{
+ ASSERT(connect && allocator);
+ str_release(&connect->name);
+ MEM_RM(allocator, connect);
+}
+
+res_T
+str_print_ss_connect
+ (struct str* str,
+ const struct solid_solid_connect* connect)
+{
+ res_T res = RES_OK;
+ ASSERT(str && connect);
+ ERR(str_append_printf(str,
+ "Solid-Solid connection '%s': contact resistance=%g",
+ str_cget(&connect->name), connect->tcr));
+end:
+ return res;
+error:
+ goto end;
+}
+
diff --git a/src/stardis-ssconnect.h b/src/stardis-ssconnect.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SDIS_SS_CONNECT_H
+#define SDIS_SS_CONNECT_H
+
+#include <rsys/rsys.h>
+#include <rsys/str.h>
+
+struct mem_allocator;
+
+/*******************************************************************************
+ * Solid-Solid connection type
+ ******************************************************************************/
+struct solid_solid_connect {
+ struct str name;
+ double tcr;
+ unsigned connection_id;
+};
+
+res_T
+init_ss_connect
+ (struct mem_allocator* allocator,
+ struct solid_solid_connect** dst);
+
+void
+release_ss_connect
+ (struct solid_solid_connect* connect,
+ struct mem_allocator* allocator);
+
+res_T
+str_print_ss_connect
+ (struct str* str,
+ const struct solid_solid_connect* cconnect);
+
+#endif
diff --git a/src/stardis-tbound.c b/src/stardis-tbound.c
@@ -0,0 +1,81 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "stardis-app.h"
+#include "stardis-tbound.h"
+#include "stardis-fluid.h"
+#include "stardis-intface.h"
+
+#include <rsys/rsys.h>
+#include <rsys/mem_allocator.h>
+#include <rsys/str.h>
+
+#include <sdis.h>
+
+#include <limits.h>
+
+/*******************************************************************************
+ * Public Functions
+ ******************************************************************************/
+res_T
+init_t_boundary
+ (struct mem_allocator* allocator,
+ struct t_boundary** dst)
+{
+ res_T res = RES_OK;
+ int str_initialized = 0;
+ ASSERT(allocator && dst && *dst == NULL);
+ *dst = MEM_CALLOC(allocator, 1, sizeof(**dst));
+ if(! *dst) {
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ str_init(allocator, &(*dst)->name);
+ str_initialized = 1;
+ (*dst)->imposed_temperature = -1;
+ (*dst)->mat_id = UINT_MAX;
+end:
+ return res;
+error:
+ if(str_initialized) str_release(&(*dst)->name);
+ if(*dst) MEM_RM(allocator, *dst);
+ goto end;
+}
+
+void
+release_t_boundary
+ (struct t_boundary* bound,
+ struct mem_allocator* allocator)
+{
+ ASSERT(bound && allocator);
+ str_release(&bound->name);
+ MEM_RM(allocator, bound);
+}
+
+res_T
+str_print_t_boundary
+ (struct str* str,
+ const struct t_boundary* b)
+{
+ res_T res = RES_OK;
+ ASSERT(str && b);
+ ERR(str_append_printf(str,
+ "T boundary for solid '%s': T=%g (using medium %u as external medium)",
+ str_cget(&b->name), b->imposed_temperature, b->mat_id));
+end:
+ return res;
+error:
+ goto end;
+}
diff --git a/src/stardis-tbound.h b/src/stardis-tbound.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SDIS_TBOUND_H
+#define SDIS_TBOUND_H
+
+#include <rsys/rsys.h>
+#include <rsys/str.h>
+
+struct mem_allocator;
+
+/*******************************************************************************
+ * H boundary type
+ ******************************************************************************/
+struct t_boundary {
+ struct str name;
+ double imposed_temperature;
+ unsigned mat_id;
+};
+
+res_T
+init_t_boundary
+ (struct mem_allocator* allocator,
+ struct t_boundary** dst);
+
+void
+release_t_boundary
+ (struct t_boundary* bound,
+ struct mem_allocator* allocator);
+
+res_T
+str_print_t_boundary
+ (struct str* str,
+ const struct t_boundary* bound);
+
+#endif