Debian Codegraph @

packages/rol/adapters/tpetra/src/pebbl/ROL_PEBBL_TpetraIntegerTransformation.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef ROL_PEBBL_TPETRAINTEGERTRANSFORMATION_H
11 #define ROL_PEBBL_TPETRAINTEGERTRANSFORMATION_H
12
13 #include "ROL_PEBBL_IntegerTransformation.hpp"
14 #include "ROL_TpetraMultiVector.hpp"
15
16 /** @ingroup func_group
17 \class ROL::PEBBL::TpetraIntegerTransformation
18 \brief Defines the pebbl transform operator interface for TpetraMultiVectors.
19
20 ROL's pebbl constraint interface is designed to set individual components
21 of a vector to a fixed value. The range space is the same as the domain.
22
23 ---
24 */
25
26
27 namespace ROL {
28 namespace PEBBL {
29
30 template <class Real>
31 class TpetraIntegerTransformation : public IntegerTransformation<Real> {
32 private:
33 Ptr<Tpetra::MultiVector<>> getData(Vector<Real> &x) const {
34 return dynamic_cast<TpetraMultiVector<Real>&>(x).getVector();
35 }
36
37 using IntegerTransformation<Real>::map_;
38
39 public:
40 TpetraIntegerTransformation(void)
41 : IntegerTransformation<Real>() {}
42
43 TpetraIntegerTransformation(const TpetraIntegerTransformation &T)
44 : IntegerTransformation<Real>(T) {}
45
46 void fixValues(Vector<Real> &c, bool zero = false) const {
47 Teuchos::ArrayView<Real> cview = (getData(c)->getDataNonConst(0))();
48 for (auto it=map_.begin(); it!=map_.end(); ++it) {
49 cview[it->first] = (zero ? static_cast<Real>(0) : it->second);
50 }
51 }
52
53 }; // class TpetraIntegerTransformation
54
55 } // namespace PEBBL
56 } // namespace ROL
57
58 #endif