mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Some cleanup from self-review
This commit is contained in:
parent
a5a98fdfcd
commit
f7220b62db
7 changed files with 26 additions and 38 deletions
|
|
@ -15,12 +15,6 @@ if(@LIBMESH_FOUND@)
|
|||
pkg_check_modules(LIBMESH REQUIRED libmesh IMPORTED_TARGET)
|
||||
endif()
|
||||
|
||||
if(@LIBMESH_FOUND@)
|
||||
include(FindPkgConfig)
|
||||
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:@LIBMESH_PC@")
|
||||
pkg_check_modules(LIBMESH REQUIRED libmesh IMPORTED_TARGET)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET OpenMC::libopenmc)
|
||||
include("${OpenMC_CMAKE_DIR}/OpenMCTargets.cmake")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -24,15 +24,14 @@
|
|||
|
||||
#ifdef LIBMESH
|
||||
#include "libmesh/bounding_box.h"
|
||||
#include "libmesh/libmesh.h"
|
||||
#include "libmesh/dof_map.h"
|
||||
#include "libmesh/elem.h"
|
||||
#include "libmesh/equation_systems.h"
|
||||
#include "libmesh/exodusII_io.h"
|
||||
#include "libmesh/explicit_system.h"
|
||||
#include "libmesh/dof_map.h"
|
||||
#include "libmesh/libmesh.h"
|
||||
#include "libmesh/mesh.h"
|
||||
#include "libmesh/point.h"
|
||||
#include "libmesh/sphere.h"
|
||||
#endif
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -109,7 +108,6 @@ public:
|
|||
virtual std::pair<std::vector<double>, std::vector<double>>
|
||||
plot(Position plot_ll, Position plot_ur) const = 0;
|
||||
|
||||
//! Get a label for the mesh bin
|
||||
//! Return a string representation of the mesh bin
|
||||
//
|
||||
//! \param[in] bin Mesh bin to generate a label for
|
||||
|
|
@ -285,6 +283,13 @@ public:
|
|||
UnstructuredMesh(const std::string& filename);
|
||||
|
||||
// Methods
|
||||
private:
|
||||
|
||||
//! Setup method for the mesh. Builds data structures,
|
||||
//! element mapping, etc.
|
||||
virtual void initialize() = 0;
|
||||
|
||||
public:
|
||||
|
||||
//! Add a variable to the mesh instance
|
||||
virtual void add_score(const std::string& var_name) = 0;
|
||||
|
|
@ -383,7 +388,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
void initialize();
|
||||
void initialize() override;
|
||||
|
||||
//! Find all intersections with faces of the mesh.
|
||||
//
|
||||
|
|
@ -528,9 +533,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
//! Setup method for the mesh. Builds data structures,
|
||||
//! element mapping, etc.
|
||||
void initialize();
|
||||
void initialize() override;
|
||||
|
||||
//! Translate a bin value to an element pointer
|
||||
const libMesh::Elem* get_element_from_bin(int bin) const;
|
||||
|
|
|
|||
|
|
@ -616,8 +616,8 @@ class UnstructuredMesh(MeshBase):
|
|||
Name of the mesh
|
||||
filename : str
|
||||
Name of the file containing the unstructured mesh
|
||||
mesh_lib : str
|
||||
Library used for the unstructured mesh tally
|
||||
library : str
|
||||
Mesh library used for the unstructured mesh tally
|
||||
volumes : Iterable of float
|
||||
Volumes of the unstructured mesh elements
|
||||
total_volume : float
|
||||
|
|
@ -627,12 +627,12 @@ class UnstructuredMesh(MeshBase):
|
|||
(1.0, 1.0, 1.0), ...]
|
||||
"""
|
||||
|
||||
def __init__(self, filename, mesh_id=None, name=''):
|
||||
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 = 'moab'
|
||||
self.library = library
|
||||
|
||||
@property
|
||||
def filename(self):
|
||||
|
|
@ -645,12 +645,12 @@ class UnstructuredMesh(MeshBase):
|
|||
|
||||
@property
|
||||
def library(self):
|
||||
return self._mesh_lib
|
||||
return self._library
|
||||
|
||||
@library.setter
|
||||
def library(self, mesh_lib):
|
||||
cv.check_value('mesh_lib', mesh_lib, ('moab', 'libmesh'))
|
||||
self._library = mesh_lib
|
||||
def library(self, lib):
|
||||
cv.check_value('mesh_lib', lib, ('moab', 'libmesh'))
|
||||
self._library = lib
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
|
|
@ -786,13 +786,13 @@ class UnstructuredMesh(MeshBase):
|
|||
def from_hdf5(cls, group):
|
||||
mesh_id = int(group.name.split('/')[-1].lstrip('mesh '))
|
||||
filename = group['filename'][()].decode()
|
||||
library = group['library'][()].decode()
|
||||
|
||||
mesh = cls(filename, mesh_id=mesh_id)
|
||||
mesh = cls(filename, library, mesh_id=mesh_id)
|
||||
vol_data = group['volumes'][()]
|
||||
centroids = group['centroids'][()]
|
||||
mesh.volumes = np.reshape(vol_data, (vol_data.shape[0],))
|
||||
mesh.centroids = np.reshape(centroids, (vol_data.shape[0], 3))
|
||||
mesh.mesh_lib = group['library'][()].decode()
|
||||
mesh.size = mesh.volumes.size
|
||||
|
||||
return mesh
|
||||
|
|
@ -810,8 +810,8 @@ class UnstructuredMesh(MeshBase):
|
|||
element = ET.Element("mesh")
|
||||
element.set("id", str(self._id))
|
||||
element.set("type", "unstructured")
|
||||
subelement = ET.SubElement(element, "filename")
|
||||
element.set("library", self._library)
|
||||
subelement = ET.SubElement(element, "filename")
|
||||
subelement.text = self.filename
|
||||
|
||||
return element
|
||||
|
|
@ -834,6 +834,5 @@ class UnstructuredMesh(MeshBase):
|
|||
filename = get_text(elem, 'filename')
|
||||
library = get_text(elem, 'library')
|
||||
|
||||
mesh = cls(filename, mesh_id)
|
||||
mesh.library = library
|
||||
mesh = cls(filename, library, mesh_id)
|
||||
return mesh
|
||||
|
|
|
|||
|
|
@ -192,5 +192,4 @@ int openmc_hard_reset()
|
|||
// Reset the random number generator state
|
||||
openmc::openmc_set_seed(DEFAULT_SEED);
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ int openmc_init(int argc, char* argv[], const void* intracomm)
|
|||
initialize_mpi(comm);
|
||||
#endif
|
||||
|
||||
|
||||
// Parse command-line arguments
|
||||
int err = parse_command_line(argc, argv);
|
||||
if (err) return err;
|
||||
|
|
@ -89,7 +88,6 @@ int openmc_init(int argc, char* argv[], const void* intracomm)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Initialize random number generator -- if the user specifies a seed, it
|
||||
// will be re-initialized later
|
||||
openmc::openmc_set_seed(DEFAULT_SEED);
|
||||
|
|
|
|||
|
|
@ -45,10 +45,6 @@ const
|
|||
}
|
||||
|
||||
double total = std::accumulate(match.weights_.begin(), match.weights_.end(), 0.0);
|
||||
// if ( fabs(1.0 - total) > FP_PRECISION) {
|
||||
// std::cout << "Total weight for score < 1.0 (" << total << ")" << std::endl;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ def test_unstructured_mesh(test_opts):
|
|||
|
||||
### Tallies ###
|
||||
|
||||
# create meshes
|
||||
# create meshes and mesh filters
|
||||
regular_mesh = openmc.RegularMesh()
|
||||
regular_mesh.dimension = (10, 10, 10)
|
||||
regular_mesh.lower_left = (-10.0, -10.0, -10.0)
|
||||
|
|
@ -197,8 +197,7 @@ def test_unstructured_mesh(test_opts):
|
|||
else:
|
||||
mesh_filename = "test_mesh_tets.exo"
|
||||
|
||||
uscd_mesh = openmc.UnstructuredMesh(mesh_filename)
|
||||
uscd_mesh.library = test_opts['library']
|
||||
uscd_mesh = openmc.UnstructuredMesh(mesh_filename, test_opts['library'])
|
||||
uscd_filter = openmc.MeshFilter(mesh=uscd_mesh)
|
||||
|
||||
# create tallies
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue