stardis-test

Test Stardis behaviors
git clone git://git.meso-star.fr/stardis-test.git
Log | Files | Refs | README | LICENSE

commit afedf40670f072b16a614169c9247140a1b3e913
parent 5478cc19df38a4e8572c3c7bac3e91119782ec3a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sat, 13 Apr 2024 21:13:19 +0200

Start implementing a conducto radiative test

Eventually, this test will enable us to verify the programmable
radiation environment.

Diffstat:
MMakefile | 26+++++++++++++++-----------
Asrc/sadist_conducto_radiative.c | 143+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 158 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile @@ -19,6 +19,7 @@ include config.mk TESTS =\ + sadist_conducto_radiative\ sadist_external_flux\ sadist_probe_boundary\ sadist_unsteady @@ -40,11 +41,13 @@ default: .config $(TESTS) $(LIBS) clean: rm -f .config src/*.o src/*.d - rm -f ground.stl sphere.stl sshape.stl wall.stl probes.txt - rm -f scene.txt scene2.txt + rm -f cube.stl ground.stl sphere.stl sshape.stl wall.stl + rm -f adiabatic_boundary.stl radiative_boundary.stl + rm -f probes.txt scene.txt scene2.txt rm -f $(TESTS) $(LIBS) test: $(TESTS) $(LIBS) + @$(SHELL) make.sh check sadist_conducto_radiative ./sadist_conducto_radiative @$(SHELL) make.sh check sadist_probe_boundary ./sadist_probe_boundary @$(SHELL) make.sh check sadist_probe_boundary_list ./sadist_probe_boundary -p4 @$(SHELL) make.sh check sadist_external_flux ./sadist_external_flux @@ -83,19 +86,22 @@ libsadist_unsteady_profile.so: src/sadist_lib_unsteady_profile.o ################################################################################ # Tests ################################################################################ +src/sadist_conducto_radiative.o:\ + config.mk src/sadist.h src/sadist_conducto_radiative.c + $(CC) $(CFLAGS_EXE) -c $(@:.o=.c) -o $@ + +sadist_conducto_radiative: config.mk src/sadist_conducto_radiative.o + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(RSYS_LIBS) + src/sadist_external_flux.o:\ - config.mk\ - src/sadist.h\ - src/sadist_external_flux.c + config.mk src/sadist.h src/sadist_external_flux.c $(CC) $(CFLAGS_EXE) -c $(@:.o=.c) -o $@ sadist_external_flux: config.mk src/sadist_external_flux.o $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(RSYS_LIBS) -lm src/sadist_probe_boundary.o:\ - config.mk\ - src/sadist.h\ - src/sadist_probe_boundary.c + config.mk src/sadist.h src/sadist_probe_boundary.c $(CC) $(CFLAGS_EXE) $(S3DUT_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ sadist_probe_boundary: config.mk src/sadist_probe_boundary.o @@ -103,9 +109,7 @@ sadist_probe_boundary: config.mk src/sadist_probe_boundary.o $(LDFLAGS_EXE) $(S3DUT_LIBS) $(RSYS_LIBS) -lm src/sadist_unsteady.o:\ - config.mk\ - src/sadist.h\ - src/sadist_unsteady.c + config.mk src/sadist.h src/sadist_unsteady.c $(CC) $(CFLAGS_EXE) $(S3DUT_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ sadist_unsteady: config.mk src/sadist_unsteady.o diff --git a/src/sadist_conducto_radiative.c b/src/sadist_conducto_radiative.c @@ -0,0 +1,143 @@ +/* Copyright (C) 2024 |Méso|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/>. */ + +#define _POSIX_C_SOURCE 200112L /* popen */ + +#include "sadist.h" + +#include <rsys/rsys.h> + +#include <errno.h> +#include <stdio.h> +#include <string.h> /* strerror */ +#include <wait.h> /* WIFEXITED, WEXITSTATUS */ + +/* + * The scene is a solid cube whose +/-X faces exchange with the radiative + * environment. All other faces are adiabatic. The radiative environment is set + * at 300K along the -X direction and 310K along the +X direction. + * + * This test calculates the steady temperature at a given position of the probe + * in the solid and validates it against its analytical solution. + * + * //////(1,1,1) + * +-------+ + * ---> /' /| <--- + * 300 K ---> +-------+ | E=1 <--- 310 K + * Y ---> E=1 | +.....|.+ <--- + * | |, |/ + * o--X +-------+ + * / (0,0,0) //// + * Z + */ + +#define FILENAME_CUBE "cube.stl" +#define FILENAME_ADIABATIC "adiabatic_boundary.stl" +#define FILENAME_RADIATIVE "radiative_boundary.stl" +#define FILENAME_SCENE "scene.txt" + +#define LAMBDA 0.1 + +static const double vertices[] = { + 0.0, 0.0, 0.0, + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 1.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + 1.0, 0.0, 1.0, + 0.0, 1.0, 1.0, + 1.0, 1.0, 1.0 +}; +static const size_t nvertices = sizeof(vertices) / (sizeof(double)*3); + +static const size_t indices[] = { + 0, 4, 2, 2, 4, 6, /* -x */ + 3, 7, 5, 5, 1, 3, /* +x */ + 0, 1, 5, 5, 4, 0, /* -y */ + 2, 6, 7, 7, 3, 2, /* +y */ + 0, 2, 1, 1, 2, 3, /* -z */ + 4, 5, 6, 6, 5, 7 /* +z */ +}; +static const size_t ntriangles = sizeof(indices) / (sizeof(size_t)*3); + +/******************************************************************************* + * Helper functions + ******************************************************************************/ +static void +setup_scene(FILE* fp) +{ + ASSERT(fp); + fprintf(fp, "SOLID cube "STR(LAMBDA)" 1 1 0.05 0 UNKNOWN 0 FRONT "FILENAME_CUBE"\n"); + fprintf(fp, "SOLID_FLUID_CONNECTION radiative 300 1 0 0 "FILENAME_RADIATIVE"\n"); + fprintf(fp, "SOLID_FLUID_CONNECTION adiabatic 0 0 0 0 "FILENAME_ADIABATIC"\n"); + fprintf(fp, "TRAD 310 300\n"); +} + +static int +init(void) +{ + FILE* fp_cube = NULL; + FILE* fp_adiabatic = NULL; + FILE* fp_radiative = NULL; + FILE* fp_scene = NULL; + int err = 0; + + #define FOPEN(Fp, Filename) \ + if(((Fp) = fopen((Filename), "w")) == NULL) { \ + fprintf(stderr, "Error opening `%s' -- file %s\n", \ + (Filename), strerror(errno)); \ + err = errno; \ + goto error; \ + } (void)0 + FOPEN(fp_cube, FILENAME_CUBE); + FOPEN(fp_adiabatic, FILENAME_ADIABATIC); + FOPEN(fp_radiative, FILENAME_RADIATIVE); + FOPEN(fp_scene, FILENAME_SCENE); + #undef FOPEN + + sadist_write_stl(fp_cube, vertices, nvertices, indices, ntriangles); + sadist_write_stl(fp_adiabatic, vertices, nvertices, indices+12, ntriangles-4); + sadist_write_stl(fp_radiative, vertices, nvertices, indices, 4); + setup_scene(fp_scene); + +exit: + #define FCLOSE(Fp) \ + if((Fp) && fclose(Fp)) { perror("fclose"); if(!err) err = errno; } (void)0 + FCLOSE(fp_cube); + FCLOSE(fp_adiabatic); + FCLOSE(fp_radiative); + FCLOSE(fp_scene); + #undef FCLOSE + return err; +error: + goto exit; +} + +/******************************************************************************* + * The test + ******************************************************************************/ +int +main(int argc, char** argv) +{ + int err = 0; + (void)argc, (void)argv; + + if((err = init())) goto error; + +exit: + return err; +error: + goto exit; +}