1 #ifndef __FLOWCONSTRAINTS_H__ 2 #define __FLOWCONSTRAINTS_H__ 4 #include <deal.II/optimization/rol/vector_adaptor.h> 7 #include "ROL_Constraint_SimOpt.hpp" 8 #include "design_parameterization/base_parameterization.hpp" 9 #include "dg/dg_base.hpp" 10 #include "linear_solver/linear_solver.h" 11 #include "parameters/all_parameters.h" 15 using dealii_Vector = dealii::LinearAlgebra::distributed::Vector<double>;
16 using AdaptVector = dealii::Rol::VectorAdaptor<dealii_Vector>;
33 std::shared_ptr<DGBase<dim,double>>
dg;
44 dealii::LinearAlgebra::distributed::Vector<double>
design_var;
61 dealii::TrilinosWrappers::SparseMatrix
dXvdXp;
64 using ROL::Constraint_SimOpt<double>::value;
69 using ROL::Constraint_SimOpt<double>::applyAdjointJacobian_1;
79 using ROL::Constraint_SimOpt<double>::applyAdjointJacobian_2;
90 std::shared_ptr<dealii::TrilinosWrappers::SparseMatrix> precomputed_dXvdXp =
nullptr);
96 void update_1(
const ROL::Vector<double>& des_var_sim,
bool flag =
true,
int iter = -1 );
101 void update_2(
const ROL::Vector<double>& des_var_ctl,
bool flag =
true,
int iter = -1 );
108 ROL::Vector<double>& constraint_values,
109 ROL::Vector<double>& des_var_sim,
110 const ROL::Vector<double>& des_var_ctl,
116 ROL::Vector<double>& constraint_values,
117 const ROL::Vector<double>& des_var_sim,
118 const ROL::Vector<double>& des_var_ctl,
124 ROL::Vector<double>& output_vector,
125 const ROL::Vector<double>& input_vector,
126 const ROL::Vector<double>& des_var_sim,
127 const ROL::Vector<double>& des_var_ctl,
133 ROL::Vector<double>& output_vector,
134 const ROL::Vector<double>& input_vector,
135 const ROL::Vector<double>& des_var_sim,
136 const ROL::Vector<double>& des_var_ctl,
142 ROL::Vector<double>& output_vector,
143 const ROL::Vector<double>& input_vector,
144 const ROL::Vector<double>& des_var_sim,
145 const ROL::Vector<double>& des_var_ctl,
151 const ROL::Vector<double>& des_var_sim,
152 const ROL::Vector<double>& des_var_ctl);
161 ROL::Vector<double>& output_vector,
162 const ROL::Vector<double>& input_vector,
163 const ROL::Vector<double>& des_var_sim,
164 const ROL::Vector<double>& des_var_ctl,
170 const ROL::Vector<double>& des_var_sim,
171 const ROL::Vector<double>& des_var_ctl);
180 ROL::Vector<double>& output_vector,
181 const ROL::Vector<double>& input_vector,
182 const ROL::Vector<double>& des_var_sim,
183 const ROL::Vector<double>& des_var_ctl,
189 ROL::Vector<double>& output_vector,
190 const ROL::Vector<double>& input_vector,
191 const ROL::Vector<double>& des_var_sim,
192 const ROL::Vector<double>& des_var_ctl,
198 ROL::Vector<double>& output_vector,
199 const ROL::Vector<double>& input_vector,
200 const ROL::Vector<double>& des_var_sim,
201 const ROL::Vector<double>& des_var_ctl,
208 ROL::Vector<double>& output_vector,
209 const ROL::Vector<double>& input_vector,
210 const ROL::Vector<double>& des_var_sim,
211 const ROL::Vector<double>& des_var_ctl,
223 ROL::Vector<double> &output_vector,
224 const ROL::Vector<double> &dual,
225 const ROL::Vector<double> &input_vector,
226 const ROL::Vector<double> &des_var_sim,
227 const ROL::Vector<double> &des_var_ctl,
239 ROL::Vector<double> &output_vector,
240 const ROL::Vector<double> &dual,
241 const ROL::Vector<double> &input_vector,
242 const ROL::Vector<double> &des_var_sim,
243 const ROL::Vector<double> &des_var_ctl,
255 ROL::Vector<double> &output_vector,
256 const ROL::Vector<double> &dual,
257 const ROL::Vector<double> &input_vector,
258 const ROL::Vector<double> &des_var_sim,
259 const ROL::Vector<double> &des_var_ctl,
278 ROL::Vector<double> &output_vector,
279 const ROL::Vector<double> &dual,
280 const ROL::Vector<double> &input_vector,
281 const ROL::Vector<double> &des_var_sim,
282 const ROL::Vector<double> &des_var_ctl,
void applyAdjointJacobian_1(ROL::Vector< double > &output_vector, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Applies the Jacobian of the Constraints w. r. t. the simulation variables onto a vector.
void update_1(const ROL::Vector< double > &des_var_sim, bool flag=true, int iter=-1)
Update the simulation variables.
Parameters related to the linear solver.
void applyAdjointJacobian_2(ROL::Vector< double > &output_vector, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Applies the Jacobian of the Constraints w. r. t. the control variables onto a vector.
void applyAdjointHessian_12(ROL::Vector< double > &output_vector, const ROL::Vector< double > &dual, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &tol) override
Applies the adjoint of the Hessian of the constraints w. r. t. the simulation variables onto a vector...
Parameters::LinearSolverParam linear_solver_param
Linear solver parameters.
int i_out
ID used when outputting the flow solution.
void applyInverseAdjointJacobianPreconditioner_1(ROL::Vector< double > &output_vector, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &)
Applies the inverse Adjoint Jacobian preconditioner.
void destroy_JacobianPreconditioner_1()
Frees Jacobian preconditioner from memory;.
const bool i_print
Whether the current processor should print or not.
void destroy_AdjointJacobianPreconditioner_1()
Frees adjoint Jacobian preconditioner from memory;.
Files for the baseline physics.
void applyJacobian_2(ROL::Vector< double > &output_vector, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Applies the Jacobian of the Constraints w. r. t. the control variables onto a vector.
void applyInverseJacobian_1(ROL::Vector< double > &output_vector, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Applies the inverse Jacobian of the Constraints w. r. t. the simulation variables onto a vector...
void applyAdjointHessian_11(ROL::Vector< double > &output_vector, const ROL::Vector< double > &dual, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &tol) override
Applies the adjoint of the Hessian of the constraints w. r. t. the simulation variables onto a vector...
void applyJacobian_1(ROL::Vector< double > &output_vector, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Applies the Jacobian of the Constraints w. r. t. the simulation variables onto a vector.
const int mpi_rank
MPI rank used for printing.
void value(ROL::Vector< double > &constraint_values, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Returns the current constraint residual given a set of control and simulation variables.
void solve(ROL::Vector< double > &constraint_values, ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Solve the Simulation Constraint and returns the constraints values.
Abstract class for design parameterization. Objective function and the constraints take this class's ...
double flow_CFL_
Regularization of the constraint by adding flow_CFL_ times the mass matrix.
Use DGBase as a Simulation Constraint ROL::Constraint_SimOpt.
Ifpack_Preconditioner * adjoint_jacobian_prec
Adjoint Jacobian preconditioner.
dealii::LinearAlgebra::distributed::Vector< double > design_var
Design variables values.
~FlowConstraints()
Destructor.
int construct_AdjointJacobianPreconditioner_1(const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl)
Constructs the Adjoint Jacobian preconditioner.
void applyInverseAdjointJacobian_1(ROL::Vector< double > &output_vector, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Applies the adjoint Jacobian of the Constraints w. r. t. the simulation variables onto a vector...
Ifpack_Preconditioner * jacobian_prec
Jacobian preconditioner.
void applyInverseJacobianPreconditioner_1(ROL::Vector< double > &output_vector, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &)
Applies the inverse Jacobian preconditioner.
void applyAdjointHessian_22(ROL::Vector< double > &output_vector, const ROL::Vector< double > &dual, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &tol) override
Applies the adjoint of the Hessian of the constraints w. r. t. the simulation variables onto a vector...
int iupdate
ID used when outputting the flow solution.
void update_2(const ROL::Vector< double > &des_var_ctl, bool flag=true, int iter=-1)
Update the control variables.
std::shared_ptr< BaseParameterization< dim > > design_parameterization
Parameterization which links design variables to the volume nodes.
std::shared_ptr< DGBase< dim, double > > dg
Smart pointer to DGBase.
FlowConstraints(std::shared_ptr< DGBase< dim, double >> &_dg, std::shared_ptr< BaseParameterization< dim >> _design_parameterization, std::shared_ptr< dealii::TrilinosWrappers::SparseMatrix > precomputed_dXvdXp=nullptr)
Constructor.
void applyAdjointHessian_21(ROL::Vector< double > &output_vector, const ROL::Vector< double > &dual, const ROL::Vector< double > &input_vector, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &tol) override
Applies the adjoint of the Hessian of the constraints w. r. t. the simulation variables onto a vector...
dealii::TrilinosWrappers::SparseMatrix dXvdXp
Stores the mesh sensitivities.
DGBase is independent of the number of state variables.
int construct_JacobianPreconditioner_1(const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl)
Constructs the Jacobian preconditioner.