mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Add C++ CellFromFilter
This commit is contained in:
parent
0084ae613b
commit
b27242e726
4 changed files with 43 additions and 22 deletions
27
include/openmc/tallies/tally_filter_cellfrom.h
Normal file
27
include/openmc/tallies/tally_filter_cellfrom.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef OPENMC_TALLY_FILTER_CELLFROM_H
|
||||
#define OPENMC_TALLY_FILTER_CELLFROM_H
|
||||
|
||||
#include "openmc/tallies/tally_filter_cell.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
class CellFromFilter : public CellFilter
|
||||
{
|
||||
public:
|
||||
virtual void
|
||||
get_all_bins(Particle* p, int estimator, TallyFilterMatch& match) const
|
||||
{
|
||||
for (int i = 0; i < p->last_n_coord; i++) {
|
||||
auto search = map_.find(p->last_cell[i]);
|
||||
if (search != map_.end()) {
|
||||
// TODO: off-by-one
|
||||
match.bins.push_back(search->second + 1);
|
||||
match.weights.push_back(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_TALLY_FILTER_CELLFROM_H
|
||||
|
|
@ -136,18 +136,10 @@ contains
|
|||
allocate(AzimuthalFilter :: filters(index) % obj)
|
||||
case ('cell')
|
||||
allocate(CellFilter :: filters(index) % obj)
|
||||
select type(filt => filters(index) % obj)
|
||||
type is (CellFilter)
|
||||
filt % ptr = allocate_filter(type)
|
||||
if (.not. c_associated(filt % ptr)) then
|
||||
err = E_UNASSIGNED
|
||||
call set_errmsg("Could not allocate C++ tally filter")
|
||||
end if
|
||||
end select
|
||||
case ('cellborn')
|
||||
allocate(CellbornFilter :: filters(index) % obj)
|
||||
case ('cellfrom')
|
||||
allocate(CellfromFilter :: filters(index) % obj)
|
||||
allocate(CellFromFilter :: filters(index) % obj)
|
||||
case ('delayedgroup')
|
||||
allocate(DelayedGroupFilter :: filters(index) % obj)
|
||||
case ('distribcell')
|
||||
|
|
@ -188,6 +180,16 @@ contains
|
|||
err = E_UNASSIGNED
|
||||
call set_errmsg("Unknown filter type: " // trim(type_))
|
||||
end select
|
||||
|
||||
select type(filt => filters(index) % obj)
|
||||
class is (CppTallyFilter)
|
||||
filt % ptr = allocate_filter(type)
|
||||
if (.not. c_associated(filt % ptr)) then
|
||||
err = E_UNASSIGNED
|
||||
call set_errmsg("Could not allocate C++ tally filter")
|
||||
end if
|
||||
end select
|
||||
|
||||
end if
|
||||
else
|
||||
err = E_OUT_OF_BOUNDS
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "openmc/tallies/tally_filter_cell.h"
|
||||
#include "openmc/tallies/tally_filter_cellfrom.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -60,10 +61,12 @@ extern "C" {
|
|||
std::string type_ {type};
|
||||
if (type_ == "cell") {
|
||||
tally_filters.push_back(new CellFilter());
|
||||
return tally_filters.back();
|
||||
} else if (type_ == "cellfrom") {
|
||||
tally_filters.push_back(new CellFromFilter());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
return tally_filters.back();
|
||||
}
|
||||
|
||||
void filter_from_xml(TallyFilter* filt, pugi::xml_node* node)
|
||||
|
|
|
|||
|
|
@ -37,18 +37,7 @@ contains
|
|||
integer, intent(in) :: estimator
|
||||
type(TallyFilterMatch), intent(inout) :: match
|
||||
|
||||
integer :: i
|
||||
integer :: val
|
||||
|
||||
! Starting one coordinate level deeper, find the next bin.
|
||||
do i = 1, p % last_n_coord
|
||||
val = this % map % get(p % last_cell(i) + 1)
|
||||
if (val /= EMPTY) then
|
||||
call match % bins_push_back(val)
|
||||
call match % weights_push_back(ONE)
|
||||
exit
|
||||
end if
|
||||
end do
|
||||
call this % get_all_bins_c(p, estimator, match)
|
||||
|
||||
end subroutine get_all_bins_cell_from
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue