star-uvm

Spatial structuring of unstructured volumetric meshes
git clone git://git.meso-star.fr/star-uvm.git
Log | Files | Refs | README | LICENSE

commit 46356b5b1f7253681a1ea93a1cb3955a3cd04cb5
parent 91a9c2f2ad40114caa16ae2333893e7dc08d77fe
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 23 May 2025 11:38:13 +0200

Revert "suvm-map-data only maps a single data per tetra"

This reverts commit bebcae08b751defad93583b4f02aeb610af3219f.

Diffstat:
Msrc/suvm_map_data.c | 22++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/suvm_map_data.c b/src/suvm_map_data.c @@ -19,17 +19,24 @@ #include <rsys/cstr.h> #include <rsys/mem_allocator.h> -#include <rsys/text_reader.h> #include <errno.h> #include <string.h> /* strerror */ #include <unistd.h> /* getopt */ +/* Maximum number of data items that can be mapped to each cell */ +#define MAX_DATA 8 + /* Input arguments */ struct args { const char* mesh; /* Tetrahedral mesh */ const char* output; /* Output file */ const char* data; /* Data to map */ + + /* List of data names. + * If a name is missing for a data item, a default name is used */ + const char* names[MAX_DATA]; + int nnames; /* Number of names */ }; static const struct args ARGS_DEFAULT = {0}; @@ -38,6 +45,8 @@ struct cmd { struct smsh* mesh; /* Tetrahedral mesh */ FILE* output; /* Ouput file */ FILE* data; /* Data to map */ + + const char* names[MAX_DATA]; }; static const struct cmd CMD_NULL = {0}; @@ -48,7 +57,7 @@ static INLINE void usage(FILE* stream) { fprintf(stream, - "usage: suvm-map-data [-d data] [-o output] -m mesh\n"); + "usage: suvm-map-data [-d data] [-o output] [-n name ...] -m mesh\n"); } static void @@ -70,6 +79,12 @@ args_init(struct args* args, const int argc, char** argv) switch(opt) { case 'd': args->data = optarg; break; case 'm': args->mesh = optarg; break; + case 'n': + if(args->nnames < MAX_DATA) { + args->names[args->nnames] = optarg; + ++args->nnames; + } + break; case 'o': args->output = optarg; break; default: res = RES_BAD_ARG; } @@ -155,8 +170,6 @@ write_mesh(struct cmd* cmd) FPRINTF("CELL_TYPES %zu\n", desc.ncells); FOR_EACH(i, 0, desc.ncells) FPRINTF("10\n"); /* VTK_TETRA == 10 */ - #undef FPRINTF - exit: return res; error: @@ -250,6 +263,7 @@ cmd_init(struct cmd* cmd, const struct args* args) if((res = setup_mesh(cmd, args)) != RES_OK) goto error; if((res = setup_data(cmd, args)) != RES_OK) goto error; if((res = setup_output(cmd, args)) != RES_OK) goto error; + memcpy(cmd->names, args->names, sizeof(char*)*MAX_DATA); exit: return res;