got it working with OpenMP

This commit is contained in:
Adam G Nelson 2018-06-14 20:22:31 -04:00
parent 7fd4cbb140
commit 7c819f02bc
9 changed files with 404 additions and 416 deletions

View file

@ -6,10 +6,11 @@ namespace openmc {
// Mgxs data loading interface methods
//==============================================================================
void add_mgxs_c(hid_t file_id, char* name, int energy_groups,
int delayed_groups, int n_temps, double temps[], int& method,
double tolerance, int max_order, bool legendre_to_tabular,
int legendre_to_tabular_points)
void add_mgxs_c(hid_t file_id, char* name, const int energy_groups,
const int delayed_groups, const int n_temps, double temps[], int& method,
const double tolerance, const int max_order,
const bool legendre_to_tabular, const int legendre_to_tabular_points,
const int n_threads)
{
//!! mgxs_data.F90 will be modified to just create the list of names
//!! in the order needed
@ -32,7 +33,7 @@ void add_mgxs_c(hid_t file_id, char* name, int energy_groups,
Mgxs mg;
mg.from_hdf5(xs_grp, energy_groups, delayed_groups,
temperature, method, tolerance, max_order, legendre_to_tabular,
legendre_to_tabular_points);
legendre_to_tabular_points, n_threads);
nuclides_MG.push_back(mg);
}
@ -50,7 +51,8 @@ bool query_fissionable_c(const int n_nuclides, const int i_nuclides[])
void create_macro_xs_c(char* mat_name, const int n_nuclides,
const int i_nuclides[], const int n_temps, const double temps[],
const double atom_densities[], int& method, const double tolerance)
const double atom_densities[], int& method, const double tolerance,
const int n_threads)
{
Mgxs macro;
if (n_temps > 0) {
@ -70,7 +72,7 @@ void create_macro_xs_c(char* mat_name, const int n_nuclides,
}
macro.build_macro(mat_name, temperature, mgxs_ptr, atom_densities_vec,
method, tolerance);
method, tolerance, n_threads);
}
macro_xs.push_back(macro);
}
@ -79,19 +81,20 @@ void create_macro_xs_c(char* mat_name, const int n_nuclides,
// Mgxs tracking/transport/tallying interface methods
//==============================================================================
void calculate_xs_c(const int i_mat, const int gin, const double sqrtkT,
const double uvw[3], double& total_xs, double& abs_xs, double& nu_fiss_xs)
void calculate_xs_c(const int i_mat, const int tid, const int gin,
const double sqrtkT, const double uvw[3], double& total_xs, double& abs_xs,
double& nu_fiss_xs)
{
macro_xs[i_mat - 1].calculate_xs(gin - 1, sqrtkT, uvw, total_xs, abs_xs,
macro_xs[i_mat - 1].calculate_xs(tid, gin - 1, sqrtkT, uvw, total_xs, abs_xs,
nu_fiss_xs);
}
void sample_scatter_c(const int i_mat, const int gin, int& gout, double& mu,
double& wgt, double uvw[3])
void sample_scatter_c(const int i_mat, const int tid, const int gin, int& gout,
double& mu, double& wgt, double uvw[3])
{
int gout_c = gout - 1;
macro_xs[i_mat - 1].sample_scatter(gin - 1, gout_c, mu, wgt);
macro_xs[i_mat - 1].sample_scatter(tid, gin - 1, gout_c, mu, wgt);
// adjust return value for fortran indexing
gout = gout_c + 1;
@ -101,11 +104,12 @@ void sample_scatter_c(const int i_mat, const int gin, int& gout, double& mu,
}
void sample_fission_energy_c(const int i_mat, const int gin, int& dg, int& gout)
void sample_fission_energy_c(const int i_mat, const int tid, const int gin,
int& dg, int& gout)
{
int dg_c = 0;
int gout_c = 0;
macro_xs[i_mat - 1].sample_fission_energy(gin - 1, dg_c, gout_c);
macro_xs[i_mat - 1].sample_fission_energy(tid, gin - 1, dg_c, gout_c);
// adjust return values for fortran indexing
dg = dg_c + 1;
@ -113,6 +117,82 @@ void sample_fission_energy_c(const int i_mat, const int gin, int& dg, int& gout)
}
double get_nuclide_xs_c(const int index, const int tid, const int xstype,
const int gin, int* gout, double* mu, int* dg)
{
int gout_c;
int* gout_c_p;
int dg_c;
int* dg_c_p;
if (gout != nullptr) {
gout_c = *gout - 1;
gout_c_p = &gout_c;
} else {
gout_c_p = gout;
}
if (dg != nullptr) {
dg_c = *dg - 1;
dg_c_p = &dg_c;
} else {
dg_c_p = dg;
}
return nuclides_MG[index - 1].get_xs(tid, xstype, gin - 1, gout_c_p, mu,
dg_c_p);
}
double get_macro_xs_c(const int index, const int tid, const int xstype,
const int gin, int* gout, double* mu, int* dg)
{
int gout_c;
int* gout_c_p;
int dg_c;
int* dg_c_p;
if (gout != nullptr) {
gout_c = *gout - 1;
gout_c_p = &gout_c;
} else {
gout_c_p = gout;
}
if (dg != nullptr) {
dg_c = *dg - 1;
dg_c_p = &dg_c;
} else {
dg_c_p = dg;
}
return macro_xs[index - 1].get_xs(tid, xstype, gin - 1, gout_c_p, mu,
dg_c_p);
}
void set_nuclide_angle_index_c(const int index, const int tid,
const double uvw[3])
{
// Update the values
nuclides_MG[index - 1].set_angle_index(tid, uvw);
}
void set_macro_angle_index_c(const int index, const int tid,
const double uvw[3])
{
// Update the values
macro_xs[index - 1].set_angle_index(tid, uvw);
}
void set_nuclide_temperature_index_c(const int index, const int tid,
const double sqrtkT)
{
// Update the values
nuclides_MG[index - 1].set_temperature_index(tid, sqrtkT);
}
//==============================================================================
// Mgxs general methods
//==============================================================================
void get_name_c(const int index, int name_len, char* name)
{
// First blank out our input string
@ -133,115 +213,4 @@ double get_awr_c(const int index)
return nuclides_MG[index - 1].awr;
}
double get_nuclide_xs_c(const int index, const int xstype, const int gin,
int* gout, double* mu, int* dg)
{
int gout_c;
int* gout_c_p;
int dg_c;
int* dg_c_p;
if (gout != nullptr) {
gout_c = *gout - 1;
gout_c_p = &gout_c;
} else {
gout_c_p = gout;
}
if (dg != nullptr) {
dg_c = *dg - 1;
dg_c_p = &dg_c;
} else {
dg_c_p = dg;
}
return nuclides_MG[index - 1].get_xs(xstype, gin - 1, gout_c_p, mu, dg_c_p);
}
double get_macro_xs_c(const int index, const int xstype, const int gin,
int* gout, double* mu, int* dg)
{
int gout_c;
int* gout_c_p;
int dg_c;
int* dg_c_p;
if (gout != nullptr) {
gout_c = *gout - 1;
gout_c_p = &gout_c;
} else {
gout_c_p = gout;
}
if (dg != nullptr) {
dg_c = *dg - 1;
dg_c_p = &dg_c;
} else {
dg_c_p = dg;
}
return macro_xs[index - 1].get_xs(xstype, gin - 1, gout_c_p, mu, dg_c_p);
}
void set_nuclide_angle_index_c(const int index, const double uvw[3],
int& last_pol, int& last_azi, double last_uvw[3])
{
// Store the old
last_pol = nuclides_MG[index - 1].index_pol;
last_azi = nuclides_MG[index - 1].index_azi;
last_uvw[0] = nuclides_MG[index - 1].last_uvw[0];
last_uvw[1] = nuclides_MG[index - 1].last_uvw[1];
last_uvw[2] = nuclides_MG[index - 1].last_uvw[2];
// Update the values
nuclides_MG[index - 1].set_angle_index(uvw);
}
void reset_nuclide_angle_index_c(const int index, const int last_pol,
const int last_azi, const double last_uvw[3])
{
nuclides_MG[index - 1].index_pol = last_pol;
nuclides_MG[index - 1].index_azi = last_azi;
nuclides_MG[index - 1].last_uvw[0] = last_uvw[0];
nuclides_MG[index - 1].last_uvw[1] = last_uvw[1];
nuclides_MG[index - 1].last_uvw[2] = last_uvw[2];
}
void set_macro_angle_index_c(const int index, const double uvw[3],
int& last_pol, int& last_azi, double last_uvw[3])
{
// Store the old
last_pol = macro_xs[index - 1].index_pol;
last_azi = macro_xs[index - 1].index_azi;
last_uvw[0] = macro_xs[index - 1].last_uvw[0];
last_uvw[1] = macro_xs[index - 1].last_uvw[1];
last_uvw[2] = macro_xs[index - 1].last_uvw[2];
// Update the values
macro_xs[index - 1].set_angle_index(uvw);
}
void reset_macro_angle_index_c(const int index, const int last_pol,
const int last_azi, const double last_uvw[3])
{
macro_xs[index - 1].index_pol = last_pol;
macro_xs[index - 1].index_azi = last_azi;
macro_xs[index - 1].last_uvw[0] = last_uvw[0];
macro_xs[index - 1].last_uvw[1] = last_uvw[1];
macro_xs[index - 1].last_uvw[2] = last_uvw[2];
}
int set_nuclide_temperature_index_c(const int index, const double sqrtkT)
{
int old = nuclides_MG[index - 1].index_temp;
nuclides_MG[index - 1].set_temperature_index(sqrtkT);
return old;
}
void reset_nuclide_temperature_index_c(const int index, const int last_temp)
{
nuclides_MG[index - 1].index_temp = last_temp;
}
} // namespace openmc