// @HEADER // ***************************************************************************** // Rapid Optimization Library (ROL) Package // // Copyright 2014 NTESS and the ROL contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef ROL_FRACTIONALVECTOR_H #define ROL_FRACTIONALVECTOR_H #include "ROL_TpetraMultiVector.hpp" #include "../../TOOLS/assembler.hpp" #include // Do not instantiate the template in this translation unit. extern template class Assembler; template class FractionalVector { private: const ROL::Ptr > pde_local_; const ROL::Ptr > pde_cylinder_; ROL::Ptr > assembler_local_; ROL::Ptr > assembler_cylinder_; ROL::Ptr > Flocal_; ROL::Ptr > Klocal_; ROL::Ptr > Mcylinder_; ROL::Ptr > Fptr_; ROL::Ptr > F_; public: FractionalVector(const ROL::Ptr > &pde_local, const ROL::Ptr > &mesh_local, const ROL::Ptr > &pde_cylinder, const ROL::Ptr > &mesh_cylinder, const ROL::Ptr > &comm, Teuchos::ParameterList &parlist, std::ostream &outStream = std::cout) : pde_local_(pde_local), pde_cylinder_(pde_cylinder) { ROL::Ptr > uvec; ROL::Ptr > zvec; // Assemble local components assembler_local_ = ROL::makePtr>(pde_local_->getFields(),mesh_local,comm,parlist,outStream); assembler_local_->setCellNodes(*pde_local_); uvec = assembler_local_->createStateVector(); uvec->putScalar(static_cast(0)); zvec = assembler_local_->createControlVector(); zvec->putScalar(static_cast(0)); assembler_local_->assemblePDEJacobian1(Klocal_,pde_local_,uvec,zvec); assembler_local_->assemblePDEResidual(Flocal_,pde_local_,uvec,zvec); // Assemble cylinder components assembler_cylinder_ = ROL::makePtr>(pde_cylinder_->getFields(),mesh_cylinder,comm,parlist,outStream); assembler_cylinder_->setCellNodes(*pde_cylinder_); assembler_cylinder_->assemblePDERieszMap1(Mcylinder_,pde_cylinder_); // Build fractional vector Real s = parlist.sublist("Problem").get("Fractional Power",0.5); Real alpha = static_cast(1) - static_cast(2)*s; Real ds = std::pow(static_cast(2), alpha) * tgamma(static_cast(1)-s)/tgamma(s); Fptr_ = ROL::makePtr>(Klocal_->getRowMap(),Mcylinder_->getGlobalNumCols()); Fptr_->getVectorNonConst(0)->scale(-ds,*Flocal_); F_ = ROL::makePtr>(Fptr_); } FractionalVector(const ROL::Ptr > &F, const ROL::Ptr > &map, const int numCylinder, const Real s) { // Build fractional vector Real alpha = static_cast(1) - static_cast(2)*s; Real ds = std::pow(static_cast(2), alpha) * tgamma(static_cast(1)-s)/tgamma(s); Fptr_ = ROL::makePtr>(map,numCylinder); Fptr_->getVectorNonConst(0)->scale(-ds,*F); F_ = ROL::makePtr>(Fptr_); } const ROL::Ptr > get(void) const { return F_; } }; #endif