Renamed the old .sas and .sdh files to regular headers and added #pragma once.
This commit is contained in:
@@ -1,17 +1,4 @@
|
|||||||
#include "stencil_definition.sdh"
|
#pragma once
|
||||||
|
|
||||||
Preprocessed Scalar
|
|
||||||
value(in ScalarField vertex)
|
|
||||||
{
|
|
||||||
return vertex[vertexIdx];
|
|
||||||
}
|
|
||||||
|
|
||||||
Preprocessed Vector
|
|
||||||
gradient(in ScalarField vertex)
|
|
||||||
{
|
|
||||||
return (Vector){derx(vertexIdx, vertex), dery(vertexIdx, vertex), derz(vertexIdx, vertex)};
|
|
||||||
}
|
|
||||||
|
|
||||||
#if LUPWD
|
#if LUPWD
|
||||||
|
|
||||||
Preprocessed Scalar
|
Preprocessed Scalar
|
||||||
@@ -60,16 +47,3 @@ der6z_upwd(in ScalarField vertex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Preprocessed Matrix
|
|
||||||
hessian(in ScalarField vertex)
|
|
||||||
{
|
|
||||||
Matrix hessian;
|
|
||||||
|
|
||||||
hessian.row[0] = (Vector){derxx(vertexIdx, vertex), derxy(vertexIdx, vertex),
|
|
||||||
derxz(vertexIdx, vertex)};
|
|
||||||
hessian.row[1] = (Vector){hessian.row[0].y, deryy(vertexIdx, vertex), deryz(vertexIdx, vertex)};
|
|
||||||
hessian.row[2] = (Vector){hessian.row[0].z, hessian.row[1].z, derzz(vertexIdx, vertex)};
|
|
||||||
|
|
||||||
return hessian;
|
|
||||||
}
|
|
@@ -1,3 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
#define LDENSITY (1)
|
#define LDENSITY (1)
|
||||||
#define LHYDRO (1)
|
#define LHYDRO (1)
|
||||||
#define LMAGNETIC (1)
|
#define LMAGNETIC (1)
|
||||||
@@ -8,6 +9,8 @@
|
|||||||
#define LSINK (0)
|
#define LSINK (0)
|
||||||
|
|
||||||
#define AC_THERMAL_CONDUCTIVITY (AcReal(0.001)) // TODO: make an actual config parameter
|
#define AC_THERMAL_CONDUCTIVITY (AcReal(0.001)) // TODO: make an actual config parameter
|
||||||
|
#define H_CONST (0) // TODO: make an actual config parameter
|
||||||
|
#define C_CONST (0) // TODO: make an actual config parameter
|
||||||
|
|
||||||
// Int params
|
// Int params
|
||||||
uniform int AC_max_steps;
|
uniform int AC_max_steps;
|
||||||
@@ -20,9 +23,6 @@ uniform int AC_start_step;
|
|||||||
uniform Scalar AC_dt;
|
uniform Scalar AC_dt;
|
||||||
uniform Scalar AC_max_time;
|
uniform Scalar AC_max_time;
|
||||||
// Spacing
|
// Spacing
|
||||||
uniform Scalar AC_dsx;
|
|
||||||
uniform Scalar AC_dsy;
|
|
||||||
uniform Scalar AC_dsz;
|
|
||||||
uniform Scalar AC_dsmin;
|
uniform Scalar AC_dsmin;
|
||||||
// physical grid
|
// physical grid
|
||||||
uniform Scalar AC_xlen;
|
uniform Scalar AC_xlen;
|
||||||
@@ -96,9 +96,6 @@ uniform Scalar AC_GM_star;
|
|||||||
uniform Scalar AC_unit_mass;
|
uniform Scalar AC_unit_mass;
|
||||||
uniform Scalar AC_sq2GM_star;
|
uniform Scalar AC_sq2GM_star;
|
||||||
uniform Scalar AC_cs2_sound;
|
uniform Scalar AC_cs2_sound;
|
||||||
uniform Scalar AC_inv_dsx;
|
|
||||||
uniform Scalar AC_inv_dsy;
|
|
||||||
uniform Scalar AC_inv_dsz;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
@@ -134,4 +131,3 @@ uniform ScalarField VTXBUF_LNRHO;
|
|||||||
#if LSINK
|
#if LSINK
|
||||||
uniform ScalarField VTXBUF_ACCRETION;
|
uniform ScalarField VTXBUF_ACCRETION;
|
||||||
#endif
|
#endif
|
||||||
|
|
@@ -1,13 +1,10 @@
|
|||||||
#include "stencil_definition.sdh"
|
#include <stdderiv.h>
|
||||||
|
|
||||||
Vector
|
#include "stencil_definition.h"
|
||||||
value(in VectorField uu)
|
#include "stencil_assembly.h"
|
||||||
{
|
|
||||||
return (Vector){value(uu.x), value(uu.y), value(uu.z)};
|
|
||||||
}
|
|
||||||
|
|
||||||
#if LUPWD
|
#if LUPWD
|
||||||
Scalar
|
Device Scalar
|
||||||
upwd_der6(in VectorField uu, in ScalarField lnrho)
|
upwd_der6(in VectorField uu, in ScalarField lnrho)
|
||||||
{
|
{
|
||||||
Scalar uux = fabs(value(uu).x);
|
Scalar uux = fabs(value(uu).x);
|
||||||
@@ -17,14 +14,14 @@ upwd_der6(in VectorField uu, in ScalarField lnrho)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Matrix
|
Device Matrix
|
||||||
gradients(in VectorField uu)
|
gradients(in VectorField uu)
|
||||||
{
|
{
|
||||||
return (Matrix){gradient(uu.x), gradient(uu.y), gradient(uu.z)};
|
return (Matrix){gradient(uu.x), gradient(uu.y), gradient(uu.z)};
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LSINK
|
#if LSINK
|
||||||
Vector
|
Device Vector
|
||||||
sink_gravity(int3 globalVertexIdx){
|
sink_gravity(int3 globalVertexIdx){
|
||||||
int accretion_switch = int(AC_switch_accretion);
|
int accretion_switch = int(AC_switch_accretion);
|
||||||
if (accretion_switch == 1){
|
if (accretion_switch == 1){
|
||||||
@@ -55,7 +52,7 @@ sink_gravity(int3 globalVertexIdx){
|
|||||||
|
|
||||||
#if LSINK
|
#if LSINK
|
||||||
// Give Truelove density
|
// Give Truelove density
|
||||||
Scalar
|
Device Scalar
|
||||||
truelove_density(in ScalarField lnrho){
|
truelove_density(in ScalarField lnrho){
|
||||||
const Scalar rho = exp(value(lnrho));
|
const Scalar rho = exp(value(lnrho));
|
||||||
const Scalar Jeans_length_squared = (M_PI * AC_cs2_sound) / (AC_G_const * rho);
|
const Scalar Jeans_length_squared = (M_PI * AC_cs2_sound) / (AC_G_const * rho);
|
||||||
@@ -68,7 +65,7 @@ truelove_density(in ScalarField lnrho){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This controls accretion of density/mass to the sink particle.
|
// This controls accretion of density/mass to the sink particle.
|
||||||
Scalar
|
Device Scalar
|
||||||
sink_accretion(int3 globalVertexIdx, in ScalarField lnrho, Scalar dt){
|
sink_accretion(int3 globalVertexIdx, in ScalarField lnrho, Scalar dt){
|
||||||
const Vector grid_pos = (Vector){(globalVertexIdx.x - DCONST(AC_nx_min)) * AC_dsx,
|
const Vector grid_pos = (Vector){(globalVertexIdx.x - DCONST(AC_nx_min)) * AC_dsx,
|
||||||
(globalVertexIdx.y - DCONST(AC_ny_min)) * AC_dsy,
|
(globalVertexIdx.y - DCONST(AC_ny_min)) * AC_dsy,
|
||||||
@@ -108,7 +105,7 @@ sink_accretion(int3 globalVertexIdx, in ScalarField lnrho, Scalar dt){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This controls accretion of velocity to the sink particle.
|
// This controls accretion of velocity to the sink particle.
|
||||||
Vector
|
Device Vector
|
||||||
sink_accretion_velocity(int3 globalVertexIdx, in VectorField uu, Scalar dt) {
|
sink_accretion_velocity(int3 globalVertexIdx, in VectorField uu, Scalar dt) {
|
||||||
const Vector grid_pos = (Vector){(globalVertexIdx.x - DCONST(AC_nx_min)) * AC_dsx,
|
const Vector grid_pos = (Vector){(globalVertexIdx.x - DCONST(AC_nx_min)) * AC_dsx,
|
||||||
(globalVertexIdx.y - DCONST(AC_ny_min)) * AC_dsy,
|
(globalVertexIdx.y - DCONST(AC_ny_min)) * AC_dsy,
|
||||||
@@ -153,7 +150,7 @@ sink_accretion_velocity(int3 globalVertexIdx, in VectorField uu, Scalar dt) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Scalar
|
Device Scalar
|
||||||
continuity(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, Scalar dt)
|
continuity(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, Scalar dt)
|
||||||
{
|
{
|
||||||
return -dot(value(uu), gradient(lnrho))
|
return -dot(value(uu), gradient(lnrho))
|
||||||
@@ -170,7 +167,7 @@ continuity(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, Scalar
|
|||||||
|
|
||||||
|
|
||||||
#if LENTROPY
|
#if LENTROPY
|
||||||
Vector
|
Device Vector
|
||||||
momentum(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, in ScalarField ss, in VectorField aa, Scalar dt)
|
momentum(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, in ScalarField ss, in VectorField aa, Scalar dt)
|
||||||
{
|
{
|
||||||
const Matrix S = stress_tensor(uu);
|
const Matrix S = stress_tensor(uu);
|
||||||
@@ -204,7 +201,7 @@ momentum(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, in Scala
|
|||||||
return mom;
|
return mom;
|
||||||
}
|
}
|
||||||
#elif LTEMPERATURE
|
#elif LTEMPERATURE
|
||||||
Vector
|
Device Vector
|
||||||
momentum(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, in ScalarField tt)
|
momentum(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, in ScalarField tt)
|
||||||
{
|
{
|
||||||
Vector mom;
|
Vector mom;
|
||||||
@@ -230,7 +227,7 @@ momentum(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, in Scala
|
|||||||
return mom;
|
return mom;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Vector
|
Device Vector
|
||||||
momentum(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, Scalar dt)
|
momentum(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, Scalar dt)
|
||||||
{
|
{
|
||||||
Vector mom;
|
Vector mom;
|
||||||
@@ -261,7 +258,7 @@ momentum(int3 globalVertexIdx, in VectorField uu, in ScalarField lnrho, Scalar d
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Vector
|
Device Vector
|
||||||
induction(in VectorField uu, in VectorField aa)
|
induction(in VectorField uu, in VectorField aa)
|
||||||
{
|
{
|
||||||
// Note: We do (-nabla^2 A + nabla(nabla dot A)) instead of (nabla x (nabla
|
// Note: We do (-nabla^2 A + nabla(nabla dot A)) instead of (nabla x (nabla
|
||||||
@@ -279,7 +276,7 @@ induction(in VectorField uu, in VectorField aa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if LENTROPY
|
#if LENTROPY
|
||||||
Scalar
|
Device Scalar
|
||||||
lnT(in ScalarField ss, in ScalarField lnrho)
|
lnT(in ScalarField ss, in ScalarField lnrho)
|
||||||
{
|
{
|
||||||
const Scalar lnT = AC_lnT0 + AC_gamma * value(ss) / AC_cp_sound +
|
const Scalar lnT = AC_lnT0 + AC_gamma * value(ss) / AC_cp_sound +
|
||||||
@@ -288,7 +285,7 @@ lnT(in ScalarField ss, in ScalarField lnrho)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Nabla dot (K nabla T) / (rho T)
|
// Nabla dot (K nabla T) / (rho T)
|
||||||
Scalar
|
Device Scalar
|
||||||
heat_conduction(in ScalarField ss, in ScalarField lnrho)
|
heat_conduction(in ScalarField ss, in ScalarField lnrho)
|
||||||
{
|
{
|
||||||
const Scalar inv_AC_cp_sound = AcReal(1.0) / AC_cp_sound;
|
const Scalar inv_AC_cp_sound = AcReal(1.0) / AC_cp_sound;
|
||||||
@@ -306,13 +303,13 @@ heat_conduction(in ScalarField ss, in ScalarField lnrho)
|
|||||||
return AC_cp_sound * chi * (first_term + dot(second_term, third_term));
|
return AC_cp_sound * chi * (first_term + dot(second_term, third_term));
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar
|
Device Scalar
|
||||||
heating(const int i, const int j, const int k)
|
heating(const int i, const int j, const int k)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar
|
Device Scalar
|
||||||
entropy(in ScalarField ss, in VectorField uu, in ScalarField lnrho, in VectorField aa)
|
entropy(in ScalarField ss, in VectorField uu, in ScalarField lnrho, in VectorField aa)
|
||||||
{
|
{
|
||||||
const Matrix S = stress_tensor(uu);
|
const Matrix S = stress_tensor(uu);
|
||||||
@@ -328,7 +325,7 @@ entropy(in ScalarField ss, in VectorField uu, in ScalarField lnrho, in VectorFie
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LTEMPERATURE
|
#if LTEMPERATURE
|
||||||
Scalar
|
Device Scalar
|
||||||
heat_transfer(in VectorField uu, in ScalarField lnrho, in ScalarField tt)
|
heat_transfer(in VectorField uu, in ScalarField lnrho, in ScalarField tt)
|
||||||
{
|
{
|
||||||
const Matrix S = stress_tensor(uu);
|
const Matrix S = stress_tensor(uu);
|
||||||
@@ -341,7 +338,7 @@ heat_transfer(in VectorField uu, in ScalarField lnrho, in ScalarField tt)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LFORCING
|
#if LFORCING
|
||||||
Vector
|
Device Vector
|
||||||
simple_vortex_forcing(Vector a, Vector b, Scalar magnitude){
|
simple_vortex_forcing(Vector a, Vector b, Scalar magnitude){
|
||||||
int accretion_switch = AC_switch_accretion;
|
int accretion_switch = AC_switch_accretion;
|
||||||
|
|
||||||
@@ -351,7 +348,7 @@ Vector
|
|||||||
return (Vector){0,0,0};
|
return (Vector){0,0,0};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vector
|
Device Vector
|
||||||
simple_outward_flow_forcing(Vector a, Vector b, Scalar magnitude){
|
simple_outward_flow_forcing(Vector a, Vector b, Scalar magnitude){
|
||||||
int accretion_switch = AC_switch_accretion;
|
int accretion_switch = AC_switch_accretion;
|
||||||
if (accretion_switch == 0){
|
if (accretion_switch == 0){
|
||||||
@@ -363,7 +360,7 @@ Vector
|
|||||||
|
|
||||||
// The Pencil Code forcing_hel_noshear(), manual Eq. 222, inspired forcing function with adjustable
|
// The Pencil Code forcing_hel_noshear(), manual Eq. 222, inspired forcing function with adjustable
|
||||||
// helicity
|
// helicity
|
||||||
Vector
|
Device Vector
|
||||||
helical_forcing(Scalar magnitude, Vector k_force, Vector xx, Vector ff_re, Vector ff_im, Scalar phi)
|
helical_forcing(Scalar magnitude, Vector k_force, Vector xx, Vector ff_re, Vector ff_im, Scalar phi)
|
||||||
{
|
{
|
||||||
// JP: This looks wrong:
|
// JP: This looks wrong:
|
@@ -1,3 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef STENCIL_ORDER
|
#ifndef STENCIL_ORDER
|
||||||
#define STENCIL_ORDER (6)
|
#define STENCIL_ORDER (6)
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user