Added acMeshRandomize to astaroth.h to keep core and utils separate
This commit is contained in:
@@ -590,6 +590,9 @@ AcResult acUpdateBuiltinParams(AcMeshInfo* config);
|
|||||||
/** Creates a mesh stored in host memory */
|
/** Creates a mesh stored in host memory */
|
||||||
AcResult acMeshCreate(const AcMeshInfo mesh_info, AcMesh* mesh);
|
AcResult acMeshCreate(const AcMeshInfo mesh_info, AcMesh* mesh);
|
||||||
|
|
||||||
|
/** Randomizes a host mesh */
|
||||||
|
AcResult acMeshRandomize(AcMesh* mesh);
|
||||||
|
|
||||||
/** Destroys a mesh stored in host memory */
|
/** Destroys a mesh stored in host memory */
|
||||||
AcResult acMeshDestroy(AcMesh* mesh);
|
AcResult acMeshDestroy(AcMesh* mesh);
|
||||||
|
|
||||||
|
@@ -50,9 +50,6 @@ AcResult acVertexBufferSet(const VertexBufferHandle handle, const AcReal value,
|
|||||||
/** */
|
/** */
|
||||||
AcResult acMeshSet(const AcReal value, AcMesh* mesh);
|
AcResult acMeshSet(const AcReal value, AcMesh* mesh);
|
||||||
|
|
||||||
/** */
|
|
||||||
AcResult acMeshRandomize(AcMesh* mesh);
|
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
AcResult acMeshApplyPeriodicBounds(AcMesh* mesh);
|
AcResult acMeshApplyPeriodicBounds(AcMesh* mesh);
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ find_package(CUDAToolkit)
|
|||||||
|
|
||||||
## Astaroth Core
|
## Astaroth Core
|
||||||
add_library(astaroth_core STATIC device.cc node.cc astaroth.cc astaroth_fortran.cc)
|
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
|
## Options
|
||||||
if (MPI_ENABLED)
|
if (MPI_ENABLED)
|
||||||
|
@@ -221,6 +221,23 @@ acMeshCreate(const AcMeshInfo info, AcMesh* mesh)
|
|||||||
return AC_SUCCESS;
|
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
|
AcResult
|
||||||
acMeshDestroy(AcMesh* mesh)
|
acMeshDestroy(AcMesh* mesh)
|
||||||
{
|
{
|
||||||
|
@@ -1242,8 +1242,6 @@ acGridSynchronizeStream(const Stream stream)
|
|||||||
return AC_SUCCESS;
|
return AC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "astaroth_utils.h" // HACK TO RANDOMIZE
|
|
||||||
AcResult
|
AcResult
|
||||||
acGridRandomize(void)
|
acGridRandomize(void)
|
||||||
{
|
{
|
||||||
|
@@ -38,23 +38,6 @@ acMeshSet(const AcReal value, AcMesh* mesh)
|
|||||||
return AC_SUCCESS;
|
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
|
AcResult
|
||||||
acMeshApplyPeriodicBounds(AcMesh* mesh)
|
acMeshApplyPeriodicBounds(AcMesh* mesh)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user