// @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_MULTIMAT_HPP #define PDEOPT_QOI_VOLUME_MULTIMAT_HPP #include "ROL_StdConstraint.hpp" #include "ROL_ParameterList.hpp" template class Volume_TopoOpt : public ROL::StdConstraint { private: Real w0_, vol_; std::vector w_; int N_, M_, T_; public: Volume_TopoOpt(ROL::ParameterList &list) { w_ = ROL::getArrayFromStringParameter(list.sublist("Problem"), "Density"); M_ = list.sublist("Problem").get("Number of Horizontal Cells",10); N_ = list.sublist("Problem").get("Number of Vertical Cells",20); T_ = w_.size(); Real width = list.sublist("Geometry").get("Width",2.0); Real height = list.sublist("Geometry").get("Height",1.0); vol_ = width*height/static_cast(M_*N_); Real mw(0); for (int i = 0; i < T_; ++i) { mw = std::max(mw,w_[i]); } w0_ = list.sublist("Problem").get("Maximum Weight Fraction", 0.5) * mw * width * height; } void value( std::vector &c, const std::vector &x, Real &tol ) { c[0] = -w0_; for (int i=0; i &jv, const std::vector &v, const std::vector &x, Real &tol ) { jv[0] = static_cast(0); for (int i=0; i &ajv, const std::vector &v, const std::vector &x, Real &tol ) { for (int i=0; i &ahuv, const std::vector &u, const std::vector &v, const std::vector &x, Real &tol ) { int size = ahuv.size(); ahuv.assign(size,static_cast(0)); } }; template class Selection_TopoOpt : public ROL::StdConstraint { private: int N_, M_, T_; public: Selection_TopoOpt(ROL::ParameterList &list) { std::vector w = ROL::getArrayFromStringParameter(list.sublist("Problem"), "Density"); M_ = list.sublist("Problem").get("Number of Horizontal Cells",10); N_ = list.sublist("Problem").get("Number of Vertical Cells",20); T_ = w.size(); } void value( std::vector &c, const std::vector &x, Real &tol ) { for (int i=0; i(-1); for (int k=0; k &jv, const std::vector &v, const std::vector &x, Real &tol ) { for (int i=0; i(0); for (int k=0; k &ajv, const std::vector &v, const std::vector &x, Real &tol ) { for (int i=0; i &ahuv, const std::vector &u, const std::vector &v, const std::vector &x, Real &tol ) { int size = ahuv.size(); ahuv.assign(size,static_cast(0)); } }; #endif