Added acMeshRandomize to astaroth.h to keep core and utils separate

This commit is contained in:
jpekkila
2020-11-02 17:14:26 +02:00
parent d48a478254
commit 349093768d
6 changed files with 21 additions and 23 deletions

View File

@@ -590,6 +590,9 @@ AcResult acUpdateBuiltinParams(AcMeshInfo* config);
/** Creates a mesh stored in host memory */
AcResult acMeshCreate(const AcMeshInfo mesh_info, AcMesh* mesh);
/** Randomizes a host mesh */
AcResult acMeshRandomize(AcMesh* mesh);
/** Destroys a mesh stored in host memory */
AcResult acMeshDestroy(AcMesh* mesh);

View File

@@ -50,9 +50,6 @@ AcResult acVertexBufferSet(const VertexBufferHandle handle, const AcReal value,
/** */
AcResult acMeshSet(const AcReal value, AcMesh* mesh);
/** */
AcResult acMeshRandomize(AcMesh* mesh);
/** */
AcResult acMeshApplyPeriodicBounds(AcMesh* mesh);

View File

@@ -2,7 +2,7 @@ find_package(CUDAToolkit)
## Astaroth Core
add_library(astaroth_core STATIC device.cc node.cc astaroth.cc astaroth_fortran.cc)
target_link_libraries(astaroth_core astaroth_utils astaroth_kernels CUDA::cudart CUDA::cuda_driver)
target_link_libraries(astaroth_core astaroth_kernels CUDA::cudart CUDA::cuda_driver)
## Options
if (MPI_ENABLED)

View File

@@ -221,6 +221,23 @@ acMeshCreate(const AcMeshInfo info, AcMesh* mesh)
return AC_SUCCESS;
}
static AcReal
randf(void)
{
return (AcReal)rand() / (AcReal)RAND_MAX;
}
AcResult
acMeshRandomize(AcMesh* mesh)
{
const int n = acVertexBufferSize(mesh->info);
for (int w = 0; w < NUM_VTXBUF_HANDLES; ++w)
for (int i = 0; i < n; ++i)
mesh->vertex_buffer[w][i] = randf();
return AC_SUCCESS;
}
AcResult
acMeshDestroy(AcMesh* mesh)
{

View File

@@ -1242,8 +1242,6 @@ acGridSynchronizeStream(const Stream stream)
return AC_SUCCESS;
}
#include "astaroth_utils.h" // HACK TO RANDOMIZE
AcResult
acGridRandomize(void)
{

View File

@@ -38,23 +38,6 @@ acMeshSet(const AcReal value, AcMesh* mesh)
return AC_SUCCESS;
}
static AcReal
randf(void)
{
return (AcReal)rand() / (AcReal)RAND_MAX;
}
AcResult
acMeshRandomize(AcMesh* mesh)
{
const int n = acVertexBufferSize(mesh->info);
for (int w = 0; w < NUM_VTXBUF_HANDLES; ++w)
for (int i = 0; i < n; ++i)
mesh->vertex_buffer[w][i] = randf();
return AC_SUCCESS;
}
AcResult
acMeshApplyPeriodicBounds(AcMesh* mesh)
{