// @HEADER // ***************************************************************************** // Rapid Optimization Library (ROL) Package // // Copyright 2014 NTESS and the ROL contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef ROL_PDEOPT_ELASTICITYSIMP_CONSTRAINT_VOLUME_SimOpt_H #define ROL_PDEOPT_ELASTICITYSIMP_CONSTRAINT_VOLUME_SimOpt_H #include "ROL_Constraint_SimOpt.hpp" #include "ROL_TpetraMultiVector.hpp" #include "ROL_StdVector.hpp" #include "Amesos2.hpp" template class EqualityConstraint_PDEOPT_ElasticitySIMP_Volume_SimOpt : public ROL::Constraint_SimOpt { private: Real volFrac_; public: EqualityConstraint_PDEOPT_ElasticitySIMP_Volume_SimOpt(const ROL::Ptr > &data, const Teuchos::RCP &parlist) { volFrac_ = parlist->sublist("ElasticityTopoOpt").get("volfrac", 0.5); } using ROL::Constraint_SimOpt::value; void value(ROL::Vector &c, const ROL::Vector &u, const ROL::Vector &z, Real &tol) { ROL::Ptr > cp = (dynamic_cast&>(c)).getVector(); ROL::Ptr > zp = (dynamic_cast&>(z)).getVector(); ROL::Ptr > unit = ROL::makePtr>(zp->getMap(), 1, true); unit->putScalar(1.0); Teuchos::Array sumZ(1, 0); zp->dot(*unit, sumZ); (*cp)[0] = sumZ[0] - 400*volFrac_; } void applyJacobian_1(ROL::Vector &jv, const ROL::Vector &v, const ROL::Vector &u, const ROL::Vector &z, Real &tol) { jv.zero(); } void applyJacobian_2(ROL::Vector &jv, const ROL::Vector &v, const ROL::Vector &u, const ROL::Vector &z, Real &tol) { ROL::Ptr > jvp = (dynamic_cast&>(jv)).getVector(); ROL::Ptr > vp = (dynamic_cast&>(v)).getVector(); ROL::Ptr > unit = ROL::makePtr>(vp->getMap(), 1, true); unit->putScalar(1.0); Teuchos::Array sumV(1, 0); vp->dot(*unit, sumV); (*jvp)[0] = sumV[0]; } void applyAdjointJacobian_1(ROL::Vector &ajv, const ROL::Vector &v, const ROL::Vector &u, const ROL::Vector &z, Real &tol) { ajv.zero(); } void applyAdjointJacobian_2(ROL::Vector &ajv, const ROL::Vector &v, const ROL::Vector &u, const ROL::Vector &z, Real &tol) { ROL::Ptr > ajvp = (dynamic_cast&>(ajv)).getVector(); ROL::Ptr > vp = (dynamic_cast&>(v)).getVector(); ajvp->putScalar(1.0); ajvp->scale((*vp)[0]); } void applyAdjointHessian_11(ROL::Vector &ahwv, const ROL::Vector &w, const ROL::Vector &v, const ROL::Vector &u, const ROL::Vector &z, Real &tol) { ahwv.zero(); } void applyAdjointHessian_12(ROL::Vector &ahwv, const ROL::Vector &w, const ROL::Vector &v, const ROL::Vector &u, const ROL::Vector &z, Real &tol) { ahwv.zero(); } void applyAdjointHessian_21(ROL::Vector &ahwv, const ROL::Vector &w, const ROL::Vector &v, const ROL::Vector &u, const ROL::Vector &z, Real &tol) { ahwv.zero(); } void applyAdjointHessian_22(ROL::Vector &ahwv, const ROL::Vector &w, const ROL::Vector &v, const ROL::Vector &u, const ROL::Vector &z, Real &tol) { ahwv.zero(); } }; #endif