Skip to content

Commit f7220b6

Browse files
committed
Some cleanup from self-review
1 parent a5a98fd commit f7220b6

File tree

7 files changed

+26
-38
lines changed

7 files changed

+26
-38
lines changed

cmake/OpenMCConfig.cmake.in

-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ if(@LIBMESH_FOUND@)
1515
pkg_check_modules(LIBMESH REQUIRED libmesh IMPORTED_TARGET)
1616
endif()
1717

18-
if(@LIBMESH_FOUND@)
19-
include(FindPkgConfig)
20-
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:@LIBMESH_PC@")
21-
pkg_check_modules(LIBMESH REQUIRED libmesh IMPORTED_TARGET)
22-
endif()
23-
2418
if(NOT TARGET OpenMC::libopenmc)
2519
include("${OpenMC_CMAKE_DIR}/OpenMCTargets.cmake")
2620
endif()

include/openmc/mesh.h

+11-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@
2424

2525
#ifdef LIBMESH
2626
#include "libmesh/bounding_box.h"
27-
#include "libmesh/libmesh.h"
27+
#include "libmesh/dof_map.h"
2828
#include "libmesh/elem.h"
2929
#include "libmesh/equation_systems.h"
3030
#include "libmesh/exodusII_io.h"
3131
#include "libmesh/explicit_system.h"
32-
#include "libmesh/dof_map.h"
32+
#include "libmesh/libmesh.h"
3333
#include "libmesh/mesh.h"
3434
#include "libmesh/point.h"
35-
#include "libmesh/sphere.h"
3635
#endif
3736

3837
namespace openmc {
@@ -109,7 +108,6 @@ class Mesh
109108
virtual std::pair<std::vector<double>, std::vector<double>>
110109
plot(Position plot_ll, Position plot_ur) const = 0;
111110

112-
//! Get a label for the mesh bin
113111
//! Return a string representation of the mesh bin
114112
//
115113
//! \param[in] bin Mesh bin to generate a label for
@@ -285,6 +283,13 @@ class UnstructuredMesh : public Mesh {
285283
UnstructuredMesh(const std::string& filename);
286284

287285
// Methods
286+
private:
287+
288+
//! Setup method for the mesh. Builds data structures,
289+
//! element mapping, etc.
290+
virtual void initialize() = 0;
291+
292+
public:
288293

289294
//! Add a variable to the mesh instance
290295
virtual void add_score(const std::string& var_name) = 0;
@@ -383,7 +388,7 @@ class MOABUnstructuredMesh : public UnstructuredMesh {
383388

384389
private:
385390

386-
void initialize();
391+
void initialize() override;
387392

388393
//! Find all intersections with faces of the mesh.
389394
//
@@ -528,9 +533,7 @@ class LibMesh : public UnstructuredMesh {
528533

529534
private:
530535

531-
//! Setup method for the mesh. Builds data structures,
532-
//! element mapping, etc.
533-
void initialize();
536+
void initialize() override;
534537

535538
//! Translate a bin value to an element pointer
536539
const libMesh::Elem* get_element_from_bin(int bin) const;

openmc/mesh.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,8 @@ class UnstructuredMesh(MeshBase):
616616
Name of the mesh
617617
filename : str
618618
Name of the file containing the unstructured mesh
619-
mesh_lib : str
620-
Library used for the unstructured mesh tally
619+
library : str
620+
Mesh library used for the unstructured mesh tally
621621
volumes : Iterable of float
622622
Volumes of the unstructured mesh elements
623623
total_volume : float
@@ -627,12 +627,12 @@ class UnstructuredMesh(MeshBase):
627627
(1.0, 1.0, 1.0), ...]
628628
"""
629629

630-
def __init__(self, filename, mesh_id=None, name=''):
630+
def __init__(self, filename, library, mesh_id=None, name=''):
631631
super().__init__(mesh_id, name)
632632
self.filename = filename
633633
self._volumes = None
634634
self._centroids = None
635-
self._library = 'moab'
635+
self.library = library
636636

637637
@property
638638
def filename(self):
@@ -645,12 +645,12 @@ def filename(self, filename):
645645

646646
@property
647647
def library(self):
648-
return self._mesh_lib
648+
return self._library
649649

650650
@library.setter
651-
def library(self, mesh_lib):
652-
cv.check_value('mesh_lib', mesh_lib, ('moab', 'libmesh'))
653-
self._library = mesh_lib
651+
def library(self, lib):
652+
cv.check_value('mesh_lib', lib, ('moab', 'libmesh'))
653+
self._library = lib
654654

655655
@property
656656
def size(self):
@@ -786,13 +786,13 @@ def write_data_to_vtk(self, filename, datasets, volume_normalization=True):
786786
def from_hdf5(cls, group):
787787
mesh_id = int(group.name.split('/')[-1].lstrip('mesh '))
788788
filename = group['filename'][()].decode()
789+
library = group['library'][()].decode()
789790

790-
mesh = cls(filename, mesh_id=mesh_id)
791+
mesh = cls(filename, library, mesh_id=mesh_id)
791792
vol_data = group['volumes'][()]
792793
centroids = group['centroids'][()]
793794
mesh.volumes = np.reshape(vol_data, (vol_data.shape[0],))
794795
mesh.centroids = np.reshape(centroids, (vol_data.shape[0], 3))
795-
mesh.mesh_lib = group['library'][()].decode()
796796
mesh.size = mesh.volumes.size
797797

798798
return mesh
@@ -810,8 +810,8 @@ def to_xml_element(self):
810810
element = ET.Element("mesh")
811811
element.set("id", str(self._id))
812812
element.set("type", "unstructured")
813-
subelement = ET.SubElement(element, "filename")
814813
element.set("library", self._library)
814+
subelement = ET.SubElement(element, "filename")
815815
subelement.text = self.filename
816816

817817
return element
@@ -834,6 +834,5 @@ def from_xml_element(cls, elem):
834834
filename = get_text(elem, 'filename')
835835
library = get_text(elem, 'library')
836836

837-
mesh = cls(filename, mesh_id)
838-
mesh.library = library
837+
mesh = cls(filename, library, mesh_id)
839838
return mesh

src/finalize.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,4 @@ int openmc_hard_reset()
192192
// Reset the random number generator state
193193
openmc::openmc_set_seed(DEFAULT_SEED);
194194
return 0;
195-
196-
}
195+
}

src/initialize.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ int openmc_init(int argc, char* argv[], const void* intracomm)
5555
initialize_mpi(comm);
5656
#endif
5757

58-
5958
// Parse command-line arguments
6059
int err = parse_command_line(argc, argv);
6160
if (err) return err;
@@ -89,7 +88,6 @@ int openmc_init(int argc, char* argv[], const void* intracomm)
8988
}
9089
#endif
9190

92-
9391
// Initialize random number generator -- if the user specifies a seed, it
9492
// will be re-initialized later
9593
openmc::openmc_set_seed(DEFAULT_SEED);

src/tallies/filter_mesh.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ const
4545
}
4646

4747
double total = std::accumulate(match.weights_.begin(), match.weights_.end(), 0.0);
48-
// if ( fabs(1.0 - total) > FP_PRECISION) {
49-
// std::cout << "Total weight for score < 1.0 (" << total << ")" << std::endl;
50-
// }
51-
5248
}
5349

5450
void

tests/regression_tests/unstructured_mesh/test.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_unstructured_mesh(test_opts):
184184

185185
### Tallies ###
186186

187-
# create meshes
187+
# create meshes and mesh filters
188188
regular_mesh = openmc.RegularMesh()
189189
regular_mesh.dimension = (10, 10, 10)
190190
regular_mesh.lower_left = (-10.0, -10.0, -10.0)
@@ -197,8 +197,7 @@ def test_unstructured_mesh(test_opts):
197197
else:
198198
mesh_filename = "test_mesh_tets.exo"
199199

200-
uscd_mesh = openmc.UnstructuredMesh(mesh_filename)
201-
uscd_mesh.library = test_opts['library']
200+
uscd_mesh = openmc.UnstructuredMesh(mesh_filename, test_opts['library'])
202201
uscd_filter = openmc.MeshFilter(mesh=uscd_mesh)
203202

204203
# create tallies

0 commit comments

Comments
 (0)