mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Updating unstructured mesh constructors to take a filename (template). Exposing unstructured mesh addition via CAPI.
This commit is contained in:
parent
df997644b6
commit
9695cc2771
3 changed files with 56 additions and 3 deletions
|
|
@ -47,6 +47,7 @@ extern "C" {
|
|||
int openmc_get_mesh_index(int32_t id, int32_t* index);
|
||||
int openmc_get_n_batches(int* n_batches, bool get_max_batches);
|
||||
int openmc_get_nuclide_index(const char name[], int* index);
|
||||
int openmc_add_unstructured_mesh(const char filename[], const char library[], int* id);
|
||||
int64_t openmc_get_seed();
|
||||
int openmc_get_tally_index(int32_t id, int32_t* index);
|
||||
void openmc_get_tally_next_id(int32_t* id);
|
||||
|
|
|
|||
|
|
@ -266,17 +266,23 @@ public:
|
|||
|
||||
class UnstructuredMeshBase : public Mesh {
|
||||
public:
|
||||
// constructors
|
||||
UnstructuredMeshBase() {};
|
||||
UnstructuredMeshBase(pugi::xml_node node);
|
||||
UnstructuredMeshBase(const std::string& filename);
|
||||
|
||||
std::string filename_;
|
||||
};
|
||||
|
||||
#ifdef DAGMC
|
||||
|
||||
class UnstructuredMesh : public Mesh {
|
||||
class UnstructuredMesh : public UnstructuredMeshBase {
|
||||
|
||||
public:
|
||||
|
||||
UnstructuredMesh() = default;
|
||||
UnstructuredMesh(pugi::xml_node);
|
||||
UnstructuredMesh(const std::string& filename);
|
||||
~UnstructuredMesh() = default;
|
||||
|
||||
void bins_crossed(const Particle& p,
|
||||
|
|
@ -447,8 +453,9 @@ class LibMesh : public UnstructuredMeshBase {
|
|||
typedef std::vector<std::pair<double, const libMesh::Elem*>> UnstructuredMeshHits;
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
// Constructors
|
||||
LibMesh(pugi::xml_node node);
|
||||
LibMesh(const std::string& filename);
|
||||
|
||||
// Methods
|
||||
|
||||
|
|
@ -489,6 +496,10 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
//! Setup method for the mesh. Builds data structures,
|
||||
//! element mapping, etc.
|
||||
void initialize();
|
||||
|
||||
//! Translate a bin value to an element pointer
|
||||
const libMesh::Elem* get_element_from_bin(int bin) const;
|
||||
|
||||
|
|
|
|||
43
src/mesh.cpp
43
src/mesh.cpp
|
|
@ -1295,6 +1295,27 @@ openmc_extend_meshes(int32_t n, const char* type, int32_t* index_start,
|
|||
return 0;
|
||||
}
|
||||
|
||||
//! Adds a new unstructured mesh to OpenMC
|
||||
extern "C" int openmc_add_unstrucutred_mesh(const char filename[],
|
||||
const char library[],
|
||||
int* mesh_id)
|
||||
{
|
||||
if (library == "moab") {
|
||||
model::meshes.push_back(std::move(std::make_unique<UnstructuredMesh>(filename)));
|
||||
} else if (library == "libmesh") {
|
||||
model::meshes.push_back(std::move(std::make_unique<LibMesh>(filename)));
|
||||
} else {
|
||||
set_errmsg("Mesh library " + std::string(library) + \
|
||||
"is not supported by this build of OpenMC");
|
||||
return OPENMC_E_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
*mesh_id = model::meshes.back()->id_;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! Return the index in the meshes array of a mesh with a given ID
|
||||
extern "C" int
|
||||
openmc_get_mesh_index(int32_t id, int32_t* index)
|
||||
|
|
@ -1452,6 +1473,7 @@ openmc_rectilinear_mesh_set_grid(int32_t index, const double* grid_x,
|
|||
|
||||
#ifdef DAGMC
|
||||
|
||||
<<<<<<< HEAD
|
||||
UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node)
|
||||
{
|
||||
// unstructured always assumed to be 3D
|
||||
|
|
@ -1472,7 +1494,18 @@ UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node)
|
|||
fatal_error("No filename supplied for unstructured mesh with ID: " +
|
||||
std::to_string(id_));
|
||||
}
|
||||
=======
|
||||
UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : UnstructuredMeshBase(node) {
|
||||
initialize();
|
||||
}
|
||||
|
||||
UnstructuredMesh::UnstructuredMesh(const std::string& filename) {
|
||||
filename_ = filename;
|
||||
initialize();
|
||||
}
|
||||
>>>>>>> Updating unstructured mesh constructors to take a filename (template). Exposing unstructured mesh addition via CAPI.
|
||||
|
||||
void UnstructuredMesh::initialize() {
|
||||
// create MOAB instance
|
||||
mbi_ = std::make_unique<moab::Core>();
|
||||
// load unstructured mesh file
|
||||
|
|
@ -2057,8 +2090,16 @@ UnstructuredMeshBase::UnstructuredMeshBase(pugi::xml_node node) : Mesh(node) {
|
|||
|
||||
#ifdef LIBMESH
|
||||
LibMesh::LibMesh(pugi::xml_node node) : UnstructuredMeshBase(node) {
|
||||
initialize();
|
||||
}
|
||||
|
||||
// always 3 for unstructured meshes
|
||||
LibMesh::LibMesh(const std::string& filename) {
|
||||
filename_ = filename;
|
||||
initialize();
|
||||
}
|
||||
|
||||
void LibMesh::initialize() {
|
||||
// always 3 for unstructured meshes
|
||||
n_dimension_ = 3;
|
||||
|
||||
m_ = std::unique_ptr<libMesh::Mesh>(new libMesh::Mesh(settings::LMI->comm(), 3));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue