Merged in cmakelist_rewrite_and_C_API_conformity_07-26 (pull request #1)
This commit is contained in:
@@ -1,10 +1,39 @@
|
||||
################################
|
||||
## CMakeLists.txt for utils ##
|
||||
################################
|
||||
##############################################
|
||||
## CMakeLists.txt for Astaroth Standalone ##
|
||||
##############################################
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
## Files
|
||||
file (GLOB SOURCES "*.cc" "model/*.cc")
|
||||
|
||||
add_library(astaroth_standalone STATIC ${SOURCES})
|
||||
target_include_directories(astaroth_standalone PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
#target_compile_definitions(astaroth_standalone PRIVATE CONFIG_PATH=\"${CMAKE_SOURCE_DIR}/config/\")
|
||||
target_compile_definitions(astaroth_standalone PRIVATE CONFIG_PATH=\"${ASTAROTH_CONF_PATH}\")
|
||||
## Find packages
|
||||
find_package(OpenMP REQUIRED)
|
||||
if (BUILD_RT_VISUALIZATION)
|
||||
add_definitions(-DAC_BUILD_RT_VISUALIZATION=1)
|
||||
# SDL 2
|
||||
set(SDL2_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/SDL2/include/)
|
||||
set(SDL2_LIBRARY_DIR ${CMAKE_SOURCE_DIR}/3rdparty/SDL2/build/)
|
||||
set(SDL2_LIBRARY "SDL2")
|
||||
include_directories(${SDL2_INCLUDE_DIR})
|
||||
link_directories(${SDL2_LIBRARY_DIR})
|
||||
endif ()
|
||||
|
||||
## Compilation flags
|
||||
add_compile_options(-pipe ${OpenMP_CXX_FLAGS})
|
||||
add_compile_options(-Wall -Wextra -Werror -Wdouble-promotion -Wfloat-conversion)# -Wshadow)
|
||||
|
||||
## Compile and link
|
||||
add_library(astaroth_standalone ${SOURCES})
|
||||
|
||||
add_executable(ac_run main.cc)
|
||||
target_link_libraries(ac_run PRIVATE astaroth_standalone astaroth_core "${OpenMP_CXX_FLAGS}" ${SDL2_LIBRARY})
|
||||
|
||||
# Define the config directory
|
||||
if (ALTER_CONF)
|
||||
# ASTAROTH_CONF_PATH supplied by ac_mkbuilddir.sh
|
||||
target_compile_definitions(astaroth_standalone PRIVATE CONFIG_PATH="${ASTAROTH_CONF_PATH}/")
|
||||
else()
|
||||
target_compile_definitions(astaroth_standalone PRIVATE CONFIG_PATH="${CMAKE_SOURCE_DIR}/config/")
|
||||
endif()
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "config_loader.h"
|
||||
#include "core/math_utils.h"
|
||||
#include "src/core/math_utils.h"
|
||||
#include "model/host_forcing.h"
|
||||
#include "model/host_memory.h"
|
||||
#include "model/host_timestep.h"
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "model/model_reduce.h"
|
||||
#include "model/model_rk3.h"
|
||||
|
||||
#include "core/errchk.h"
|
||||
#include "src/core/errchk.h"
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ run_benchmark(void)
|
||||
#if AUTO_OPTIMIZE
|
||||
const char* benchmark_path = "benchmark.out";
|
||||
|
||||
#include "core/kernels/rk3_threadblock.conf"
|
||||
#include "src/core/kernels/rk3_threadblock.conf"
|
||||
static int
|
||||
write_result_to_file(const float& ms_per_step)
|
||||
{
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#include <stdio.h> // print
|
||||
#include <string.h> // memset
|
||||
|
||||
#include "core/errchk.h"
|
||||
#include "core/math_utils.h"
|
||||
#include "src/core/errchk.h"
|
||||
#include "src/core/math_utils.h"
|
||||
|
||||
static inline void
|
||||
print(const AcMeshInfo& config)
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core/errchk.h"
|
||||
#include "run.h"
|
||||
#include "src/core/errchk.h"
|
||||
|
||||
// Write all errors from stderr to an <errorlog_name> in the current working
|
||||
// directory
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
*/
|
||||
#include "host_forcing.h"
|
||||
|
||||
#include "core/math_utils.h"
|
||||
#include "src/core/math_utils.h"
|
||||
|
||||
// The is a wrapper for genering random numbers with a chosen system.
|
||||
AcReal
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "core/errchk.h"
|
||||
#include "src/core/errchk.h"
|
||||
|
||||
#define AC_GEN_STR(X) #X
|
||||
const char* init_type_names[] = {AC_FOR_INIT_TYPES(AC_GEN_STR)};
|
||||
|
||||
@@ -26,32 +26,35 @@
|
||||
*/
|
||||
#include "host_timestep.h"
|
||||
|
||||
#include "core/math_utils.h"
|
||||
#include "src/core/math_utils.h"
|
||||
|
||||
static AcReal timescale = AcReal(1.0);
|
||||
|
||||
AcReal
|
||||
host_timestep(const AcReal& umax, const AcMeshInfo& mesh_info)
|
||||
{
|
||||
const long double cdt = mesh_info.real_params[AC_cdt];
|
||||
const long double cdtv = mesh_info.real_params[AC_cdtv];
|
||||
const long double cdt = mesh_info.real_params[AC_cdt];
|
||||
const long double cdtv = mesh_info.real_params[AC_cdtv];
|
||||
// const long double cdts = mesh_info.real_params[AC_cdts];
|
||||
const long double cs2_sound = mesh_info.real_params[AC_cs2_sound];
|
||||
const long double nu_visc = mesh_info.real_params[AC_nu_visc];
|
||||
const long double eta = mesh_info.real_params[AC_eta];
|
||||
const long double chi = 0; // mesh_info.real_params[AC_chi]; // TODO not calculated
|
||||
const long double gamma = mesh_info.real_params[AC_gamma];
|
||||
const long double dsmin = mesh_info.real_params[AC_dsmin];
|
||||
const long double nu_visc = mesh_info.real_params[AC_nu_visc];
|
||||
const long double eta = mesh_info.real_params[AC_eta];
|
||||
const long double chi = 0; // mesh_info.real_params[AC_chi]; // TODO not calculated
|
||||
const long double gamma = mesh_info.real_params[AC_gamma];
|
||||
const long double dsmin = mesh_info.real_params[AC_dsmin];
|
||||
|
||||
// Old ones from legacy Astaroth
|
||||
//const long double uu_dt = cdt * (dsmin / (umax + cs_sound));
|
||||
//const long double visc_dt = cdtv * dsmin * dsmin / nu_visc;
|
||||
// const long double uu_dt = cdt * (dsmin / (umax + cs_sound));
|
||||
// const long double visc_dt = cdtv * dsmin * dsmin / nu_visc;
|
||||
|
||||
// New, closer to the actual Courant timestep
|
||||
// See Pencil Code user manual p. 38 (timestep section)
|
||||
const long double uu_dt = cdt * dsmin / (fabsl(umax) + sqrtl(cs2_sound + 0.0l));
|
||||
const long double visc_dt = cdtv * dsmin * dsmin / max(max(nu_visc, eta), max(gamma, chi));// + 1; // TODO NOTE: comment the +1 out to get scientifically accurate results
|
||||
//MV: White the +1? It was messing up my computations!
|
||||
const long double visc_dt = cdtv * dsmin * dsmin /
|
||||
max(max(nu_visc, eta),
|
||||
max(gamma, chi)); // + 1; // TODO NOTE: comment the +1 out to
|
||||
// get scientifically accurate results
|
||||
// MV: White the +1? It was messing up my computations!
|
||||
|
||||
const long double dt = min(uu_dt, visc_dt);
|
||||
return AcReal(timescale) * AcReal(dt);
|
||||
|
||||
@@ -26,73 +26,68 @@
|
||||
*/
|
||||
#include "model_boundconds.h"
|
||||
|
||||
#include "core/errchk.h"
|
||||
|
||||
#include "src/core/errchk.h"
|
||||
|
||||
void
|
||||
boundconds(const AcMeshInfo& mesh_info, ModelMesh* mesh)
|
||||
{
|
||||
#pragma omp parallel for
|
||||
#pragma omp parallel for
|
||||
for (int w = 0; w < NUM_VTXBUF_HANDLES; ++w) {
|
||||
const int3 start = (int3){0, 0, 0};
|
||||
const int3 end = (int3){
|
||||
mesh_info.int_params[AC_mx],
|
||||
mesh_info.int_params[AC_my],
|
||||
mesh_info.int_params[AC_mz]
|
||||
};
|
||||
const int3 end = (int3){mesh_info.int_params[AC_mx], mesh_info.int_params[AC_my],
|
||||
mesh_info.int_params[AC_mz]};
|
||||
|
||||
const int nx = mesh_info.int_params[AC_nx];
|
||||
const int ny = mesh_info.int_params[AC_ny];
|
||||
const int nz = mesh_info.int_params[AC_nz];
|
||||
|
||||
const int nx_min = mesh_info.int_params[AC_nx_min];
|
||||
const int ny_min = mesh_info.int_params[AC_ny_min];
|
||||
const int nz_min = mesh_info.int_params[AC_nz_min];
|
||||
const int nx_min = mesh_info.int_params[AC_nx_min];
|
||||
const int ny_min = mesh_info.int_params[AC_ny_min];
|
||||
const int nz_min = mesh_info.int_params[AC_nz_min];
|
||||
|
||||
// The old kxt was inclusive, but our mx_max is exclusive
|
||||
const int nx_max = mesh_info.int_params[AC_nx_max];
|
||||
const int ny_max = mesh_info.int_params[AC_ny_max];
|
||||
const int nz_max = mesh_info.int_params[AC_nz_max];
|
||||
// The old kxt was inclusive, but our mx_max is exclusive
|
||||
const int nx_max = mesh_info.int_params[AC_nx_max];
|
||||
const int ny_max = mesh_info.int_params[AC_ny_max];
|
||||
const int nz_max = mesh_info.int_params[AC_nz_max];
|
||||
|
||||
for (int k_dst = start.z; k_dst < end.z; ++k_dst) {
|
||||
for (int j_dst = start.y; j_dst < end.y; ++j_dst) {
|
||||
for (int i_dst = start.x; i_dst < end.x; ++i_dst) {
|
||||
for (int j_dst = start.y; j_dst < end.y; ++j_dst) {
|
||||
for (int i_dst = start.x; i_dst < end.x; ++i_dst) {
|
||||
|
||||
// If destination index is inside the computational domain, return since
|
||||
// the boundary conditions are only applied to the ghost zones
|
||||
if (i_dst >= nx_min && i_dst < nx_max &&
|
||||
j_dst >= ny_min && j_dst < ny_max &&
|
||||
k_dst >= nz_min && k_dst < nz_max)
|
||||
continue;
|
||||
// If destination index is inside the computational domain, return since
|
||||
// the boundary conditions are only applied to the ghost zones
|
||||
if (i_dst >= nx_min && i_dst < nx_max && j_dst >= ny_min && j_dst < ny_max &&
|
||||
k_dst >= nz_min && k_dst < nz_max)
|
||||
continue;
|
||||
|
||||
// Find the source index
|
||||
// Map to nx, ny, nz coordinates
|
||||
int i_src = i_dst - nx_min;
|
||||
int j_src = j_dst - ny_min;
|
||||
int k_src = k_dst - nz_min;
|
||||
// Find the source index
|
||||
// Map to nx, ny, nz coordinates
|
||||
int i_src = i_dst - nx_min;
|
||||
int j_src = j_dst - ny_min;
|
||||
int k_src = k_dst - nz_min;
|
||||
|
||||
// Translate (s.t. the index is always positive)
|
||||
i_src += nx;
|
||||
j_src += ny;
|
||||
k_src += nz;
|
||||
// Translate (s.t. the index is always positive)
|
||||
i_src += nx;
|
||||
j_src += ny;
|
||||
k_src += nz;
|
||||
|
||||
// Wrap
|
||||
i_src %= nx;
|
||||
j_src %= ny;
|
||||
k_src %= nz;
|
||||
// Wrap
|
||||
i_src %= nx;
|
||||
j_src %= ny;
|
||||
k_src %= nz;
|
||||
|
||||
// Map to mx, my, mz coordinates
|
||||
i_src += nx_min;
|
||||
j_src += ny_min;
|
||||
k_src += nz_min;
|
||||
// Map to mx, my, mz coordinates
|
||||
i_src += nx_min;
|
||||
j_src += ny_min;
|
||||
k_src += nz_min;
|
||||
|
||||
const size_t src_idx = acVertexBufferIdx(i_src, j_src, k_src, mesh_info);
|
||||
const size_t dst_idx = acVertexBufferIdx(i_dst, j_dst, k_dst, mesh_info);
|
||||
ERRCHK(src_idx < acVertexBufferSize(mesh_info));
|
||||
ERRCHK(dst_idx < acVertexBufferSize(mesh_info));
|
||||
mesh->vertex_buffer[w][dst_idx] = mesh->vertex_buffer[w][src_idx];
|
||||
}
|
||||
}
|
||||
const size_t src_idx = acVertexBufferIdx(i_src, j_src, k_src, mesh_info);
|
||||
const size_t dst_idx = acVertexBufferIdx(i_dst, j_dst, k_dst, mesh_info);
|
||||
ERRCHK(src_idx < acVertexBufferSize(mesh_info));
|
||||
ERRCHK(dst_idx < acVertexBufferSize(mesh_info));
|
||||
mesh->vertex_buffer[w][dst_idx] = mesh->vertex_buffer[w][src_idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "core/errchk.h"
|
||||
#include "src/core/errchk.h"
|
||||
|
||||
typedef long double MODEL_REAL;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "core/errchk.h"
|
||||
#include "src/core/errchk.h"
|
||||
|
||||
// Function pointer definitions
|
||||
typedef ModelScalar (*ReduceFunc)(const ModelScalar&, const ModelScalar&);
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#include <string.h> // memcpy
|
||||
|
||||
#include "config_loader.h"
|
||||
#include "core/errchk.h"
|
||||
#include "core/math_utils.h"
|
||||
#include "src/core/errchk.h"
|
||||
#include "src/core/math_utils.h"
|
||||
#include "model/host_forcing.h"
|
||||
#include "model/host_memory.h"
|
||||
#include "model/host_timestep.h"
|
||||
@@ -430,7 +430,7 @@ run_renderer(void)
|
||||
return 0;
|
||||
}
|
||||
#else // BUILD_RT_VISUALIZATION == 0
|
||||
#include "core/errchk.h"
|
||||
#include "src/core/errchk.h"
|
||||
int
|
||||
run_renderer(void)
|
||||
{
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#include "run.h"
|
||||
|
||||
#include "config_loader.h"
|
||||
#include "core/errchk.h"
|
||||
#include "core/math_utils.h"
|
||||
#include "src/core/errchk.h"
|
||||
#include "src/core/math_utils.h"
|
||||
#include "model/host_forcing.h"
|
||||
#include "model/host_memory.h"
|
||||
#include "model/host_timestep.h"
|
||||
|
||||
Reference in New Issue
Block a user