OpenFCST: The open-source Fuel Cell Simulation Toolbox
|
Application handling matrices and assembling linear systems of equations. More...
#include <block_matrix_application.h>
Public Member Functions | |
void | do_assemble (const FEVectors &, typename DoFHandler< dim >::active_cell_iterator begin, typename DoFHandler< dim >::active_cell_iterator end, Threads::Mutex &mutex) |
Multithreaded assemble function called by assemble(). | |
virtual void | post_cell_assemble () |
A call back function for assemble(), called after all cell matrices have been entered, but before the face matrices are computed. | |
Constructors and Initialization | |
BlockMatrixApplication (boost::shared_ptr< ApplicationData > data=boost::shared_ptr< ApplicationData >()) | |
Constructor for an object, owning its own mesh and dof handler. | |
BlockMatrixApplication (DoFApplication< dim > &, bool triangulation_only) | |
Constructor for an object, borrowing mesh and dof handler from another object. | |
void | _initialize (ParameterHandler ¶m) |
Initialize data of this class. | |
virtual void | declare_parameters (ParameterHandler ¶m) |
Declare parameters related to matrices. | |
virtual void | initialize (ParameterHandler ¶m) |
Initialize application. | |
Data management functions | |
void | add_vector_for_cell_matrix (std::string name, unsigned int block, unsigned int components, bool values, bool derivatives) |
Add a named vector from data to be handed to the cell_matrix() function via CellInfo::values and CellInfo::derivatives. | |
void | add_vector_for_flux_matrix (std::string name, unsigned int block, unsigned int components, bool values, bool derivatives) |
Add a named vector from data to be handed to the bdry_matrix() and face_matrix() functions via FaceInfo::values and FaceInfo::derivatives. | |
ApplicationBase interface | |
void | remesh_matrices () |
Initialize sparsity patterns and matrices for the new mesh. | |
virtual void | remesh () |
Refine grid accordingly to the Refinement options under "Grid Generation" in the parameter file. | |
void | assemble (const FEVectors &) |
Loop over all cells and assemble the system #matrices by using the local matrix integration functions cell_matrix(), bdry_matrix() and face_matrix() provided by the derived class. | |
void | assemble_numerically (const FEVectors &src, const double delta=1e-6) |
Compute the Jacobian of the system of equations,
\[ J(i,j) = \frac{\partial R_i}{\partial u_j} \] | |
void | residual_constraints (FEVector &dst) const |
Redefinition of residual_constraints() in DoFHandler. | |
Local integrators | |
virtual void | cell_matrix (MatrixVector &cell_matrices, const typename DoFApplication< dim >::CellInfo &cell) |
Integration of local bilinear form. | |
virtual void | bdry_matrix (MatrixVector &face_matrices, const typename DoFApplication< dim >::FaceInfo &face) |
Integration of local bilinear form. | |
virtual void | face_matrix (MatrixVector &matrices11, MatrixVector &matrices12, MatrixVector &matrices21, MatrixVector &matrices22, const typename DoFApplication< dim >::FaceInfo &face1, const typename DoFApplication< dim >::FaceInfo &face2) |
Integration of local bilinear form. | |
Dirichlet boundary conditions | |
Member function used to set dirichlet boundary conditions. This function is application specific and it only computes the boundary_value values that are used to constraint the linear system of equations that is being solved | |
virtual void | dirichlet_bc (std::map< unsigned int, double > &boundary_values) const |
![]() | |
DoFApplication (boost::shared_ptr< ApplicationData > data=boost::shared_ptr< ApplicationData >(), bool multigrid=false) | |
Constructor for an object, owning its own mesh and dof handler. | |
DoFApplication (bool multigrid) | |
Constructor for an object owning its own mesh and dof handler and creating new ApplicationData. | |
DoFApplication (DoFApplication< dim > &, bool triangulation_only, bool multigrid=false) | |
Constructor for an object, borrowing mesh and dof handler from another object. | |
~DoFApplication () | |
Destructor which deletes owned objects. | |
void | _initialize (ParameterHandler ¶m) |
Initialize from parameter values. | |
void | add_vector_for_transfer (FEVector *) |
Add the vector to be transfered from one mesh to the next. | |
void | delete_vector_for_transfer () |
Delete the vector to be transfered from one mesh to the next. | |
virtual void | remesh_dofs () |
Initialize dof handler, count the dofs in each block and renumber the dofs. | |
virtual void | init_vector (FEVector &dst) const |
Reinitialize the BlockVector dst such that it contains block_size.size() blocks. | |
virtual double | evaluate (const FEVectors &) |
Evaluate a functional during postprocessing such as drag or lift on an aerodynamics problem. | |
virtual double | estimate (const FEVectors &src) |
Estimate the error. | |
virtual double | residual (FEVector &dst, const FEVectors &src, bool apply_boundaries=true) |
Loop over all cells to compute the residual. | |
unsigned int | memory_consumption () const |
Compute the amount of memory needed by this object. | |
virtual double | cell_estimate (const CellInfo &) |
Integration of estimate inside a cell. | |
virtual double | bdry_estimate (const FaceInfo &) |
Integration of estimate on a boundary face. | |
virtual double | face_estimate (const FaceInfo &, const FaceInfo &) |
Integration of estimate on an interior face. | |
virtual void | cell_residual (FEVector &cell_vector, const CellInfo &cell) |
Integration of local linear form. | |
virtual void | bdry_residual (FEVector &face_vector, const FaceInfo &face) |
Integration of local linear form. | |
virtual void | face_residual (FEVector &face_vector1, FEVector &face_vector2, const FaceInfo &face1, const FaceInfo &face2) |
Integration of local linear form. | |
template<class BOX , class WORKER > | |
void | integrate_1form (BOX &box, WORKER &local_forms, FEVector &dst, const FEVectors &src) |
The function integrating 1-forms as for instance used by residual(). | |
void | integrate_functional (LocalEstimate< dim > &local_forms, FEVectors &dst, const FEVectors &src) |
The function integrating functionals using local integrators. | |
void | store_triangulation (Triangulation< dim > &new_tr) |
Function to copy a triangulation object for use after refinement. | |
void | transfer_solution_to_coarse_mesh (Triangulation< dim > &tr_coarse, AppFrame::FEVector &coarse_solution, AppFrame::FEVector &refined_solution) |
Function to perform the transfer of a solution on a refined grid to the initial coarse grid. | |
void | read_init_solution (AppFrame::FEVector &dst, bool &good_solution) const |
Function to transfer a solution on a refined grid to the initial coarse grid. | |
template<class INFO , typename TYPE > | |
void | fill_local_data (const INFO &info, const std::vector< VectorSelector > &data_vector, std::vector< std::vector< std::vector< TYPE > > > &data) const |
Fill local data vector with values of the stored finite element function vectors. | |
virtual void | grid_out (const std::string &basename) |
Output the grid used to solve the problem. | |
virtual void | data_out (const std::string &basename, const FEVectors &src) |
virtual void | data_out (const std::string &basename, const FEVectors &src, const std::vector< std::string > &solution_names) |
virtual void | data_out (const std::string &basename, const FEVector &solution, const std::vector< std::string > &solution_names, const FEVector &postprocessing=FEVector(), const std::vector< std::string > &postprocessing_names=std::vector< std::string >()) |
This function outputs the results of a computation. | |
![]() | |
ApplicationBase (boost::shared_ptr< ApplicationData > ex_data=boost::shared_ptr< ApplicationData >()) | |
Constructor for an application. | |
ApplicationBase (const ApplicationBase &other) | |
Copy constructor. | |
virtual | ~ApplicationBase () |
Virtual destructor. | |
void | print_parameters_to_file (ParameterHandler ¶m, const std::string &file_name, const ParameterHandler::OutputStyle &style) |
Print default parameters for the application to a file. | |
virtual void | start_vector (FEVector &dst, std::string caller) const |
Initialize vector to problem size. | |
virtual void | solve (FEVector &start, const FEVectors &rhs) |
Solve the system assembled with right hand side rhs and return the result in start . | |
virtual void | Tsolve (FEVector &start, const FEVectors &rhs) |
Solve the dual system assembled with right hand side rhs and return the result in start . | |
virtual void | grid_out (const std::string &filename) const |
Write the mesh in the format specified by the ParameterHandler. | |
virtual void | data_out (const std::string &filename, const FEVectors &src, const std::vector< std::string >) |
boost::shared_ptr < ApplicationData > | get_data () |
Get access to the protected variable data. | |
const boost::shared_ptr < ApplicationData > | get_data () const |
Get read-only access to the protected variable data. | |
virtual std::string | id () const |
Return a unique identification string for this application. | |
virtual void | notify (const Event &reason) |
Add a reason for assembling. | |
virtual void | clear () |
Reset the application class such that a call to initialize() is possible again and will produce the same result as if the object was fresh. | |
void | clear_events () |
Clear all notifications. | |
Protected Attributes | |
Table< 2, DoFTools::Coupling > | cell_couplings |
Couplings through cell bilinear forms. | |
Table< 2, DoFTools::Coupling > | flux_couplings |
Couplings through flux bilinear forms. | |
boost::shared_ptr< Quadrature < dim > > | quadrature_assemble_cell |
Quadrature rule for matrix assembling on cells. | |
boost::shared_ptr< Quadrature < dim-1 > > | quadrature_assemble_face |
Quadrature rule for matrix assembling on faces. | |
BlockSparseMatrix< double > | matrix |
Storage for the actual matrix. | |
FilteredMatrix< BlockVector < double > > | filtered_matrix |
Wrapper for the actual matrix that contains all the boundary conditions. | |
![]() | |
std::map< unsigned int, double > | boundary_constraints |
List of all nodes constrained by a strong boundary condition, together with a value to be assigned. | |
ConstraintMatrix | hanging_node_constraints |
Constraint Matrix object. | |
boost::shared_ptr< Mapping< dim > > | mapping |
The mapping used for the transformation of mesh cells. | |
unsigned int | mapping_degree |
Degree used for polynomial mapping of arbitrary order. | |
boost::shared_ptr < Triangulation< dim > > | tr |
Pointer to the Triangulation object. | |
boost::shared_ptr < FiniteElement< dim > > | element |
The finite element used in dof. | |
boost::shared_ptr< DoFHandler < dim > > | dof |
Pointer to the DoFHandler object. | |
boost::shared_ptr < MGDoFHandler< dim > > | mg_dof |
Pointer to the MGDoFHandler object. | |
MeshWorker::BlockInfo | block_info |
Vector< float > | cell_errors |
The result of error estimation by cell. | |
Vector< float > | face_errors |
The result of error estimation by face. | |
GridOut | g_out |
The object for writing grids. | |
DataOut< dim, DoFHandler< dim > > | d_out |
The object for writing data. | |
std::vector < DataComponentInterpretation::DataComponentInterpretation > | data_interpretation |
Vector for adjusting output to vector data. | |
std::string | refinement |
Refinement parameter from parameter file. | |
unsigned int | initial_refinement |
Initial refinement from parameter file. | |
double | refinement_threshold |
Refinement threshold for adaptive method from parameter file. | |
double | coarsening_threshold |
Coarsening threshold for adaptive method from parameter file. | |
bool | sort_cuthill |
Flag for sorting with Cuthill McKee algorithm. | |
Point< dim > | sort_direction |
Direction for downstream sorting. | |
std::vector< FEVector * > | transfer_vectors |
List of vector names to be transfered from one grid to the next. | |
Quadrature< dim > | quadrature_residual_cell |
Quadrature rule for residual computation on cells. | |
Quadrature< dim-1 > | quadrature_residual_bdry |
Quadrature rule for residual computation on boundary faces. | |
Quadrature< dim-1 > | quadrature_residual_face |
Quadrature rule for residual computation on faces. | |
bool | boundary_fluxes |
Extend the integration loops in assemble() and residual() also to boundary faces. | |
bool | interior_fluxes |
Extend the integration loops in assemble() and residual() also to interior faces. | |
![]() | |
boost::shared_ptr < ApplicationData > | data |
Object for auxiliary data. | |
Event | notifications |
Accumulate reasons for reassembling here. | |
Private Attributes | |
BlockSparsityPattern | sparsities |
Sparsity patterns. | |
MeshWorker::VectorSelector | cell_matrix_values |
The set of all vector data to be used in cell_matrix(). | |
MeshWorker::VectorSelector | flux_matrix_values |
The set of all vector data to be used in bdry_matrix() and face_matrix(). | |
Additional Inherited Members | |
![]() | |
typedef MeshWorker::InfoObjects::IntegrationInfo < dim, FEValuesBase< dim > > | CellInfo |
This is a redefinition of CellInfo in order to call MeshWorker objects instead of the previous implementation in AppFrame. | |
typedef MeshWorker::InfoObjects::IntegrationInfo < dim, FEFaceValuesBase< dim > > | FaceInfo |
This is a redefinition of CellInfo in order to call MeshWorker objects instead of the previous implementation in AppFrame. | |
![]() | |
unsigned int | verbosity |
Controls verbosity of certain functions. | |
std::vector < DataComponentInterpretation::DataComponentInterpretation > | solution_interpretations |
solution_interpretations identifies whether some solution_names are scalars or parts of a vector. | |
std::vector < DataComponentInterpretation::DataComponentInterpretation > | postprocessing_interpretations |
postprocessing_interpretations identifies whether some postprocessing_names are scalars or parts of a vector. | |
bool | output_materials_and_levels |
output_materials_and_levels if true then visualized, otherwise suppressed. | |
Vector< double > | output_materials |
Vector that will be used by data_out to store the material ids. | |
Vector< double > | output_levels |
Vector that will be used by data_out to store the refinement levels at each cell. | |
![]() | |
void | constrain_boundary (FEVector &v, bool homogeneous) const |
Apply either homogeneous or inhomogeneous boundary_constraints. | |
Application handling matrices and assembling linear systems of equations.
This class inherits the information on Triangulation and DoFHandler from its base class DoFApplication. It adds information on the linear system, in particular the sparsities.
Additionally, it holds a BlockSparseMatrix as the system matrix of the finite element problem. Generic loops over mesh cells and faces are implemented in order to assemble() the system matrices and compute the residual(). These functions use the virtual local integration functions declared here and implemented by the derived actual application class.
src
.AppFrame::BlockMatrixApplication< dim >::BlockMatrixApplication | ( | boost::shared_ptr< ApplicationData > | data = boost::shared_ptr< ApplicationData >() | ) |
Constructor for an object, owning its own mesh and dof handler.
If data
is null, a new handler for application data is generated.
see constructor of DoFApplication.
AppFrame::BlockMatrixApplication< dim >::BlockMatrixApplication | ( | DoFApplication< dim > & | , |
bool | triangulation_only | ||
) |
Constructor for an object, borrowing mesh and dof handler from another object.
If triangulation_only
is true, only the triangulation is borrowed.
see constructor of DoFApplication.
void AppFrame::BlockMatrixApplication< dim >::_initialize | ( | ParameterHandler & | param | ) |
Initialize data of this class.
void AppFrame::BlockMatrixApplication< dim >::add_vector_for_cell_matrix | ( | std::string | name, |
unsigned int | block, | ||
unsigned int | components, | ||
bool | values, | ||
bool | derivatives | ||
) |
Add a named vector from data to be handed to the cell_matrix() function via CellInfo::values and CellInfo::derivatives.
void AppFrame::BlockMatrixApplication< dim >::add_vector_for_flux_matrix | ( | std::string | name, |
unsigned int | block, | ||
unsigned int | components, | ||
bool | values, | ||
bool | derivatives | ||
) |
Add a named vector from data to be handed to the bdry_matrix() and face_matrix() functions via FaceInfo::values and FaceInfo::derivatives.
void AppFrame::BlockMatrixApplication< dim >::assemble | ( | const FEVectors & | ) |
Loop over all cells and assemble the system #matrices by using the local matrix integration functions cell_matrix(), bdry_matrix() and face_matrix() provided by the derived class.
void AppFrame::BlockMatrixApplication< dim >::assemble_numerically | ( | const FEVectors & | src, |
const double | delta = 1e-6 |
||
) |
Compute the Jacobian of the system of equations,
\[ J(i,j) = \frac{\partial R_i}{\partial u_j} \]
by using forward differences.
The solution is perturbed at each degree of freedom and the residual function is used to compute the residual for each perturbed solution. Forward differences are used to compute the Jacobian.
The Jacobian is stored in this->matrix and a version with the boundary conditions already applied is stored in this->filtered_matrix
[in] | src | A vector of BlockVectors containting the solution at the previous Newton step and the residual. |
[in] | delta | The step size used for numerical differenciation. |
|
virtual |
Integration of local bilinear form.
Reimplemented in FuelCell::Application::AppCathode< dim >.
|
virtual |
Integration of local bilinear form.
Here we loop over the quadrature points and over degrees of freedom in order to compute the matrix for the cell.
Reimplemented in FuelCell::Application::AppCathode< dim >, FuelCell::Application::AppPemfc< dim >, and FuelCell::Application::AppLaplace< dim >.
|
virtual |
Declare parameters related to matrices.
Reimplemented from AppFrame::DoFApplication< dim >.
Reimplemented in FuelCell::Application::AppCathode< dim >, FuelCell::Application::AppPemfc< dim >, FuelCell::Application::AppReadMesh< dim >, FuelCell::Application::AppLaplace< dim >, and AppFrame::OptimizationBlockMatrixApplication< dim >.
|
virtual |
void AppFrame::BlockMatrixApplication< dim >::do_assemble | ( | const FEVectors & | , |
typename DoFHandler< dim >::active_cell_iterator | begin, | ||
typename DoFHandler< dim >::active_cell_iterator | end, | ||
Threads::Mutex & | mutex | ||
) |
Multithreaded assemble function called by assemble().
|
virtual |
Integration of local bilinear form.
|
virtual |
Initialize application.
Reimplemented from AppFrame::DoFApplication< dim >.
Reimplemented in FuelCell::Application::AppCathode< dim >, FuelCell::Application::AppPemfc< dim >, FuelCell::Application::AppLaplace< dim >, FuelCell::Application::AppReadMesh< dim >, and AppFrame::OptimizationBlockMatrixApplication< dim >.
|
virtual |
A call back function for assemble(), called after all cell matrices have been entered, but before the face matrices are computed.
|
virtual |
Refine grid accordingly to the Refinement options under "Grid Generation" in the parameter file.
Reimplemented from AppFrame::DoFApplication< dim >.
void AppFrame::BlockMatrixApplication< dim >::remesh_matrices | ( | ) |
Initialize sparsity patterns and matrices for the new mesh.
|
virtual |
Redefinition of residual_constraints() in DoFHandler.
In this member function, I adjust the residual in order to account for hanging nodes and I apply Dirichlet boundary conditions given by dirichlet_bc().
Reimplemented from AppFrame::DoFApplication< dim >.
|
protected |
Couplings through cell bilinear forms.
cell_coupling allows to specify which variables couple with which equations. This is used by DoFTools to generate a sparsity pattern that does not contain elements unless specified in the cell_coupings, therefore, reducing the amount of memory needed.
Example: For the 2D Stokes equations
\begin{eqnarray*} \frac{d^2u}{dx^2} +\frac{d^2u}{dy^2} + \frac{dp}{dx} = 0 \\ \frac{d^2v}{dx^2} +\frac{d^2v}{dy^2} + \frac{dp}{dy} = 0 \\ \frac{du}{dx} +\frac{dv}{dy} = 0 \end{eqnarray*}
we need to initialize cell_coupling to:
* cell_coupling.reinit(3,3); * cell_coupling(0,0) = DoFTools::always; * cell_coupling(0,1) = DoFTools::zero; * cell_couplings(0,2) = DoFTools::always; * cell_couplings(1,0) = DoFTools::zero; * ... *
|
private |
The set of all vector data to be used in cell_matrix().
|
protected |
Wrapper for the actual matrix that contains all the boundary conditions.
This is the matrix that should be used to solve the linear system of equations and NOT matrix.
|
protected |
Couplings through flux bilinear forms.
|
private |
The set of all vector data to be used in bdry_matrix() and face_matrix().
|
protected |
Storage for the actual matrix.
|
protected |
Quadrature rule for matrix assembling on cells.
|
protected |
Quadrature rule for matrix assembling on faces.
|
private |
Sparsity patterns.