Allow constant scaling factor to be applied to libMesh unstructured meshes. Refs #1872

This commit is contained in:
aprilnovak 2021-08-18 15:49:58 -05:00
parent 922f688978
commit ea79fa079f
2 changed files with 30 additions and 2 deletions

View file

@ -492,7 +492,7 @@ class LibMesh : public UnstructuredMesh {
public:
// Constructors
LibMesh(pugi::xml_node node);
LibMesh(const std::string& filename);
LibMesh(const std::string& filename, const double length_multiplier = 1.0);
// Overridden Methods
void bins_crossed(Position r0, Position r1, const Direction& u,
@ -533,6 +533,9 @@ private:
//! Translate an element pointer to a bin index
int get_bin_from_element(const libMesh::Elem* elem) const;
//! Set the length multiplier to apply to each point in the mesh
void set_length_multiplier(const double length_multiplier);
// Data members
unique_ptr<libMesh::Mesh> m_; //!< pointer to the libMesh mesh instance
vector<unique_ptr<libMesh::PointLocatorBase>>
@ -547,6 +550,8 @@ private:
libMesh::BoundingBox bbox_; //!< bounding box of the mesh
libMesh::dof_id_type
first_element_id_; //!< id of the first element in the mesh
double length_multiplier_ {1.0}; //!< Constant multiplication factor to apply to mesh coordinates
bool specified_length_multiplier_ {false};
};
#endif

View file

@ -35,6 +35,7 @@
#ifdef LIBMESH
#include "libmesh/mesh_tools.h"
#include "libmesh/numeric_vector.h"
#include "libmesh/mesh_modification.h"
#endif
namespace openmc {
@ -2141,15 +2142,32 @@ void MOABMesh::write(const std::string& base_filename) const
LibMesh::LibMesh(pugi::xml_node node) : UnstructuredMesh(node)
{
// check if a length unit multiplier was specified
if (check_for_node(node, "length_multiplier")) {
length_multiplier_ = std::stod(get_node_value(node, "length_multiplier"));
specified_length_multiplier_ = true;
}
initialize();
}
LibMesh::LibMesh(const std::string& filename)
LibMesh::LibMesh(const std::string& filename, const double length_multiplier)
{
filename_ = filename;
if (length_multiplier != 1.0) {
set_length_multiplier(length_multiplier);
}
initialize();
}
void LibMesh::set_length_multiplier(const double length_multiplier)
{
length_multiplier_ = length_multiplier;
specified_length_multiplier_ = true;
}
void LibMesh::initialize()
{
if (!settings::libmesh_comm) {
@ -2162,6 +2180,11 @@ void LibMesh::initialize()
m_ = make_unique<libMesh::Mesh>(*settings::libmesh_comm, n_dimension_);
m_->read(filename_);
if (specified_length_multiplier_) {
libMesh::MeshTools::Modification::scale(*m_, length_multiplier_);
}
m_->prepare_for_use();
// ensure that the loaded mesh is 3 dimensional