stardis-test

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

commit 6c33d15d449ba161c55cad32454d453842ac5fec
parent e381e777826b313d3580461dfd5b4d2648cbc3e6
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue,  9 Apr 2024 18:08:42 +0200

Finalizing the unsteady test

Run two different stardis commands, the first using the delta sphere
algorithm, the second using the Walk on Sphere algorithm. The results of
both commands are validated against the analytical solutions provided by
the unsteady profile.

Diffstat:
MMakefile | 4+++-
Msrc/sadist_lib_unsteady_profile.c | 4++--
Msrc/sadist_unsteady.c | 72+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 74 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile @@ -40,13 +40,15 @@ default: .config $(TESTS) $(LIBS) clean: rm -f .config src/*.o src/*.d - rm -f ground.stl sphere.stl sshape.stl wall.stl probes.txt scene.txt + rm -f ground.stl sphere.stl sshape.stl wall.stl probes.txt + rm -f scene.txt scene2.txt rm -f $(TESTS) $(LIBS) test: $(TESTS) $(LIBS) @$(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 + @$(SHELL) make.sh check sadist_unsteady ./sadist_unsteady ################################################################################ # Libraries diff --git a/src/sadist_lib_unsteady_profile.c b/src/sadist_lib_unsteady_profile.c @@ -278,7 +278,7 @@ stardis_t_range(void* data, double range[2]) { ASSERT(data && range); (void)data; - range[0] = -INF; - range[1] = INF; + range[0] = 0; + range[1] = INF; return range; } diff --git a/src/sadist_unsteady.c b/src/sadist_unsteady.c @@ -13,6 +13,8 @@ * 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 <star/s3dut.h> @@ -20,8 +22,10 @@ #include <rsys/math.h> #include <rsys/mem_allocator.h> -#include <string.h> /* strerror */ #include <errno.h> +#include <stdio.h> /* popen */ +#include <string.h> /* strerror */ +#include <wait.h> /* WIFEXITED, WEXITSTATUS */ /* * The system is an unsteady-state temperature profile, meaning that at any @@ -54,8 +58,21 @@ #define UPROF_B2 1000.0 #define UPROF_K (PI/4.0) +/* Probe position */ +#define PX 0.2 /* [m/fp_to_meter] */ +#define PY 0.3 /* [m/fp_to_meter] */ +#define PZ 0.4 /* [m/fp_to_meter] */ + +/* Observation time */ +#define TIME 5 /* [s] */ + #define NREALISATIONS 100000 +#define COMMAND "stardis -V3 -p "STR(PX)","STR(PY)","STR(PZ)","STR(TIME) \ + " -n "STR(NREALISATIONS)" -M "FILENAME_SCENE " -I -INF" +#define COMMAND_DSPHERE COMMAND" -a dsphere" +#define COMMAND_WOS COMMAND" -a wos" + /******************************************************************************* * Helper functions ******************************************************************************/ @@ -66,7 +83,7 @@ setup_sshape(FILE* stream) struct s3dut_mesh_data sshape_data; struct s3dut_super_formula f0 = S3DUT_SUPER_FORMULA_NULL; struct s3dut_super_formula f1 = S3DUT_SUPER_FORMULA_NULL; - const double radius = 2; + const double radius = 1; const unsigned nslices = 256; f0.A = 1.5; f0.B = 1; f0.M = 11.0; f0.N0 = 1; f0.N1 = 1; f0.N2 = 2.0; @@ -88,7 +105,7 @@ setup_scene { ASSERT(sshape && profile); - fprintf(fp, "PROGRAM unsteady_profile libsadist-unsteady-profile.so\n"); + fprintf(fp, "PROGRAM unsteady_profile libsadist_unsteady_profile.so\n"); fprintf(fp, "SOLID SuperShape %g %g %g %g 0 UNKNOWN 0 BACK %s\n", LAMBDA, RHO, CP, DELTA, sshape); @@ -139,6 +156,53 @@ error: goto exit; } +static int +run(struct sadist_unsteady_profile* profile, const char* command) +{ + const double P[3] = {PX, PY, PZ}; + FILE* output = NULL; + double ref = 0; + double E = 0; + double SE = 0; + int n = 0; + int err = 0; + int status = 0; + + printf("%s\n", command); + + if(!(output = popen(command, "r"))) { + fprintf(stderr, "Error executing stardis -- %s\n", strerror(errno)); + fprintf(stderr, "\t"COMMAND"\n"); + err = errno; + goto error; + } + + if((n = fscanf(output, "%lf %lf %*d %*d", &E, &SE)), n != 2 && n != EOF) { + fprintf(stderr, "Error reading the output stream -- %s\n", strerror(errno)); + err = errno; + goto error; + } + + /* Check command exit status */ + if((status=pclose(output), output=NULL, status)) { + if(WIFEXITED(status)) err = WEXITSTATUS(status); + goto error; + } + + ref = sadist_unsteady_profile_temperature(profile, P, TIME); + printf("T = %g ~ %g +/- %g\n", ref, E, SE); + if(!eq_eps(ref, E, SE*3)) { + err = 1; + goto error; + } + +exit: + if(output) pclose(output); + return err; +error: + goto exit; +} + /******************************************************************************* * The test ******************************************************************************/ @@ -150,6 +214,8 @@ main(int argc, char** argv) (void)argc, (void)argv; if((err = init(&profile))) goto error; + if((err = run(&profile, COMMAND_DSPHERE))) goto error; + if((err = run(&profile, COMMAND_WOS))) goto error; exit: if(mem_allocated_size() != 0) {