Some small improvements to the utils library

This commit is contained in:
jpekkila
2019-10-15 17:00:58 +03:00
parent 46ad9da8c8
commit ff1ad37047
3 changed files with 21 additions and 6 deletions

View File

@@ -77,8 +77,8 @@ parse_config(const char* path, AcMeshInfo* config)
fclose(fp);
}
void
update_config(AcMeshInfo* config)
AcResult
acUpdateConfig(AcMeshInfo* config)
{
config->int_params[AC_mx] = config->int_params[AC_nx] + STENCIL_ORDER;
///////////// PAD TEST
@@ -109,6 +109,8 @@ update_config(AcMeshInfo* config)
config->int_params[AC_mxy] = config->int_params[AC_mx] * config->int_params[AC_my];
config->int_params[AC_nxy] = config->int_params[AC_nx] * config->int_params[AC_ny];
config->int_params[AC_nxyz] = config->int_params[AC_nxy] * config->int_params[AC_nz];
return AC_SUCCESS;
}
/**
@@ -126,7 +128,7 @@ acLoadConfig(const char* config_path, AcMeshInfo* config)
memset(config, (uint8_t)0xFF, sizeof(*config));
parse_config(config_path, config);
update_config(config);
acUpdateConfig(config);
#if VERBOSE_PRINTING // Defined in astaroth.h
printf("###############################################################\n");
printf("Config dimensions recalculated:\n");

View File

@@ -32,6 +32,9 @@ extern "C" {
/** Loads data from the config file */
AcResult acLoadConfig(const char* config_path, AcMeshInfo* config);
/** Updates the built-in parameters based on nx, ny and nz */
AcResult acUpdateConfig(AcMeshInfo* config);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -128,13 +128,23 @@ print_error_to_file(const char* path, const int n, const Error error)
fclose(file);
}
static bool
is_acceptable(const Error error)
{
// TODO FIXME
const AcReal range = error.maximum_magnitude - error.minimum_magnitude;
if (error.abs_error < range * AC_REAL_EPSILON)
return true;
else
return false;
}
static void
print_error_to_screen(const Error error)
{
const bool is_acceptable = true;
printf("WARNING: is_acceptable() not yet complete\n");
printf("\t%-15s... ", vtxbuf_names[error.handle]);
if (is_acceptable) {
if (is_acceptable(error)) {
printf(GRN "OK! " RESET);
}
else {