Merge branch 'master' into sink_20190723
This commit is contained in:
@@ -318,7 +318,7 @@ verify_meshes(const ModelMesh& model, const AcMesh& candidate)
|
||||
|
||||
const ModelScalar range = get_data_range(model);
|
||||
for (int w = 0; w < NUM_VTXBUF_HANDLES; ++w) {
|
||||
const size_t n = AC_VTXBUF_SIZE(model.info);
|
||||
const size_t n = acVertexBufferSize(model.info);
|
||||
|
||||
// Maximum errors
|
||||
ErrorInfo max_abs_error = ErrorInfo();
|
||||
@@ -555,7 +555,7 @@ get_max_abs_error_mesh(const ModelMesh& model_mesh, const AcMesh& candidate_mesh
|
||||
error.abs_error = -1;
|
||||
|
||||
for (size_t j = 0; j < NUM_VTXBUF_HANDLES; ++j) {
|
||||
for (size_t i = 0; i < AC_VTXBUF_SIZE(model_mesh.info); ++i) {
|
||||
for (size_t i = 0; i < acVertexBufferSize(model_mesh.info); ++i) {
|
||||
Error curr_error = get_error(model_mesh.vertex_buffer[j][i],
|
||||
candidate_mesh.vertex_buffer[j][i]);
|
||||
if (curr_error.abs_error > error.abs_error)
|
||||
@@ -574,7 +574,7 @@ get_maximum_magnitude(const ModelScalar* field, const AcMeshInfo info)
|
||||
{
|
||||
ModelScalar maximum = -INFINITY;
|
||||
|
||||
for (size_t i = 0; i < AC_VTXBUF_SIZE(info); ++i)
|
||||
for (size_t i = 0; i < acVertexBufferSize(info); ++i)
|
||||
maximum = max(maximum, fabsl(field[i]));
|
||||
|
||||
return maximum;
|
||||
@@ -585,7 +585,7 @@ get_minimum_magnitude(const ModelScalar* field, const AcMeshInfo info)
|
||||
{
|
||||
ModelScalar minimum = INFINITY;
|
||||
|
||||
for (size_t i = 0; i < AC_VTXBUF_SIZE(info); ++i)
|
||||
for (size_t i = 0; i < acVertexBufferSize(info); ++i)
|
||||
minimum = min(minimum, fabsl(field[i]));
|
||||
|
||||
return minimum;
|
||||
@@ -601,7 +601,7 @@ get_max_abs_error_vtxbuf(const VertexBufferHandle vtxbuf_handle, const ModelMesh
|
||||
Error error;
|
||||
error.abs_error = -1;
|
||||
|
||||
for (size_t i = 0; i < AC_VTXBUF_SIZE(model_mesh.info); ++i) {
|
||||
for (size_t i = 0; i < acVertexBufferSize(model_mesh.info); ++i) {
|
||||
|
||||
Error curr_error = get_error(model_vtxbuf[i], candidate_vtxbuf[i]);
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
static inline void
|
||||
print(const AcMeshInfo& config)
|
||||
{
|
||||
for (int i = 0; i < NUM_INT_PARAM_TYPES; ++i)
|
||||
for (int i = 0; i < NUM_INT_PARAMS; ++i)
|
||||
printf("[%s]: %d\n", intparam_names[i], config.int_params[i]);
|
||||
for (int i = 0; i < NUM_REAL_PARAM_TYPES; ++i)
|
||||
for (int i = 0; i < NUM_REAL_PARAMS; ++i)
|
||||
printf("[%s]: %g\n", realparam_names[i], double(config.real_params[i]));
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ parse_config(const char* path, AcMeshInfo* config)
|
||||
continue;
|
||||
|
||||
int idx = -1;
|
||||
if ((idx = find_str(keyword, intparam_names, NUM_INT_PARAM_TYPES)) >= 0)
|
||||
if ((idx = find_str(keyword, intparam_names, NUM_INT_PARAMS)) >= 0)
|
||||
config->int_params[idx] = atoi(value);
|
||||
else if ((idx = find_str(keyword, realparam_names, NUM_REAL_PARAM_TYPES)) >= 0)
|
||||
else if ((idx = find_str(keyword, realparam_names, NUM_REAL_PARAMS)) >= 0)
|
||||
config->real_params[idx] = AcReal(atof(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
|
||||
#include "core/errchk.h"
|
||||
|
||||
#define AC_GEN_STR(X) #X
|
||||
const char* init_type_names[] = {AC_FOR_INIT_TYPES(AC_GEN_STR)};
|
||||
#undef AC_GEN_STR
|
||||
|
||||
#define XORIG (AcReal(.5) * mesh->info.int_params[AC_nx] * mesh->info.real_params[AC_dsx])
|
||||
#define YORIG (AcReal(.5) * mesh->info.int_params[AC_ny] * mesh->info.real_params[AC_dsy])
|
||||
@@ -43,14 +45,14 @@ static uint64_t ac_rand_next = 1;
|
||||
static int32_t
|
||||
ac_rand(void)
|
||||
{
|
||||
ac_rand_next = ac_rand_next * 1103515245 + 12345;
|
||||
return (uint32_t)(ac_rand_next/65536) % 32768;
|
||||
ac_rand_next = ac_rand_next * 1103515245 + 12345;
|
||||
return (uint32_t)(ac_rand_next/65536) % 32768;
|
||||
}
|
||||
|
||||
static void
|
||||
ac_srand(const uint32_t seed)
|
||||
{
|
||||
ac_rand_next = seed;
|
||||
ac_rand_next = seed;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -60,7 +62,7 @@ acmesh_create(const AcMeshInfo& mesh_info)
|
||||
AcMesh* mesh = (AcMesh*)malloc(sizeof(*mesh));
|
||||
mesh->info = mesh_info;
|
||||
|
||||
const size_t bytes = AC_VTXBUF_SIZE_BYTES(mesh->info);
|
||||
const size_t bytes = acVertexBufferSizeBytes(mesh->info);
|
||||
for (int i = 0; i < NUM_VTXBUF_HANDLES; ++i) {
|
||||
mesh->vertex_buffer[VertexBufferHandle(i)] = (AcReal*)malloc(bytes);
|
||||
ERRCHK(mesh->vertex_buffer[VertexBufferHandle(i)] != NULL);
|
||||
@@ -70,15 +72,13 @@ acmesh_create(const AcMeshInfo& mesh_info)
|
||||
}
|
||||
|
||||
static void
|
||||
vertex_buffer_set(const VertexBufferHandle& key, const AcReal& val,
|
||||
AcMesh* mesh)
|
||||
vertex_buffer_set(const VertexBufferHandle& key, const AcReal& val, AcMesh* mesh)
|
||||
{
|
||||
const int n = AC_VTXBUF_SIZE(mesh->info);
|
||||
const int n = acVertexBufferSize(mesh->info);
|
||||
for (int i = 0; i < n; ++i)
|
||||
mesh->vertex_buffer[key][i] = val;
|
||||
}
|
||||
|
||||
|
||||
/** Inits all fields to 1. Setting the mesh to zero is problematic because some fields are supposed
|
||||
to be > 0 and the results would vary widely, which leads to loss of precision in the
|
||||
computations */
|
||||
@@ -95,13 +95,12 @@ randr(void)
|
||||
return AcReal(rand()) / AcReal(RAND_MAX);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
lnrho_step(AcMesh* mesh)
|
||||
{
|
||||
const int mx = mesh->info.int_params[AC_mx];
|
||||
const int my = mesh->info.int_params[AC_my];
|
||||
const int mz = mesh->info.int_params[AC_mz];
|
||||
const int mx = mesh->info.int_params[AC_mx];
|
||||
const int my = mesh->info.int_params[AC_my];
|
||||
const int mz = mesh->info.int_params[AC_mz];
|
||||
|
||||
// const int nx_min = mesh->info.int_params[AC_nx_min];
|
||||
// const int nx_max = mesh->info.int_params[AC_nx_max];
|
||||
@@ -116,22 +115,23 @@ lnrho_step(AcMesh* mesh)
|
||||
// const AcReal xmax = DX * (nx_max - nx_min) ;
|
||||
// const AcReal zmax = DZ * (nz_max - nz_min) ;
|
||||
|
||||
// const AcReal lnrho1 = (AcReal) -1.0; // TODO mesh->info.real_params[AC_lnrho1];
|
||||
const AcReal lnrho2 = (AcReal) 0.0; // TODO mesh->info.real_params[AC_lnrho2];
|
||||
// const AcReal rho1 = (AcReal) exp(lnrho1);
|
||||
// const AcReal lnrho1 = (AcReal) -1.0; // TODO mesh->info.real_params[AC_lnrho1];
|
||||
const AcReal lnrho2 = (AcReal)0.0; // TODO mesh->info.real_params[AC_lnrho2];
|
||||
// const AcReal rho1 = (AcReal) exp(lnrho1);
|
||||
// const AcReal rho2 = (AcReal) exp(lnrho2);
|
||||
|
||||
// const AcReal k_pert = (AcReal) 1.0; //mesh->info.real_params[AC_k_pert]; //Wamenumber of the perturbation
|
||||
// const AcReal k_pert = 4.0; //mesh->info.real_params[AC_k_pert]; //Wamenumber of the perturbation
|
||||
//const AcReal ampl_pert = xmax/10.0; // xmax/mesh->info.real_params[AC_pert]; //Amplitude of the perturbation
|
||||
// const AcReal ampl_pert = (AcReal) 0.0;//xmax/20.0; // xmax/mesh->info.real_params[AC_pert]; //Amplitude of the perturbation
|
||||
// const AcReal two_pi = (AcReal) 6.28318531;
|
||||
// const AcReal k_pert = (AcReal) 1.0; //mesh->info.real_params[AC_k_pert]; //Wamenumber of
|
||||
// the perturbation const AcReal k_pert = 4.0; //mesh->info.real_params[AC_k_pert];
|
||||
// //Wamenumber of the perturbation
|
||||
// const AcReal ampl_pert = xmax/10.0; // xmax/mesh->info.real_params[AC_pert]; //Amplitude of
|
||||
// the perturbation
|
||||
// const AcReal ampl_pert = (AcReal) 0.0;//xmax/20.0; // xmax/mesh->info.real_params[AC_pert];
|
||||
// //Amplitude of the perturbation const AcReal two_pi = (AcReal) 6.28318531;
|
||||
|
||||
// const AcReal xorig = mesh->info.real_params[AC_xorig];
|
||||
// const AcReal zorig = mesh->info.real_params[AC_zorig];
|
||||
// const AcReal trans = mesh->info.real_params[AC_trans];
|
||||
|
||||
|
||||
|
||||
// AcReal xx, zz, tanhprof, cosz_wave;
|
||||
|
||||
for (int k = 0; k < mz; k++) {
|
||||
@@ -139,21 +139,19 @@ lnrho_step(AcMesh* mesh)
|
||||
for (int i = 0; i < mx; i++) {
|
||||
int idx = i + j * mx + k * mx * my;
|
||||
// zz = DZ * AcReal(k) - zorig; // Not used
|
||||
// cosz_wave = ampl_pert*AcReal(cos(k_pert*((zz/zmax)*two_pi))); // Not used
|
||||
// cosz_wave = ampl_pert*AcReal(cos(k_pert*((zz/zmax)*two_pi))); // Not used
|
||||
// xx = DX * AcReal(i) - xorig + cosz_wave; //ADD WAVE TODO // Not used
|
||||
// tanhprof = AcReal(0.5)*((rho2+rho1) + (rho2-rho1)*AcReal(tanh(xx/trans))); // Not used
|
||||
// Commented out the step function initial codition.
|
||||
//mesh->vertex_buffer[VTXBUF_LNRHO][idx] = log(tanhprof);
|
||||
// tanhprof = AcReal(0.5)*((rho2+rho1) + (rho2-rho1)*AcReal(tanh(xx/trans))); // Not
|
||||
// used Commented out the step function initial codition.
|
||||
// mesh->vertex_buffer[VTXBUF_LNRHO][idx] = log(tanhprof);
|
||||
mesh->vertex_buffer[VTXBUF_LNRHO][idx] = lnrho2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// This is the initial condition type for the infalling vedge in the pseudodisk
|
||||
// model.
|
||||
// model.
|
||||
void
|
||||
inflow_vedge(AcMesh* mesh)
|
||||
{
|
||||
@@ -170,7 +168,7 @@ inflow_vedge(AcMesh* mesh)
|
||||
|
||||
// const double DX = mesh->info.real_params[AC_dsx];
|
||||
// const double DY = mesh->info.real_params[AC_dsy];
|
||||
const double DZ = mesh->info.real_params[AC_dsz];
|
||||
const double DZ = mesh->info.real_params[AC_dsz];
|
||||
|
||||
const double AMPL_UU = mesh->info.real_params[AC_ampl_uu];
|
||||
const double ANGL_UU = mesh->info.real_params[AC_angl_uu];
|
||||
@@ -184,30 +182,33 @@ inflow_vedge(AcMesh* mesh)
|
||||
// const AcReal zmax = AcReal(DZ * (nz_max - nz_min));
|
||||
// const AcReal gaussr = zmax / AcReal(4.0);
|
||||
|
||||
//for (int k = nz_min; k < nz_max; k++) {
|
||||
// for (int k = nz_min; k < nz_max; k++) {
|
||||
// for (int j = ny_min; j < ny_max; j++) {
|
||||
// for (int i = nx_min; i < nx_max; i++) {
|
||||
for (int k = 0; k < mz; k++) {
|
||||
for (int j = 0; j < my; j++) {
|
||||
for (int i = 0; i < mx; i++) {
|
||||
int idx = i + j * mx + k * mx * my;
|
||||
zz = DZ * double(k) - zorig;
|
||||
//mesh->vertex_buffer[VTXBUF_UUX][idx] = -AMPL_UU*cos(ANGL_UU);
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = AcReal(-AMPL_UU*cos(ANGL_UU)*fabs(tanh(zz/trans)));
|
||||
zz = DZ * double(k) - zorig;
|
||||
// mesh->vertex_buffer[VTXBUF_UUX][idx] = -AMPL_UU*cos(ANGL_UU);
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = AcReal(-AMPL_UU * cos(ANGL_UU) *
|
||||
fabs(tanh(zz / trans)));
|
||||
mesh->vertex_buffer[VTXBUF_UUY][idx] = AcReal(0.0);
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = AcReal(-AMPL_UU*sin(ANGL_UU)*tanh(zz/trans));
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = AcReal(-AMPL_UU * sin(ANGL_UU) *
|
||||
tanh(zz / trans));
|
||||
|
||||
//Variarion to density
|
||||
//AcReal rho = exp(mesh->vertex_buffer[VTXBUF_LNRHO][idx]);
|
||||
//NO GAUSSIAN//rho = rho*exp(-(zz/gaussr)*(zz/gaussr));
|
||||
//mesh->vertex_buffer[VTXBUF_LNRHO][idx] = log(rho + (range*rho) * (randr() - AcReal(-0.5)));
|
||||
// Variarion to density
|
||||
// AcReal rho = exp(mesh->vertex_buffer[VTXBUF_LNRHO][idx]);
|
||||
// NO GAUSSIAN//rho = rho*exp(-(zz/gaussr)*(zz/gaussr));
|
||||
// mesh->vertex_buffer[VTXBUF_LNRHO][idx] = log(rho + (range*rho) * (randr() -
|
||||
// AcReal(-0.5)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is the initial condition type for the infalling vedge in the pseudodisk
|
||||
// model.
|
||||
// model.
|
||||
void
|
||||
inflow_vedge_freefall(AcMesh* mesh)
|
||||
{
|
||||
@@ -222,13 +223,13 @@ inflow_vedge_freefall(AcMesh* mesh)
|
||||
// const int nz_min = mesh->info.int_params[AC_nz_min];
|
||||
// const int nz_max = mesh->info.int_params[AC_nz_max];
|
||||
|
||||
const double DX = mesh->info.real_params[AC_dsx];
|
||||
const double DX = mesh->info.real_params[AC_dsx];
|
||||
// const double DY = mesh->info.real_params[AC_dsy];
|
||||
const double DZ = mesh->info.real_params[AC_dsz];
|
||||
const double DZ = mesh->info.real_params[AC_dsz];
|
||||
|
||||
// const double AMPL_UU = mesh->info.real_params[AC_ampl_uu];
|
||||
const double ANGL_UU = mesh->info.real_params[AC_angl_uu];
|
||||
const double SQ2GM = mesh->info.real_params[AC_sq2GM_star];
|
||||
const double SQ2GM = mesh->info.real_params[AC_sq2GM_star];
|
||||
// const double GM = mesh->info.real_params[AC_GM_star];
|
||||
// const double M_star = mesh->info.real_params[AC_M_star];
|
||||
// const double G_CONST = mesh->info.real_params[AC_G_CONST];
|
||||
@@ -255,46 +256,51 @@ inflow_vedge_freefall(AcMesh* mesh)
|
||||
for (int j = 0; j < my; j++) {
|
||||
for (int i = 0; i < mx; i++) {
|
||||
int idx = i + j * mx + k * mx * my;
|
||||
xx = DX * double(i) - xorig;
|
||||
zz = DZ * double(k) - zorig;
|
||||
xx = DX * double(i) - xorig;
|
||||
zz = DZ * double(k) - zorig;
|
||||
|
||||
delx = xx - star_pos_x;
|
||||
delx = xx - star_pos_x;
|
||||
delz = zz - star_pos_z;
|
||||
//TODO: Figure out isthis needed. Now a placeholder.
|
||||
//tanhz = fabs(tanh(zz/trans));
|
||||
// TODO: Figure out isthis needed. Now a placeholder.
|
||||
// tanhz = fabs(tanh(zz/trans));
|
||||
tanhz = 1.0;
|
||||
|
||||
RR = sqrt(delx*delx + delz*delz);
|
||||
veltot = SQ2GM/sqrt(RR); //Free fall velocity
|
||||
|
||||
//Normal velocity components
|
||||
u_x = - veltot*(delx/RR);
|
||||
u_z = - veltot*(delz/RR);
|
||||
RR = sqrt(delx * delx + delz * delz);
|
||||
veltot = SQ2GM / sqrt(RR); // Free fall velocity
|
||||
|
||||
//printf("star_pos_z %e, zz %e, delz %e, RR %e\n", star_pos_z, zz, delz, RR);
|
||||
// Normal velocity components
|
||||
u_x = -veltot * (delx / RR);
|
||||
u_z = -veltot * (delz / RR);
|
||||
|
||||
//printf("unit_length = %e, unit_density = %e, unit_velocity = %e,\n M_star = %e, G_CONST = %e, GM = %e, SQ2GM = %e, \n RR = %e, u_x = %e, u_z %e\n",
|
||||
// unit_length, unit_density,
|
||||
// printf("star_pos_z %e, zz %e, delz %e, RR %e\n", star_pos_z, zz, delz, RR);
|
||||
|
||||
// printf("unit_length = %e, unit_density = %e, unit_velocity = %e,\n M_star = %e,
|
||||
// G_CONST = %e, GM = %e, SQ2GM = %e, \n RR = %e, u_x = %e, u_z %e\n",
|
||||
// unit_length, unit_density,
|
||||
// unit_velocity, M_star, G_CONST, GM, SQ2GM, RR, u_x, u_z);
|
||||
//printf("%e\n", unit_length*unit_length*unit_length);
|
||||
// printf("%e\n", unit_length*unit_length*unit_length);
|
||||
|
||||
|
||||
//Here including an angel tilt due to pseudodisk
|
||||
// Here including an angel tilt due to pseudodisk
|
||||
if (delz >= 0.0) {
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = AcReal((u_x*cos(ANGL_UU) - u_z*sin(ANGL_UU))*tanhz);
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = AcReal(
|
||||
(u_x * cos(ANGL_UU) - u_z * sin(ANGL_UU)) * tanhz);
|
||||
mesh->vertex_buffer[VTXBUF_UUY][idx] = AcReal(0.0);
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = AcReal((u_x*sin(ANGL_UU) + u_z*cos(ANGL_UU))*tanhz);
|
||||
} else {
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = AcReal((u_x*cos(ANGL_UU) + u_z*sin(ANGL_UU))*tanhz);
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = AcReal(
|
||||
(u_x * sin(ANGL_UU) + u_z * cos(ANGL_UU)) * tanhz);
|
||||
}
|
||||
else {
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = AcReal(
|
||||
(u_x * cos(ANGL_UU) + u_z * sin(ANGL_UU)) * tanhz);
|
||||
mesh->vertex_buffer[VTXBUF_UUY][idx] = AcReal(0.0);
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = AcReal((-u_x*sin(ANGL_UU) + u_z*cos(ANGL_UU))*tanhz);
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = AcReal(
|
||||
(-u_x * sin(ANGL_UU) + u_z * cos(ANGL_UU)) * tanhz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only x-direction free fall
|
||||
// Only x-direction free fall
|
||||
void
|
||||
inflow_freefall_x(AcMesh* mesh)
|
||||
{
|
||||
@@ -302,7 +308,7 @@ inflow_freefall_x(AcMesh* mesh)
|
||||
const int my = mesh->info.int_params[AC_my];
|
||||
const int mz = mesh->info.int_params[AC_mz];
|
||||
|
||||
const double DX = mesh->info.real_params[AC_dsx];
|
||||
const double DX = mesh->info.real_params[AC_dsx];
|
||||
|
||||
const double SQ2GM = mesh->info.real_params[AC_sq2GM_star];
|
||||
// const double G_CONST = mesh->info.real_params[AC_G_CONST];
|
||||
@@ -320,37 +326,37 @@ inflow_freefall_x(AcMesh* mesh)
|
||||
for (int j = 0; j < my; j++) {
|
||||
for (int i = 0; i < mx; i++) {
|
||||
int idx = i + j * mx + k * mx * my;
|
||||
xx = DX * double(i) - xorig;
|
||||
xx = DX * double(i) - xorig;
|
||||
|
||||
delx = xx - star_pos_x;
|
||||
|
||||
|
||||
RR = fabs(delx);
|
||||
|
||||
veltot = SQ2GM/sqrt(RR); //Free fall velocity
|
||||
veltot = SQ2GM / sqrt(RR); // Free fall velocity
|
||||
|
||||
if (isinf(veltot) == 1) printf("xx %e star_pos_x %e delz %e RR %e veltot %e\n",xx, star_pos_x, delx, RR, veltot);
|
||||
if (isinf(veltot) == 1)
|
||||
printf("xx %e star_pos_x %e delz %e RR %e veltot %e\n", xx, star_pos_x, delx,
|
||||
RR, veltot);
|
||||
|
||||
//Normal velocity components
|
||||
// u_x = - veltot; // Not used
|
||||
// Normal velocity components
|
||||
// u_x = - veltot; // Not used
|
||||
|
||||
//Freefall condition
|
||||
//mesh->vertex_buffer[VTXBUF_UUX][idx] = u_x;
|
||||
//mesh->vertex_buffer[VTXBUF_UUY][idx] = 0.0;
|
||||
//mesh->vertex_buffer[VTXBUF_UUZ][idx] = 0.0;
|
||||
// Freefall condition
|
||||
// mesh->vertex_buffer[VTXBUF_UUX][idx] = u_x;
|
||||
// mesh->vertex_buffer[VTXBUF_UUY][idx] = 0.0;
|
||||
// mesh->vertex_buffer[VTXBUF_UUZ][idx] = 0.0;
|
||||
|
||||
//Starting with steady state
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = 0.0;
|
||||
// Starting with steady state
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = 0.0;
|
||||
mesh->vertex_buffer[VTXBUF_UUY][idx] = 0.0;
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = 0.0;
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = 0.0;
|
||||
|
||||
mesh->vertex_buffer[VTXBUF_LNRHO][idx] = AcReal(ampl_lnrho);
|
||||
mesh->vertex_buffer[VTXBUF_LNRHO][idx] = AcReal(ampl_lnrho);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
gaussian_radial_explosion(AcMesh* mesh)
|
||||
{
|
||||
@@ -368,11 +374,11 @@ gaussian_radial_explosion(AcMesh* mesh)
|
||||
const int nz_min = mesh->info.int_params[AC_nz_min];
|
||||
const int nz_max = mesh->info.int_params[AC_nz_max];
|
||||
|
||||
const double DX = mesh->info.real_params[AC_dsx];
|
||||
const double DY = mesh->info.real_params[AC_dsy];
|
||||
const double DZ = mesh->info.real_params[AC_dsz];
|
||||
const double DX = mesh->info.real_params[AC_dsx];
|
||||
const double DY = mesh->info.real_params[AC_dsy];
|
||||
const double DZ = mesh->info.real_params[AC_dsz];
|
||||
|
||||
const double xorig = double(XORIG) - 0.000001;
|
||||
const double xorig = double(XORIG) - 0.000001;
|
||||
const double yorig = double(YORIG) - 0.000001;
|
||||
const double zorig = double(ZORIG) - 0.000001;
|
||||
|
||||
@@ -447,8 +453,7 @@ gaussian_radial_explosion(AcMesh* mesh)
|
||||
//+-
|
||||
yy_abs = -yy;
|
||||
phi = 2.0 * M_PI - atan(yy_abs / xx);
|
||||
if (phi < (3.0 * M_PI) / 2.0 ||
|
||||
phi > (2.0 * M_PI + 1e-6)) {
|
||||
if (phi < (3.0 * M_PI) / 2.0 || phi > (2.0 * M_PI + 1e-6)) {
|
||||
printf("Explosion PHI WRONG +-: xx = %.3f, yy "
|
||||
"= %.3f, phi = %.3e/PI, M_PI = %.3e\n",
|
||||
xx, yy, phi / M_PI, M_PI);
|
||||
@@ -459,23 +464,20 @@ gaussian_radial_explosion(AcMesh* mesh)
|
||||
yy_abs = -yy;
|
||||
xx_abs = -xx;
|
||||
phi = M_PI + atan(yy_abs / xx_abs);
|
||||
if (phi < M_PI ||
|
||||
phi > ((3.0 * M_PI) / 2.0 + 1e-6)) {
|
||||
if (phi < M_PI || phi > ((3.0 * M_PI) / 2.0 + 1e-6)) {
|
||||
printf("Explosion PHI WRONG --: xx = %.3f, yy "
|
||||
"= %.3f, xx_abs = %.3f, yy_abs = %.3f, "
|
||||
"phi = %.3e, (3.0*M_PI)/2.0 = %.3e\n",
|
||||
xx, yy, xx_abs, yy_abs, phi,
|
||||
(3.0 * M_PI) / 2.0);
|
||||
xx, yy, xx_abs, yy_abs, phi, (3.0 * M_PI) / 2.0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//++
|
||||
phi = atan(yy / xx);
|
||||
if (phi < 0 || phi > M_PI / 2.0) {
|
||||
printf(
|
||||
"Explosion PHI WRONG --: xx = %.3f, yy = "
|
||||
"%.3f, phi = %.3e, (3.0*M_PI)/2.0 = %.3e\n",
|
||||
xx, yy, phi, (3.0 * M_PI) / 2.0);
|
||||
printf("Explosion PHI WRONG --: xx = %.3f, yy = "
|
||||
"%.3f, phi = %.3e, (3.0*M_PI)/2.0 = %.3e\n",
|
||||
xx, yy, phi, (3.0 * M_PI) / 2.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -502,8 +504,8 @@ gaussian_radial_explosion(AcMesh* mesh)
|
||||
// the exact centre coordinates uu_radial = AMPL_UU*exp(
|
||||
// -pow((rr - 4.0*WIDTH_UU),2.0) / (2.0*pow(WIDTH_UU, 2.0))
|
||||
// ); //TODO: Parametrize the peak location.
|
||||
uu_radial = AMPL_UU * exp(-pow((rr - UU_SHELL_R), 2.0) /
|
||||
(2.0 * pow(WIDTH_UU, 2.0)));
|
||||
uu_radial = AMPL_UU *
|
||||
exp(-pow((rr - UU_SHELL_R), 2.0) / (2.0 * pow(WIDTH_UU, 2.0)));
|
||||
}
|
||||
else {
|
||||
uu_radial = 0.0; // TODO: There will be a discontinuity in
|
||||
@@ -537,8 +539,7 @@ acmesh_init_to(const InitType& init_type, AcMesh* mesh)
|
||||
{
|
||||
srand(123456789);
|
||||
|
||||
|
||||
const int n = AC_VTXBUF_SIZE(mesh->info);
|
||||
const int n = acVertexBufferSize(mesh->info);
|
||||
|
||||
const int mx = mesh->info.int_params[AC_mx];
|
||||
const int my = mesh->info.int_params[AC_my];
|
||||
@@ -563,7 +564,7 @@ acmesh_init_to(const InitType& init_type, AcMesh* mesh)
|
||||
}
|
||||
case INIT_TYPE_GAUSSIAN_RADIAL_EXPL:
|
||||
acmesh_clear(mesh);
|
||||
//acmesh_init_to(INIT_TYPE_RANDOM, mesh);
|
||||
// acmesh_init_to(INIT_TYPE_RANDOM, mesh);
|
||||
gaussian_radial_explosion(mesh);
|
||||
|
||||
break;
|
||||
@@ -573,21 +574,22 @@ acmesh_init_to(const InitType& init_type, AcMesh* mesh)
|
||||
for (int k = 0; k < mz; k++) {
|
||||
for (int j = 0; j < my; j++) {
|
||||
for (int i = 0; i < mx; i++) {
|
||||
int idx = i + j * mx + k * mx * my;
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = 2*AcReal(sin(j * AcReal(M_PI) / mx)) - 1;
|
||||
int idx = i + j * mx + k * mx * my;
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = 2 * AcReal(sin(j * AcReal(M_PI) / mx)) -
|
||||
1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INIT_TYPE_VEDGE:
|
||||
case INIT_TYPE_VEDGE:
|
||||
acmesh_clear(mesh);
|
||||
inflow_vedge_freefall(mesh);
|
||||
break;
|
||||
case INIT_TYPE_VEDGEX:
|
||||
case INIT_TYPE_VEDGEX:
|
||||
acmesh_clear(mesh);
|
||||
inflow_freefall_x(mesh);
|
||||
break;
|
||||
case INIT_TYPE_RAYLEIGH_TAYLOR:
|
||||
case INIT_TYPE_RAYLEIGH_TAYLOR:
|
||||
acmesh_clear(mesh);
|
||||
inflow_freefall_x(mesh);
|
||||
lnrho_step(mesh);
|
||||
@@ -627,9 +629,15 @@ acmesh_init_to(const InitType& init_type, AcMesh* mesh)
|
||||
const AcReal ky_uu = 8.;
|
||||
const AcReal kz_uu = 8.;
|
||||
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = ampl_uu * (ABC_A * (AcReal)sin(kz_uu * zz) + ABC_C * (AcReal)cos(ky_uu * yy));
|
||||
mesh->vertex_buffer[VTXBUF_UUY][idx] = ampl_uu * (ABC_B * (AcReal)sin(kx_uu * xx) + ABC_A * (AcReal)cos(kz_uu * zz));
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = ampl_uu * (ABC_C * (AcReal)sin(ky_uu * yy) + ABC_B * (AcReal)cos(kx_uu * xx));
|
||||
mesh->vertex_buffer[VTXBUF_UUX][idx] = ampl_uu *
|
||||
(ABC_A * (AcReal)sin(kz_uu * zz) +
|
||||
ABC_C * (AcReal)cos(ky_uu * yy));
|
||||
mesh->vertex_buffer[VTXBUF_UUY][idx] = ampl_uu *
|
||||
(ABC_B * (AcReal)sin(kx_uu * xx) +
|
||||
ABC_A * (AcReal)cos(kz_uu * zz));
|
||||
mesh->vertex_buffer[VTXBUF_UUZ][idx] = ampl_uu *
|
||||
(ABC_C * (AcReal)sin(ky_uu * yy) +
|
||||
ABC_B * (AcReal)cos(kx_uu * xx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -637,20 +645,23 @@ acmesh_init_to(const InitType& init_type, AcMesh* mesh)
|
||||
}
|
||||
case INIT_TYPE_RAYLEIGH_BENARD: {
|
||||
acmesh_init_to(INIT_TYPE_RANDOM, mesh);
|
||||
#if LTEMPERATURE
|
||||
#if LTEMPERATURE
|
||||
vertex_buffer_set(VTXBUF_LNRHO, 1, mesh);
|
||||
const AcReal range = AcReal(0.9);
|
||||
for (int k = nz_min; k < nz_max; k++) {
|
||||
for (int j = ny_min; j < ny_max; j++) {
|
||||
for (int i = nx_min; i < nx_max; i++) {
|
||||
const int idx = i + j * mx + k * mx * my;
|
||||
mesh->vertex_buffer[VTXBUF_TEMPERATURE][idx] = (range * (k - nz_min)) / mesh->info.int_params[AC_nz] + 0.1;
|
||||
const int idx = i + j * mx + k * mx * my;
|
||||
mesh->vertex_buffer[VTXBUF_TEMPERATURE][idx] = (range * (k - nz_min)) /
|
||||
mesh->info
|
||||
.int_params[AC_nz] +
|
||||
0.1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#else
|
||||
WARNING("INIT_TYPE_RAYLEIGH_BERNARD called even though VTXBUF_TEMPERATURE is not used");
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -688,14 +699,13 @@ acmesh_destroy(AcMesh* mesh)
|
||||
free(mesh);
|
||||
}
|
||||
|
||||
|
||||
ModelMesh*
|
||||
modelmesh_create(const AcMeshInfo& mesh_info)
|
||||
{
|
||||
ModelMesh* mesh = (ModelMesh*)malloc(sizeof(*mesh));
|
||||
mesh->info = mesh_info;
|
||||
mesh->info = mesh_info;
|
||||
|
||||
const size_t bytes = AC_VTXBUF_SIZE(mesh->info) * sizeof(mesh->vertex_buffer[0][0]);
|
||||
const size_t bytes = acVertexBufferSize(mesh->info) * sizeof(mesh->vertex_buffer[0][0]);
|
||||
for (int i = 0; i < NUM_VTXBUF_HANDLES; ++i) {
|
||||
mesh->vertex_buffer[VertexBufferHandle(i)] = (ModelScalar*)malloc(bytes);
|
||||
ERRCHK(mesh->vertex_buffer[VertexBufferHandle(i)] != NULL);
|
||||
@@ -721,7 +731,7 @@ acmesh_to_modelmesh(const AcMesh& acmesh, ModelMesh* modelmesh)
|
||||
memcpy(&modelmesh->info, &acmesh.info, sizeof(acmesh.info));
|
||||
|
||||
for (int i = 0; i < NUM_VTXBUF_HANDLES; ++i)
|
||||
for (size_t j = 0; j < AC_VTXBUF_SIZE(acmesh.info); ++j)
|
||||
for (size_t j = 0; j < acVertexBufferSize(acmesh.info); ++j)
|
||||
modelmesh->vertex_buffer[i][j] = (ModelScalar)acmesh.vertex_buffer[i][j];
|
||||
}
|
||||
|
||||
@@ -732,6 +742,6 @@ modelmesh_to_acmesh(const ModelMesh& modelmesh, AcMesh* acmesh)
|
||||
memcpy(&acmesh->info, &modelmesh.info, sizeof(modelmesh.info));
|
||||
|
||||
for (int i = 0; i < NUM_VTXBUF_HANDLES; ++i)
|
||||
for (size_t j = 0; j < AC_VTXBUF_SIZE(modelmesh.info); ++j)
|
||||
for (size_t j = 0; j < acVertexBufferSize(modelmesh.info); ++j)
|
||||
acmesh->vertex_buffer[i][j] = (AcReal)modelmesh.vertex_buffer[i][j];
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
FUNC(INIT_TYPE_RAYLEIGH_BENARD)
|
||||
// clang-format on
|
||||
|
||||
#define AC_GEN_ID(X) X
|
||||
typedef enum { AC_FOR_INIT_TYPES(AC_GEN_ID), NUM_INIT_TYPES } InitType;
|
||||
#undef AC_GEN_ID
|
||||
|
||||
extern const char* init_type_names[]; // Defined in host_memory.cc
|
||||
|
||||
|
||||
@@ -86,10 +86,10 @@ boundconds(const AcMeshInfo& mesh_info, ModelMesh* mesh)
|
||||
j_src += ny_min;
|
||||
k_src += nz_min;
|
||||
|
||||
const size_t src_idx = AC_VTXBUF_IDX(i_src, j_src, k_src, mesh_info);
|
||||
const size_t dst_idx = AC_VTXBUF_IDX(i_dst, j_dst, k_dst, mesh_info);
|
||||
ERRCHK(src_idx < AC_VTXBUF_SIZE(mesh_info));
|
||||
ERRCHK(dst_idx < AC_VTXBUF_SIZE(mesh_info));
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,30 +41,30 @@ der_scal(const int& i, const int& j, const int& k, const AcMeshInfo& mesh_info,
|
||||
|
||||
switch (axis) {
|
||||
case AXIS_X:
|
||||
f0 = scal[AC_VTXBUF_IDX(i - 3, j, k, mesh_info)];
|
||||
f1 = scal[AC_VTXBUF_IDX(i - 2, j, k, mesh_info)];
|
||||
f2 = scal[AC_VTXBUF_IDX(i - 1, j, k, mesh_info)];
|
||||
f4 = scal[AC_VTXBUF_IDX(i + 1, j, k, mesh_info)];
|
||||
f5 = scal[AC_VTXBUF_IDX(i + 2, j, k, mesh_info)];
|
||||
f6 = scal[AC_VTXBUF_IDX(i + 3, j, k, mesh_info)];
|
||||
f0 = scal[acVertexBufferIdx(i - 3, j, k, mesh_info)];
|
||||
f1 = scal[acVertexBufferIdx(i - 2, j, k, mesh_info)];
|
||||
f2 = scal[acVertexBufferIdx(i - 1, j, k, mesh_info)];
|
||||
f4 = scal[acVertexBufferIdx(i + 1, j, k, mesh_info)];
|
||||
f5 = scal[acVertexBufferIdx(i + 2, j, k, mesh_info)];
|
||||
f6 = scal[acVertexBufferIdx(i + 3, j, k, mesh_info)];
|
||||
ds = mesh_info.real_params[AC_dsx];
|
||||
break;
|
||||
case AXIS_Y:
|
||||
f0 = scal[AC_VTXBUF_IDX(i, j - 3, k, mesh_info)];
|
||||
f1 = scal[AC_VTXBUF_IDX(i, j - 2, k, mesh_info)];
|
||||
f2 = scal[AC_VTXBUF_IDX(i, j - 1, k, mesh_info)];
|
||||
f4 = scal[AC_VTXBUF_IDX(i, j + 1, k, mesh_info)];
|
||||
f5 = scal[AC_VTXBUF_IDX(i, j + 2, k, mesh_info)];
|
||||
f6 = scal[AC_VTXBUF_IDX(i, j + 3, k, mesh_info)];
|
||||
f0 = scal[acVertexBufferIdx(i, j - 3, k, mesh_info)];
|
||||
f1 = scal[acVertexBufferIdx(i, j - 2, k, mesh_info)];
|
||||
f2 = scal[acVertexBufferIdx(i, j - 1, k, mesh_info)];
|
||||
f4 = scal[acVertexBufferIdx(i, j + 1, k, mesh_info)];
|
||||
f5 = scal[acVertexBufferIdx(i, j + 2, k, mesh_info)];
|
||||
f6 = scal[acVertexBufferIdx(i, j + 3, k, mesh_info)];
|
||||
ds = mesh_info.real_params[AC_dsy];
|
||||
break;
|
||||
case AXIS_Z:
|
||||
f0 = scal[AC_VTXBUF_IDX(i, j, k - 3, mesh_info)];
|
||||
f1 = scal[AC_VTXBUF_IDX(i, j, k - 2, mesh_info)];
|
||||
f2 = scal[AC_VTXBUF_IDX(i, j, k - 1, mesh_info)];
|
||||
f4 = scal[AC_VTXBUF_IDX(i, j, k + 1, mesh_info)];
|
||||
f5 = scal[AC_VTXBUF_IDX(i, j, k + 2, mesh_info)];
|
||||
f6 = scal[AC_VTXBUF_IDX(i, j, k + 3, mesh_info)];
|
||||
f0 = scal[acVertexBufferIdx(i, j, k - 3, mesh_info)];
|
||||
f1 = scal[acVertexBufferIdx(i, j, k - 2, mesh_info)];
|
||||
f2 = scal[acVertexBufferIdx(i, j, k - 1, mesh_info)];
|
||||
f4 = scal[acVertexBufferIdx(i, j, k + 1, mesh_info)];
|
||||
f5 = scal[acVertexBufferIdx(i, j, k + 2, mesh_info)];
|
||||
f6 = scal[acVertexBufferIdx(i, j, k + 3, mesh_info)];
|
||||
ds = mesh_info.real_params[AC_dsz];
|
||||
break;
|
||||
default:
|
||||
@@ -82,34 +82,34 @@ der2_scal(const int& i, const int& j, const int& k, const AcMeshInfo& mesh_info,
|
||||
MODEL_REAL f0, f1, f2, f3, f4, f5, f6;
|
||||
MODEL_REAL ds;
|
||||
|
||||
f3 = scal[AC_VTXBUF_IDX(i, j, k, mesh_info)];
|
||||
f3 = scal[acVertexBufferIdx(i, j, k, mesh_info)];
|
||||
|
||||
switch (axis) {
|
||||
case AXIS_X:
|
||||
f0 = scal[AC_VTXBUF_IDX(i - 3, j, k, mesh_info)];
|
||||
f1 = scal[AC_VTXBUF_IDX(i - 2, j, k, mesh_info)];
|
||||
f2 = scal[AC_VTXBUF_IDX(i - 1, j, k, mesh_info)];
|
||||
f4 = scal[AC_VTXBUF_IDX(i + 1, j, k, mesh_info)];
|
||||
f5 = scal[AC_VTXBUF_IDX(i + 2, j, k, mesh_info)];
|
||||
f6 = scal[AC_VTXBUF_IDX(i + 3, j, k, mesh_info)];
|
||||
f0 = scal[acVertexBufferIdx(i - 3, j, k, mesh_info)];
|
||||
f1 = scal[acVertexBufferIdx(i - 2, j, k, mesh_info)];
|
||||
f2 = scal[acVertexBufferIdx(i - 1, j, k, mesh_info)];
|
||||
f4 = scal[acVertexBufferIdx(i + 1, j, k, mesh_info)];
|
||||
f5 = scal[acVertexBufferIdx(i + 2, j, k, mesh_info)];
|
||||
f6 = scal[acVertexBufferIdx(i + 3, j, k, mesh_info)];
|
||||
ds = mesh_info.real_params[AC_dsx];
|
||||
break;
|
||||
case AXIS_Y:
|
||||
f0 = scal[AC_VTXBUF_IDX(i, j - 3, k, mesh_info)];
|
||||
f1 = scal[AC_VTXBUF_IDX(i, j - 2, k, mesh_info)];
|
||||
f2 = scal[AC_VTXBUF_IDX(i, j - 1, k, mesh_info)];
|
||||
f4 = scal[AC_VTXBUF_IDX(i, j + 1, k, mesh_info)];
|
||||
f5 = scal[AC_VTXBUF_IDX(i, j + 2, k, mesh_info)];
|
||||
f6 = scal[AC_VTXBUF_IDX(i, j + 3, k, mesh_info)];
|
||||
f0 = scal[acVertexBufferIdx(i, j - 3, k, mesh_info)];
|
||||
f1 = scal[acVertexBufferIdx(i, j - 2, k, mesh_info)];
|
||||
f2 = scal[acVertexBufferIdx(i, j - 1, k, mesh_info)];
|
||||
f4 = scal[acVertexBufferIdx(i, j + 1, k, mesh_info)];
|
||||
f5 = scal[acVertexBufferIdx(i, j + 2, k, mesh_info)];
|
||||
f6 = scal[acVertexBufferIdx(i, j + 3, k, mesh_info)];
|
||||
ds = mesh_info.real_params[AC_dsy];
|
||||
break;
|
||||
case AXIS_Z:
|
||||
f0 = scal[AC_VTXBUF_IDX(i, j, k - 3, mesh_info)];
|
||||
f1 = scal[AC_VTXBUF_IDX(i, j, k - 2, mesh_info)];
|
||||
f2 = scal[AC_VTXBUF_IDX(i, j, k - 1, mesh_info)];
|
||||
f4 = scal[AC_VTXBUF_IDX(i, j, k + 1, mesh_info)];
|
||||
f5 = scal[AC_VTXBUF_IDX(i, j, k + 2, mesh_info)];
|
||||
f6 = scal[AC_VTXBUF_IDX(i, j, k + 3, mesh_info)];
|
||||
f0 = scal[acVertexBufferIdx(i, j, k - 3, mesh_info)];
|
||||
f1 = scal[acVertexBufferIdx(i, j, k - 2, mesh_info)];
|
||||
f2 = scal[acVertexBufferIdx(i, j, k - 1, mesh_info)];
|
||||
f4 = scal[acVertexBufferIdx(i, j, k + 1, mesh_info)];
|
||||
f5 = scal[acVertexBufferIdx(i, j, k + 2, mesh_info)];
|
||||
f6 = scal[acVertexBufferIdx(i, j, k + 3, mesh_info)];
|
||||
ds = mesh_info.real_params[AC_dsz];
|
||||
break;
|
||||
default:
|
||||
@@ -163,7 +163,7 @@ vec_dot_nabla_scal(const int& i, const int& j, const int& k,
|
||||
const AcMeshInfo& mesh_info, const MODEL_REAL* vec_x,
|
||||
const MODEL_REAL* vec_y, const MODEL_REAL* vec_z, const MODEL_REAL* scal)
|
||||
{
|
||||
const int idx = AC_VTXBUF_IDX(i, j, k, mesh_info);
|
||||
const int idx = acVertexBufferIdx(i, j, k, mesh_info);
|
||||
MODEL_REAL ddx_scal, ddy_scal, ddz_scal;
|
||||
grad(i, j, k, mesh_info, scal, &ddx_scal, &ddy_scal, &ddz_scal);
|
||||
return vec_x[idx] * ddx_scal + vec_y[idx] * ddy_scal +
|
||||
@@ -196,56 +196,56 @@ dernm_scal(const int& i, const int& j, const int& k,
|
||||
switch (dernm) {
|
||||
case DERNM_XY:
|
||||
fac = MODEL_REAL(1. / 720.) * (MODEL_REAL(1.) / dsx) * (MODEL_REAL(1.) / dsy);
|
||||
f_p1_p1 = scal[AC_VTXBUF_IDX(i + 1, j + 1, k, mesh_info)];
|
||||
f_m1_p1 = scal[AC_VTXBUF_IDX(i - 1, j + 1, k, mesh_info)];
|
||||
f_m1_m1 = scal[AC_VTXBUF_IDX(i - 1, j - 1, k, mesh_info)];
|
||||
f_p1_m1 = scal[AC_VTXBUF_IDX(i + 1, j - 1, k, mesh_info)];
|
||||
f_p1_p1 = scal[acVertexBufferIdx(i + 1, j + 1, k, mesh_info)];
|
||||
f_m1_p1 = scal[acVertexBufferIdx(i - 1, j + 1, k, mesh_info)];
|
||||
f_m1_m1 = scal[acVertexBufferIdx(i - 1, j - 1, k, mesh_info)];
|
||||
f_p1_m1 = scal[acVertexBufferIdx(i + 1, j - 1, k, mesh_info)];
|
||||
|
||||
f_p2_p2 = scal[AC_VTXBUF_IDX(i + 2, j + 2, k, mesh_info)];
|
||||
f_m2_p2 = scal[AC_VTXBUF_IDX(i - 2, j + 2, k, mesh_info)];
|
||||
f_m2_m2 = scal[AC_VTXBUF_IDX(i - 2, j - 2, k, mesh_info)];
|
||||
f_p2_m2 = scal[AC_VTXBUF_IDX(i + 2, j - 2, k, mesh_info)];
|
||||
f_p2_p2 = scal[acVertexBufferIdx(i + 2, j + 2, k, mesh_info)];
|
||||
f_m2_p2 = scal[acVertexBufferIdx(i - 2, j + 2, k, mesh_info)];
|
||||
f_m2_m2 = scal[acVertexBufferIdx(i - 2, j - 2, k, mesh_info)];
|
||||
f_p2_m2 = scal[acVertexBufferIdx(i + 2, j - 2, k, mesh_info)];
|
||||
|
||||
f_p3_p3 = scal[AC_VTXBUF_IDX(i + 3, j + 3, k, mesh_info)];
|
||||
f_m3_p3 = scal[AC_VTXBUF_IDX(i - 3, j + 3, k, mesh_info)];
|
||||
f_m3_m3 = scal[AC_VTXBUF_IDX(i - 3, j - 3, k, mesh_info)];
|
||||
f_p3_m3 = scal[AC_VTXBUF_IDX(i + 3, j - 3, k, mesh_info)];
|
||||
f_p3_p3 = scal[acVertexBufferIdx(i + 3, j + 3, k, mesh_info)];
|
||||
f_m3_p3 = scal[acVertexBufferIdx(i - 3, j + 3, k, mesh_info)];
|
||||
f_m3_m3 = scal[acVertexBufferIdx(i - 3, j - 3, k, mesh_info)];
|
||||
f_p3_m3 = scal[acVertexBufferIdx(i + 3, j - 3, k, mesh_info)];
|
||||
break;
|
||||
case DERNM_YZ:
|
||||
// NOTE this is a bit different from the old one, second is j+1k-1
|
||||
// instead of j-1,k+1
|
||||
fac = MODEL_REAL(1. / 720.) * (MODEL_REAL(1.) / dsy) * (MODEL_REAL(1.) / dsz);
|
||||
f_p1_p1 = scal[AC_VTXBUF_IDX(i, j + 1, k + 1, mesh_info)];
|
||||
f_m1_p1 = scal[AC_VTXBUF_IDX(i, j - 1, k + 1, mesh_info)];
|
||||
f_m1_m1 = scal[AC_VTXBUF_IDX(i, j - 1, k - 1, mesh_info)];
|
||||
f_p1_m1 = scal[AC_VTXBUF_IDX(i, j + 1, k - 1, mesh_info)];
|
||||
f_p1_p1 = scal[acVertexBufferIdx(i, j + 1, k + 1, mesh_info)];
|
||||
f_m1_p1 = scal[acVertexBufferIdx(i, j - 1, k + 1, mesh_info)];
|
||||
f_m1_m1 = scal[acVertexBufferIdx(i, j - 1, k - 1, mesh_info)];
|
||||
f_p1_m1 = scal[acVertexBufferIdx(i, j + 1, k - 1, mesh_info)];
|
||||
|
||||
f_p2_p2 = scal[AC_VTXBUF_IDX(i, j + 2, k + 2, mesh_info)];
|
||||
f_m2_p2 = scal[AC_VTXBUF_IDX(i, j - 2, k + 2, mesh_info)];
|
||||
f_m2_m2 = scal[AC_VTXBUF_IDX(i, j - 2, k - 2, mesh_info)];
|
||||
f_p2_m2 = scal[AC_VTXBUF_IDX(i, j + 2, k - 2, mesh_info)];
|
||||
f_p2_p2 = scal[acVertexBufferIdx(i, j + 2, k + 2, mesh_info)];
|
||||
f_m2_p2 = scal[acVertexBufferIdx(i, j - 2, k + 2, mesh_info)];
|
||||
f_m2_m2 = scal[acVertexBufferIdx(i, j - 2, k - 2, mesh_info)];
|
||||
f_p2_m2 = scal[acVertexBufferIdx(i, j + 2, k - 2, mesh_info)];
|
||||
|
||||
f_p3_p3 = scal[AC_VTXBUF_IDX(i, j + 3, k + 3, mesh_info)];
|
||||
f_m3_p3 = scal[AC_VTXBUF_IDX(i, j - 3, k + 3, mesh_info)];
|
||||
f_m3_m3 = scal[AC_VTXBUF_IDX(i, j - 3, k - 3, mesh_info)];
|
||||
f_p3_m3 = scal[AC_VTXBUF_IDX(i, j + 3, k - 3, mesh_info)];
|
||||
f_p3_p3 = scal[acVertexBufferIdx(i, j + 3, k + 3, mesh_info)];
|
||||
f_m3_p3 = scal[acVertexBufferIdx(i, j - 3, k + 3, mesh_info)];
|
||||
f_m3_m3 = scal[acVertexBufferIdx(i, j - 3, k - 3, mesh_info)];
|
||||
f_p3_m3 = scal[acVertexBufferIdx(i, j + 3, k - 3, mesh_info)];
|
||||
break;
|
||||
case DERNM_XZ:
|
||||
fac = MODEL_REAL(1. / 720.) * (MODEL_REAL(1.) / dsx) * (MODEL_REAL(1.) / dsz);
|
||||
f_p1_p1 = scal[AC_VTXBUF_IDX(i + 1, j, k + 1, mesh_info)];
|
||||
f_m1_p1 = scal[AC_VTXBUF_IDX(i - 1, j, k + 1, mesh_info)];
|
||||
f_m1_m1 = scal[AC_VTXBUF_IDX(i - 1, j, k - 1, mesh_info)];
|
||||
f_p1_m1 = scal[AC_VTXBUF_IDX(i + 1, j, k - 1, mesh_info)];
|
||||
f_p1_p1 = scal[acVertexBufferIdx(i + 1, j, k + 1, mesh_info)];
|
||||
f_m1_p1 = scal[acVertexBufferIdx(i - 1, j, k + 1, mesh_info)];
|
||||
f_m1_m1 = scal[acVertexBufferIdx(i - 1, j, k - 1, mesh_info)];
|
||||
f_p1_m1 = scal[acVertexBufferIdx(i + 1, j, k - 1, mesh_info)];
|
||||
|
||||
f_p2_p2 = scal[AC_VTXBUF_IDX(i + 2, j, k + 2, mesh_info)];
|
||||
f_m2_p2 = scal[AC_VTXBUF_IDX(i - 2, j, k + 2, mesh_info)];
|
||||
f_m2_m2 = scal[AC_VTXBUF_IDX(i - 2, j, k - 2, mesh_info)];
|
||||
f_p2_m2 = scal[AC_VTXBUF_IDX(i + 2, j, k - 2, mesh_info)];
|
||||
f_p2_p2 = scal[acVertexBufferIdx(i + 2, j, k + 2, mesh_info)];
|
||||
f_m2_p2 = scal[acVertexBufferIdx(i - 2, j, k + 2, mesh_info)];
|
||||
f_m2_m2 = scal[acVertexBufferIdx(i - 2, j, k - 2, mesh_info)];
|
||||
f_p2_m2 = scal[acVertexBufferIdx(i + 2, j, k - 2, mesh_info)];
|
||||
|
||||
f_p3_p3 = scal[AC_VTXBUF_IDX(i + 3, j, k + 3, mesh_info)];
|
||||
f_m3_p3 = scal[AC_VTXBUF_IDX(i - 3, j, k + 3, mesh_info)];
|
||||
f_m3_m3 = scal[AC_VTXBUF_IDX(i - 3, j, k - 3, mesh_info)];
|
||||
f_p3_m3 = scal[AC_VTXBUF_IDX(i + 3, j, k - 3, mesh_info)];
|
||||
f_p3_p3 = scal[acVertexBufferIdx(i + 3, j, k + 3, mesh_info)];
|
||||
f_m3_p3 = scal[acVertexBufferIdx(i - 3, j, k + 3, mesh_info)];
|
||||
f_m3_m3 = scal[acVertexBufferIdx(i - 3, j, k - 3, mesh_info)];
|
||||
f_p3_m3 = scal[acVertexBufferIdx(i + 3, j, k - 3, mesh_info)];
|
||||
break;
|
||||
default:
|
||||
ERROR("Invalid dernm type");
|
||||
|
||||
@@ -99,7 +99,7 @@ model_reduce_scal(const ModelMesh& mesh, const ReductionType& rtype,
|
||||
ERROR("Unrecognized RTYPE");
|
||||
}
|
||||
|
||||
const int initial_idx = AC_VTXBUF_IDX(
|
||||
const int initial_idx = acVertexBufferIdx(
|
||||
mesh.info.int_params[AC_nx_min], mesh.info.int_params[AC_ny_min],
|
||||
mesh.info.int_params[AC_nz_min], mesh.info);
|
||||
|
||||
@@ -115,7 +115,7 @@ model_reduce_scal(const ModelMesh& mesh, const ReductionType& rtype,
|
||||
j < mesh.info.int_params[AC_ny_max]; ++j) {
|
||||
for (int i = mesh.info.int_params[AC_nx_min];
|
||||
i < mesh.info.int_params[AC_nx_max]; ++i) {
|
||||
const int idx = AC_VTXBUF_IDX(i, j, k, mesh.info);
|
||||
const int idx = acVertexBufferIdx(i, j, k, mesh.info);
|
||||
const ModelScalar curr_val = reduce_initial(
|
||||
mesh.vertex_buffer[a][idx]);
|
||||
res = reduce(res, curr_val);
|
||||
@@ -166,7 +166,7 @@ model_reduce_vec(const ModelMesh& mesh, const ReductionType& rtype,
|
||||
ERROR("Unrecognized RTYPE");
|
||||
}
|
||||
|
||||
const int initial_idx = AC_VTXBUF_IDX(
|
||||
const int initial_idx = acVertexBufferIdx(
|
||||
mesh.info.int_params[AC_nx_min], mesh.info.int_params[AC_ny_min],
|
||||
mesh.info.int_params[AC_nz_min], mesh.info);
|
||||
|
||||
@@ -184,7 +184,7 @@ model_reduce_vec(const ModelMesh& mesh, const ReductionType& rtype,
|
||||
j < mesh.info.int_params[AC_ny_max]; j++) {
|
||||
for (int i = mesh.info.int_params[AC_nx_min];
|
||||
i < mesh.info.int_params[AC_nx_max]; i++) {
|
||||
const int idx = AC_VTXBUF_IDX(i, j, k, mesh.info);
|
||||
const int idx = acVertexBufferIdx(i, j, k, mesh.info);
|
||||
const ModelScalar curr_val = reduce_initial(
|
||||
mesh.vertex_buffer[a][idx], mesh.vertex_buffer[b][idx],
|
||||
mesh.vertex_buffer[c][idx]);
|
||||
|
||||
@@ -68,7 +68,7 @@ get(const AcRealParam param)
|
||||
static inline int
|
||||
IDX(const int i, const int j, const int k)
|
||||
{
|
||||
return AC_VTXBUF_IDX(i, j, k, (*mesh_info));
|
||||
return acVertexBufferIdx(i, j, k, (*mesh_info));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -749,7 +749,7 @@ static void
|
||||
solve_alpha_step(const int step_number, const ModelScalar dt, const int i, const int j, const int k,
|
||||
ModelMesh& in, ModelMesh* out)
|
||||
{
|
||||
const int idx = AC_VTXBUF_IDX(i, j, k, in.info);
|
||||
const int idx = acVertexBufferIdx(i, j, k, in.info);
|
||||
|
||||
const ModelScalarData lnrho = read_data(i, j, k, in.vertex_buffer, VTXBUF_LNRHO);
|
||||
const ModelVectorData uu = read_data(i, j, k, in.vertex_buffer,
|
||||
@@ -797,7 +797,7 @@ static void
|
||||
solve_beta_step(const int step_number, const ModelScalar dt, const int i, const int j, const int k,
|
||||
const ModelMesh& in, ModelMesh* out)
|
||||
{
|
||||
const int idx = AC_VTXBUF_IDX(i, j, k, in.info);
|
||||
const int idx = acVertexBufferIdx(i, j, k, in.info);
|
||||
|
||||
// Williamson (1980) NOTE: older version of astaroth used inhomogenous
|
||||
const ModelScalar beta[] = {ModelScalar(1. / 3.), ModelScalar(15. / 16.),
|
||||
|
||||
@@ -162,7 +162,7 @@ draw_vertex_buffer(const AcMesh& mesh, const VertexBufferHandle& vertex_buffer,
|
||||
for (int i = 0; i < mesh.info.int_params[AC_mx]; ++i) {
|
||||
ERRCHK(i < datasurface_width && j < datasurface_height);
|
||||
|
||||
const int idx = AC_VTXBUF_IDX(i, j, k, mesh.info);
|
||||
const int idx = acVertexBufferIdx(i, j, k, mesh.info);
|
||||
const uint8_t shade = (uint8_t)(
|
||||
255.f * (fabsf(float(mesh.vertex_buffer[vertex_buffer][idx]) - mid)) / range);
|
||||
uint8_t color[4] = {0, 0, 0, 255};
|
||||
@@ -219,7 +219,7 @@ draw_vertex_buffer_vec(const AcMesh& mesh, const VertexBufferHandle& vertex_buff
|
||||
for (int i = 0; i < mesh.info.int_params[AC_mx]; ++i) {
|
||||
ERRCHK(i < datasurface_width && j < datasurface_height);
|
||||
|
||||
const int idx = AC_VTXBUF_IDX(i, j, k, mesh.info);
|
||||
const int idx = acVertexBufferIdx(i, j, k, mesh.info);
|
||||
const uint8_t r = (uint8_t)(
|
||||
255.f * (fabsf(float(mesh.vertex_buffer[vertex_buffer_a][idx]) - mid)) / range);
|
||||
const uint8_t g = (uint8_t)(
|
||||
|
||||
@@ -100,7 +100,7 @@ save_mesh(const AcMesh& save_mesh, const int step, const AcReal t_step)
|
||||
FILE* save_ptr;
|
||||
|
||||
for (int w = 0; w < NUM_VTXBUF_HANDLES; ++w) {
|
||||
const size_t n = AC_VTXBUF_SIZE(save_mesh.info);
|
||||
const size_t n = acVertexBufferSize(save_mesh.info);
|
||||
|
||||
const char* buffername = vtxbuf_names[w];
|
||||
char cstep[11];
|
||||
|
||||
Reference in New Issue
Block a user