diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 674c3cb6c3..0be9f65386 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -325,6 +325,7 @@ public: void to_hdf5(hid_t group) const override; // Data members + bool output_ {true}; std::string filename_; //!< Path to unstructured mesh file }; diff --git a/openmc/mesh.py b/openmc/mesh.py index 969a776917..ef6455b96a 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -618,6 +618,9 @@ class UnstructuredMesh(MeshBase): Name of the file containing the unstructured mesh library : str Mesh library used for the unstructured mesh tally + output : bool + Indicates whether or not automatic tally output should + be generated for this mesh volumes : Iterable of float Volumes of the unstructured mesh elements total_volume : float @@ -626,13 +629,13 @@ class UnstructuredMesh(MeshBase): An iterable of element centroid coordinates, e.g. [(0.0, 0.0, 0.0), (1.0, 1.0, 1.0), ...] """ - def __init__(self, filename, library, mesh_id=None, name=''): super().__init__(mesh_id, name) self.filename = filename self._volumes = None self._centroids = None self.library = library + self._output = True @property def filename(self): @@ -661,6 +664,15 @@ class UnstructuredMesh(MeshBase): cv.check_type("Unstructured mesh size", size, Integral) self._size = size + @property + def output(self): + return self._output + + @output.setter + def output(self, val): + cv.check_type("Unstructured mesh output value", val, bool) + self._output = val + @property def volumes(self): return self._volumes diff --git a/src/mesh.cpp b/src/mesh.cpp index 3b6891907f..a2aa823183 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -138,6 +138,13 @@ UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) { fatal_error("No filename supplied for unstructured mesh with ID: " + std::to_string(id_)); } + + // check if mesh tally data should be written with + // statepoint files + if (check_for_node(node, "output")) { + output_ = get_node_value_bool(node, "output"); + } + } std::string @@ -2294,6 +2301,7 @@ LibMesh::set_score_data(const std::string& var_name, void LibMesh::write(std::string filename) const { std::cout << "Writing file : " << filename + ".e" << std::endl; + libMesh::ExodusII_IO exo(*m_); std::set systems_out = {eq_system_name_}; exo.write_discontinuous_exodusII(filename + ".e", *equation_systems_, &systems_out); diff --git a/src/state_point.cpp b/src/state_point.cpp index 29430ed6cb..0e569a0700 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -788,6 +788,8 @@ void write_unstructured_mesh_results() { if (!umesh) continue; + if (!umesh->output_) continue; + // if this tally has more than one filter, print // warning and skip writing the mesh if (tally->filters().size() > 1) { @@ -857,6 +859,9 @@ void write_unstructured_mesh_results() { tally->id_, simulation::current_batch, w); + + if (umesh->library() == "moab" && !mpi::master) continue; + // Write the unstructured mesh and data to file umesh->write(filename);