mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Meshborn filter (#2925)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
1a34ddf121
commit
cc848effe7
21 changed files with 720 additions and 11 deletions
|
|
@ -121,6 +121,7 @@ void Particle::from_source(const SourceSite* src)
|
|||
wgt_last() = src->wgt;
|
||||
r() = src->r;
|
||||
u() = src->u;
|
||||
r_born() = src->r;
|
||||
r_last_current() = src->r;
|
||||
r_last() = src->r;
|
||||
u_last() = src->u;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "openmc/tallies/filter_material.h"
|
||||
#include "openmc/tallies/filter_materialfrom.h"
|
||||
#include "openmc/tallies/filter_mesh.h"
|
||||
#include "openmc/tallies/filter_meshborn.h"
|
||||
#include "openmc/tallies/filter_meshsurface.h"
|
||||
#include "openmc/tallies/filter_mu.h"
|
||||
#include "openmc/tallies/filter_particle.h"
|
||||
|
|
@ -126,6 +127,8 @@ Filter* Filter::create(const std::string& type, int32_t id)
|
|||
return Filter::create<MaterialFromFilter>(id);
|
||||
} else if (type == "mesh") {
|
||||
return Filter::create<MeshFilter>(id);
|
||||
} else if (type == "meshborn") {
|
||||
return Filter::create<MeshBornFilter>(id);
|
||||
} else if (type == "meshsurface") {
|
||||
return Filter::create<MeshSurfaceFilter>(id);
|
||||
} else if (type == "mu") {
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ extern "C" int openmc_mesh_filter_get_translation(
|
|||
// Check the filter type
|
||||
const auto& filter = model::tally_filters[index];
|
||||
if (filter->type() != FilterType::MESH &&
|
||||
filter->type() != FilterType::MESHBORN &&
|
||||
filter->type() != FilterType::MESH_SURFACE) {
|
||||
set_errmsg("Tried to get a translation from a non-mesh-based filter.");
|
||||
return OPENMC_E_INVALID_TYPE;
|
||||
|
|
@ -186,6 +187,7 @@ extern "C" int openmc_mesh_filter_set_translation(
|
|||
const auto& filter = model::tally_filters[index];
|
||||
// Check the filter type
|
||||
if (filter->type() != FilterType::MESH &&
|
||||
filter->type() != FilterType::MESHBORN &&
|
||||
filter->type() != FilterType::MESH_SURFACE) {
|
||||
set_errmsg("Tried to set mesh on a non-mesh-based filter.");
|
||||
return OPENMC_E_INVALID_TYPE;
|
||||
|
|
|
|||
61
src/tallies/filter_meshborn.cpp
Normal file
61
src/tallies/filter_meshborn.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#include "openmc/tallies/filter_meshborn.h"
|
||||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/mesh.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
void MeshBornFilter::get_all_bins(
|
||||
const Particle& p, TallyEstimator estimator, FilterMatch& match) const
|
||||
{
|
||||
Position r_born = p.r_born();
|
||||
|
||||
// apply translation if present
|
||||
if (translated_) {
|
||||
r_born -= translation();
|
||||
}
|
||||
|
||||
auto bin = model::meshes[mesh_]->get_bin(r_born);
|
||||
if (bin >= 0) {
|
||||
match.bins_.push_back(bin);
|
||||
match.weights_.push_back(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
std::string MeshBornFilter::text_label(int bin) const
|
||||
{
|
||||
auto& mesh = *model::meshes.at(mesh_);
|
||||
return mesh.bin_label(bin) + " (born)";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// C-API functions
|
||||
//==============================================================================
|
||||
|
||||
extern "C" int openmc_meshborn_filter_get_mesh(
|
||||
int32_t index, int32_t* index_mesh)
|
||||
{
|
||||
return openmc_mesh_filter_get_mesh(index, index_mesh);
|
||||
}
|
||||
|
||||
extern "C" int openmc_meshborn_filter_set_mesh(
|
||||
int32_t index, int32_t index_mesh)
|
||||
{
|
||||
return openmc_mesh_filter_set_mesh(index, index_mesh);
|
||||
}
|
||||
|
||||
extern "C" int openmc_meshborn_filter_get_translation(
|
||||
int32_t index, double translation[3])
|
||||
{
|
||||
return openmc_mesh_filter_get_translation(index, translation);
|
||||
}
|
||||
|
||||
extern "C" int openmc_meshborn_filter_set_translation(
|
||||
int32_t index, double translation[3])
|
||||
{
|
||||
return openmc_mesh_filter_set_translation(index, translation);
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
@ -100,4 +100,16 @@ extern "C" int openmc_meshsurface_filter_set_mesh(
|
|||
return openmc_mesh_filter_set_mesh(index, index_mesh);
|
||||
}
|
||||
|
||||
extern "C" int openmc_meshsurface_filter_get_translation(
|
||||
int32_t index, double translation[3])
|
||||
{
|
||||
return openmc_mesh_filter_get_translation(index, translation);
|
||||
}
|
||||
|
||||
extern "C" int openmc_meshsurface_filter_set_translation(
|
||||
int32_t index, double translation[3])
|
||||
{
|
||||
return openmc_mesh_filter_set_translation(index, translation);
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "openmc/tallies/filter_energy.h"
|
||||
#include "openmc/tallies/filter_legendre.h"
|
||||
#include "openmc/tallies/filter_mesh.h"
|
||||
#include "openmc/tallies/filter_meshborn.h"
|
||||
#include "openmc/tallies/filter_meshsurface.h"
|
||||
#include "openmc/tallies/filter_particle.h"
|
||||
#include "openmc/tallies/filter_sph_harm.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue