Created a new ForcingParams structure and some functions for generating and transferring the forcing parameters to the host/device

This commit is contained in:
jpekkila
2019-07-08 15:43:37 +03:00
parent f9be905703
commit eda2f6543b
3 changed files with 109 additions and 36 deletions

View File

@@ -216,16 +216,6 @@ run_simulation(void)
AcReal bin_save_t = mesh_info.real_params[AC_bin_save_t];
AcReal bin_crit_t = bin_save_t;
#if LFORCING
// Forcing properties
AcReal relhel = mesh_info.real_params[AC_relhel];
AcReal magnitude = mesh_info.real_params[AC_forcing_magnitude];
AcReal kmin = mesh_info.real_params[AC_kmin];
AcReal kmax = mesh_info.real_params[AC_kmax];
AcReal kaver = (kmax - kmin) / AcReal(2.0);
#endif
/* initialize random seed: */
srand(312256655);
@@ -235,28 +225,8 @@ run_simulation(void)
const AcReal dt = host_timestep(umax, mesh_info);
#if LFORCING
// Generate a forcing vector before canculating an integration step.
// Generate forcing wave vector k_force
AcReal3 k_force;
k_force = helical_forcing_k_generator(kmax, kmin);
// Randomize the phase
AcReal phase = AcReal(2.0) * AcReal(M_PI) * get_random_number_01();
// Generate e for k. Needed for the sake of isotrophy.
AcReal3 e_force;
if ((k_force.y == AcReal(0.0)) && (k_force.z == AcReal(0.0))) {
e_force = (AcReal3){0.0, 1.0, 0.0};
}
else {
e_force = (AcReal3){1.0, 0.0, 0.0};
}
helical_forcing_e_generator(&e_force, k_force);
AcReal3 ff_hel_re, ff_hel_im;
helical_forcing_special_vector(&ff_hel_re, &ff_hel_im, k_force, e_force, relhel);
acForcingVec(magnitude, k_force, ff_hel_re, ff_hel_im, phase, kaver);
const ForcingParams forcing_params = generateForcingParams(mesh_info);
loadForcingParamsToDevice(forcing_params);
#endif
acIntegrate(dt);