|
|
@ -75,7 +75,7 @@ da::sha::top::Tensor3d da::sha::top::ThermoelasticTop3d::TopOptMainLoop() { |
|
|
|
spdlog::warn("using Eigen built-in direct solver!"); |
|
|
|
#endif |
|
|
|
// start iteration
|
|
|
|
while (change > sp_para_->tol_x * 1 && loop < sp_para_->max_loop) { |
|
|
|
while (change > sp_para_->tol_x && loop < sp_para_->max_loop) { |
|
|
|
++loop; |
|
|
|
// filter
|
|
|
|
xPhys_col = sp_mech_top3d_->H_ * (xPhys_col.array() / sp_mech_top3d_->Hs_.array()).matrix().eval(); |
|
|
@ -151,6 +151,7 @@ da::sha::top::Tensor3d da::sha::top::ThermoelasticTop3d::TopOptMainLoop() { |
|
|
|
F_th(dofs_m) += beta_rho * (Te - sp_mech_top3d_->sp_para_->T_ref) * Inted_; |
|
|
|
} |
|
|
|
Eigen::VectorXd F = Eigen::VectorXd(sp_mech_top3d_->F_) + F_th; |
|
|
|
|
|
|
|
sp_mech_top3d_->IntroduceFixedDofs(sp_mech_top3d_->K_, F); |
|
|
|
#ifdef USE_SUITESPARSE |
|
|
|
Eigen::CholmodSupernodalLLT<Eigen::SparseMatrix<double>> solver; |
|
|
@ -170,11 +171,13 @@ da::sha::top::Tensor3d da::sha::top::ThermoelasticTop3d::TopOptMainLoop() { |
|
|
|
} |
|
|
|
double c = |
|
|
|
ce.transpose() * CalE_Vec(xPhys_col); |
|
|
|
|
|
|
|
double v = flg_chosen ? xPhys_col(chosen_ele_id).sum() : xPhys_col.sum(); |
|
|
|
|
|
|
|
// sensitivity
|
|
|
|
// lambda_m
|
|
|
|
Eigen::VectorXd lambda_m = -sp_mech_top3d_->U_; |
|
|
|
|
|
|
|
// dFth_drho
|
|
|
|
Eigen::SparseMatrix<double> dFth_drho(sp_mech_top3d_->sp_mesh_->GetNumEles(), |
|
|
|
sp_mech_top3d_->sp_mesh_->GetNumDofs()); |
|
|
@ -193,6 +196,7 @@ da::sha::top::Tensor3d da::sha::top::ThermoelasticTop3d::TopOptMainLoop() { |
|
|
|
auto v_dFth_drho_tri = Vec2Triplet(i_dFth_drho_, j_dFth_drho_, v_dFth_drho); |
|
|
|
dFth_drho.setFromTriplets(v_dFth_drho_tri.begin(), v_dFth_drho_tri.end()); |
|
|
|
|
|
|
|
|
|
|
|
// dFth_dT
|
|
|
|
Eigen::SparseMatrix<double> dFth_dT(sp_thermal_top3d_->sp_mesh_->GetNumDofs(), |
|
|
|
sp_mech_top3d_->sp_mesh_->GetNumDofs()); |
|
|
@ -259,6 +263,7 @@ da::sha::top::Tensor3d da::sha::top::ThermoelasticTop3d::TopOptMainLoop() { |
|
|
|
dT_drho(ele_id, limited.idx_of_load_dof) = ele_dT_drho(limited.idx_in_ele); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// for (int i = 0; i < sp_thermal_top3d_->sp_mesh_->GetNumEles(); ++i) {
|
|
|
|
// Eigen::VectorXi dofs_in_ele_i = sp_thermal_top3d_->sp_mesh_->MapEleId2Dofs(i);
|
|
|
|
// Eigen::VectorXd dKe_th_Mul_T =
|
|
|
@ -279,13 +284,15 @@ da::sha::top::Tensor3d da::sha::top::ThermoelasticTop3d::TopOptMainLoop() { |
|
|
|
// }
|
|
|
|
|
|
|
|
// dc_dx
|
|
|
|
Eigen::VectorXd dc_dx = drho_dx_ * dc_drho; |
|
|
|
Eigen::VectorXd dc_dx = sp_mech_top3d_->drho_dx_ * dc_drho; |
|
|
|
// dT_dx
|
|
|
|
Eigen::MatrixXd dT_dx = drho_dx_ * dT_drho; |
|
|
|
Eigen::MatrixXd dT_dx = sp_mech_top3d_->drho_dx_ * dT_drho; |
|
|
|
|
|
|
|
// mma solver
|
|
|
|
size_t num_constraints = |
|
|
|
1 + dT_dx.cols();// volume and temperature constraints
|
|
|
|
|
|
|
|
|
|
|
|
size_t num_variables = flg_chosen ? chosen_ele_id.size() : sp_mesh_->GetNumEles(); |
|
|
|
auto mma = std::make_shared<MMASolver>(num_variables, num_constraints); |
|
|
|
Eigen::VectorXd variables_tmp = flg_chosen ? xPhys_col(chosen_ele_id) : xPhys_col; |
|
|
@ -299,6 +306,8 @@ da::sha::top::Tensor3d da::sha::top::ThermoelasticTop3d::TopOptMainLoop() { |
|
|
|
// Eigen::VectorXd dfdx = flg_chosen ? dv(chosen_ele_id) : dv;
|
|
|
|
Eigen::MatrixXd dfdx = (Eigen::MatrixXd(num_variables, num_constraints) |
|
|
|
<< 1.0 / num_variables * dv, 1.0 / sp_para_->T_limit * dT_dx).finished().transpose(); |
|
|
|
|
|
|
|
|
|
|
|
static Eigen::VectorXd low_bounds = Eigen::VectorXd::Zero(num_variables); |
|
|
|
static Eigen::VectorXd up_bounds = Eigen::VectorXd::Ones(num_variables); |
|
|
|
|
|
|
|