Skip to content

Commit 3af0fb0

Browse files
committed
api change
1 parent b53b9e3 commit 3af0fb0

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

include/openmc/mesh.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,6 @@ class LibMesh : public UnstructuredMesh {
946946
LibMesh(pugi::xml_node node);
947947
LibMesh(const std::string& filename, double length_multiplier = 1.0);
948948
LibMesh(libMesh::MeshBase& input_mesh, double length_multiplier = 1.0);
949-
LibMesh(libMesh::MeshBase& input_mesh,const std::string& cluster_element_integer_name, double length_multiplier = 1.0);
950949

951950
static const std::string mesh_lib_type;
952951

@@ -992,6 +991,10 @@ class LibMesh : public UnstructuredMesh {
992991

993992
libMesh::MeshBase* mesh_ptr() const { return m_; };
994993

994+
995+
//!setter for mesh tally amalgamtion
996+
void set_mesh_tally_amalgamation(std::string cluster_element_integer_name);
997+
995998
private:
996999
void initialize() override;
9971000
void set_mesh_pointer_from_filename(const std::string& filename);

src/mesh.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3238,25 +3238,39 @@ LibMesh::LibMesh(libMesh::MeshBase& input_mesh, double length_multiplier)
32383238
initialize();
32393239
}
32403240

3241-
LibMesh::LibMesh(libMesh::MeshBase& input_mesh,
3242-
const std::string& cluster_element_integer_name, double length_multiplier)
3243-
: adaptive_(input_mesh.n_active_elem() != input_mesh.n_elem())
3244-
{
3245-
if (!dynamic_cast<libMesh::ReplicatedMesh*>(&input_mesh)) {
3246-
fatal_error("At present LibMesh tallies require a replicated mesh. Please "
3247-
"ensure 'input_mesh' is a libMesh::ReplicatedMesh.");
3248-
}
32493241

3250-
m_ = &input_mesh;
3251-
set_length_multiplier(length_multiplier);
3242+
void LibMesh::set_mesh_tally_amalgamation(std::string cluster_element_integer_name){
32523243

3253-
cluster_element_integer_index_ =
3254-
input_mesh.has_elem_integer(cluster_element_integer_name)
3244+
cluster_element_integer_index_ = input_mesh.has_elem_integer(cluster_element_integer_name)
32553245
? input_mesh.get_elem_integer_index(cluster_element_integer_name)
32563246
: -1;
32573247
amalgamation_ = (cluster_element_integer_index_ != -1);
32583248

3259-
initialize();
3249+
//should we add a warning if amalgamation is false?
3250+
3251+
if (adaptive_ && amalgamation_) {
3252+
3253+
//reseve the hash map for cluster elements
3254+
clustering_element_mapping_.reserve(m_->n_active_elem());
3255+
3256+
//adding clustering map
3257+
for (auto it = m_->active_elements_begin(); it != m_->active_elements_end(); it++) {
3258+
3259+
auto cluster_elem = *it;
3260+
unsigned int cluster_id = elem->get_extra_integer(cluster_element_integer_index_);
3261+
3262+
if (cluster_id != -1) {
3263+
auto first_element_in_a_cluster = m_->elem_ptr(cluster_id);
3264+
3265+
if (first_element_in_a_cluster and first_element_in_a_cluster->active())
3266+
cluster_elem = first_element_in_a_cluster;
3267+
}
3268+
clustering_element_mapping_.insert(std::make_pair(elem, cluster_elem));
3269+
3270+
}
3271+
}
3272+
3273+
32603274
}
32613275

32623276
// create the mesh from an input file
@@ -3288,6 +3302,7 @@ void LibMesh::build_eqn_sys()
32883302

32893303
// intialize from mesh file
32903304
void LibMesh::initialize()
3305+
void LibMesh::initialize()
32913306
{
32923307
if (!settings::libmesh_comm) {
32933308
fatal_error("Attempting to use an unstructured mesh without a libMesh "
@@ -3329,26 +3344,10 @@ void LibMesh::initialize()
33293344
if (adaptive_) {
33303345
bin_to_elem_map_.reserve(m_->n_active_elem());
33313346
elem_to_bin_map_.resize(m_->n_elem(), -1);
3332-
3333-
//reseve the hash map for cluster elements
3334-
clustering_element_mapping_.reserve(m_->n_active_elem());
3335-
3336-
//adding clustering map
33373347
for (auto it = m_->active_elements_begin(); it != m_->active_elements_end();
33383348
it++) {
33393349
auto elem = *it;
33403350

3341-
if (amalgamation_) {
3342-
auto cluster_elem = elem;
3343-
unsigned int cluster_id = elem->get_extra_integer(cluster_element_integer_index_);
3344-
if (cluster_id != -1) {
3345-
auto first_element_in_a_cluster = m_->elem_ptr(cluster_id);
3346-
if (first_element_in_a_cluster and first_element_in_a_cluster->active())
3347-
cluster_elem = first_element_in_a_cluster;
3348-
}
3349-
clustering_element_mapping_.insert(std::make_pair(elem, cluster_elem));
3350-
}
3351-
33523351
bin_to_elem_map_.push_back(elem->id());
33533352
elem_to_bin_map_[elem->id()] = bin_to_elem_map_.size() - 1;
33543353
}
@@ -3362,6 +3361,7 @@ void LibMesh::initialize()
33623361
upper_right_ = {ur(0), ur(1), ur(2)};
33633362
}
33643363

3364+
33653365
// Sample position within a tet for LibMesh type tets
33663366
Position LibMesh::sample_element(int32_t bin, uint64_t* seed) const
33673367
{

0 commit comments

Comments
 (0)