Debian Codegraph @

packages/rol/adapters/tpetra/src/sol/ROL_TpetraTeuchosBatchManager.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_TPETRATEUCHOSBATCHMANAGER_HPP
11 #define ROL_TPETRATEUCHOSBATCHMANAGER_HPP
12
13 #include "ROL_TeuchosBatchManager.hpp"
14 #include "ROL_TpetraMultiVector.hpp"
15
16 namespace ROL {
17
18 template<class Real,
19 class LO=Tpetra::Map<>::local_ordinal_type,
20 class GO=Tpetra::Map<>::global_ordinal_type,
21 class Node=Tpetra::Map<>::node_type >
22 class TpetraTeuchosBatchManager : public TeuchosBatchManager<Real,GO> {
23 typedef Tpetra::MultiVector<Real,LO,GO,Node> Tpetra_Vector;
24 typedef TpetraMultiVector<Real,LO,GO,Node> OptVector;
25
26 public:
27 TpetraTeuchosBatchManager(const ROL::Ptr<const Teuchos::Comm<int> > &comm)
28 : TeuchosBatchManager<Real,GO>(comm) {}
29
30 void sumAll(Vector<Real> &input, Vector<Real> &output) {
31 ROL::Ptr<Tpetra_Vector> ivec = dynamic_cast<OptVector&>(input).getVector();
32 ROL::Ptr<Tpetra_Vector> ovec = dynamic_cast<OptVector&>(output).getVector();
33
34 size_t ilength = ivec->getLocalLength(), olength = ovec->getLocalLength();
35 ROL_TEST_FOR_EXCEPTION(ilength != olength, std::invalid_argument,
36 ">>> (TpetraTeuchosBatchManager::sumAll): Inconsistent local lengths!");
37
38 size_t invec = ivec->getNumVectors(), onvec = ovec->getNumVectors();
39 ROL_TEST_FOR_EXCEPTION(invec != onvec, std::invalid_argument,
40 ">>> (TpetraTeuchosBatchManager::sumAll): Inconsistent number of vectors!");
41
42 for (size_t i = 0; i < invec; ++i) {
43 TeuchosBatchManager<Real,GO>::sumAll((ivec->getDataNonConst(i)).getRawPtr(),
44 (ovec->getDataNonConst(i)).getRawPtr(),
45 ilength);
46 }
47 }
48 };
49
50 }
51
52 #endif