Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ list(APPEND libopenmc_SOURCES
src/tallies/filter_polar.cpp
src/tallies/filter_reaction.cpp
src/tallies/filter_sph_harm.cpp
src/tallies/filter_sptl_expansion.cpp
src/tallies/filter_sptl_fourier.cpp
src/tallies/filter_sptl_legendre.cpp
src/tallies/filter_surface.cpp
src/tallies/filter_time.cpp
Expand Down
1 change: 1 addition & 0 deletions docs/source/pythonapi/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Constructing Tallies
openmc.EnergyFunctionFilter
openmc.LegendreFilter
openmc.SpatialLegendreFilter
openmc.SpatialFourierFilter
openmc.SphericalHarmonicsFilter
openmc.TimeFilter
openmc.WeightFilter
Expand Down
1 change: 1 addition & 0 deletions docs/source/pythonapi/capi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Classes
ReactionFilter
RectilinearMesh
RegularMesh
SpatialFourierFilter
SpatialLegendreFilter
SphericalHarmonicsFilter
SphericalMesh
Expand Down
6 changes: 6 additions & 0 deletions include/openmc/capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ int openmc_set_n_batches(
int openmc_simulation_finalize();
int openmc_simulation_init();
int openmc_source_bank(void** ptr, int64_t* n);
int openmc_spatial_fourier_filter_get_order(int32_t index, int* order);
int openmc_spatial_fourier_filter_get_params(
int32_t index, int* axis, double* min, double* max);
int openmc_spatial_fourier_filter_set_order(int32_t index, int order);
int openmc_spatial_fourier_filter_set_params(
int32_t index, const int* axis, const double* min, const double* max);
int openmc_spatial_legendre_filter_get_order(int32_t index, int* order);
int openmc_spatial_legendre_filter_get_params(
int32_t index, int* axis, double* min, double* max);
Expand Down
1 change: 1 addition & 0 deletions include/openmc/tallies/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum class FilterType {
POLAR,
REACTION,
SPHERICAL_HARMONICS,
SPATIAL_FOURIER,
SPATIAL_LEGENDRE,
SURFACE,
TIME,
Expand Down
70 changes: 70 additions & 0 deletions include/openmc/tallies/filter_sptl_expansion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#ifndef OPENMC_TALLIES_FILTER_SPTL_EXPANSION_H
#define OPENMC_TALLIES_FILTER_SPTL_EXPANSION_H

#include "openmc/tallies/filter.h"

namespace openmc {

//==============================================================================
//! Abstract filter for functional expansions of the particle's normalized
//! position along a Cartesian axis
//==============================================================================

class SpatialExpansionFilter : public Filter {
public:
enum class Axis { x, y, z };

//----------------------------------------------------------------------------
// Constructors, destructors

~SpatialExpansionFilter() = default;

//----------------------------------------------------------------------------
// Methods

void from_xml(pugi::xml_node node) override;

void to_statepoint(hid_t filter_group) const override;

//----------------------------------------------------------------------------
// Accessors

int order() const { return order_; }

//! Set the expansion order and the corresponding number of bins
virtual void set_order(int order) = 0;

Axis axis() const { return axis_; }
void set_axis(Axis axis);

double min() const { return min_; }
double max() const { return max_; }
void set_minmax(double min, double max);

protected:
//----------------------------------------------------------------------------
// Methods

//! Get the particle's coordinate along the expansion axis
double position(const Particle& p) const;

//! Get the name of the expansion axis ("x", "y", or "z")
const char* axis_label() const;

//----------------------------------------------------------------------------
// Data members

int order_;

//! The Cartesian coordinate axis that the expansion is applied to.
Axis axis_;

//! The minimum coordinate along the reference axis that the expansion covers.
double min_;

//! The maximum coordinate along the reference axis that the expansion covers.
double max_;
};

} // namespace openmc
#endif // OPENMC_TALLIES_FILTER_SPTL_EXPANSION_H
39 changes: 39 additions & 0 deletions include/openmc/tallies/filter_sptl_fourier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef OPENMC_TALLIES_FILTER_SPTL_FOURIER_H
#define OPENMC_TALLIES_FILTER_SPTL_FOURIER_H

#include <string>

#include "openmc/tallies/filter_sptl_expansion.h"

namespace openmc {

//==============================================================================
//! Gives Fourier moments of the particle's normalized position along an axis
//==============================================================================

class SpatialFourierFilter : public SpatialExpansionFilter {
public:
//----------------------------------------------------------------------------
// Constructors, destructors

~SpatialFourierFilter() = default;

//----------------------------------------------------------------------------
// Methods

std::string type_str() const override { return "spatialfourier"; }
FilterType type() const override { return FilterType::SPATIAL_FOURIER; }

void get_all_bins(const Particle& p, TallyEstimator estimator,
FilterMatch& match) const override;

std::string text_label(int bin) const override;

//----------------------------------------------------------------------------
// Accessors

void set_order(int order) override;
};

} // namespace openmc
#endif // OPENMC_TALLIES_FILTER_SPTL_FOURIER_H
35 changes: 3 additions & 32 deletions include/openmc/tallies/filter_sptl_legendre.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@

#include <string>

#include "openmc/tallies/filter.h"
#include "openmc/tallies/filter_sptl_expansion.h"

namespace openmc {

enum class LegendreAxis { x, y, z };

//==============================================================================
//! Gives Legendre moments of the particle's normalized position along an axis
//==============================================================================

class SpatialLegendreFilter : public Filter {
class SpatialLegendreFilter : public SpatialExpansionFilter {
public:
//----------------------------------------------------------------------------
// Constructors, destructors
Expand All @@ -26,42 +24,15 @@ class SpatialLegendreFilter : public Filter {
std::string type_str() const override { return "spatiallegendre"; }
FilterType type() const override { return FilterType::SPATIAL_LEGENDRE; }

void from_xml(pugi::xml_node node) override;

void get_all_bins(const Particle& p, TallyEstimator estimator,
FilterMatch& match) const override;

void to_statepoint(hid_t filter_group) const override;

std::string text_label(int bin) const override;

//----------------------------------------------------------------------------
// Accessors

int order() const { return order_; }
void set_order(int order);

LegendreAxis axis() const { return axis_; }
void set_axis(LegendreAxis axis);

double min() const { return min_; }
double max() const { return max_; }
void set_minmax(double min, double max);

private:
//----------------------------------------------------------------------------
// Data members

int order_;

//! The Cartesian coordinate axis that the Legendre expansion is applied to.
LegendreAxis axis_;

//! The minimum coordinate along the reference axis that the expansion covers.
double min_;

//! The maximum coordinate along the reference axis that the expansion covers.
double max_;
void set_order(int order) override;
};

} // namespace openmc
Expand Down
3 changes: 2 additions & 1 deletion openmc/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
'universe', 'material', 'cell', 'cellborn', 'surface', 'mesh', 'energy',
'energyout', 'mu', 'musurface', 'polar', 'azimuthal', 'distribcell',
'delayedgroup', 'energyfunction', 'cellfrom', 'materialfrom', 'legendre',
'spatiallegendre', 'sphericalharmonics', 'zernike', 'zernikeradial', 'particle',
'spatialfourier', 'spatiallegendre', 'sphericalharmonics',
'zernike', 'zernikeradial', 'particle',
'particleproduction', 'cellinstance', 'collision', 'time', 'parentnuclide',
'weight', 'meshborn', 'meshsurface', 'meshmaterial', 'reaction',
)
Expand Down
Loading
Loading