// @HEADER // ***************************************************************************** // Rapid Optimization Library (ROL) Package // // Copyright 2014 NTESS and the ROL contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER /*! \file obj.hpp \brief Provides the interface for local (cell-based) objective function computations. */ #ifndef PDEOPT_QOI_VOLUME_HPP #define PDEOPT_QOI_VOLUME_HPP #include "../../TOOLS/qoi.hpp" #include "../../TOOLS/fe.hpp" template class QoI_Volume_TopoOpt : public QoI { private: const ROL::Ptr> fe_; ROL::Ptr> ones_; ROL::Ptr> volFrac_; public: QoI_Volume_TopoOpt(const ROL::Ptr> &fe, const Real v0 = Real(0)) : fe_(fe) { // Get relevant dimensions int c = fe_->cubPts()->dimension(0); int p = fe_->cubPts()->dimension(1); ones_ = ROL::makePtr>(c,p); volFrac_ = ROL::makePtr>(c,p); ones_->initialize(static_cast(1)); volFrac_->initialize(v0); } Real value(ROL::Ptr> & val, const ROL::Ptr> & u_coeff, const ROL::Ptr> & z_coeff = ROL::nullPtr, const ROL::Ptr> & z_param = ROL::nullPtr) { // Get relevant dimensions int c = fe_->gradN()->dimension(0); int p = fe_->gradN()->dimension(2); // Initialize output val val = ROL::makePtr>(c); // Evaluate on FE basis ROL::Ptr> valZ_eval = ROL::makePtr>(c, p); fe_->evaluateValue(valZ_eval, z_coeff); Intrepid::RealSpaceTools::subtract(*valZ_eval,*volFrac_); // Compute energy fe_->computeIntegral(val,valZ_eval,ones_); return static_cast(0); } void gradient_1(ROL::Ptr> & grad, const ROL::Ptr> & u_coeff, const ROL::Ptr> & z_coeff = ROL::nullPtr, const ROL::Ptr> & z_param = ROL::nullPtr) { throw Exception::Zero(">>> QoI_Volume_TopoOpt::gradient_1 is zero."); } void gradient_2(ROL::Ptr> & grad, const ROL::Ptr> & u_coeff, const ROL::Ptr> & z_coeff = ROL::nullPtr, const ROL::Ptr> & z_param = ROL::nullPtr) { // Get relevant dimensions int c = fe_->gradN()->dimension(0); int f = fe_->gradN()->dimension(1); // Initialize output grad grad = ROL::makePtr>(c, f); // Compute gradient of energy Intrepid::FunctionSpaceTools::integrate(*grad, *ones_, *fe_->NdetJ(), Intrepid::COMP_CPP, false); } void HessVec_11(ROL::Ptr> & hess, const ROL::Ptr> & v_coeff, const ROL::Ptr> & u_coeff, const ROL::Ptr> & z_coeff = ROL::nullPtr, const ROL::Ptr> & z_param = ROL::nullPtr) { throw Exception::Zero(">>> QoI_Volume_TopoOpt::HessVec_11 is zero."); } void HessVec_12(ROL::Ptr> & hess, const ROL::Ptr> & v_coeff, const ROL::Ptr> & u_coeff, const ROL::Ptr> & z_coeff = ROL::nullPtr, const ROL::Ptr> & z_param = ROL::nullPtr) { throw Exception::Zero(">>> QoI_Volume_TopoOpt::HessVec_12 is zero."); } void HessVec_21(ROL::Ptr> & hess, const ROL::Ptr> & v_coeff, const ROL::Ptr> & u_coeff, const ROL::Ptr> & z_coeff = ROL::nullPtr, const ROL::Ptr> & z_param = ROL::nullPtr) { throw Exception::Zero(">>> QoI_Volume_TopoOpt::HessVec_21 is zero."); } void HessVec_22(ROL::Ptr> & hess, const ROL::Ptr> & v_coeff, const ROL::Ptr> & u_coeff, const ROL::Ptr> & z_coeff = ROL::nullPtr, const ROL::Ptr> & z_param = ROL::nullPtr) { throw Exception::Zero(">>> QoI_Volume_TopoOpt::HessVec_22 is zero."); } }; // QoI_VolumeObj #endif