mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Merge 1f75b45f46 into d3bc1669d3
This commit is contained in:
commit
a82979b8b2
2 changed files with 59 additions and 1 deletions
|
|
@ -1094,6 +1094,9 @@ public:
|
|||
|
||||
int get_bin(Position r) const override;
|
||||
|
||||
//! setter for mesh tally amalgamtion
|
||||
void set_mesh_tally_amalgamation(std::string cluster_element_integer_name);
|
||||
|
||||
protected:
|
||||
// Overridden methods
|
||||
int get_bin_from_element(const libMesh::Elem* elem) const override;
|
||||
|
|
@ -1112,6 +1115,21 @@ private:
|
|||
//!< elements
|
||||
std::vector<int> elem_to_bin_map_; //!< mapping dof indices to bin indices for
|
||||
//!< active elements
|
||||
|
||||
bool amalgamation_ = false; //!< whether we are doing mesh and tally
|
||||
//!< amalgamation by default it's turned off.
|
||||
|
||||
int clustering_element_integer_index_ =
|
||||
-1; //!< extra element integer index for
|
||||
// element clustering
|
||||
|
||||
/*create a hash map where every element in a cluster would map to the first
|
||||
* element of in that cluster if the element isn't part of a cluster then it
|
||||
* will point to it self <any_element_in_a_cluster, first element in that
|
||||
* cluster >
|
||||
*/
|
||||
std::unordered_map<const libMesh::Elem*, const libMesh::Elem*>
|
||||
clustering_element_mapping_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
42
src/mesh.cpp
42
src/mesh.cpp
|
|
@ -3929,6 +3929,44 @@ AdaptiveLibMesh::AdaptiveLibMesh(libMesh::MeshBase& input_mesh,
|
|||
}
|
||||
}
|
||||
|
||||
void AdaptiveLibMesh::set_mesh_tally_amalgamation(
|
||||
std::string cluster_element_integer_name)
|
||||
{
|
||||
|
||||
clustering_element_integer_index_ =
|
||||
m_->has_elem_integer(cluster_element_integer_name)
|
||||
? m_->get_elem_integer_index(cluster_element_integer_name)
|
||||
: -1;
|
||||
amalgamation_ = (clustering_element_integer_index_ != -1);
|
||||
|
||||
if (amalgamation_) {
|
||||
// reseve the hash map for cluster elements
|
||||
clustering_element_mapping_.reserve(m_->n_active_elem());
|
||||
|
||||
// adding clustering map
|
||||
for (auto it = m_->active_elements_begin(); it != m_->active_elements_end();
|
||||
it++) {
|
||||
|
||||
auto elem = *it;
|
||||
auto cluster_elem = elem;
|
||||
int cluster_id =
|
||||
elem->get_extra_integer(clustering_element_integer_index_);
|
||||
|
||||
if (cluster_id != -1) {
|
||||
auto first_element_in_a_cluster = m_->elem_ptr(cluster_id);
|
||||
|
||||
if (first_element_in_a_cluster and first_element_in_a_cluster->active())
|
||||
cluster_elem = first_element_in_a_cluster;
|
||||
}
|
||||
clustering_element_mapping_.insert(std::make_pair(elem, cluster_elem));
|
||||
}
|
||||
} else {
|
||||
fatal_error(fmt::format("No extra element integer named: {} found in the "
|
||||
"mesh",
|
||||
cluster_element_integer_name));
|
||||
}
|
||||
}
|
||||
|
||||
int AdaptiveLibMesh::n_bins() const
|
||||
{
|
||||
return num_active_;
|
||||
|
|
@ -3979,7 +4017,9 @@ int AdaptiveLibMesh::get_bin(Position r) const
|
|||
|
||||
int AdaptiveLibMesh::get_bin_from_element(const libMesh::Elem* elem) const
|
||||
{
|
||||
int bin = elem_to_bin_map_[elem->id()];
|
||||
auto tally_elem = amalgamation_ ? clustering_element_mapping_.at(elem) : elem;
|
||||
int bin = elem_to_bin_map_[tally_elem->id()];
|
||||
|
||||
if (bin >= n_bins() || bin < 0) {
|
||||
fatal_error(fmt::format("Invalid bin: {}", bin));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue