A slightly safer method for writing out meshes independent of library.

This commit is contained in:
Patrick Shriwise 2020-04-28 12:11:38 -05:00
parent 210d99aed3
commit 03f3d7ac73
4 changed files with 27 additions and 1 deletions

View file

@ -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
};

View file

@ -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

View file

@ -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<std::string> systems_out = {eq_system_name_};
exo.write_discontinuous_exodusII(filename + ".e", *equation_systems_, &systems_out);

View file

@ -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);