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");
This is the EquationSystems class.
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< NumericVector< Number > > lambda_ineq
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
virtual void solve() override
Solves the optimization problem.
virtual void clear() override
Clear all the data structures associated with the system.
virtual void init_data() override
Initializes new data members of the system.
virtual void init_data()
Initializes the data for the system.
std::unique_ptr< NumericVector< Number > > C_eq
The vector that stores equality constraints.
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
const Parallel::Communicator & comm() 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.
The libMesh namespace provides an interface to certain functionality in the library.
dof_id_type n_local_dofs() const
std::unique_ptr< SparseMatrix< Number > > C_ineq_jac
The sparse matrix that stores the Jacobian of C_ineq.
dof_id_type n_dofs() const
processor_id_type size() const
dof_id_type numeric_index_type
Manages consistently variables, degrees of freedom, and coefficient vectors.
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
std::vector< std::set< numeric_index_type > > ineq_constraint_jac_sparsity
std::vector< std::set< numeric_index_type > > eq_constraint_jac_sparsity
A copy of the equality and inequality constraint Jacobian sparsity patterns.
std::unique_ptr< SparseMatrix< Number > > C_eq_jac
The sparse matrix that stores the Jacobian of C_eq.
std::unique_ptr< OptimizationSolver< Number > > optimization_solver
The OptimizationSolver that is used for performing the optimization.
std::unique_ptr< NumericVector< Number > > lambda_eq
Vectors to store the dual variables associated with equality and inequality constraints.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
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.
virtual ~OptimizationSystem()
This base class can be inherited from to provide interfaces to optimization solvers from different pa...
virtual void clear() override
Clear all the data structures associated with the system.
OptimizationSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
const DofMap & get_dof_map() const
std::unique_ptr< NumericVector< Number > > C_ineq
The vector that stores inequality constraints.