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); fclose(fp);
} }
void AcResult
update_config(AcMeshInfo* config) acUpdateConfig(AcMeshInfo* config)
{ {
config->int_params[AC_mx] = config->int_params[AC_nx] + STENCIL_ORDER; config->int_params[AC_mx] = config->int_params[AC_nx] + STENCIL_ORDER;
///////////// PAD TEST ///////////// 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_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_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]; 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)); memset(config, (uint8_t)0xFF, sizeof(*config));
parse_config(config_path, config); parse_config(config_path, config);
update_config(config); acUpdateConfig(config);
#if VERBOSE_PRINTING // Defined in astaroth.h #if VERBOSE_PRINTING // Defined in astaroth.h
printf("###############################################################\n"); printf("###############################################################\n");
printf("Config dimensions recalculated:\n"); printf("Config dimensions recalculated:\n");

View File

@@ -32,6 +32,9 @@ extern "C" {
/** Loads data from the config file */ /** Loads data from the config file */
AcResult acLoadConfig(const char* config_path, AcMeshInfo* config); 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 #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif

View File

@@ -128,13 +128,23 @@ print_error_to_file(const char* path, const int n, const Error error)
fclose(file); 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 static void
print_error_to_screen(const Error error) 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]); printf("\t%-15s... ", vtxbuf_names[error.handle]);
if (is_acceptable) { if (is_acceptable(error)) {
printf(GRN "OK! " RESET); printf(GRN "OK! " RESET);
} }
else { else {