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

Base class defining a formulation of the transport equation to be solved. More...

#include <problem_base.h>

Inheritance diagram for hummingbird::ProblemBase:
[legend]

Public Member Functions

 ProblemBase (const size_t n_dofs, const size_t n_ordinates)
 Construct a new Problem Base object.
virtual ~ProblemBase ()=default
 Destroy the Problem Base object.
void AssembleGlobalSystem (const std::vector< GlobalMatrixData > &global_matrix_data, const size_t ordinate_index)
 Assemble the global element system. That is, form the matrix \(A\) in \( Ax=b\). This only should be called once per ordinate per simulation. The global matrix is sized from the n_dofs supplied at construction, not from global_matrix_data; row_id/col_id pairs are expected to repeat (shared nodes get summed contributions from multiple elements) and are summed via Armadillo's batch SpMat constructor's add_values=true overload (the default overload errors on duplicate locations instead of summing them).
void AssembleGlobalForcing (const std::vector< GlobalForcingData > &global_forcing_data, const size_t ordinate_index)
 Assemble the global forcing vector for a given ordinate index. The global vector is sized from the n_dofs supplied at construction, not from global_forcing_data; row_id values are expected to repeat (shared nodes get summed contributions from multiple elements).
void Solve (const size_t ordinate_index)
 Solve the linear system using Armadillo's sparse matrix solver. Stores the results in the solution_vectors_ member at the ordinate_index index.
virtual std::vector< GlobalMatrixData > AssembleGlobalMatrixData (const Mesh &mesh, const GaussLobattoLegendre &gll_quad, const MaterialBank &material_bank, const Ordinate &ordinate)=0
 Assemble the vector of GlobalMatrixData structs that will be used in AssembleGlobalSystem to create the global system matrix.
virtual std::vector< GlobalForcingData > AssembleGlobalForcingData (const GaussLobattoLegendre &gll_quad, Mesh &mesh, const MaterialBank &material_bank, const SourceBank &source_bank, const Ordinate &ordinate, const size_t ordinate_index, const QuadratureBase< Ordinate > &angular_quad_set)=0
 Assemble the vector of GlobalForcingData structs that will be using in AssembleGlobalForcing to create the global forcing vector. Implementations may overwrite Node::source_fluxes on the mesh, which is why mesh is non-const.
void ApplyBCs (const Mesh &mesh, const Ordinate &ordinate, const BCBank &bc_bank, const size_t ordinate_index)
 Apply boundary conditions by adding in values needed at boundary nodes. Internally, a switch calls the correct methods depending on the mesh dimension.
const std::vector< arma::Col< double > > & solution_vectors () const
 Get the solution vectors.
size_t n_dofs () const
 Get the number of degrees of freedom.

Protected Member Functions

void CheckGlobalMatrixData (const std::vector< GlobalMatrixData > &gmd)
 Validate a vector of GlobalMatrixData before it is used to assemble the global system matrix. row_id/col_id pairs are expected to repeat (shared nodes get summed contributions from multiple elements), so unique (row_id, col_id) pairs are not required. Instead, this checks that the set of distinct row/col IDs referenced is contiguous starting from 0, i.e. no node ID is missing from the data.
void CheckGlobalForcingData (const std::vector< GlobalForcingData > &gfd)
 Validate a vector of GlobalForcingData before it is used to assemble the global forcing vector. row_id values are expected to repeat (shared nodes get summed contributions from multiple elements), so unique row_ids are not required. Instead, this checks that the set of distinct row IDs referenced is contiguous starting from 0, i.e. no DOF is missing from the data.
virtual void Apply1DBCs (const Mesh &mesh, const Ordinate &Ordinate, const BCBank &bc_bank, const size_t ordinate_index)=0
 Apply boundary conditions to a 1D problem.

Protected Attributes

const size_t n_dofs_
 Number of degrees of freedom in simulation.
std::vector< arma::SpMat< double > > global_system_matrices_
 Global system matrices in order of ordinates in angular quadrature set.
std::vector< arma::Col< double > > global_forcing_vectors_
 Global forcing vectors in order of ordinates in angular quadrature set.
std::vector< arma::Col< double > > solution_vectors_
 Column vector of the angular flux at the nodes in order of ordinates in angular quadrature set.

Detailed Description

Base class defining a formulation of the transport equation to be solved.

Definition at line 52 of file problem_base.h.

Constructor & Destructor Documentation

◆ ProblemBase()

hummingbird::ProblemBase::ProblemBase ( const size_t n_dofs,
const size_t n_ordinates )

Construct a new Problem Base object.

Parameters
n_dofsNumber of Degrees of Freedom
n_ordinatesNumber of ordinates in angular mesh

Definition at line 8 of file problem_base.cc.

◆ ~ProblemBase()

virtual hummingbird::ProblemBase::~ProblemBase ( )
virtualdefault

Destroy the Problem Base object.

Member Function Documentation

◆ Apply1DBCs()

virtual void hummingbird::ProblemBase::Apply1DBCs ( const Mesh & mesh,
const Ordinate & Ordinate,
const BCBank & bc_bank,
const size_t ordinate_index )
protectedpure virtual

Apply boundary conditions to a 1D problem.

Parameters
meshMesh
OrdinateOrdinate (direction)
bc_bankBCBank object
ordinate_indexIndex of the ordinate in the angular quadrature

Implemented in hummingbird::CGProblem.

◆ ApplyBCs()

void hummingbird::ProblemBase::ApplyBCs ( const Mesh & mesh,
const Ordinate & ordinate,
const BCBank & bc_bank,
const size_t ordinate_index )

Apply boundary conditions by adding in values needed at boundary nodes. Internally, a switch calls the correct methods depending on the mesh dimension.

Parameters
meshMesh
ordinateOrdinate (direction)
bc_bankBCBank object
ordinate_indexIndex of the ordinate in the angular quadrature

Definition at line 58 of file problem_base.cc.

◆ AssembleGlobalForcing()

void hummingbird::ProblemBase::AssembleGlobalForcing ( const std::vector< GlobalForcingData > & global_forcing_data,
const size_t ordinate_index )

Assemble the global forcing vector for a given ordinate index. The global vector is sized from the n_dofs supplied at construction, not from global_forcing_data; row_id values are expected to repeat (shared nodes get summed contributions from multiple elements).

Parameters
global_forcing_dataVector of GlobalForcingData structs
ordinate_indexOrdinate index

Definition at line 40 of file problem_base.cc.

◆ AssembleGlobalForcingData()

virtual std::vector< GlobalForcingData > hummingbird::ProblemBase::AssembleGlobalForcingData ( const GaussLobattoLegendre & gll_quad,
Mesh & mesh,
const MaterialBank & material_bank,
const SourceBank & source_bank,
const Ordinate & ordinate,
const size_t ordinate_index,
const QuadratureBase< Ordinate > & angular_quad_set )
pure virtual

Assemble the vector of GlobalForcingData structs that will be using in AssembleGlobalForcing to create the global forcing vector. Implementations may overwrite Node::source_fluxes on the mesh, which is why mesh is non-const.

Parameters
gll_quadGaussLobattoLegendre quadrature set
meshMesh
material_bankMaterial bank
source_bankSource bank
ordinateOrdinate (direction)
ordinate_indexIndex in the angular quadrature
angular_quad_setAngular quadrature set
Returns
std::vector<GlobalForcingData>

Implemented in hummingbird::CGProblem.

◆ AssembleGlobalMatrixData()

virtual std::vector< GlobalMatrixData > hummingbird::ProblemBase::AssembleGlobalMatrixData ( const Mesh & mesh,
const GaussLobattoLegendre & gll_quad,
const MaterialBank & material_bank,
const Ordinate & ordinate )
pure virtual

Assemble the vector of GlobalMatrixData structs that will be used in AssembleGlobalSystem to create the global system matrix.

Parameters
meshMesh
gll_quadGaussLobattoLegendre quadrature set
material_bankMaterial bank
ordinateOrdinate for equation
Returns
std::vector<GlobalMatrixData>

Implemented in hummingbird::CGProblem.

◆ AssembleGlobalSystem()

void hummingbird::ProblemBase::AssembleGlobalSystem ( const std::vector< GlobalMatrixData > & global_matrix_data,
const size_t ordinate_index )

Assemble the global element system. That is, form the matrix \(A\) in \( Ax=b\). This only should be called once per ordinate per simulation. The global matrix is sized from the n_dofs supplied at construction, not from global_matrix_data; row_id/col_id pairs are expected to repeat (shared nodes get summed contributions from multiple elements) and are summed via Armadillo's batch SpMat constructor's add_values=true overload (the default overload errors on duplicate locations instead of summing them).

Parameters
global_matrix_dataVector of GlobalMatrixData structs
ordinate_indexOrdinate index within the angular quadrature set (i.e. the direction number)

Definition at line 18 of file problem_base.cc.

◆ CheckGlobalForcingData()

void hummingbird::ProblemBase::CheckGlobalForcingData ( const std::vector< GlobalForcingData > & gfd)
protected

Validate a vector of GlobalForcingData before it is used to assemble the global forcing vector. row_id values are expected to repeat (shared nodes get summed contributions from multiple elements), so unique row_ids are not required. Instead, this checks that the set of distinct row IDs referenced is contiguous starting from 0, i.e. no DOF is missing from the data.

Parameters
gfdVector of GlobalForcingData structs

Definition at line 91 of file problem_base.cc.

◆ CheckGlobalMatrixData()

void hummingbird::ProblemBase::CheckGlobalMatrixData ( const std::vector< GlobalMatrixData > & gmd)
protected

Validate a vector of GlobalMatrixData before it is used to assemble the global system matrix. row_id/col_id pairs are expected to repeat (shared nodes get summed contributions from multiple elements), so unique (row_id, col_id) pairs are not required. Instead, this checks that the set of distinct row/col IDs referenced is contiguous starting from 0, i.e. no node ID is missing from the data.

Parameters
gmdVector of GlobalMatrixData structs

Definition at line 72 of file problem_base.cc.

◆ n_dofs()

size_t hummingbird::ProblemBase::n_dofs ( ) const
inline

Get the number of degrees of freedom.

Returns
size_t

Definition at line 169 of file problem_base.h.

◆ solution_vectors()

const std::vector< arma::Col< double > > & hummingbird::ProblemBase::solution_vectors ( ) const
inline

Get the solution vectors.

Returns
const std::vector<arma::Col<double>>&

Definition at line 160 of file problem_base.h.

◆ Solve()

void hummingbird::ProblemBase::Solve ( const size_t ordinate_index)

Solve the linear system using Armadillo's sparse matrix solver. Stores the results in the solution_vectors_ member at the ordinate_index index.

Definition at line 52 of file problem_base.cc.

Member Data Documentation

◆ global_forcing_vectors_

std::vector<arma::Col<double> > hummingbird::ProblemBase::global_forcing_vectors_
protected

Global forcing vectors in order of ordinates in angular quadrature set.

Definition at line 181 of file problem_base.h.

◆ global_system_matrices_

std::vector<arma::SpMat<double> > hummingbird::ProblemBase::global_system_matrices_
protected

Global system matrices in order of ordinates in angular quadrature set.

Definition at line 177 of file problem_base.h.

◆ n_dofs_

const size_t hummingbird::ProblemBase::n_dofs_
protected

Number of degrees of freedom in simulation.

Definition at line 173 of file problem_base.h.

◆ solution_vectors_

std::vector<arma::Col<double> > hummingbird::ProblemBase::solution_vectors_
protected

Column vector of the angular flux at the nodes in order of ordinates in angular quadrature set.

Definition at line 185 of file problem_base.h.


The documentation for this class was generated from the following files: