mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Directly access C++ material data in tally.cpp
This commit is contained in:
parent
2d0ea1154b
commit
675ed32b34
3 changed files with 23 additions and 27 deletions
|
|
@ -636,7 +636,7 @@ void Material::init_nuclide_index()
|
|||
int n = settings::run_CE ?
|
||||
data::nuclides.size() : data::nuclides_MG.size();
|
||||
mat_nuclide_index_.resize(n);
|
||||
std::fill(mat_nuclide_index_.begin(), mat_nuclide_index_.end(), -1);
|
||||
std::fill(mat_nuclide_index_.begin(), mat_nuclide_index_.end(), C_NONE);
|
||||
for (int i = 0; i < nuclide_.size(); ++i) {
|
||||
mat_nuclide_index_[nuclide_[i]] = i;
|
||||
}
|
||||
|
|
@ -1135,11 +1135,6 @@ extern "C" {
|
|||
return model::materials[i_mat - 1]->density_gpcc_;
|
||||
}
|
||||
|
||||
int material_nuclide_index(int32_t i_mat, int i_nuc)
|
||||
{
|
||||
return model::materials[i_mat - 1]->mat_nuclide_index_[i_nuc - 1] + 1;
|
||||
}
|
||||
|
||||
void material_calculate_xs(const Particle* p)
|
||||
{
|
||||
model::materials[p->material - 1]->calculate_xs(*p);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ module material_header
|
|||
public :: material_id
|
||||
public :: material_nuclide
|
||||
public :: material_nuclide_size
|
||||
public :: material_nuclide_index
|
||||
public :: material_atom_density
|
||||
public :: material_density_gpcc
|
||||
|
||||
|
|
@ -40,13 +39,6 @@ module material_header
|
|||
integer(C_INT) :: n
|
||||
end function
|
||||
|
||||
function material_nuclide_index(i_mat, i_nuc) bind(C) result(idx)
|
||||
import C_INT32_T, C_INT
|
||||
integer(C_INT32_T), value :: i_mat
|
||||
integer(C_INT), value :: i_nuc
|
||||
integer(C_INT) :: idx
|
||||
end function
|
||||
|
||||
function material_atom_density(i_mat, idx) bind(C) result(density)
|
||||
import C_INT32_T, C_INT, C_DOUBLE
|
||||
integer(C_INT32_T), value :: i_mat
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "openmc/capi.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/material.h"
|
||||
#include "openmc/message_passing.h"
|
||||
#include "openmc/nuclide.h"
|
||||
#include "openmc/settings.h"
|
||||
|
|
@ -44,10 +45,6 @@ score_general_mg(Particle* p, int i_tally, int start_index, int filter_index,
|
|||
extern "C" void
|
||||
score_all_nuclides(Particle* p, int i_tally, double flux, int filter_index);
|
||||
|
||||
extern "C" int material_nuclide_index(int i_material, int i_nuclide);
|
||||
|
||||
extern "C" double material_atom_density(int i_material, int i);
|
||||
|
||||
//==============================================================================
|
||||
// Global variable definitions
|
||||
//==============================================================================
|
||||
|
|
@ -729,9 +726,13 @@ score_analog_tally_mg(Particle* p)
|
|||
|
||||
double atom_density = 0.;
|
||||
if (i_nuclide > 0) {
|
||||
auto j = material_nuclide_index(p->material, i_nuclide);
|
||||
if (j == 0) continue;
|
||||
atom_density = material_atom_density(p->material, j);
|
||||
//TODO: off-by-one
|
||||
auto j = model::materials[p->material-1]
|
||||
->mat_nuclide_index_[i_nuclide-1];
|
||||
if (j == C_NONE) continue;
|
||||
//atom_density = material_atom_density(p->material, j);
|
||||
//TODO: off-by-one
|
||||
atom_density = model::materials[p->material-1]->atom_density_(j);
|
||||
}
|
||||
|
||||
score_general_mg(p, i_tally, i*tally.scores_.size(), filter_index,
|
||||
|
|
@ -791,9 +792,13 @@ score_tracklength_tally(Particle* p, double distance)
|
|||
double atom_density = 0.;
|
||||
if (i_nuclide > 0) {
|
||||
if (p->material != MATERIAL_VOID) {
|
||||
auto j = material_nuclide_index(p->material, i_nuclide);
|
||||
if (j == 0) continue;
|
||||
atom_density = material_atom_density(p->material, j);
|
||||
//TODO: off-by-one
|
||||
auto j = model::materials[p->material-1]
|
||||
->mat_nuclide_index_[i_nuclide-1];
|
||||
if (j == C_NONE) continue;
|
||||
//atom_density = material_atom_density(p->material, j);
|
||||
//TODO: off-by-one
|
||||
atom_density = model::materials[p->material-1]->atom_density_(j);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -867,9 +872,13 @@ score_collision_tally(Particle* p)
|
|||
|
||||
double atom_density = 0.;
|
||||
if (i_nuclide > 0) {
|
||||
auto j = material_nuclide_index(p->material, i_nuclide);
|
||||
if (j == 0) continue;
|
||||
atom_density = material_atom_density(p->material, j);
|
||||
//TODO: off-by-one
|
||||
auto j = model::materials[p->material-1]
|
||||
->mat_nuclide_index_[i_nuclide-1];
|
||||
if (j == C_NONE) continue;
|
||||
//atom_density = material_atom_density(p->material, j);
|
||||
//TODO: off-by-one
|
||||
atom_density = model::materials[p->material-1]->atom_density_(j);
|
||||
}
|
||||
|
||||
//TODO: consider replacing this "if" with pointers or templates
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue