Skip to content

Commit

Permalink
Trim muppet data and fix vector allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj committed Nov 30, 2024
1 parent 6527e6d commit 0cee03d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/celer-export-geant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void run(std::string const& gdml_filename,
if (gen_test)
{
ImportDataTrimmer::Input options;
options.max_size = 3;
options.mupp = true;
ImportDataTrimmer trim(options);
trim(&imported);
}
Expand Down
27 changes: 23 additions & 4 deletions src/celeritas/io/ImportDataTrimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void ImportDataTrimmer::operator()(ImportData* data)
(*this)(&data->geo_materials);
(*this)(&data->phys_materials);
(*this)(&data->optical_materials);
(*this)(&data->neutron_elastic_data);
(*this)(&data->atomic_relaxation_data);
}

if (options_.physics)
Expand All @@ -52,6 +54,11 @@ void ImportDataTrimmer::operator()(ImportData* data)
(*this)(&data->volumes);
}

if (options_.mupp)
{
(*this)(&data->mu_pair_production_data);
}

for (auto& e : data->elements)
{
(*this)(&e);
Expand Down Expand Up @@ -79,9 +86,15 @@ void ImportDataTrimmer::operator()(ImportData* data)

(*this)(&data->sb_data);
(*this)(&data->livermore_pe_data);
(*this)(&data->neutron_elastic_data);
(*this)(&data->atomic_relaxation_data);
(*this)(&data->mu_pair_production_data);

if (this->options_.physics)
{
for (auto&& kv : data->neutron_elastic_data)
{
(*this)(&kv.second);
}
// TODO: trim relaxation shells
}

for (auto& m : data->optical_models)
{
Expand Down Expand Up @@ -305,8 +318,14 @@ void ImportDataTrimmer::operator()(std::vector<T>* vec)
{
CELER_EXPECT(vec);

if (options_.max_size == numeric_limits<size_type>::max())
{
// Don't trim
return;
}

std::vector<T> result;
result.reserve(options_.max_size);
result.reserve(std::min(options_.max_size + 1, vec->size()));

auto filter = this->make_filterer(vec->size());
for (auto i : range(vec->size()))
Expand Down
4 changes: 3 additions & 1 deletion src/celeritas/io/ImportDataTrimmer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ class ImportDataTrimmer
bool materials{false};
//! Reduce the number of physics models and processes
bool physics{false};
//! Reduce the MuPPET table fidelity
bool mupp{false};
//! Maximum number of elements in a vector (approximate)
size_type max_size{numeric_limits<size_type>::max()};
std::size_t max_size{numeric_limits<std::size_t>::max()};
};

public:
Expand Down

0 comments on commit 0cee03d

Please sign in to comment.