4#ifndef HUMMINGBIRD_MESH_MESH_H_
5#define HUMMINGBIRD_MESH_MESH_H_
9#include <unordered_map>
40 Mesh(
const std::string& msh_file);
61 void AddElement(std::unique_ptr<Element> element);
83 const std::vector<std::unique_ptr<Element>>&
elements()
const {
209 const size_t n_ordinates);
218 const std::vector<double>& source_fluxes) {
219 nodes_.at(node_id).source_fluxes = source_fluxes;
289 void ReadGMSH(
const std::string& msh_file);
346 const std::vector<int>& curve_physical_tags,
347 const std::unordered_map<int, std::string>& physical_names)
const;
361 const std::vector<int>& curve_physical_tags,
362 const std::unordered_map<int, std::string>& physical_names)
const;
375 int GetBCID(
const std::vector<int>& point_physical_tags,
376 const std::unordered_map<int, std::string>& physical_names)
const;
385 std::string
ExtractName(
const std::string& physical_name)
const;
Bank holding the boundary conditions defined in the input file.
Defines a subset of the domain (an "element").
Class defining a 1D Gauss-Legendre-Lobatto quadrature set on [-1,1]. The quadrature set approximates ...
Bank holding the materials defined in the input file.
void AddNodes(const std::vector< Node > &nodes)
Add nodes in a vector to Mesh.
const Node & GetNode(const size_t id) const
Get Node by ID.
void ResolveIDs(const MaterialBank &material_bank, const SourceBank &source_bank, const BCBank &bc_bank)
Resolve the raw gmsh Physical Group tags currently stored in material_id()/source_id()/bc_id (set fro...
std::unordered_map< int, std::string > physical_names_
Map from Physical Group tag to its name (e.g. "material:foo"), persisted from GmshReadState::physical...
void RenumberNodes()
Renumber nodes in mesh to keep node IDs near each other in a single element.
void ReadPhysicalNames(std::ifstream &file, GmshReadState &state)
Read the $PhysicalNames section into state.physical_names.
void ReadGMSH(const std::string &msh_file)
Construct a Mesh from a gmsh ASCII (format 4.1) .msh file. Reading routes to a section-specific subro...
std::string ExtractName(const std::string &physical_name) const
Extract the name after the ":" in a Physical Group name (e.g. "mms_material" from "material:mms_mater...
Mesh()=default
Construct a new Mesh object.
size_t n_nodes() const
Get the number of nodes in the mesh.
void FindBoundaryNodes()
Populates the boundary_node_ids_ member. Must be called after ResolveIDs!
size_t n_elements() const
Get the number of Elements in the mesh.
std::vector< std::unique_ptr< Element > > elements_
Elements in the mesh.
int GetBCID(const std::vector< int > &point_physical_tags, const std::unordered_map< int, std::string > &physical_names) const
Find the BC ID for a point entity, defined as the tag of the Physical Group on that point whose name ...
void ReadNodes(std::ifstream &file, GmshReadState &state)
Read the $Nodes section, adding Node objects to the mesh and recording the gmsh tag to Node ID mappin...
const std::vector< Node > & nodes() const
Get the Nodes in the mesh.
const std::vector< size_t > & boundary_node_ids() const
Get the boundary node IDs.
void SetNodeSourceFluxes(const size_t node_id, const std::vector< double > &source_fluxes)
Set the Node's source flux values.
void AddNode(const Node &node)
Add node to Mesh.
void SetOutwardNormals()
Set the outward-pointing unit normal vector on each boundary node (Node::outward_normal),...
void InitializeNodeSolutions(const size_t n_ordinates, const QuadratureBase< Ordinate > &angular_quad_set, const SourceBank &source_bank)
Initialize node solution vectors to the correct lengths. Scalar and angular fluxes are set to 0 and s...
void CreateInteriorElementNodes(const GaussLobattoLegendre &gll_quadrature)
Create interior nodes on elements using Gauss-Lobatto-Legendre quadrature set and add to Mesh.
void UpdateNodeScalarFluxes(const QuadratureBase< Ordinate > &angular_quad_set)
Update the nodes' scalar flux values.
void CheckMaterialIDsOnElements()
Check that the material IDs on the elements are set on construction.
unsigned int dimension_
Spatial dimension of the mesh's elements, set by the first call to AddElement. 0 if no elements have ...
int GetMaterialID(const std::vector< int > &curve_physical_tags, const std::unordered_map< int, std::string > &physical_names) const
Find the material ID for a curve entity, defined as the tag of the Physical Group on that curve whose...
void Prepare(const GaussLobattoLegendre &gll_quadrature)
Prepare the mesh for running a simulation by generating interior nodes using the GLL quadrature set,...
int GetSourceID(const std::vector< int > &curve_physical_tags, const std::unordered_map< int, std::string > &physical_names) const
Find the source ID for a curve entity, defined as the tag of the Physical Group on the curve whose na...
void UpdateNodeAngularFluxes(const SEMProblem &sem_problem, const size_t n_ordinates)
Update the nodes' angular flux values.
unsigned int dimension() const
Get the spatial dimension of the mesh, derived from the elements it contains (e.g....
void ReadEntities(std::ifstream &file, GmshReadState &state)
Read the $Entities section into state.point_physical_tags and state.curve_physical_tags.
const std::vector< std::unique_ptr< Element > > & elements() const
Get the elements in the mesh.
const Element & GetElement(const size_t index) const
Get an Element by index.
void ReadElements(std::ifstream &file, GmshReadState &state)
Read the $Elements section, adding Segment elements to the mesh for 2-node line elements....
std::vector< Node > nodes_
Nodes in the mesh.
void CheckNodeIDs()
Check that all Node IDs are unique and continuous from 0 to N-1 for N total nodes.
void AddElement(std::unique_ptr< Element > element)
Add element to Mesh.
std::vector< size_t > boundary_node_ids_
Nodes in the mesh that exist on the mesh boundaries (that is, they have a boundary condition assigned...
Base class for defining a quadrature set.
Wrapper class that owns a ProblemBase of the type corresponding to the given FEFormulation.
Bank holding the volumetric sources defined in the input file.
Intermediate state accumulated while reading a gmsh file, shared across the section subroutines below...
std::unordered_map< int, std::vector< int > > curve_physical_tags
Map from curve entity tag to its Physical Group tags.
std::unordered_map< int, std::vector< int > > point_physical_tags
Map from point entity tag to its Physical Group tags.
std::unordered_map< int, std::string > physical_names
Map from Physical Group tag to its name (e.g. "material:foo").
std::unordered_map< size_t, size_t > node_tag_to_id
Map from gmsh node tag to the corresponding Node's ID in nodes_.
A point in the mesh holding its coordinates, boundary info, and flux solution values.