Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_BlockVector_def.hpp
1// @HEADER
2// ***********************************************************************
3//
4// Tpetra: Templated Linear Algebra Services Package
5// Copyright (2008) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ************************************************************************
40// @HEADER
41
42#ifndef TPETRA_BLOCKVECTOR_DEF_HPP
43#define TPETRA_BLOCKVECTOR_DEF_HPP
44
45namespace Tpetra {
46
47 template<class Scalar, class LO, class GO, class Node>
49 BlockVector () :
50 base_type ()
51 {}
52
53 template<class Scalar, class LO, class GO, class Node>
56 const Teuchos::DataAccess copyOrView) :
57 base_type (in, copyOrView)
58 {}
59
60 template<class Scalar, class LO, class GO, class Node>
62 BlockVector (const map_type& meshMap, const LO blockSize) :
63 base_type (meshMap, blockSize, 1)
64 {}
65
66 template<class Scalar, class LO, class GO, class Node>
68 BlockVector (const map_type& meshMap,
69 const map_type& pointMap,
70 const LO blockSize) :
71 base_type (meshMap, pointMap, blockSize, 1)
72 {}
73
74 template<class Scalar, class LO, class GO, class Node>
76 BlockVector (const mv_type& X_mv,
77 const map_type& meshMap,
78 const LO blockSize) :
79 base_type (X_mv, meshMap, blockSize)
80 {
81 TEUCHOS_TEST_FOR_EXCEPTION(
82 X_mv.getNumVectors () != 1, std::invalid_argument,
83 "Tpetra::BlockVector: Input MultiVector has "
84 << X_mv.getNumVectors () << " != 1 columns.");
85 }
86
87 template<class Scalar, class LO, class GO, class Node>
89 BlockVector (const vec_type& X_vec,
90 const map_type& meshMap,
91 const LO blockSize) :
92 base_type (X_vec, meshMap, blockSize)
93 {}
94
95 template<class Scalar, class LO, class GO, class Node>
98 const map_type& newMeshMap,
99 const map_type& newPointMap,
100 const size_t offset) :
101 base_type (X, newMeshMap, newPointMap, offset)
102 {}
103
104 template<class Scalar, class LO, class GO, class Node>
107 const map_type& newMeshMap,
108 const size_t offset) :
109 base_type (X, newMeshMap, offset)
110 {}
111
112 template<class Scalar, class LO, class GO, class Node>
115 Teuchos::RCP<vec_type> vPtr = this->mv_.getVectorNonConst (0);
116 return *vPtr; // shallow copy
117 }
118
119 template<class Scalar, class LO, class GO, class Node>
120 bool
122 replaceLocalValues (const LO localRowIndex, const Scalar vals[]) {
123 return ((base_type*) this)->replaceLocalValues (localRowIndex, 0, vals);
124 }
125
126 template<class Scalar, class LO, class GO, class Node>
127 bool
129 replaceGlobalValues (const GO globalRowIndex, const Scalar vals[]) {
130 return ((base_type*) this)->replaceGlobalValues (globalRowIndex, 0, vals);
131 }
132
133 template<class Scalar, class LO, class GO, class Node>
134 bool
136 sumIntoLocalValues (const LO localRowIndex, const Scalar vals[]) {
137 return ((base_type*) this)->sumIntoLocalValues (localRowIndex, 0, vals);
138 }
139
140 template<class Scalar, class LO, class GO, class Node>
141 bool
143 sumIntoGlobalValues (const GO globalRowIndex, const Scalar vals[]) {
144 return ((base_type*) this)->sumIntoLocalValues (globalRowIndex, 0, vals);
145 }
146
147 template<class Scalar, class LO, class GO, class Node>
148 typename BlockVector<Scalar, LO, GO, Node>::const_little_host_vec_type
150 getLocalBlockHost (const LO localRowIndex, Access::ReadOnlyStruct) const
151 {
152 return ((const base_type*) this)->getLocalBlockHost(localRowIndex, 0,
153 Access::ReadOnly);
154 }
155
156 template<class Scalar, class LO, class GO, class Node>
157 typename BlockVector<Scalar, LO, GO, Node>::little_host_vec_type
159 getLocalBlockHost (const LO localRowIndex, Access::ReadWriteStruct)
160 {
161 return ((base_type*) this)->getLocalBlockHost(localRowIndex, 0,
162 Access::ReadWrite);
163 }
164
165 template<class Scalar, class LO, class GO, class Node>
166 typename BlockVector<Scalar, LO, GO, Node>::little_host_vec_type
168 getLocalBlockHost (const LO localRowIndex, Access::OverwriteAllStruct)
169 {
170 return ((base_type*) this)->getLocalBlockHost(localRowIndex, 0,
171 Access::OverwriteAll);
172 }
173
174} // namespace Tpetra
175
176//
177// Explicit instantiation macro
178//
179// Must be expanded from within the Tpetra namespace!
180//
181#define TPETRA_BLOCKVECTOR_INSTANT(S,LO,GO,NODE) \
182 template class BlockVector< S, LO, GO, NODE >;
183
184#endif // TPETRA_BLOCKVECTOR_DEF_HPP
MultiVector for multiple degrees of freedom per mesh point.
Vector for multiple degrees of freedom per mesh point.
const_little_host_vec_type getLocalBlockHost(const LO localRowIndex, Access::ReadOnlyStruct) const
Get a view of the degrees of freedom at the given mesh point, using a local index.
bool sumIntoGlobalValues(const GO globalRowIndex, const Scalar vals[])
Sum into all values at the given mesh point, using a global index.
bool replaceGlobalValues(const GO globalRowIndex, const Scalar vals[])
Replace all values at the given mesh point, using a global index.
BlockVector()
Default constructor.
bool sumIntoLocalValues(const LO localRowIndex, const Scalar vals[])
Sum into all values at the given mesh point, using a local index.
vec_type getVectorView()
Get a Tpetra::Vector that views this BlockVector's data.
bool replaceLocalValues(const LO localRowIndex, const Scalar vals[])
Replace all values at the given mesh point, using a local index.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(const size_t j)
Return a Vector which is a nonconst view of column j.
size_t getNumVectors() const
Number of columns in the multivector.
A distributed dense vector.
Namespace Tpetra contains the class and methods constituting the Tpetra library.