Changed #if 0 to #if LFORCING instead to get the code to compile if forcing is used (even though autotesting does not support it yet). Also more autoformatting. Maybe I should disable it or then everyone should start using it to avoid cluttering commits with these superficial changes
This commit is contained in:
@@ -687,8 +687,8 @@ is_valid(const ModelVector& a)
|
|||||||
return is_valid(a.x) && is_valid(a.y) && is_valid(a.z);
|
return is_valid(a.x) && is_valid(a.y) && is_valid(a.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if LFORCING
|
||||||
//FORCING NOT SUPPORTED FOR AUTOTEST
|
// FORCING NOT SUPPORTED FOR AUTOTEST
|
||||||
|
|
||||||
static inline ModelVector
|
static inline ModelVector
|
||||||
simple_vortex_forcing(ModelVector a, ModelVector b, ModelScalar magnitude)
|
simple_vortex_forcing(ModelVector a, ModelVector b, ModelScalar magnitude)
|
||||||
@@ -702,28 +702,28 @@ simple_outward_flow_forcing(ModelVector a, ModelVector b, ModelScalar magnitude)
|
|||||||
return magnitude * (1 / length(b - a)) * normalized(b - a); // Outward flow
|
return magnitude * (1 / length(b - a)) * normalized(b - a); // Outward flow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
static inline ModelVector
|
static inline ModelVector
|
||||||
helical_forcing(ModelScalar magnitude, ModelVector k_force, ModelVector xx, ModelVector ff_re, ModelVector ff_im, ModelScalar phi)
|
helical_forcing(ModelScalar /* magnitude */, ModelVector k_force, ModelVector xx, ModelVector ff_re,
|
||||||
|
ModelVector ff_im, ModelScalar phi)
|
||||||
{
|
{
|
||||||
|
|
||||||
xx.x = xx.x*(2.0*M_PI/(get(AC_dsx)*(get(AC_ny_max) - get(AC_ny_min))));
|
xx.x = xx.x * (2.0 * M_PI / (get(AC_dsx) * (get(AC_ny_max) - get(AC_ny_min))));
|
||||||
xx.y = xx.y*(2.0*M_PI/(get(AC_dsy)*(get(AC_ny_max) - get(AC_ny_min))));
|
xx.y = xx.y * (2.0 * M_PI / (get(AC_dsy) * (get(AC_ny_max) - get(AC_ny_min))));
|
||||||
xx.z = xx.z*(2.0*M_PI/(get(AC_dsz)*(get(AC_ny_max) - get(AC_ny_min))));
|
xx.z = xx.z * (2.0 * M_PI / (get(AC_dsz) * (get(AC_ny_max) - get(AC_ny_min))));
|
||||||
|
|
||||||
ModelScalar cos_phi = cos(phi);
|
ModelScalar cos_phi = cos(phi);
|
||||||
ModelScalar sin_phi = sin(phi);
|
ModelScalar sin_phi = sin(phi);
|
||||||
ModelScalar cos_k_dox_x = cos(dot(k_force, xx));
|
ModelScalar cos_k_dox_x = cos(dot(k_force, xx));
|
||||||
ModelScalar sin_k_dox_x = sin(dot(k_force, xx));
|
ModelScalar sin_k_dox_x = sin(dot(k_force, xx));
|
||||||
// Phase affect only the x-component
|
// Phase affect only the x-component
|
||||||
ModelScalar real_comp_phase = cos_k_dox_x*cos_phi - sin_k_dox_x*sin_phi;
|
ModelScalar real_comp_phase = cos_k_dox_x * cos_phi - sin_k_dox_x * sin_phi;
|
||||||
ModelScalar imag_comp_phase = cos_k_dox_x*sin_phi + sin_k_dox_x*cos_phi;
|
ModelScalar imag_comp_phase = cos_k_dox_x * sin_phi + sin_k_dox_x * cos_phi;
|
||||||
|
|
||||||
|
ModelVector force = (ModelVector){ff_re.x * real_comp_phase - ff_im.x * imag_comp_phase,
|
||||||
ModelVector force = (ModelVector){ ff_re.x*real_comp_phase - ff_im.x*imag_comp_phase,
|
ff_re.y * real_comp_phase - ff_im.y * imag_comp_phase,
|
||||||
ff_re.y*real_comp_phase - ff_im.y*imag_comp_phase,
|
ff_re.z * real_comp_phase - ff_im.z * imag_comp_phase};
|
||||||
ff_re.z*real_comp_phase - ff_im.z*imag_comp_phase};
|
|
||||||
|
|
||||||
return force;
|
return force;
|
||||||
}
|
}
|
||||||
@@ -731,37 +731,43 @@ helical_forcing(ModelScalar magnitude, ModelVector k_force, ModelVector xx, Mode
|
|||||||
static inline ModelVector
|
static inline ModelVector
|
||||||
forcing(int3 globalVertexIdx, ModelScalar dt)
|
forcing(int3 globalVertexIdx, ModelScalar dt)
|
||||||
{
|
{
|
||||||
ModelVector a = ModelScalar(.5) * (ModelVector){ get(AC_nx) * get(AC_dsx),
|
/*
|
||||||
get(AC_ny) * get(AC_dsy),
|
ModelVector a = ModelScalar(.5) * (ModelVector){get(AC_nx) * get(AC_dsx),
|
||||||
get(AC_nz) * get(AC_dsz)}; // source (origin)
|
get(AC_ny) * get(AC_dsy),
|
||||||
ModelVector xx = (ModelVector){(globalVertexIdx.x - get(AC_nx_min)) * get(AC_dsx),
|
get(AC_nz) * get(AC_dsz)}; // source (origin)
|
||||||
(globalVertexIdx.y - get(AC_ny_min) * get(AC_dsy)),
|
*/
|
||||||
(globalVertexIdx.z - get(AC_nz_min) * get(AC_dsz))}; // sink (current index)
|
ModelVector xx = (ModelVector){
|
||||||
|
(globalVertexIdx.x - get(AC_nx_min)) * get(AC_dsx),
|
||||||
|
(globalVertexIdx.y - get(AC_ny_min) * get(AC_dsy)),
|
||||||
|
(globalVertexIdx.z - get(AC_nz_min) * get(AC_dsz))}; // sink (current index)
|
||||||
const ModelScalar cs2 = get(AC_cs2_sound);
|
const ModelScalar cs2 = get(AC_cs2_sound);
|
||||||
const ModelScalar cs = sqrt(cs2);
|
const ModelScalar cs = sqrt(cs2);
|
||||||
|
|
||||||
//Placeholders until determined properly
|
// Placeholders until determined properly
|
||||||
ModelScalar magnitude = get(AC_forcing_magnitude);
|
ModelScalar magnitude = get(AC_forcing_magnitude);
|
||||||
ModelScalar phase = get(AC_forcing_phase);
|
ModelScalar phase = get(AC_forcing_phase);
|
||||||
ModelVector k_force = (ModelVector){ get(AC_k_forcex), get(AC_k_forcey), get(AC_k_forcez)};
|
ModelVector k_force = (ModelVector){get(AC_k_forcex), get(AC_k_forcey), get(AC_k_forcez)};
|
||||||
ModelVector ff_re = (ModelVector){get(AC_ff_hel_rex), get(AC_ff_hel_rey), get(AC_ff_hel_rez)};
|
ModelVector ff_re = (ModelVector){get(AC_ff_hel_rex), get(AC_ff_hel_rey), get(AC_ff_hel_rez)};
|
||||||
ModelVector ff_im = (ModelVector){get(AC_ff_hel_imx), get(AC_ff_hel_imy), get(AC_ff_hel_imz)};
|
ModelVector ff_im = (ModelVector){get(AC_ff_hel_imx), get(AC_ff_hel_imy), get(AC_ff_hel_imz)};
|
||||||
|
|
||||||
|
// Determine that forcing funtion type at this point.
|
||||||
|
// ModelVector force = simple_vortex_forcing(a, xx, magnitude);
|
||||||
|
// ModelVector force = simple_outward_flow_forcing(a, xx, magnitude);
|
||||||
|
ModelVector force = helical_forcing(magnitude, k_force, xx, ff_re, ff_im, phase);
|
||||||
|
|
||||||
//Determine that forcing funtion type at this point.
|
// Scaling N = magnitude*cs*sqrt(k*cs/dt) * dt
|
||||||
//ModelVector force = simple_vortex_forcing(a, xx, magnitude);
|
const ModelScalar NN = cs * sqrt(get(AC_kaver) * cs);
|
||||||
//ModelVector force = simple_outward_flow_forcing(a, xx, magnitude);
|
// MV: Like in the Pencil Code. I don't understandf the logic here.
|
||||||
ModelVector force = helical_forcing(magnitude, k_force, xx, ff_re,ff_im, phase);
|
force.x = sqrt(dt) * NN * force.x;
|
||||||
|
force.y = sqrt(dt) * NN * force.y;
|
||||||
|
force.z = sqrt(dt) * NN * force.z;
|
||||||
|
|
||||||
//Scaling N = magnitude*cs*sqrt(k*cs/dt) * dt
|
if (is_valid(force)) {
|
||||||
const ModelScalar NN = cs*sqrt(get(AC_kaver)*cs);
|
return force;
|
||||||
//MV: Like in the Pencil Code. I don't understandf the logic here.
|
}
|
||||||
force.x = sqrt(dt)*NN*force.x;
|
else {
|
||||||
force.y = sqrt(dt)*NN*force.y;
|
return (ModelVector){0, 0, 0};
|
||||||
force.z = sqrt(dt)*NN*force.z;
|
}
|
||||||
|
|
||||||
if (is_valid(force)) { return force; }
|
|
||||||
else { return (ModelVector){0, 0, 0}; }
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user