Teko Version of the Day
Loading...
Searching...
No Matches
Teko_ReorderedMappingStrategy.cpp
1// @HEADER
2// *****************************************************************************
3// Teko: A package for block and physics based preconditioning
4//
5// Copyright 2010 NTESS and the Teko contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#include "Epetra/Teko_ReorderedMappingStrategy.hpp"
11
12#include "Teko_BlockedReordering.hpp"
13
14using Teuchos::RCP;
15using Teuchos::rcp;
16using Teuchos::rcp_dynamic_cast;
17using Teuchos::rcpFromRef;
18
19namespace Teko {
20namespace Epetra {
21
22ReorderedMappingStrategy::ReorderedMappingStrategy(const BlockReorderManager& brm,
23 const Teuchos::RCP<const MappingStrategy>& map)
24 : reorderManager_(brm), mapStrategy_(map) {
25 rangeMap_ = mapStrategy_->rangeMap();
26 domainMap_ = mapStrategy_->domainMap();
27}
28
29void ReorderedMappingStrategy::copyEpetraIntoThyra(
30 const Epetra_MultiVector& X,
31 const Teuchos::Ptr<Thyra::MultiVectorBase<double> >& thyra_X) const {
32 using Teuchos::ptr_const_cast;
33 using Teuchos::rcp_const_cast;
34
35 // first flatten the vector: notice this just works on the block structure
36 RCP<Thyra::ProductMultiVectorBase<double> > prod_X =
37 rcp_dynamic_cast<Thyra::ProductMultiVectorBase<double> >(rcpFromRef(*thyra_X));
38 RCP<Thyra::MultiVectorBase<double> > flat_X = buildFlatMultiVector(reorderManager_, prod_X);
39
40 // now use the underlying mapping strategy to copy the flat vector
41 mapStrategy_->copyEpetraIntoThyra(X, flat_X.ptr());
42}
43
44void ReorderedMappingStrategy::copyThyraIntoEpetra(
45 const RCP<const Thyra::MultiVectorBase<double> >& thyra_Y, Epetra_MultiVector& Y) const {
46 // first flatten the vector: notice this just works on the block structure
47 RCP<const Thyra::ProductMultiVectorBase<double> > prod_Y =
48 rcp_dynamic_cast<const Thyra::ProductMultiVectorBase<double> >(rcpFromRef(*thyra_Y));
49 RCP<const Thyra::MultiVectorBase<double> > flat_Y = buildFlatMultiVector(reorderManager_, prod_Y);
50
51 // now use the underlying mapping strategy to copy the flat vector
52 mapStrategy_->copyThyraIntoEpetra(flat_Y, Y);
53}
54
55} // end namespace Epetra
56} // end namespace Teko