commit bebcae08b751defad93583b4f02aeb610af3219f
parent 676a52edf591956877ebfa43e7f1c845dcb9bd10
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 25 Feb 2025 16:10:04 +0100
suvm-map-data only maps a single data per tetra
Until now, the synthax command implied that multiple data could be
mapped to each tetrahedron. But this would increase the complexity of
the code and the output (and therefore its size) without any significant
advantage. Simply re-invoke the command to associate other data with the
mesh.
What's more, data names are no longer user-definable, but fixed to
further simplify the code.
Diffstat:
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/src/suvm_map_data.c b/src/suvm_map_data.c
@@ -19,24 +19,17 @@
#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};
@@ -45,8 +38,6 @@ 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};
@@ -57,7 +48,7 @@ static INLINE void
usage(FILE* stream)
{
fprintf(stream,
- "usage: suvm-map-data [-d data] [-o output] [-n name ...] -m mesh\n");
+ "usage: suvm-map-data [-d data] [-o output] -m mesh\n");
}
static void
@@ -79,12 +70,6 @@ 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;
}
@@ -170,6 +155,8 @@ 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:
@@ -263,7 +250,6 @@ 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;