This class implements a system for solution of nonlinear systems.
The class also provides a mechanism to solve associated eigenproblems . The user needs to provide an eigenproblem assembly class to assemble the A and B matrices.
Definition at line 56 of file nonlinear_system.h.
#include <nonlinear_system.h>
Public Types | |
enum | Operation { NONLINEAR_SOLVE, EIGENPROBLEM_SOLVE, FORWARD_SENSITIVITY_SOLVE, ADJOINT_SOLVE, NONE } |
Public Member Functions | |
NonlinearSystem (libMesh::EquationSystems &es, const std::string &name, const unsigned int number) | |
Default constructor. More... | |
virtual | ~NonlinearSystem () |
virtual void | adjoint_solve (const libMesh::NumericVector< Real > &X, bool if_localize_sol, MAST::AssemblyElemOperations &elem_ops, MAST::OutputAssemblyElemOperations &output, MAST::AssemblyBase &assembly, bool if_assemble_jacobian=true) |
solves the adjoint problem for the provided output function. More... | |
virtual void | clear () libmesh_override |
Clear all the data structures associated with the system. More... | |
virtual void | eigenproblem_sensitivity_solve (MAST::AssemblyElemOperations &elem_ops, MAST::EigenproblemAssembly &assembly, const MAST::FunctionBase &f, std::vector< Real > &sens, const std::vector< unsigned int > *indices=nullptr) |
Solves the sensitivity system, for the provided parameters. More... | |
virtual void | eigenproblem_solve (MAST::AssemblyElemOperations &elem_ops, MAST::EigenproblemAssembly &assembly) |
Assembles & solves the eigen system. More... | |
bool | generalized () const |
virtual void | get_eigenpair (unsigned int i, Real &re, Real &im, libMesh::NumericVector< Real > &vec_re, libMesh::NumericVector< Real > *vec_im=nullptr) |
gets the real and imaginary parts of the ith eigenvalue for the eigenproblem , and the associated eigenvector. More... | |
libMesh::EigenProblemType | get_eigenproblem_type () const |
virtual void | get_eigenvalue (unsigned int i, Real &re, Real &im) |
gets the real and imaginary parts of the ith eigenvalue for the eigenproblem , and the associated eigenvector. More... | |
virtual std::pair< unsigned int, Real > | get_linear_solve_parameters () |
calls NonlinearImplicitSystem::set_solver_parameters() before accessing the values. More... | |
unsigned int | get_n_converged_eigenvalues () const |
unsigned int | get_n_iterations () const |
unsigned int | get_n_requested_eigenvalues () const |
void | initialize_condensed_dofs (MAST::PhysicsDisciplineBase &physics) |
Loop over the dofs on each processor to initialize the list of non-condensed dofs. More... | |
unsigned int | n_global_non_condensed_dofs () const |
MAST::NonlinearSystem::Operation | operation () |
void | project_vector_without_dirichlet (libMesh::NumericVector< Real > &new_vector, libMesh::FunctionBase< Real > &f) const |
void | read_in_vector (libMesh::NumericVector< Real > &vec, const std::string &directory_name, const std::string &data_name, const bool read_binary_vectors) |
reads the specified vector with the specified name in a directory. More... | |
virtual void | reinit () libmesh_override |
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used. More... | |
virtual void | sensitivity_solve (const libMesh::NumericVector< Real > &X, bool if_localize_sol, MAST::AssemblyElemOperations &elem_ops, MAST::AssemblyBase &assembly, const MAST::FunctionBase &p, bool if_assemble_jacobian=true) |
Solves the sensitivity problem for the provided parameter. More... | |
void | set_eigenproblem_type (libMesh::EigenProblemType ept) |
Sets the type of the current eigen problem. More... | |
void | set_exchange_A_and_B (bool flag) |
sets the flag to exchange the A and B matrices for a generalized eigenvalue problem. More... | |
void | set_init_B_matrix () |
flag to also initialize the B matrix. More... | |
void | set_n_requested_eigenvalues (unsigned int n) |
sets the number of eigenvalues requested More... | |
void | set_operation (MAST::NonlinearSystem::Operation op) |
sets the current operation of the system More... | |
virtual void | solve (MAST::AssemblyElemOperations &elem_ops, MAST::AssemblyBase &assembly) |
solves the nonlinear problem with the specified assembly operation object More... | |
void | write_out_vector (libMesh::NumericVector< Real > &vec, const std::string &directory_name, const std::string &data_name, const bool write_binary_vectors) |
writes the specified vector with the specified name in a directory. More... | |
Public Attributes | |
std::unique_ptr< MAST::SlepcEigenSolver > | eigen_solver |
The EigenSolver, definig which interface, i.e solver package to use. More... | |
std::unique_ptr< libMesh::LinearSolver< Real > > | linear_solver |
The LinearSolver for solution of the linear equations. More... | |
libMesh::SparseMatrix< Real > * | matrix_A |
The system matrix for standard eigenvalue problems. More... | |
libMesh::SparseMatrix< Real > * | matrix_B |
A second system matrix for generalized eigenvalue problems. More... | |
Protected Member Functions | |
virtual void | init_data () libmesh_override |
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used. More... | |
void | set_n_converged (unsigned int nconv) |
Set the _n_converged_eigenpairs member, useful for subclasses of EigenSystem. More... | |
void | set_n_iterations (unsigned int its) |
Set the _n_iterations member, useful for subclasses of EigenSystem. More... | |
Protected Attributes | |
bool | _condensed_dofs_initialized |
A private flag to indicate whether the condensed dofs have been initialized. More... | |
libMesh::EigenProblemType | _eigen_problem_type |
The type of the eigenvalue problem. More... | |
bool | _exchange_A_and_B |
flag to exchange the A and B matrices in the eigenproblem solution More... | |
bool | _initialize_B_matrix |
initialize the B matrix in addition to A, which might be needed for solution of complex system of equations using PC field split More... | |
bool | _is_generalized_eigenproblem |
A boolean flag to indicate whether we are dealing with a generalized eigenvalue problem. More... | |
std::vector< libMesh::dof_id_type > | _local_non_condensed_dofs_vector |
Vector storing the local dof indices that will not be condensed. More... | |
unsigned int | _n_converged_eigenpairs |
The number of converged eigenpairs. More... | |
unsigned int | _n_iterations |
The number of iterations of the eigen solver algorithm. More... | |
unsigned int | _n_requested_eigenpairs |
The number of requested eigenpairs. More... | |
MAST::NonlinearSystem::Operation | _operation |
current operation of the system More... | |
Enumerator | |
---|---|
NONLINEAR_SOLVE | |
EIGENPROBLEM_SOLVE | |
FORWARD_SENSITIVITY_SOLVE | |
ADJOINT_SOLVE | |
NONE |
Definition at line 72 of file nonlinear_system.h.
MAST::NonlinearSystem::NonlinearSystem | ( | libMesh::EquationSystems & | es, |
const std::string & | name, | ||
const unsigned int | number | ||
) |
Default constructor.
Definition at line 53 of file nonlinear_system.cpp.
|
virtual |
Definition at line 74 of file nonlinear_system.cpp.
|
virtual |
solves the adjoint problem for the provided output function.
The Jacobian will be assembled before adjoint solve if if_assemble_jacobian
is true
.
Definition at line 799 of file nonlinear_system.cpp.
|
virtual |
Clear all the data structures associated with the system.
Definition at line 84 of file nonlinear_system.cpp.
|
virtual |
Solves the sensitivity system, for the provided parameters.
Sensitivity of eigenvalues are returned in sens
. This is more If only a subset of sensitivities are needed, then the indices can be passed in the last argument. If the last argument is not provided, then sensitivity of all eigenvalues will be computed and returned in sens
.
Definition at line 556 of file nonlinear_system.cpp.
|
virtual |
Assembles & solves the eigen system.
Definition at line 240 of file nonlinear_system.cpp.
|
inline |
Definition at line 261 of file nonlinear_system.h.
|
virtual |
gets the real and imaginary parts of the ith eigenvalue for the eigenproblem , and the associated eigenvector.
The returned eigenvector will be scaled such that it has a unit inner product with respect to the B matrix.
Note that eigen problem type HEP or GHEP, vec_im
must be nullptr, and for eigenproblem type NHEP or GNHEP, the real and imag parts of the eigenvector are copied to vec_re
and vec_im
, respectively. If vec_im
is not provided, then only the real part will be copied to vec_re
.
Definition at line 408 of file nonlinear_system.cpp.
|
inline |
Definition at line 255 of file nonlinear_system.h.
gets the real and imaginary parts of the ith eigenvalue for the eigenproblem , and the associated eigenvector.
Definition at line 388 of file nonlinear_system.cpp.
|
virtual |
calls NonlinearImplicitSystem::set_solver_parameters() before accessing the values.
Definition at line 202 of file nonlinear_system.cpp.
|
inline |
Definition at line 233 of file nonlinear_system.h.
|
inline |
Definition at line 244 of file nonlinear_system.h.
|
inline |
Definition at line 239 of file nonlinear_system.h.
|
protectedvirtual |
Initializes the member data fields associated with the system, so that, e.g., assemble()
may be used.
Definition at line 115 of file nonlinear_system.cpp.
void MAST::NonlinearSystem::initialize_condensed_dofs | ( | MAST::PhysicsDisciplineBase & | physics | ) |
Loop over the dofs on each processor to initialize the list of non-condensed dofs.
These are the dofs in the system that are not contained in global_dirichlet_dofs_set
.
Definition at line 691 of file nonlinear_system.cpp.
unsigned int MAST::NonlinearSystem::n_global_non_condensed_dofs | ( | ) | const |
|
inline |
Definition at line 84 of file nonlinear_system.h.
void MAST::NonlinearSystem::project_vector_without_dirichlet | ( | libMesh::NumericVector< Real > & | new_vector, |
libMesh::FunctionBase< Real > & | f | ||
) | const |
Definition at line 986 of file nonlinear_system.cpp.
void MAST::NonlinearSystem::read_in_vector | ( | libMesh::NumericVector< Real > & | vec, |
const std::string & | directory_name, | ||
const std::string & | data_name, | ||
const bool | read_binary_vectors | ||
) |
reads the specified vector with the specified name in a directory.
Definition at line 911 of file nonlinear_system.cpp.
|
virtual |
Reinitializes the member data fields associated with the system, so that, e.g., assemble()
may be used.
Definition at line 164 of file nonlinear_system.cpp.
|
virtual |
Solves the sensitivity problem for the provided parameter.
The Jacobian will be assembled before adjoint solve if if_assemble_jacobian
is true
.
Definition at line 742 of file nonlinear_system.cpp.
void MAST::NonlinearSystem::set_eigenproblem_type | ( | libMesh::EigenProblemType | ept | ) |
Sets the type of the current eigen problem.
Definition at line 105 of file nonlinear_system.cpp.
|
inline |
sets the flag to exchange the A and B matrices for a generalized eigenvalue problem.
This is needed typically when the B matrix is not positive semi-definite.
Definition at line 220 of file nonlinear_system.h.
|
inline |
flag to also initialize the B matrix.
Must be called before EquationsSystems::init(). This is false by default.
Definition at line 102 of file nonlinear_system.h.
|
inlineprotected |
Set the _n_converged_eigenpairs member, useful for subclasses of EigenSystem.
Definition at line 334 of file nonlinear_system.h.
|
inlineprotected |
Set the _n_iterations member, useful for subclasses of EigenSystem.
Definition at line 341 of file nonlinear_system.h.
|
inline |
sets the number of eigenvalues requested
Definition at line 225 of file nonlinear_system.h.
|
inline |
sets the current operation of the system
Definition at line 93 of file nonlinear_system.h.
|
virtual |
solves the nonlinear problem with the specified assembly operation object
Definition at line 210 of file nonlinear_system.cpp.
void MAST::NonlinearSystem::write_out_vector | ( | libMesh::NumericVector< Real > & | vec, |
const std::string & | directory_name, | ||
const std::string & | data_name, | ||
const bool | write_binary_vectors | ||
) |
writes the specified vector with the specified name in a directory.
Definition at line 854 of file nonlinear_system.cpp.
|
protected |
A private flag to indicate whether the condensed dofs have been initialized.
Definition at line 356 of file nonlinear_system.h.
|
protected |
The type of the eigenvalue problem.
Definition at line 387 of file nonlinear_system.h.
|
protected |
flag to exchange the A and B matrices in the eigenproblem solution
Definition at line 366 of file nonlinear_system.h.
|
protected |
initialize the B matrix in addition to A, which might be needed for solution of complex system of equations using PC field split
Definition at line 349 of file nonlinear_system.h.
|
protected |
A boolean flag to indicate whether we are dealing with a generalized eigenvalue problem.
Definition at line 382 of file nonlinear_system.h.
|
protected |
Vector storing the local dof indices that will not be condensed.
All dofs that are not in this vector will be eliminated from the system when we perform a solve.
Definition at line 399 of file nonlinear_system.h.
|
protected |
The number of converged eigenpairs.
Definition at line 371 of file nonlinear_system.h.
|
protected |
The number of iterations of the eigen solver algorithm.
Definition at line 376 of file nonlinear_system.h.
|
protected |
The number of requested eigenpairs.
Definition at line 361 of file nonlinear_system.h.
|
protected |
current operation of the system
Definition at line 392 of file nonlinear_system.h.
std::unique_ptr<MAST::SlepcEigenSolver> MAST::NonlinearSystem::eigen_solver |
The EigenSolver, definig which interface, i.e solver package to use.
Definition at line 279 of file nonlinear_system.h.
std::unique_ptr<libMesh::LinearSolver<Real> > MAST::NonlinearSystem::linear_solver |
The LinearSolver for solution of the linear equations.
Definition at line 284 of file nonlinear_system.h.
libMesh::SparseMatrix<Real>* MAST::NonlinearSystem::matrix_A |
The system matrix for standard eigenvalue problems.
Definition at line 267 of file nonlinear_system.h.
libMesh::SparseMatrix<Real>* MAST::NonlinearSystem::matrix_B |
A second system matrix for generalized eigenvalue problems.
Definition at line 272 of file nonlinear_system.h.