MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
MAST::NonlinearSystem Class Reference

Detailed Description

This class implements a system for solution of nonlinear systems.

The class also provides a mechanism to solve associated eigenproblems $ {\bf A} {\bf x} = \lambda {\bf B} {\bf x} $. 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>

Inheritance diagram for MAST::NonlinearSystem:
Collaboration diagram for MAST::NonlinearSystem:

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 $ {\bf A} {\bf x} = \lambda {\bf B} {\bf x} $, 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 $ {\bf A} {\bf x} = \lambda {\bf B} {\bf x} $, and the associated eigenvector. More...
 
virtual std::pair< unsigned int, Realget_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::SlepcEigenSolvereigen_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...
 

Member Enumeration Documentation

◆ Operation

Enumerator
NONLINEAR_SOLVE 
EIGENPROBLEM_SOLVE 
FORWARD_SENSITIVITY_SOLVE 
ADJOINT_SOLVE 
NONE 

Definition at line 72 of file nonlinear_system.h.

Constructor & Destructor Documentation

◆ NonlinearSystem()

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.

◆ ~NonlinearSystem()

MAST::NonlinearSystem::~NonlinearSystem ( )
virtual

Definition at line 74 of file nonlinear_system.cpp.

Member Function Documentation

◆ adjoint_solve()

void MAST::NonlinearSystem::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 
)
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.

◆ clear()

void MAST::NonlinearSystem::clear ( )
virtual

Clear all the data structures associated with the system.

Definition at line 84 of file nonlinear_system.cpp.

◆ eigenproblem_sensitivity_solve()

void MAST::NonlinearSystem::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 
)
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.

◆ eigenproblem_solve()

void MAST::NonlinearSystem::eigenproblem_solve ( MAST::AssemblyElemOperations elem_ops,
MAST::EigenproblemAssembly assembly 
)
virtual

Assembles & solves the eigen system.

Definition at line 240 of file nonlinear_system.cpp.

◆ generalized()

bool MAST::NonlinearSystem::generalized ( ) const
inline
Returns
true if the underlying problem is generalized , false otherwise.

Definition at line 261 of file nonlinear_system.h.

◆ get_eigenpair()

void MAST::NonlinearSystem::get_eigenpair ( unsigned int  i,
Real re,
Real im,
libMesh::NumericVector< Real > &  vec_re,
libMesh::NumericVector< Real > *  vec_im = nullptr 
)
virtual

gets the real and imaginary parts of the ith eigenvalue for the eigenproblem $ {\bf A} {\bf x} = \lambda {\bf B} {\bf x} $, 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.

◆ get_eigenproblem_type()

libMesh::EigenProblemType MAST::NonlinearSystem::get_eigenproblem_type ( ) const
inline
Returns
the eigen problem type.

Definition at line 255 of file nonlinear_system.h.

◆ get_eigenvalue()

void MAST::NonlinearSystem::get_eigenvalue ( unsigned int  i,
Real re,
Real im 
)
virtual

gets the real and imaginary parts of the ith eigenvalue for the eigenproblem $ {\bf A} {\bf x} = \lambda {\bf B} {\bf x} $, and the associated eigenvector.

Definition at line 388 of file nonlinear_system.cpp.

◆ get_linear_solve_parameters()

std::pair< unsigned int, Real > MAST::NonlinearSystem::get_linear_solve_parameters ( )
virtual

calls NonlinearImplicitSystem::set_solver_parameters() before accessing the values.

Definition at line 202 of file nonlinear_system.cpp.

◆ get_n_converged_eigenvalues()

unsigned int MAST::NonlinearSystem::get_n_converged_eigenvalues ( ) const
inline
Returns
the number of converged eigenpairs.

Definition at line 233 of file nonlinear_system.h.

◆ get_n_iterations()

unsigned int MAST::NonlinearSystem::get_n_iterations ( ) const
inline
Returns
the number of eigen solver iterations.

Definition at line 244 of file nonlinear_system.h.

◆ get_n_requested_eigenvalues()

unsigned int MAST::NonlinearSystem::get_n_requested_eigenvalues ( ) const
inline
Returns
the number of requested eigenpairs.

Definition at line 239 of file nonlinear_system.h.

◆ init_data()

void MAST::NonlinearSystem::init_data ( )
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.

◆ initialize_condensed_dofs()

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.

◆ n_global_non_condensed_dofs()

unsigned int MAST::NonlinearSystem::n_global_non_condensed_dofs ( ) const
Returns
the global number of non-condensed dofs in the system.

◆ operation()

MAST::NonlinearSystem::Operation MAST::NonlinearSystem::operation ( )
inline
Returns
the current operation of the system

Definition at line 84 of file nonlinear_system.h.

◆ project_vector_without_dirichlet()

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.

◆ read_in_vector()

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.

◆ reinit()

void MAST::NonlinearSystem::reinit ( )
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.

◆ sensitivity_solve()

void MAST::NonlinearSystem::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 
)
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.

◆ set_eigenproblem_type()

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.

◆ set_exchange_A_and_B()

void MAST::NonlinearSystem::set_exchange_A_and_B ( bool  flag)
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.

◆ set_init_B_matrix()

void MAST::NonlinearSystem::set_init_B_matrix ( )
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.

◆ set_n_converged()

void MAST::NonlinearSystem::set_n_converged ( unsigned int  nconv)
inlineprotected

Set the _n_converged_eigenpairs member, useful for subclasses of EigenSystem.

Definition at line 334 of file nonlinear_system.h.

◆ set_n_iterations()

void MAST::NonlinearSystem::set_n_iterations ( unsigned int  its)
inlineprotected

Set the _n_iterations member, useful for subclasses of EigenSystem.

Definition at line 341 of file nonlinear_system.h.

◆ set_n_requested_eigenvalues()

void MAST::NonlinearSystem::set_n_requested_eigenvalues ( unsigned int  n)
inline

sets the number of eigenvalues requested

Definition at line 225 of file nonlinear_system.h.

◆ set_operation()

void MAST::NonlinearSystem::set_operation ( MAST::NonlinearSystem::Operation  op)
inline

sets the current operation of the system

Definition at line 93 of file nonlinear_system.h.

◆ solve()

void MAST::NonlinearSystem::solve ( MAST::AssemblyElemOperations elem_ops,
MAST::AssemblyBase assembly 
)
virtual

solves the nonlinear problem with the specified assembly operation object

Definition at line 210 of file nonlinear_system.cpp.

◆ write_out_vector()

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.

Member Data Documentation

◆ _condensed_dofs_initialized

bool MAST::NonlinearSystem::_condensed_dofs_initialized
protected

A private flag to indicate whether the condensed dofs have been initialized.

Definition at line 356 of file nonlinear_system.h.

◆ _eigen_problem_type

libMesh::EigenProblemType MAST::NonlinearSystem::_eigen_problem_type
protected

The type of the eigenvalue problem.

Definition at line 387 of file nonlinear_system.h.

◆ _exchange_A_and_B

bool MAST::NonlinearSystem::_exchange_A_and_B
protected

flag to exchange the A and B matrices in the eigenproblem solution

Definition at line 366 of file nonlinear_system.h.

◆ _initialize_B_matrix

bool MAST::NonlinearSystem::_initialize_B_matrix
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.

◆ _is_generalized_eigenproblem

bool MAST::NonlinearSystem::_is_generalized_eigenproblem
protected

A boolean flag to indicate whether we are dealing with a generalized eigenvalue problem.

Definition at line 382 of file nonlinear_system.h.

◆ _local_non_condensed_dofs_vector

std::vector<libMesh::dof_id_type> MAST::NonlinearSystem::_local_non_condensed_dofs_vector
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.

◆ _n_converged_eigenpairs

unsigned int MAST::NonlinearSystem::_n_converged_eigenpairs
protected

The number of converged eigenpairs.

Definition at line 371 of file nonlinear_system.h.

◆ _n_iterations

unsigned int MAST::NonlinearSystem::_n_iterations
protected

The number of iterations of the eigen solver algorithm.

Definition at line 376 of file nonlinear_system.h.

◆ _n_requested_eigenpairs

unsigned int MAST::NonlinearSystem::_n_requested_eigenpairs
protected

The number of requested eigenpairs.

Definition at line 361 of file nonlinear_system.h.

◆ _operation

MAST::NonlinearSystem::Operation MAST::NonlinearSystem::_operation
protected

current operation of the system

Definition at line 392 of file nonlinear_system.h.

◆ eigen_solver

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.

◆ linear_solver

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.

◆ matrix_A

libMesh::SparseMatrix<Real>* MAST::NonlinearSystem::matrix_A

The system matrix for standard eigenvalue problems.

Definition at line 267 of file nonlinear_system.h.

◆ matrix_B

libMesh::SparseMatrix<Real>* MAST::NonlinearSystem::matrix_B

A second system matrix for generalized eigenvalue problems.

Definition at line 272 of file nonlinear_system.h.


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