1 #include "rol_to_dealii_vector.hpp" 2 #include "rol_objective.hpp" 4 #include <deal.II/optimization/rol/vector_adaptor.h> 6 #include "global_counter.hpp" 10 template <
int dim,
int nstate>
14 std::shared_ptr<dealii::TrilinosWrappers::SparseMatrix> precomputed_dXvdXp)
15 : functional(_functional)
16 , design_parameterization(_design_parameterization)
19 dealii::ExcMessage(
"Functional and DesignParameterization do not point to the same high order grid."));
23 if (precomputed_dXvdXp) {
24 if (precomputed_dXvdXp->m() ==
functional.
dg->high_order_grid->volume_nodes.size() && precomputed_dXvdXp->n() == n_design_variables) {
25 dXvdXp.copy_from(*precomputed_dXvdXp);
33 template <
int dim,
int nstate>
35 const ROL::Vector<double> &des_var_sim,
36 const ROL::Vector<double> &des_var_ctl,
46 template <
int dim,
int nstate>
48 const ROL::Vector<double> &des_var_sim,
49 const ROL::Vector<double> &des_var_ctl,
56 if (tol > 1e-5 || std::isnan(tol))
return 1e200;
57 update(des_var_sim, des_var_ctl);
59 const bool compute_dIdW =
false;
60 const bool compute_dIdX =
false;
61 const bool compute_d2I =
false;
65 template <
int dim,
int nstate>
67 ROL::Vector<double> &gradient_sim,
68 const ROL::Vector<double> &des_var_sim,
69 const ROL::Vector<double> &des_var_ctl,
72 update(des_var_sim, des_var_ctl);
74 const bool compute_dIdW =
true;
75 const bool compute_dIdX =
false;
76 const bool compute_d2I =
false;
82 template <
int dim,
int nstate>
84 ROL::Vector<double> &gradient_ctl,
85 const ROL::Vector<double> &des_var_sim,
86 const ROL::Vector<double> &des_var_ctl,
89 update(des_var_sim, des_var_ctl);
91 const bool compute_dIdW =
false, compute_dIdX =
true, compute_d2I =
false;
97 dXvdXp.Tvmult(dealii_output, dIdXv);
122 template <
int dim,
int nstate>
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,
130 update(des_var_sim, des_var_ctl);
132 const bool compute_dIdW =
false;
133 const bool compute_dIdX =
false;
134 const bool compute_d2I =
true;
145 template <
int dim,
int nstate>
147 ROL::Vector<double> &output_vector,
148 const ROL::Vector<double> &input_vector,
149 const ROL::Vector<double> &des_var_sim,
150 const ROL::Vector<double> &des_var_ctl,
153 update(des_var_sim, des_var_ctl);
183 auto dXvdXp_input =
functional.
dg->high_order_grid->volume_nodes;
184 dXvdXp.vmult(dXvdXp_input, dealii_input);
188 const bool compute_dIdW =
false, compute_dIdX =
false, compute_d2I =
true;
197 template <
int dim,
int nstate>
199 ROL::Vector<double> &output_vector,
200 const ROL::Vector<double> &input_vector,
201 const ROL::Vector<double> &des_var_sim,
202 const ROL::Vector<double> &des_var_ctl,
205 update(des_var_sim, des_var_ctl);
207 const bool compute_dIdW =
false;
208 const bool compute_dIdX =
false;
209 const bool compute_d2I =
true;
214 auto d2IdXdW_input =
functional.
dg->high_order_grid->volume_nodes;
237 dXvdXp.Tvmult(dealii_output, d2IdXdW_input);
242 template <
int dim,
int nstate>
244 ROL::Vector<double> &output_vector,
245 const ROL::Vector<double> &input_vector,
246 const ROL::Vector<double> &des_var_sim,
247 const ROL::Vector<double> &des_var_ctl,
250 update(des_var_sim, des_var_ctl);
275 auto dXvdXp_input =
functional.
dg->high_order_grid->volume_nodes;
276 dXvdXp.vmult(dXvdXp_input, dealii_input);
278 auto d2IdXdXp_input =
functional.
dg->high_order_grid->volume_nodes;
280 const bool compute_dIdW =
false, compute_dIdX =
false, compute_d2I =
true;
303 dXvdXp.Tvmult(dealii_output, d2IdXdXp_input);
std::shared_ptr< dealii::TrilinosWrappers::SparseMatrix > d2IdXdX
Sparse matrix for storing the functional partial second derivatives.
dealii::LinearAlgebra::distributed::Vector< real > dIdX
Vector for storing the derivatives with respect to each grid DoF.
void hessVec_22(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 functional Hessian w. r. t. the control variables onto a vector.
Interface between the ROL::Objective_SimOpt PHiLiP::Functional.
void set_state(const dealii::LinearAlgebra::distributed::Vector< real > &solution_set)
dealii::LinearAlgebra::distributed::Vector< real > dIdw
Vector for storing the derivatives with respect to each solution DoF.
std::shared_ptr< dealii::TrilinosWrappers::SparseMatrix > d2IdWdW
Sparse matrix for storing the functional partial second derivatives.
void hessVec_11(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 functional Hessian w. r. t. the simulation variables onto a vector.
std::shared_ptr< BaseParameterization< dim > > design_parameterization
Design parameterization to link design variables with volume nodes.
void gradient_1(ROL::Vector< double > &g, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Returns the gradient w. r. t. the simulation variables of the Functional object.
Files for the baseline physics.
Abstract class for design parameterization. Objective function and the constraints take this class's ...
void gradient_2(ROL::Vector< double > &g, const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Returns the gradient w. r. t. the control variables of the Functional object.
void update(const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, bool flag=true, int iter=-1) override
Update the simulation and control variables.
dealii::TrilinosWrappers::SparseMatrix dXvdXp
Stored mesh sensitivity evaluated at initialization.
void hessVec_12(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 functional Hessian w. r. t. the simulation and control variables onto a vector...
void hessVec_21(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 functional Hessian w. r. t. the control and simulation variables onto a vector...
Functional< dim, nstate, double > & functional
Functional to be evaluated.
ROLObjectiveSimOpt(Functional< dim, nstate, double > &_functional, std::shared_ptr< BaseParameterization< dim >> _design_parameterization, std::shared_ptr< dealii::TrilinosWrappers::SparseMatrix > precomputed_dXvdXp=nullptr)
Constructor.
dealii::LinearAlgebra::distributed::Vector< double > design_var
Design variables.
std::shared_ptr< dealii::TrilinosWrappers::SparseMatrix > d2IdWdX
Sparse matrix for storing the functional partial second derivatives.
std::shared_ptr< DGBase< dim, real, MeshType > > dg
Smart pointer to DGBase.
virtual real evaluate_functional(const bool compute_dIdW=false, const bool compute_dIdX=false, const bool compute_d2I=false)
Evaluates the functional derivative with respect to the solution variable.
const dealii::LinearAlgebra::distributed::Vector< double > & ROL_vector_to_dealii_vector_reference(const ROL::Vector< double > &x)
Access the read-write deali.II Vector stored within the ROL::Vector.
double value(const ROL::Vector< double > &des_var_sim, const ROL::Vector< double > &des_var_ctl, double &) override
Returns the value of the Functional object.