Merge branch 'master' into sink_20190723
This commit is contained in:
@@ -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&);
|
||||
|
||||
Reference in New Issue
Block a user