Cleaned up samples and removed old unused stuff. Simplified CMake files.

This commit is contained in:
jpekkila
2020-01-23 20:00:19 +02:00
parent 7215e842fc
commit fdd829b888
8 changed files with 43 additions and 502 deletions

View File

@@ -1,9 +1,3 @@
##############################################
## CMakeLists.txt for the C API test ##
##############################################
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
## ctest
add_executable(ctest main.c)
target_link_libraries(ctest PRIVATE astaroth_core astaroth_utils)

View File

@@ -20,17 +20,18 @@
#include <stdlib.h>
#include "astaroth.h"
// From Astaroth Utils
#include "src/utils/config_loader.h"
#include "src/utils/memory.h"
#include "src/utils/verification.h"
#include "astaroth_utils.h"
int
main(void)
{
AcMeshInfo info;
acLoadConfig(AC_DEFAULT_CONFIG, &info);
// Some real params must be calculated (for the MHD case) // TODO DANGEROUS
info.real_params[AC_inv_dsx] = (AcReal)(1.0) / info.real_params[AC_dsx];
info.real_params[AC_inv_dsy] = (AcReal)(1.0) / info.real_params[AC_dsy];
info.real_params[AC_inv_dsz] = (AcReal)(1.0) / info.real_params[AC_dsz];
info.real_params[AC_cs2_sound] = info.real_params[AC_cs_sound] * info.real_params[AC_cs_sound];
// Alloc
AcMesh model, candidate;
@@ -41,17 +42,26 @@ main(void)
acMeshRandomize(&model);
acMeshApplyPeriodicBounds(&model);
////////////////////////////////////////////////////////////////////////////////////////////////
// Verify that the mesh was loaded and stored correctly
acInit(info);
acLoad(model);
acStore(&candidate);
acQuit();
////////////////////////////////////////////////////////////////////////////////////////////////
// Verify and destroy
acVerifyMesh(model, candidate);
// Attempt to integrate and check max and min
printf("Integrating... ");
acIntegrate(FLT_EPSILON);
printf("Done.\nVTXBUF ranges after one integration step:\n");
for (size_t i = 0; i < NUM_VTXBUF_HANDLES; ++i)
printf("\t%-15s... [%.3g, %.3g]\n", vtxbuf_names[i], //
(double)acReduceScal(RTYPE_MIN, i), //
(double)acReduceScal(RTYPE_MAX, i));
// Destroy
acQuit();
acMeshDestroy(&model);
acMeshDestroy(&candidate);
puts("ctest complete.");
return EXIT_SUCCESS;
}