@@ -3485,9 +3485,6 @@ void LibMesh::initialize()
34853485 // assuming that unstructured meshes used in OpenMC are 3D
34863486 n_dimension_ = 3 ;
34873487
3488- if (length_multiplier_ > 0.0 ) {
3489- libMesh::MeshTools::Modification::scale (*m_, length_multiplier_);
3490- }
34913488 // if OpenMC is managing the libMesh::MeshBase instance, prepare the mesh.
34923489 // Otherwise assume that it is prepared by its owning application
34933490 if (unique_m_) {
@@ -3537,7 +3534,11 @@ Position LibMesh::centroid(int bin) const
35373534{
35383535 const auto & elem = this ->get_element_from_bin (bin);
35393536 auto centroid = elem.vertex_average ();
3540- return {centroid (0 ), centroid (1 ), centroid (2 )};
3537+ if (length_multiplier_ > 0.0 ) {
3538+ return length_multiplier_ * Position (centroid (0 ), centroid (1 ), centroid (2 ));
3539+ } else {
3540+ return {centroid (0 ), centroid (1 ), centroid (2 )};
3541+ }
35413542}
35423543
35433544int LibMesh::n_vertices () const
@@ -3548,7 +3549,11 @@ int LibMesh::n_vertices() const
35483549Position LibMesh::vertex (int vertex_id) const
35493550{
35503551 const auto node_ref = m_->node_ref (vertex_id);
3551- return {node_ref (0 ), node_ref (1 ), node_ref (2 )};
3552+ if (length_multiplier_ > 0.0 ) {
3553+ return length_multiplier_ * Position (node_ref (0 ), node_ref (1 ), node_ref (2 ));
3554+ } else {
3555+ return {node_ref (0 ), node_ref (1 ), node_ref (2 )};
3556+ }
35523557}
35533558
35543559std::vector<int > LibMesh::connectivity (int elem_id) const
@@ -3689,6 +3694,11 @@ int LibMesh::get_bin(Position r) const
36893694 // look-up a tet using the point locator
36903695 libMesh::Point p (r.x , r.y , r.z );
36913696
3697+ if (length_multiplier_ > 0.0 ) {
3698+ // Scale the point down
3699+ p /= length_multiplier_;
3700+ }
3701+
36923702 // quick rejection check
36933703 if (!bbox_.contains_point (p)) {
36943704 return -1 ;
@@ -3722,22 +3732,32 @@ const libMesh::Elem& LibMesh::get_element_from_bin(int bin) const
37223732
37233733double LibMesh::volume (int bin) const
37243734{
3725- return this ->get_element_from_bin (bin).volume ();
3735+ return this ->get_element_from_bin (bin).volume () * length_multiplier_ *
3736+ length_multiplier_ * length_multiplier_;
37263737}
37273738
3728- AdaptiveLibMesh::AdaptiveLibMesh (
3729- libMesh::MeshBase& input_mesh, double length_multiplier)
3730- : LibMesh (input_mesh, length_multiplier), num_active_ (m_->n_active_elem ())
3739+ AdaptiveLibMesh::AdaptiveLibMesh (libMesh::MeshBase& input_mesh,
3740+ double length_multiplier,
3741+ const std::set<libMesh::subdomain_id_type>& block_ids)
3742+ : LibMesh (input_mesh, length_multiplier), block_ids_ (block_ids),
3743+ block_restrict_ (!block_ids_.empty ()),
3744+ num_active_ (
3745+ block_restrict_
3746+ ? std::distance (m_->active_subdomain_set_elements_begin (block_ids_),
3747+ m_->active_subdomain_set_elements_end (block_ids_))
3748+ : m_->n_active_elem ())
37313749{
37323750 // if the mesh is adaptive elements aren't guaranteed by libMesh to be
37333751 // contiguous in ID space, so we need to map from bin indices (defined over
37343752 // active elements) to global dof ids
37353753 bin_to_elem_map_.reserve (num_active_);
37363754 elem_to_bin_map_.resize (m_->n_elem (), -1 );
3737- for (auto it = m_->active_elements_begin (); it != m_->active_elements_end ();
3738- it++) {
3739- auto elem = *it;
3740-
3755+ auto begin = block_restrict_
3756+ ? m_->active_subdomain_set_elements_begin (block_ids_)
3757+ : m_->active_elements_begin ();
3758+ auto end = block_restrict_ ? m_->active_subdomain_set_elements_end (block_ids_)
3759+ : m_->active_elements_end ();
3760+ for (const auto & elem : libMesh::as_range (begin, end)) {
37413761 bin_to_elem_map_.push_back (elem->id ());
37423762 elem_to_bin_map_[elem->id ()] = bin_to_elem_map_.size () - 1 ;
37433763 }
@@ -3770,6 +3790,27 @@ void AdaptiveLibMesh::write(const std::string& filename) const
37703790 this ->id_ ));
37713791}
37723792
3793+ int AdaptiveLibMesh::get_bin (Position r) const
3794+ {
3795+ // look-up a tet using the point locator
3796+ libMesh::Point p (r.x , r.y , r.z );
3797+
3798+ if (length_multiplier_ > 0.0 ) {
3799+ // Scale the point down
3800+ p /= length_multiplier_;
3801+ }
3802+
3803+ // quick rejection check
3804+ if (!bbox_.contains_point (p)) {
3805+ return -1 ;
3806+ }
3807+
3808+ const auto & point_locator = pl_.at (thread_num ());
3809+
3810+ const auto elem_ptr = (*point_locator)(p, &block_ids_);
3811+ return elem_ptr ? get_bin_from_element (elem_ptr) : -1 ;
3812+ }
3813+
37733814int AdaptiveLibMesh::get_bin_from_element (const libMesh::Elem* elem) const
37743815{
37753816 int bin = elem_to_bin_map_[elem->id ()];
0 commit comments