Class defing a mesh. More...
#include <mesh.h>
Classes | |
| struct | GmshReadState |
| Intermediate state accumulated while reading a gmsh file, shared across the section subroutines below. More... | |
Public Member Functions | |
| Mesh ()=default | |
| Construct a new Mesh object. | |
| Mesh (const std::string &msh_file) | |
| Construct a new Mesh object from a gmsh .msh file. | |
| void | AddNode (const Node &node) |
| Add node to Mesh. | |
| void | AddNodes (const std::vector< Node > &nodes) |
| Add nodes in a vector to Mesh. | |
| void | AddElement (std::unique_ptr< Element > element) |
| Add element to Mesh. | |
| void | CreateInteriorElementNodes (const GaussLobattoLegendre &gll_quadrature) |
| Create interior nodes on elements using Gauss-Lobatto-Legendre quadrature set and add to Mesh. | |
| const std::vector< Node > & | nodes () const |
| Get the Nodes in the mesh. | |
| const std::vector< std::unique_ptr< Element > > & | elements () const |
| Get the elements in the mesh. | |
| const Node & | GetNode (const size_t id) const |
| Get Node by ID. | |
| size_t | n_elements () const |
| Get the number of Elements in the mesh. | |
| size_t | n_nodes () const |
| Get the number of nodes in the mesh. | |
| unsigned int | dimension () const |
| Get the spatial dimension of the mesh, derived from the elements it contains (e.g. 1 for a mesh of Segments). 0 if no elements have been added yet. | |
| const std::vector< size_t > & | boundary_node_ids () const |
| Get the boundary node IDs. | |
| const Element & | GetElement (const size_t index) const |
| Get an Element by index. | |
| 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 source fluxes are set to the element's external source. | |
| void | Prepare (const GaussLobattoLegendre &gll_quadrature) |
| Prepare the mesh for running a simulation by generating interior nodes using the GLL quadrature set, renumbering nodes, then checking these nodes. | |
| 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 from the .msh file alone, with no bank access) into the real IDs assigned by the given banks, by looking up the name each tag's Physical Group carries (e.g. "mms_material" from "material:mms_material") via BankBase::GetIDByName. Nodes with bc_id == 0 (never tagged by a point element) are left alone. | |
| void | FindBoundaryNodes () |
| Populates the boundary_node_ids_ member. Must be called after ResolveIDs! | |
| void | SetOutwardNormals () |
| Set the outward-pointing unit normal vector on each boundary node (Node::outward_normal), normalized via arma::normalise. Must be called after FindBoundaryNodes (needs boundary_node_ids_ populated) and after Prepare (needs final, renumbered node ids). | |
| void | UpdateNodeScalarFluxes (const QuadratureBase< Ordinate > &angular_quad_set) |
| Update the nodes' scalar flux values. | |
| void | UpdateNodeAngularFluxes (const SEMProblem &sem_problem, const size_t n_ordinates) |
| Update the nodes' angular flux values. | |
| void | SetNodeSourceFluxes (const size_t node_id, const std::vector< double > &source_fluxes) |
| Set the Node's source flux values. | |
Private Member Functions | |
| void | RenumberNodes () |
| Renumber nodes in mesh to keep node IDs near each other in a single element. | |
| void | CheckNodeIDs () |
| Check that all Node IDs are unique and continuous from 0 to N-1 for N total nodes. | |
| 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 subroutine using an unordered_map keyed by the gmsh section header (e.g. "$Nodes"). Only the sections needed to build 1D meshes (Segment elements, from 2-node line elements and Physical Point/Curve groups) are currently handled; support for 2D quad elements can be added later by extending ReadElements without needing to restructure this dispatch. | |
| void | ReadPhysicalNames (std::ifstream &file, GmshReadState &state) |
| Read the $PhysicalNames section into state.physical_names. | |
| void | ReadEntities (std::ifstream &file, GmshReadState &state) |
| Read the $Entities section into state.point_physical_tags and state.curve_physical_tags. | |
| 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 mapping in state.node_tag_to_id. | |
| void | ReadElements (std::ifstream &file, GmshReadState &state) |
| Read the $Elements section, adding Segment elements to the mesh for 2-node line elements. Point elements are consumed and used to tag the boundary/bc_id of the Node they reference, since they mark boundary entities in gmsh. | |
| 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 name is prefixed with "material:" (see cases/README.md). | |
| 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 name is prefixed with "source:" (see cases/README.md). | |
| 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 is prefixed with "bc:" (see cases/README.md). | |
| 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_material"). | |
| void | CheckMaterialIDsOnElements () |
| Check that the material IDs on the elements are set on construction. | |
Private Attributes | |
| std::vector< Node > | nodes_ |
| Nodes in the 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). | |
| std::vector< std::unique_ptr< Element > > | elements_ |
| Elements in the mesh. | |
| unsigned int | dimension_ = 0 |
| Spatial dimension of the mesh's elements, set by the first call to AddElement. 0 if no elements have been added yet. | |
| std::unordered_map< int, std::string > | physical_names_ |
| Map from Physical Group tag to its name (e.g. "material:foo"), persisted from GmshReadState::physical_names for use by ResolveIDs after reading is done. | |
|
default |
Construct a new Mesh object.
| hummingbird::Mesh::Mesh | ( | const std::string & | msh_file | ) |
| void hummingbird::Mesh::AddElement | ( | std::unique_ptr< Element > | element | ) |
| void hummingbird::Mesh::AddNode | ( | const Node & | node | ) |
| void hummingbird::Mesh::AddNodes | ( | const std::vector< Node > & | nodes | ) |
|
inline |
|
private |
|
private |
| void hummingbird::Mesh::CreateInteriorElementNodes | ( | const GaussLobattoLegendre & | gll_quadrature | ) |
|
inline |
|
inline |
|
private |
| void hummingbird::Mesh::FindBoundaryNodes | ( | ) |
|
private |
Find the BC ID for a point entity, defined as the tag of the Physical Group on that point whose name is prefixed with "bc:" (see cases/README.md).
| std::runtime_error | if no such Physical Group is found |
| point_physical_tags | Physical Group tags assigned to the point |
| physical_names | Map from Physical Group tag to name |
|
inline |
|
private |
Find the material ID for a curve entity, defined as the tag of the Physical Group on that curve whose name is prefixed with "material:" (see cases/README.md).
| std::runtime_error | if no such Physical Group is found |
| curve_physical_tags | Physical Group tags assigned to the curve |
| physical_names | Map from Physical Group tag to name |
|
inline |
|
private |
Find the source ID for a curve entity, defined as the tag of the Physical Group on the curve whose name is prefixed with "source:" (see cases/README.md).
| std::runtime_error | if no such Physical Group is found |
| curve_physical_tags | Physical Group tags assigned to the curve |
| physical_names | Map from Physical Group tag to name |
| void hummingbird::Mesh::InitializeNodeSolutions | ( | const size_t | n_ordinates, |
| const QuadratureBase< Ordinate > & | angular_quad_set, | ||
| const SourceBank & | source_bank ) |
|
inline |
|
inline |
|
inline |
| void hummingbird::Mesh::Prepare | ( | const GaussLobattoLegendre & | gll_quadrature | ) |
|
private |
Read the $Elements section, adding Segment elements to the mesh for 2-node line elements. Point elements are consumed and used to tag the boundary/bc_id of the Node they reference, since they mark boundary entities in gmsh.
| std::runtime_error | for any element type other than a point or a 2-node line, since only 1D meshes are currently supported |
| file | gmsh file stream, positioned just after the section header |
| state | Shared gmsh read state |
|
private |
Read the $Entities section into state.point_physical_tags and state.curve_physical_tags.
| std::runtime_error | if the mesh contains surface or volume entities, since only 1D (point/curve) meshes are currently supported |
| file | gmsh file stream, positioned just after the section header |
| state | Shared gmsh read state |
|
private |
Construct a Mesh from a gmsh ASCII (format 4.1) .msh file. Reading routes to a section-specific subroutine using an unordered_map keyed by the gmsh section header (e.g. "$Nodes"). Only the sections needed to build 1D meshes (Segment elements, from 2-node line elements and Physical Point/Curve groups) are currently handled; support for 2D quad elements can be added later by extending ReadElements without needing to restructure this dispatch.
| msh_file | Path to the gmsh .msh file |
|
private |
|
private |
|
private |
| void hummingbird::Mesh::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 from the .msh file alone, with no bank access) into the real IDs assigned by the given banks, by looking up the name each tag's Physical Group carries (e.g. "mms_material" from "material:mms_material") via BankBase::GetIDByName. Nodes with bc_id == 0 (never tagged by a point element) are left alone.
| std::runtime_error | if a material name from the mesh has no match in material_bank |
|
inline |
| void hummingbird::Mesh::SetOutwardNormals | ( | ) |
Set the outward-pointing unit normal vector on each boundary node (Node::outward_normal), normalized via arma::normalise. Must be called after FindBoundaryNodes (needs boundary_node_ids_ populated) and after Prepare (needs final, renumbered node ids).
| std::runtime_error | if the mesh is not 1D (not yet implemented for other dimensions) |
| void hummingbird::Mesh::UpdateNodeAngularFluxes | ( | const SEMProblem & | sem_problem, |
| const size_t | n_ordinates ) |
Update the nodes' angular flux values.
| sem_problem | SEMProblem object containing updated flux values |
| n_ordinates | Number of ordinates |
| void hummingbird::Mesh::UpdateNodeScalarFluxes | ( | const QuadratureBase< Ordinate > & | angular_quad_set | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
Map from Physical Group tag to its name (e.g. "material:foo"), persisted from GmshReadState::physical_names for use by ResolveIDs after reading is done.