From 18f9f91833f8267796f63d7dde826c177300c0d0 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 30 Aug 2018 09:57:26 -0500 Subject: [PATCH] Read meshes from tallies file --- include/openmc/mesh.h | 8 ++++++++ include/openmc/output.h | 2 ++ include/openmc/settings.h | 5 ++--- src/input_xml.F90 | 31 ++++++++++--------------------- src/mesh.cpp | 15 +++++++++++++++ src/settings.cpp | 14 ++------------ 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 51a0a627f5..28f9c3eac9 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -51,6 +51,14 @@ private: bool intersects_3d(Position r0, Position r1); }; +//============================================================================== +// Non-member functions +//============================================================================== + +//! Read meshes from either settings/tallies +//! \param[in] root XML node +extern "C" void read_meshes(pugi::xml_node* root); + //============================================================================== // Global variables //============================================================================== diff --git a/include/openmc/output.h b/include/openmc/output.h index cabd39edeb..1ba5d65991 100644 --- a/include/openmc/output.h +++ b/include/openmc/output.h @@ -22,5 +22,7 @@ void header(const char* msg, int level); extern "C" void print_overlap_check(); +extern "C" void title(); + } // namespace openmc #endif // OPENMC_OUTPUT_H diff --git a/include/openmc/settings.h b/include/openmc/settings.h index be8661f4dd..e5684c7ae6 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -89,13 +89,12 @@ extern "C" double weight_survive; //!< Survival weight after Russian roul } // namespace settings -//============================================================================== //! Read settings from XML file //! \param[in] root XML node for -//============================================================================== - extern "C" void read_settings_xml(); +extern "C" void read_settings_xml_f(pugi::xml_node_struct* root_ptr); + } // namespace openmc #endif // OPENMC_SETTINGS_H diff --git a/src/input_xml.F90 b/src/input_xml.F90 index 61b3208043..bfd604f9ee 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -65,17 +65,17 @@ module input_xml subroutine read_surfaces(node_ptr) bind(C) import C_PTR - type(C_PTR) :: node_ptr + type(C_PTR), value :: node_ptr end subroutine read_surfaces subroutine read_cells(node_ptr) bind(C) import C_PTR - type(C_PTR) :: node_ptr + type(C_PTR), value :: node_ptr end subroutine read_cells subroutine read_lattices(node_ptr) bind(C) import C_PTR - type(C_PTR) :: node_ptr + type(C_PTR), value :: node_ptr end subroutine read_lattices subroutine read_settings_xml() bind(C) @@ -83,9 +83,14 @@ module input_xml subroutine read_materials(node_ptr) bind(C) import C_PTR - type(C_PTR) :: node_ptr + type(C_PTR), value :: node_ptr end subroutine read_materials + subroutine read_meshes(node_ptr) bind(C) + import C_PTR + type(C_PTR), value :: node_ptr + end subroutine + function find_root_universe() bind(C) result(root) import C_INT32_T integer(C_INT32_T) :: root @@ -1202,9 +1207,6 @@ contains ! ========================================================================== ! DETERMINE SIZE OF ARRAYS AND ALLOCATE - ! Get pointer list to XML - call get_node_list(root, "mesh", node_mesh_list) - ! Get pointer list to XML call get_node_list(root, "filter", node_filt_list) @@ -1220,20 +1222,7 @@ contains ! READ MESH DATA ! Check for user meshes and allocate - n = size(node_mesh_list) - if (n > 0) then - err = openmc_extend_meshes(n, i_start, i_end) - end if - - do i = 1, n - m => meshes(i_start + i - 1) - - ! Instantiate mesh from XML node - call m % from_xml(node_mesh_list(i)) - - ! Add mesh to dictionary - call mesh_dict % set(m % id, i_start + i - 1) - end do + call read_meshes() ! We only need the mesh info for plotting if (run_mode == MODE_PLOTTING) then diff --git a/src/mesh.cpp b/src/mesh.cpp index 47f03ad3de..113968242e 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -737,6 +737,21 @@ openmc_mesh_set_params(int32_t index, int n, const double* ll, const double* ur, return 0; } +//============================================================================== +// Non-member functions +//============================================================================== + +void read_meshes(pugi::xml_node* root) +{ + for (auto node : root->children("mesh")) { + // Read mesh and add to vector + meshes.emplace_back(new RegularMesh{node}); + + // Map ID to position in vector + mesh_map[meshes.back()->id_] = meshes.size() - 1; + } +} + //============================================================================== // Fortran compatibility //============================================================================== diff --git a/src/settings.cpp b/src/settings.cpp index 7b00b9eca7..4883d07a30 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -170,11 +170,7 @@ void get_run_parameters(pugi::xml_node node_base) } } -extern "C" void title(); -extern "C" void read_settings_xml_f(pugi::xml_node_struct* root_ptr); - -extern "C" void -read_settings_xml() +void read_settings_xml() { using namespace settings; using namespace pugi; @@ -488,13 +484,7 @@ read_settings_xml() } // Read meshes - for (auto node : root.children("mesh")) { - // Read mesh and add to vector - meshes.emplace_back(new RegularMesh{node}); - - // Map ID to position in vector - mesh_map[meshes.back()->id_] = meshes.size() - 1; - } + read_meshes(&root); // Shannon Entropy mesh if (check_for_node(root, "entropy_mesh")) {