43 #ifndef IFPACK2_DETAILS_MULTIVECTORLOCALGATHERSCATTER_HPP 44 #define IFPACK2_DETAILS_MULTIVECTORLOCALGATHERSCATTER_HPP 50 #include "Tpetra_MultiVector.hpp" 51 #include "Tpetra_Map.hpp" 84 template<
class MV_in,
class MV_out>
87 typedef typename MV_in::scalar_type InScalar;
88 typedef typename MV_out::scalar_type OutScalar;
89 typedef typename MV_in::local_ordinal_type LO;
90 typedef typename MV_in::global_ordinal_type GO;
91 typedef typename MV_in::node_type NO;
97 gather (MV_out& X_out,
99 const Teuchos::ArrayView<const LO> perm)
const 101 using Teuchos::ArrayRCP;
102 const size_t numRows = X_out.getLocalLength ();
103 const size_t numVecs = X_in.getNumVectors ();
104 for (
size_t j = 0; j < numVecs; ++j) {
105 ArrayRCP<const InScalar> X_in_j = X_in.getData(j);
106 ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
107 for (
size_t i = 0; i < numRows; ++i) {
108 const size_t i_perm = perm[i];
109 X_out_j[i] = X_in_j[i_perm];
121 const Teuchos::ArrayView<const LO> perm,
124 using Teuchos::ArrayRCP;
125 const size_t numBlocks = X_out.getLocalLength() / blockSize;
126 const size_t numVecs = X_in.getNumVectors ();
127 for (
size_t j = 0; j < numVecs; ++j) {
128 ArrayRCP<const InScalar> X_in_j = X_in.getData(j);
129 ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
130 for (
size_t i = 0; i < numBlocks; ++i) {
131 const size_t i_perm = perm[i];
132 for (LO k = 0; k < blockSize; k++) {
133 X_out_j[i * blockSize + k] = X_in_j[i_perm * blockSize + k];
140 scatter (MV_in& X_in,
142 const Teuchos::ArrayView<const LO> perm)
const 144 using Teuchos::ArrayRCP;
145 const size_t numRows = X_out.getLocalLength();
146 const size_t numVecs = X_in.getNumVectors();
147 for (
size_t j = 0; j < numVecs; ++j) {
148 ArrayRCP<InScalar> X_in_j = X_in.getDataNonConst(j);
149 ArrayRCP<const OutScalar> X_out_j = X_out.getData(j);
150 for (
size_t i = 0; i < numRows; ++i) {
151 const size_t i_perm = perm[i];
152 X_in_j[i_perm] = X_out_j[i];
161 const Teuchos::ArrayView<const LO> perm,
164 using Teuchos::ArrayRCP;
165 const size_t numBlocks = X_out.getLocalLength() / blockSize;
166 const size_t numVecs = X_in.getNumVectors ();
167 for (
size_t j = 0; j < numVecs; ++j) {
168 ArrayRCP<const InScalar> X_in_j = X_in.getData(j);
169 ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
170 for (
size_t i = 0; i < numBlocks; ++i) {
171 const size_t i_perm = perm[i];
172 for (LO k = 0; k < blockSize; k++) {
173 X_in_j[i_perm * blockSize + k] = X_out_j[i * blockSize + k];
182 template<
typename InView,
typename OutView>
183 void gatherViewToView(OutView X_out,
185 const Teuchos::ArrayView<const LO> perm)
const 188 for(
size_t j = 0; j < X_out.extent(1); ++j) {
189 for(
size_t i = 0; i < X_out.extent(0); ++i) {
190 const LO i_perm = perm[i];
191 X_out(i, j) = X_in(i_perm, j);
196 template<
typename InView,
typename OutView>
197 void scatterViewToView(InView X_in,
199 const Teuchos::ArrayView<const LO> perm)
const 201 for(
size_t j = 0; j < X_out.extent(1); ++j) {
202 for(
size_t i = 0; i < X_out.extent(0); ++i) {
203 const LO i_perm = perm[i];
204 X_in(i_perm, j) = X_out(i, j);
209 template<
typename InView,
typename OutView>
210 void gatherViewToViewBlock(OutView X_out,
212 const Teuchos::ArrayView<const LO> perm,
216 size_t numBlocks = X_out.extent(0) / blockSize;
217 for(
size_t j = 0; j < X_out.extent(1); ++j) {
218 for(
size_t i = 0; i < numBlocks; ++i) {
219 const LO i_perm = perm[i];
220 for(LO k = 0; k < blockSize; k++) {
221 X_out(i * blockSize + k, j) = X_in(i_perm * blockSize + k, j);
227 template<
typename InView,
typename OutView>
228 void scatterViewToViewBlock(InView X_in,
230 const Teuchos::ArrayView<const LO> perm,
234 size_t numBlocks = X_out.extent(0) / blockSize;
235 for(
size_t j = 0; j < X_out.extent(1); ++j) {
236 for(
size_t i = 0; i < numBlocks; ++i) {
237 const LO i_perm = perm[i];
238 for(LO k = 0; k < blockSize; k++) {
239 X_in(i_perm * blockSize + k, j) = X_out(i * blockSize + k, j);
248 template<
typename InView>
249 void gatherMVtoView(MV_out X_out,
251 const Teuchos::ArrayView<const LO> perm)
const 254 size_t numRows = X_out.getLocalLength();
255 for(
size_t j = 0; j < X_out.getNumVectors(); ++j) {
256 Teuchos::ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
257 for(
size_t i = 0; i < numRows; ++i) {
258 const LO i_perm = perm[i];
259 X_out_j[i] = X_in(i_perm, j);
264 template<
typename InView>
265 void scatterMVtoView(InView X_in,
267 const Teuchos::ArrayView<const LO> perm)
const 269 size_t numRows = X_out.getLocalLength();
270 for(
size_t j = 0; j < X_in.extent(1); ++j) {
271 Teuchos::ArrayRCP<const OutScalar> X_out_j = X_out.getData(j);
272 for(
size_t i = 0; i < numRows; ++i) {
273 const LO i_perm = perm[i];
274 X_in(i_perm, j) = X_out_j[i];
279 template<
typename InView>
280 void gatherMVtoViewBlock(MV_out X_out,
282 const Teuchos::ArrayView<const LO> perm,
286 size_t numBlocks = X_out.getLocalLength() / blockSize;
287 for(
size_t j = 0; j < X_out.getNumVectors(); ++j) {
288 Teuchos::ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
289 for(
size_t i = 0; i < numBlocks; ++i) {
290 const LO i_perm = perm[i];
291 for(LO k = 0; k < blockSize; k++) {
292 X_out_j[i * blockSize + k] = X_in(i_perm * blockSize + k, j);
298 template<
typename InView>
299 void scatterMVtoViewBlock(InView X_in,
301 const Teuchos::ArrayView<const LO> perm,
304 size_t numBlocks = X_out.getLocalLength() / blockSize;
305 for(
size_t j = 0; j < X_in.extent(1); ++j) {
306 Teuchos::ArrayRCP<const OutScalar> X_out_j = X_out.getData(j);
307 for(
size_t i = 0; i < numBlocks; ++i) {
308 const LO i_perm = perm[i];
309 for(LO k = 0; k < blockSize; k++) {
310 X_in(i_perm * blockSize + k, j) = X_out_j[i * blockSize + k];
320 #endif // IFPACK2_DETAILS_MULTIVECTORLOCALGATHERSCATTER_HPP Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:73
Implementation detail of Ifpack2::Container subclasses.
Definition: Ifpack2_Details_MultiVectorLocalGatherScatter.hpp:85