mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Add framework for calling C++ filters from F90
This commit is contained in:
parent
0c8ea4f31f
commit
1cc0271f4c
7 changed files with 157 additions and 3 deletions
|
|
@ -4,6 +4,8 @@
|
|||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/xml_interface.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -17,8 +19,11 @@ class TallyFilterMatch;
|
|||
extern std::vector<TallyFilterMatch> filter_matches;
|
||||
#pragma omp threadprivate(filter_matches)
|
||||
|
||||
class TallyFilter;
|
||||
extern std::vector<TallyFilter*> tally_filters;
|
||||
|
||||
//==============================================================================
|
||||
//! Stores bins and weights for filtered tally events
|
||||
//! Stores bins and weights for filtered tally events.
|
||||
//==============================================================================
|
||||
|
||||
class TallyFilterMatch
|
||||
|
|
@ -30,5 +35,16 @@ public:
|
|||
bool bins_present;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! Modifies tally score events.
|
||||
//==============================================================================
|
||||
|
||||
class TallyFilter
|
||||
{
|
||||
public:
|
||||
virtual void from_xml(pugi::xml_node node) = 0;
|
||||
virtual void initialize() = 0;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_TALLY_FILTER
|
||||
#endif // OPENMC_TALLY_FILTER_H
|
||||
|
|
|
|||
46
include/openmc/tallies/tally_filter_cell.h
Normal file
46
include/openmc/tallies/tally_filter_cell.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef OPENMC_TALLY_FILTER_CELL_H
|
||||
#define OPENMC_TALLY_FILTER_CELL_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/cell.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/tallies/tally_filter.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
class CellFilter : public TallyFilter
|
||||
{
|
||||
public:
|
||||
virtual void
|
||||
from_xml(pugi::xml_node node)
|
||||
{
|
||||
cells_ = get_node_array<int32_t>(node, "bins");
|
||||
}
|
||||
|
||||
virtual void
|
||||
initialize()
|
||||
{
|
||||
for (auto& c : cells_) {
|
||||
auto search = cell_map.find(c);
|
||||
if (search != cell_map.end()) {
|
||||
c = search->second;
|
||||
} else {
|
||||
std::stringstream err_msg;
|
||||
err_msg << "Could not find cell " << c << " specified on tally filter.";
|
||||
fatal_error(err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: mapping
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<int32_t> cells_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_TALLY_FILTER_CELL_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue