13 #include "libmesh/exodusII_io.h" 14 #include "libmesh/exodusII_io_helper.h" 24 params.
addRequiredParam<Point>(
"position",
"Translation vector for the file mesh [m]");
33 _file_name(getParam<FileName>(
"file")),
36 _position(getParam<Point>(
"position"))
45 "' could not be opened. Check that the file exists and that " 46 "you have permission to open it.");
66 std::vector<std::string>
69 std::vector<std::string> subdomain_names;
71 auto & thm_mesh =
mesh();
78 std::map<int, unsigned int> node_id_map;
79 std::map<int, unsigned int> elem_id_map;
80 std::map<int, unsigned int> boundary_id_map;
87 for (
int i = 0; i < exio_helper.
num_nodes; i++)
91 Point p(exio_helper.
x[i], exio_helper.
y[i], exio_helper.
z[i]);
93 node_id_map[exodus_id] = node->id();
102 int jmax_last_block = 0;
109 if (subdomain_name.empty())
111 subdomain_names.push_back(subdomain_name);
114 const std::string component_subdomain_name =
genName(
_name, subdomain_name);
123 for (
int j = jmax_last_block;
j < jmax;
j++)
132 node_ids[
k] = node_id_map[ex_node_id];
136 Elem * elem =
addElement(conv.libmesh_elem_type(), node_ids);
137 elem->subdomain_id() = sid;
141 elem_id_map[exodus_id] = elem->id();
151 std::unordered_map<BoundaryID, BoundaryName> new_ids_to_names;
161 if (sideset_name.empty())
165 unsigned int bc_id = thm_mesh.getNextBoundaryId();
166 boundary_id_map[ex_sideset_id] = bc_id;
167 new_ids_to_names.emplace(bc_id,
genName(
_name, sideset_name));
170 auto & boundary_info = thm_mesh.getMesh().get_boundary_info();
179 Elem * elem = thm_mesh.elemPtr(elem_id);
184 unsigned int raw_side_index = exio_helper.
side_list[e] - 1;
185 std::size_t side_index_offset = conv.get_shellface_index_offset();
186 unsigned int side_index =
static_cast<unsigned int>(raw_side_index - side_index_offset);
187 int mapped_side = conv.get_side_map(side_index);
190 unsigned int bc_id = boundary_id_map[exio_helper.
id_list[e]];
191 boundary_info.add_side(elem, mapped_side, bc_id);
193 std::tuple<dof_id_type, unsigned short int>(elem->id(), mapped_side));
197 for (
const auto & id_and_name : new_ids_to_names)
199 boundary_info.sideset_name(id_and_name.first) = id_and_name.second;
200 boundary_info.nodeset_name(id_and_name.first) = id_and_name.second;
206 boundary_info.build_node_list_from_side_list();
208 return subdomain_names;
220 const std::vector<std::tuple<dof_id_type, unsigned short int>> &
229 ": No boundary info exists for the boundary '",
231 "' on this component.");
std::vector< int > id_list
std::vector< int > node_num_map
std::vector< int > num_sides_per_set
const char * get_elem_type() const
std::string genName(const std::string &prefix, unsigned int id, const std::string &suffix="") const
Build a name from a prefix, number and possible suffix.
static InputParameters validParams()
std::string get_block_name(int index)
std::vector< BoundaryName > _boundary_names
Boundary names for this component.
std::string get_side_set_name(int index)
Elem * addElement(libMesh::ElemType elem_type, const std::vector< dof_id_type > &node_ids)
std::vector< int > side_list
const ExodusII_IO_Helper::Conversion & get_conversion(const ElemType type) const
virtual void setSubdomainInfo(SubdomainID subdomain_id, const std::string &subdomain_name, const Moose::CoordinateSystemType &coord_system=Moose::COORD_XYZ)
Sets the next subdomain ID, name, and coordinate system.
Node * addNode(const Point &pt)
virtual const Node & nodeRef(const dof_id_type i) const
virtual const std::string & name() const
registerMooseObject("ThermalHydraulicsApp", FileMeshComponent)
void open(const char *filename, bool read_only)
bool hasBoundary(const BoundaryName &boundary_name) const
Returns true if this component has the supplied boundary.
std::vector< int > elem_list
Loads a mesh from an ExodusII file without adding physics.
const bool _file_is_readable
Is the file readable?
const Point & _position
Translation vector for the file mesh.
std::vector< dof_id_type > _node_ids
Node IDs of this component.
const FileName & _file_name
The name of the ExodusII file to load the mesh from.
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true, bool check_for_git_lfs_pointer=true)
std::vector< int > connect
std::string stringify(const T &t)
void read_elem_in_block(int block)
THMMesh & mesh()
Non-const reference to THM mesh, which can only be called before the end of mesh setup.
FileMeshComponent(const InputParameters ¶meters)
Intermediate class for components that have mesh.
void checkSetupStatus(const EComponentSetupStatus &status) const
Throws an error if the supplied setup status of this component has not been reached.
std::map< BoundaryName, std::vector< std::tuple< dof_id_type, unsigned short int > > > _boundary_info
Map of boundary name to list of tuples of element and side IDs for that boundary. ...
void read_and_store_header_info()
const std::vector< std::tuple< dof_id_type, unsigned short int > > & getBoundaryInfo(const BoundaryName &boundary_name) const
Gets boundary info associated with the component boundary.
void read_sideset(int id, int offset)
void mooseError(Args &&... args) const
std::vector< int > elem_num_map
int get_side_set_id(int index)
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
static InputParameters validParams()
std::vector< std::string > buildMesh()
Loads the ExodusII file into the global mesh and returns the subdomain names (before prepending compo...
bool pathExists(const std::string &path)
int get_block_id(int index)
static const std::string k
auto index_range(const T &sizable)