Go to the documentation of this file.
23 #include "libmesh/equation_systems.h"
24 #include "libmesh/libmesh_logging.h"
25 #include "libmesh/sparse_matrix.h"
26 #include "libmesh/numeric_vector.h"
27 #include "libmesh/dof_map.h"
28 #include "libmesh/optimization_solver.h"
29 #include "libmesh/optimization_system.h"
37 const std::string & name_in,
38 const unsigned int number_in) :
40 Parent(es, name_in, number_in),
94 cast_int<numeric_index_type>(constraint_jac_sparsity.size());
97 unsigned int n_procs =
comm().size();
99 if (
comm().rank() < (n_eq_constraints % n_procs))
102 C_eq->init(n_eq_constraints, n_local_rows,
false,
PARALLEL);
110 cast_int<numeric_index_type>(constraint_jac_sparsity[i].size());
130 cast_int<numeric_index_type>(constraint_jac_sparsity.size());
133 unsigned int n_procs =
comm().size();
135 if (
comm().rank() < (n_ineq_constraints % n_procs))
146 cast_int<numeric_index_type>(constraint_jac_sparsity[i].size());
164 START_LOG(
"solve()",
"OptimizationSystem");
169 STOP_LOG(
"solve()",
"OptimizationSystem");
Manages consistently variables, degrees of freedom, and coefficient vectors.
std::unique_ptr< NumericVector< Number > > C_ineq
The vector that stores inequality constraints.
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.
OptimizationSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
virtual void solve() override
Solves the optimization problem.
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
The libMesh namespace provides an interface to certain functionality in the library.
const Parallel::Communicator & comm() const
virtual void init_data() override
Initializes new data members of the system.
std::unique_ptr< NumericVector< Number > > lambda_ineq
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
std::unique_ptr< NumericVector< Number > > C_eq
The vector that stores equality constraints.
This base class can be inherited from to provide interfaces to optimization solvers from different pa...
dof_id_type n_local_dofs() const
virtual void clear() override
Clear all the data structures associated with the system.
std::unique_ptr< SparseMatrix< Number > > C_ineq_jac
The sparse matrix that stores the Jacobian of C_ineq.
std::unique_ptr< OptimizationSolver< Number > > optimization_solver
The OptimizationSolver that is used for performing the optimization.
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.
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
dof_id_type numeric_index_type
This is the EquationSystems class.
std::vector< std::set< numeric_index_type > > eq_constraint_jac_sparsity
A copy of the equality and inequality constraint Jacobian sparsity patterns.
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_eq
Vectors to store the dual variables associated with equality and inequality constraints.
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
const DofMap & get_dof_map() const
dof_id_type n_dofs() const
virtual void clear() override
Clear all the data structures associated with the system.
virtual void init_data() override
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
virtual ~OptimizationSystem()
Destructor.
virtual void update()
Update the local values to reflect the solution on neighboring processors.