21#include "libmesh/equation_systems.h"
22#include "libmesh/libmesh_logging.h"
23#include "libmesh/sparse_matrix.h"
24#include "libmesh/numeric_vector.h"
25#include "libmesh/dof_map.h"
26#include "libmesh/optimization_solver.h"
27#include "libmesh/optimization_system.h"
33 const std::string & name_in,
34 const unsigned int number_in) :
36 Parent(es, name_in, number_in),
86 cast_int<numeric_index_type>(constraint_jac_sparsity.size());
89 unsigned int n_procs =
comm().
size();
91 if (
comm().rank() < (n_eq_constraints % n_procs))
94 C_eq->init(n_eq_constraints, n_local_rows,
false,
PARALLEL);
102 cast_int<numeric_index_type>(constraint_jac_sparsity[i].size());
122 cast_int<numeric_index_type>(constraint_jac_sparsity.size());
125 unsigned int n_procs =
comm().
size();
127 if (
comm().rank() < (n_ineq_constraints % n_procs))
138 cast_int<numeric_index_type>(constraint_jac_sparsity[i].size());
156 LOG_SCOPE(
"solve()",
"OptimizationSystem");
processor_id_type size() const
This is the EquationSystems class.
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...
virtual void clear() override
Clear all the data structures associated with the system.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
This base class can be inherited from to provide interfaces to optimization solvers from different pa...
std::unique_ptr< NumericVector< Number > > C_ineq
The vector that stores inequality constraints.
void initialize_equality_constraints_storage(const std::vector< std::set< numeric_index_type > > &constraint_jac_sparsity)
Initialize storage for the equality constraints, and the corresponding Jacobian.
std::unique_ptr< NumericVector< Number > > lambda_ineq
OptimizationSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
virtual void solve() override
Solves the optimization problem.
virtual ~OptimizationSystem()
std::vector< std::set< numeric_index_type > > eq_constraint_jac_sparsity
A copy of the equality and inequality constraint Jacobian sparsity patterns.
std::vector< std::set< numeric_index_type > > ineq_constraint_jac_sparsity
std::unique_ptr< SparseMatrix< Number > > C_eq_jac
The sparse matrix that stores the Jacobian of C_eq.
std::unique_ptr< NumericVector< Number > > C_eq
The vector that stores equality constraints.
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
void initialize_inequality_constraints_storage(const std::vector< std::set< numeric_index_type > > &constraint_jac_sparsity)
Initialize storage for the inequality constraints, as per initialize_equality_constraints_storage.
std::unique_ptr< SparseMatrix< Number > > C_ineq_jac
The sparse matrix that stores the Jacobian of C_ineq.
virtual void init_data() override
Initializes new data members of the system.
std::unique_ptr< NumericVector< Number > > lambda_eq
Vectors to store the dual variables associated with equality and inequality constraints.
virtual void clear() override
Clear all the data structures associated with the system.
std::unique_ptr< OptimizationSolver< Number > > optimization_solver
The OptimizationSolver that is used for performing the optimization.
const Parallel::Communicator & comm() const
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
dof_id_type n_dofs() const
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
dof_id_type n_local_dofs() const
virtual void init_data()
Initializes the data for the system.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
const DofMap & get_dof_map() const
The libMesh namespace provides an interface to certain functionality in the library.
dof_id_type numeric_index_type