hummingbird
Solving the self-adjoint angular flux transport equation using spectral elements on Cartesian geometry
Loading...
Searching...
No Matches
hummingbird::Segment Class Reference

1D line element defined by two boundary nodes, with interior nodes placed at Gauss-Lobatto-Legendre points More...

#include <segment.h>

Inheritance diagram for hummingbird::Segment:
[legend]
Collaboration diagram for hummingbird::Segment:
[legend]

Public Member Functions

 Segment (const std::array< size_t, 2 > boundary_node_ids, const int material_id, const int source_id, const Mesh &mesh)
 Construct a new Segment object.
std::vector< Node > CreateInteriorNodes (const std::vector< Node > &existing_nodes, const GaussLobattoLegendre &gll_quadrature) override
 Create interior Node objects using the Gauss-Lobatto-Legendre quadrature set. The mapping from the reference to the real domain was based on the equations provided by the book Computational Seismology by Heiner Igel (https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.geokniga.org/bookfiles/geokniga-computationalseismologyapracticalintroductionbyigelheinerz-liborg.pdf&ved=2ahUKEwiMuanq7_OVAxXVN4YAHVgAD1QQFnoECBUQAQ&usg=AOvVaw35g1Tl3ZSFUMusz8LKQxHk). For a line segment defined by two endpoints, the mapping is:
arma::Col< double > LocalForcingVector (const GaussLobattoLegendre &gll_quad, const Mesh &mesh, const MaterialBank &material_bank, const Ordinate &ordinate, const size_t ordinate_index) override
 Construct the local forcing vector, which is:
arma::Mat< double > LocalStiffnessMatrix (const GaussLobattoLegendre &gll_quad, const MaterialBank &material_bank, const Ordinate &ordinate) override
 Construct the dense local stiffness matrix using spectral elements on a Gauss-Lobatto-Legendre grid, defined as:
arma::SpMat< double > LocalMassMatrix (const GaussLobattoLegendre &gll_quad, const MaterialBank &material_bank) override
 Construct the sparse diagonal local mass matrix using spectral elements on a Gauss-Lobatto-Legendre grid, defined as:
unsigned int dimension () const override
 Get the spatial dimension of a Segment (always 1).
Public Member Functions inherited from hummingbird::Element
 Element (const int material_id, const int source_id)
 Construct a new Element object.
virtual ~Element ()=default
 Destroy the Element object. Virtual because Element is used polymorphically through std::unique_ptr<Element> (see Mesh::elements_).
std::vector< size_t > node_ids () const
 Get node IDs.
int material_id () const
 Get Material ID.
int source_id () const
 Get Source ID.
void SetMaterialID (const int material_id)
 Set the Material ID, e.g. once it has been resolved from a raw gmsh tag to a MaterialBank-assigned ID (see Mesh::ResolveIDs).
void SetSourceID (const int source_id)
 Set the Source ID, e.g. once it has been resolved from a raw gmsh tag to a SourceBank-assigned ID (see Mesh::ResolveIDs).
void SetNewNodeID (const size_t prev_id, const size_t new_id)
 Set the new Node ID.
void SetNodeIDs (std::vector< size_t > node_ids)
 Replace all node IDs at once, e.g. when renumbering. Unlike SetNewNodeID, this does not search by value, so it is safe to use when remapped IDs could otherwise collide with not-yet-remapped IDs.
void SetNodeSourceFluxes (Mesh &mesh, const MaterialBank &material_bank, const SourceBank &source_bank, const QuadratureBase< Ordinate > &angular_quadrature)
 Compute and set the source flux values on this element's nodes using this element's material and source IDs.

Private Member Functions

double ComputeLength (const std::array< size_t, 2 > boundary_node_ids, const Mesh &mesh)
 Compute the length of the element on construction.

Private Attributes

std::array< size_t, 2 > boundary_node_ids_
 Node IDs defining the Segment bounds.
const double length_
 Length of the element.

Additional Inherited Members

Protected Attributes inherited from hummingbird::Element
int material_id_ = -1
 Material ID to access Material Bank. Auto initialized to -1. Value must be set to a positive value (including 0) to map into the MaterialBank.
int source_id_ = 0
 Source ID to access Source Bank. ID of 0 is always NONE, meaning the element has no external source.
std::vector< size_t > node_ids_
 IDs of nodes defining the element.

Detailed Description

1D line element defined by two boundary nodes, with interior nodes placed at Gauss-Lobatto-Legendre points

Definition at line 20 of file segment.h.

Constructor & Destructor Documentation

◆ Segment()

hummingbird::Segment::Segment ( const std::array< size_t, 2 > boundary_node_ids,
const int material_id,
const int source_id,
const Mesh & mesh )

Construct a new Segment object.

Parameters
boundary_node_idsNode IDs defining the Segment bounds
material_idMaterial ID
source_idSource ID
meshMesh

Definition at line 4 of file segment.cc.

Member Function Documentation

◆ ComputeLength()

double hummingbird::Segment::ComputeLength ( const std::array< size_t, 2 > boundary_node_ids,
const Mesh & mesh )
private

Compute the length of the element on construction.

Parameters
boundary_node_idsBoundary node IDs
meshMesh
Returns
double

Definition at line 10 of file segment.cc.

◆ CreateInteriorNodes()

std::vector< Node > hummingbird::Segment::CreateInteriorNodes ( const std::vector< Node > & existing_nodes,
const GaussLobattoLegendre & gll_quadrature )
overridevirtual

Create interior Node objects using the Gauss-Lobatto-Legendre quadrature set. The mapping from the reference to the real domain was based on the equations provided by the book Computational Seismology by Heiner Igel (https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.geokniga.org/bookfiles/geokniga-computationalseismologyapracticalintroductionbyigelheinerz-liborg.pdf&ved=2ahUKEwiMuanq7_OVAxXVN4YAHVgAD1QQFnoECBUQAQ&usg=AOvVaw35g1Tl3ZSFUMusz8LKQxHk). For a line segment defined by two endpoints, the mapping is:

\[\mathbf{r}(\xi) = \mathbf{r}_1+\left( \frac{\xi+1}{2} \right)\left( \mathbf{r}_2-\mathbf{r}_1 \right) \]

where \(x\in[-1,1]\).

Parameters
existing_nodesNodes already existing in Mesh
gll_quadratureGauss-Lobatto-Legendre quadrature set
Returns
Additional nodes to be defined along the GLL quadrature set. Will be of length N-2 (the two endpoint account for the remaining two nodes)

Implements hummingbird::Element.

Definition at line 18 of file segment.cc.

◆ dimension()

unsigned int hummingbird::Segment::dimension ( ) const
overridevirtual

Get the spatial dimension of a Segment (always 1).

Returns
unsigned int

Implements hummingbird::Element.

Definition at line 107 of file segment.cc.

◆ LocalForcingVector()

arma::Col< double > hummingbird::Segment::LocalForcingVector ( const GaussLobattoLegendre & gll_quad,
const Mesh & mesh,
const MaterialBank & material_bank,
const Ordinate & ordinate,
const size_t ordinate_index )
overridevirtual

Construct the local forcing vector, which is:

\[f_i = \frac{h_e}{2}\int_{-1}^1Q_n(\xi)\ell_i (\xi)d\xi + \frac{\hat{\Omega}_x}{\Sigma_t^e}\int_{-1}^1Q_n(\xi)\frac{d\ell_i}{d\xi}d\xi \]

which the integrals are again approximated using the GLL quadrature set:

\[f_i \approx \sum_{k=0}^{N_x}\rho_k Q_n(\xi_k)\left[ \frac{h_e}{2}\ell_i (\xi_k) +\frac{\hat{\Omega}_x}{\Sigma_t^e}\frac{d\ell_i}{d\xi}(\xi_k)\right] \]

Parameters
gll_quadGaussLobattoLegendre quadrature set
meshMesh
material_bankMaterial bank
ordinateOrdinate (direction)
ordinate_indexIndex of the ordinate in the angular quadrature
Returns
arma::Col<double>

Implements hummingbird::Element.

Definition at line 52 of file segment.cc.

◆ LocalMassMatrix()

arma::SpMat< double > hummingbird::Segment::LocalMassMatrix ( const GaussLobattoLegendre & gll_quad,
const MaterialBank & material_bank )
overridevirtual

Construct the sparse diagonal local mass matrix using spectral elements on a Gauss-Lobatto-Legendre grid, defined as:

\[M_{ij}=\Sigma_t^e\frac{h_e}{2}\sum_{k=0}^{N_x}\rho_k\ell_i(\xi_k)\ell_j(\xi_k) \]

Which, using the cardinality of Lagrange polynomials, greatly simplifies to:

\[\Sigma_t^eM_{ij}=\begin{cases} 0, & i\neq j \\ \Sigma_t^e\frac{h_e}{2}\rho_i, &i=j \end{cases} \]

Parameters
gll_quadGaussLobattoLegendre set
material_bankMaterialBank
Returns
arma::SpMat<double>

Implements hummingbird::Element.

Definition at line 97 of file segment.cc.

◆ LocalStiffnessMatrix()

arma::Mat< double > hummingbird::Segment::LocalStiffnessMatrix ( const GaussLobattoLegendre & gll_quad,
const MaterialBank & material_bank,
const Ordinate & ordinate )
overridevirtual

Construct the dense local stiffness matrix using spectral elements on a Gauss-Lobatto-Legendre grid, defined as:

\[K_{ij}=\frac{\hat{\Omega}_x^2}{\Sigma_t^e}\frac{2}{h_e}\sum_{k=0}^{N_x}\rho_k \frac{d\ell_i}{d\xi}(\xi_k)\frac{d\ell_j}{d\xi}(\xi_k) \]

Parameters
gll_quadGaussLobattoLegendre set
material_bankMaterialBank
ordinateOrdinate (direction)
Returns
arma::Mat<double>
Todo
See about cutting the loops in half by leveraging symmetry.

Implements hummingbird::Element.

Definition at line 77 of file segment.cc.

Member Data Documentation

◆ boundary_node_ids_

std::array<size_t, 2> hummingbird::Segment::boundary_node_ids_
private

Node IDs defining the Segment bounds.

Definition at line 134 of file segment.h.

◆ length_

const double hummingbird::Segment::length_
private

Length of the element.

Definition at line 137 of file segment.h.


The documentation for this class was generated from the following files:
  • /home/runner/work/hummingbird/hummingbird/include/mesh/segment.h
  • /home/runner/work/hummingbird/hummingbird/src/mesh/segment.cc