Skip to content

Commit

Permalink
Convert remainder of tallies to C++
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Feb 22, 2019
1 parent 487b62f commit 0439eb0
Show file tree
Hide file tree
Showing 54 changed files with 410 additions and 1,420 deletions.
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ target_compile_options(faddeeva PRIVATE ${cxxflags})

add_library(libopenmc SHARED
src/bank_header.F90
src/api.F90
src/constants.F90
src/dict_header.F90
src/error.F90
Expand All @@ -321,13 +320,6 @@ add_library(libopenmc SHARED
src/string.F90
src/vector_header.F90
src/xml_interface.F90
src/tallies/tally.F90
src/tallies/tally_derivative_header.F90
src/tallies/tally_filter_header.F90
src/tallies/tally_filter_distribcell.F90
src/tallies/tally_filter_particle.F90
src/tallies/tally_filter_sph_harm.F90
src/tallies/tally_header.F90
src/bank.cpp
src/bremsstrahlung.cpp
src/dagmc.cpp
Expand Down
6 changes: 6 additions & 0 deletions include/openmc/bank.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ extern std::vector<Bank> master_fission_bank;

} // namespace simulation

//==============================================================================
// Non-member functions
//==============================================================================

void free_memory_bank();

} // namespace openmc

#endif // OPENMC_BANK_H
4 changes: 2 additions & 2 deletions include/openmc/capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern "C" {
int openmc_filter_get_type(int32_t index, const char** type);
int openmc_filter_set_id(int32_t index, int32_t id);
int openmc_finalize();
int openmc_find_cell(double* xyz, int32_t* index, int32_t* instance);
int openmc_find_cell(const double* xyz, int32_t* index, int32_t* instance);
int openmc_get_cell_index(int32_t id, int32_t* index);
int openmc_get_filter_index(int32_t id, int32_t* index);
void openmc_get_filter_next_id(int32_t* id);
Expand Down Expand Up @@ -102,7 +102,7 @@ extern "C" {
int openmc_statepoint_write(const char* filename, bool* write_source);
int openmc_tally_allocate(int32_t index, const char* type);
int openmc_tally_get_active(int32_t index, bool* active);
int openmc_tally_get_estimator(int32_t index, int32_t* estimator);
int openmc_tally_get_estimator(int32_t index, int* estimator);
int openmc_tally_get_id(int32_t index, int32_t* id);
int openmc_tally_get_filters(int32_t index, const int32_t** indices, int* n);
int openmc_tally_get_n_realizations(int32_t index, int32_t* n);
Expand Down
10 changes: 10 additions & 0 deletions include/openmc/cmfd_solver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef OPENMC_CMFD_SOLVER_H
#define OPENMC_CMFD_SOLVER_H

namespace openmc {

void free_memory_cmfd();

}

#endif // OPENMC_CMFD_SOLVER_H
2 changes: 2 additions & 0 deletions include/openmc/cross_sections.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ void read_ce_cross_sections(const std::vector<std::vector<double>>& nuc_temps,
//! Read cross_sections.xml and populate data libraries
void read_ce_cross_sections_xml();

void library_clear();

} // namespace openmc

#endif // OPENMC_CROSS_SECTIONS_H
2 changes: 1 addition & 1 deletion include/openmc/dagmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace model {
//==============================================================================

void load_dagmc_geometry();
extern "C" void free_memory_dagmc();
void free_memory_dagmc();
void read_geometry_dagmc();
bool read_uwuw_materials(pugi::xml_document& doc);
bool get_uwuw_materials_xml(std::string& s);
Expand Down
2 changes: 1 addition & 1 deletion include/openmc/geometry_aux.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ extern "C" int maximum_levels(int32_t univ);
//! Deallocates global vectors and maps for cells, universes, and lattices.
//==============================================================================

extern "C" void free_memory_geometry();
void free_memory_geometry();

} // namespace openmc
#endif // OPENMC_GEOMETRY_AUX_H
2 changes: 2 additions & 0 deletions include/openmc/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class Material
//! Read material data from materials.xml
void read_materials_xml();

void free_memory_material();

//==============================================================================
// Fortran compatibility
//==============================================================================
Expand Down
2 changes: 2 additions & 0 deletions include/openmc/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ void read_meshes(pugi::xml_node root);
//! \param[in] group HDF5 group
void meshes_to_hdf5(hid_t group);

void free_memory_mesh();

} // namespace openmc

#endif // OPENMC_MESH_H
6 changes: 6 additions & 0 deletions include/openmc/nuclide.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ extern MaterialMacroXS material_xs;

} // namespace simulation

//==============================================================================
// Non-member functions
//==============================================================================

void nuclides_clear();

//==============================================================================
// Fortran compatibility
//==============================================================================
Expand Down
2 changes: 2 additions & 0 deletions include/openmc/photon.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ struct ElementMicroXS {

std::pair<double, double> klein_nishina(double alpha);

void free_memory_photon();

//==============================================================================
// Global variables
//==============================================================================
Expand Down
6 changes: 5 additions & 1 deletion include/openmc/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ extern double weight_cutoff; //!< Weight cutoff for Russian roulette
extern double weight_survive; //!< Survival weight after Russian roulette
} // namespace settings

//==============================================================================
// Functions
//==============================================================================

//! Read settings from XML file
//! \param[in] root XML node for <settings>
void read_settings_xml();

extern "C" void read_settings_xml_f(pugi::xml_node_struct* root_ptr);
void free_memory_settings();

} // namespace openmc

Expand Down
5 changes: 2 additions & 3 deletions include/openmc/simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ void finalize_generation();
//! Determine overall generation number
extern "C" int overall_generation();

extern "C" void simulation_init_f();
extern "C" void simulation_finalize_f();

#ifdef OPENMC_MPI
void broadcast_results();
#endif

void free_memory_simulation();

} // namespace openmc

#endif // OPENMC_SIMULATION_H
2 changes: 2 additions & 0 deletions include/openmc/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Bank sample_external_source();
//! Fill source bank at end of generation for fixed source simulations
void fill_source_bank_fixedsource();

void free_memory_source();

} // namespace openmc

#endif // OPENMC_SOURCE_H
16 changes: 1 addition & 15 deletions include/openmc/surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,21 +401,7 @@ class SurfaceQuadric : public CSGSurface

void read_surfaces(pugi::xml_node node);

//==============================================================================
// Fortran compatibility functions
//==============================================================================

extern "C" {
Surface* surface_pointer(int surf_ind);
int surface_id(Surface* surf);
int surface_bc(Surface* surf);
bool surface_sense(Surface* surf, double xyz[3], double uvw[3]);
void surface_reflect(Surface* surf, double xyz[3], double uvw[3]);
int surface_i_periodic(PeriodicSurface* surf);
bool surface_periodic(PeriodicSurface* surf, PeriodicSurface* other,
double xyz[3], double uvw[3]);
void free_memory_surfaces_c();
}
void free_memory_surfaces();

} // namespace openmc
#endif // OPENMC_SURFACE_H
4 changes: 1 addition & 3 deletions include/openmc/tallies/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ namespace model {
Filter* allocate_filter(const std::string& type);

// Filter-related Fortran functions that will be called from C++
extern "C" int verify_filter(int32_t index);
extern "C" Filter* filter_from_f(int32_t index);
extern "C" void filter_update_n_bins(int32_t index);
int verify_filter(int32_t index);

} // namespace openmc
#endif // OPENMC_TALLIES_FILTER_H
4 changes: 3 additions & 1 deletion include/openmc/tallies/tally.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Tally {

void init_results();

void reset();

void accumulate();

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -172,7 +174,7 @@ using adaptor_type = xt::xtensor_adaptor<xt::xbuffer_adaptor<double*&, xt::no_ow
void reduce_tally_results();
#endif

extern "C" void free_memory_tally_c();
void free_memory_tally();

} // namespace openmc

Expand Down
2 changes: 2 additions & 0 deletions include/openmc/thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class ThermalScattering {
std::vector<ThermalData> data_;
};

void free_memory_thermal();

} // namespace openmc

#endif // OPENMC_THERMAL_H
14 changes: 10 additions & 4 deletions include/openmc/volume_calc.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef VOLUME_CALC_H
#define VOLUME_CALC_H
#ifndef OPENMC_VOLUME_CALC_H
#define OPENMC_VOLUME_CALC_H

#include "openmc/position.h"

Expand Down Expand Up @@ -66,9 +66,15 @@ class VolumeCalculation {
//==============================================================================

namespace model {
extern std::vector<VolumeCalculation> volume_calcs;
extern std::vector<VolumeCalculation> volume_calcs;
}

//==============================================================================
// Non-member functions
//==============================================================================

void free_memory_volume();

} // namespace openmc

#endif // VOLUME_CALC_H
#endif // OPENMC_VOLUME_CALC_H
7 changes: 4 additions & 3 deletions openmc/capi/tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
_dll.openmc_tally_get_active.argtypes = [c_int32, POINTER(c_bool)]
_dll.openmc_tally_get_active.restype = c_int
_dll.openmc_tally_get_active.errcheck = _error_handler
_dll.openmc_tally_get_estimator.argtypes = [c_int32, POINTER(c_int32)]
_dll.openmc_tally_get_estimator.argtypes = [c_int32, POINTER(int32)]
_dll.openmc_tally_get_estimator.restype = c_int
_dll.openmc_tally_get_estimator.errcheck = _error_handler
_dll.openmc_tally_get_id.argtypes = [c_int32, POINTER(c_int32)]
Expand Down Expand Up @@ -84,6 +84,7 @@
_dll.openmc_tally_set_type.argtypes = [c_int32, c_char_p]
_dll.openmc_tally_set_type.restype = c_int
_dll.openmc_tally_set_type.errcheck = _error_handler
_dll.tallies_size.restype = c_size_t


_SCORES = {
Expand Down Expand Up @@ -227,7 +228,7 @@ def type(self, type):

@property
def estimator(self):
estimator = c_int32()
estimator = c_int()
_dll.openmc_tally_get_estimator(self._index, estimator)
return _ESTIMATORS[estimator.value]

Expand Down Expand Up @@ -387,7 +388,7 @@ def __iter__(self):
yield Tally(index=i + 1).id

def __len__(self):
return c_int32.in_dll(_dll, 'n_tallies').value
return _dll.tallies_size()

def __repr__(self):
return repr(dict(self))
Expand Down
Loading

0 comments on commit 0439eb0

Please sign in to comment.