Skip to content

Commit

Permalink
Start incremental block phixs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed Aug 30, 2024
1 parent 1fbd96d commit ea77e26
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ inline auto get_nphixstargets(const int element, const int ion, const int level)
}

inline auto get_phixs_table(const int element, const int ion, const int level) -> float * {
return globals::elements[element].ions[ion].levels[level].photoion_xs;
return globals::allphixs + globals::elements[element].ions[ion].levels[level].phixsstart;
}

// Calculate the photoionisation cross-section at frequency nu out of the atomic data.
Expand Down
1 change: 1 addition & 0 deletions globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct EnergyLevel {
int ndowntrans{0};
PhotoionTarget *phixstargets{}; // pointer to table of target states and probabilities
float *photoion_xs{}; // Pointer to a lookup-table providing photoionisation cross-sections for this level.
int phixsstart{-1}; // index to start of photoionisation cross-sections table in global::allphixs
int nphixstargets{0}; // length of phixstargets array:
float stat_weight{0.}; // Statistical weight of this level.

Expand Down
14 changes: 10 additions & 4 deletions input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ constexpr std::array<std::string_view, 24> inputlinecomments = {

CellCachePhixsTargets *chphixstargetsblock{};

std::vector<float> tmpallphixs;

void read_phixs_data_table(std::fstream &phixsfile, const int nphixspoints_inputtable, const int element,
const int lowerion, const int lowerlevel, const int upperion, int upperlevel_in,
size_t *mem_usage_phixs, const int phixs_file_version) {
Expand Down Expand Up @@ -175,11 +177,13 @@ void read_phixs_data_table(std::fstream &phixsfile, const int nphixspoints_input
}

*mem_usage_phixs += globals::NPHIXSPOINTS * sizeof(float);
globals::elements[element].ions[lowerion].levels[lowerlevel].phixsstart = tmpallphixs.size();
tmpallphixs.resize(tmpallphixs.size() + globals::NPHIXSPOINTS);
globals::elements[element].ions[lowerion].levels[lowerlevel].photoion_xs =
static_cast<float *>(malloc(globals::NPHIXSPOINTS * sizeof(float)));
assert_always(globals::elements[element].ions[lowerion].levels[lowerlevel].photoion_xs != nullptr);

auto *levelphixstable = globals::elements[element].ions[lowerion].levels[lowerlevel].photoion_xs;
auto *levelphixstable = tmpallphixs.data() + globals::elements[element].ions[lowerion].levels[lowerlevel].phixsstart;
if (phixs_file_version == 1) {
assert_always(get_nphixstargets(element, lowerion, lowerlevel) == 1);
assert_always(get_phixsupperlevel(element, lowerion, lowerlevel, 0) == 0);
Expand Down Expand Up @@ -1438,18 +1442,20 @@ void setup_phixs_list() {

// different targets share the same cross section table, so don't repeat this process
if (phixstargetindex == 0) {
auto *sourcetable = tmpallphixs.data() + globals::elements[element].ions[ion].levels[level].phixsstart;
auto *blocktablestart = globals::allphixs + (nbftableschanged * globals::NPHIXSPOINTS);
if (globals::rank_in_node == 0) {
memcpy(blocktablestart, globals::elements[element].ions[ion].levels[level].photoion_xs,
globals::NPHIXSPOINTS * sizeof(float));
memcpy(blocktablestart, sourcetable, globals::NPHIXSPOINTS * sizeof(float));
}

free(globals::elements[element].ions[ion].levels[level].photoion_xs);
globals::elements[element].ions[ion].levels[level].photoion_xs = blocktablestart;
globals::elements[element].ions[ion].levels[level].phixsstart = nbftableschanged * globals::NPHIXSPOINTS;

nbftableschanged++;
}
}
tmpallphixs.clear();
tmpallphixs.shrink_to_fit();
assert_always(nbftableschanged == nbftables);
#ifdef MPI_ON
MPI_Barrier(MPI_COMM_WORLD);
Expand Down

0 comments on commit ea77e26

Please sign in to comment.