Teko Version of the Day
Loading...
Searching...
No Matches
Teko_TpetraBasicMappingStrategy.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 "Teko_TpetraBasicMappingStrategy.hpp"
11#include "Teko_TpetraHelpers.hpp"
12
13#include "Thyra_TpetraThyraWrappers.hpp"
14#include "Thyra_DefaultSpmdMultiVector.hpp"
15
16using Teuchos::RCP;
17using Teuchos::rcp;
18using Teuchos::rcp_dynamic_cast;
19
20namespace Teko {
21namespace TpetraHelpers {
22
23// Creates a strided mapping strategy. This class is useful
24// for breaking up nodally ordered matrices (i.e. the unknowns
25// in a FEM problem are ordered [u0,v0,p0,u1,v1,p1,...]). Current
26// implimentation only supports a fixed number of variables
27//
28// arguments:
29// vars - Number of different variables
30// map - original Epetra_Map to be broken up
31// comm - Epetra_Comm object related to the map
32//
33BasicMappingStrategy::BasicMappingStrategy(const Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >& rMap,
34 const Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >& dMap,
35 const Teuchos::Comm<Thyra::Ordinal>& /* comm */) {
36 rangeMap_ = rMap;
37 domainMap_ = dMap;
38}
39
40// Virtual function defined in MappingStrategy. This copies
41// an Epetra_MultiVector into a Thyra::MultiVectorBase with
42// blocking handled by the strides defined in the constructor.
43//
44// arguments:
45// X - source Epetra_MultiVector
46// thyra_X - destination Thyra::MultiVectorBase
47//
48void BasicMappingStrategy::copyTpetraIntoThyra(
49 const Tpetra::MultiVector<ST, LO, GO, NT>& X,
50 const Teuchos::Ptr<Thyra::MultiVectorBase<ST> >& thyra_X) const {
51 // perform a simple copy
52 // RCP<Thyra::DefaultSpmdMultiVector<ST> > vec
53 // = rcp_dynamic_cast<Thyra::DefaultSpmdMultiVector<ST> >(Teuchos::rcpFromRef(*thyra_X));
54 RCP<Thyra::TpetraMultiVector<ST, LO, GO, NT> > vec =
55 rcp_dynamic_cast<Thyra::TpetraMultiVector<ST, LO, GO, NT> >(Teuchos::rcpFromRef(*thyra_X));
56 Teuchos::RCP<Tpetra::MultiVector<ST, LO, GO, NT> > ptrX =
57 Teuchos::rcp_const_cast<Tpetra::MultiVector<ST, LO, GO, NT> >(Teuchos::rcpFromRef(X));
58 fillDefaultSpmdMultiVector(vec, ptrX);
59}
60
61// Virtual function defined in MappingStrategy. This copies
62// an Epetra_MultiVector into a Thyra::MultiVectorBase with
63// blocking handled by the strides defined in the constructor.
64//
65// arguments:
66// thyra_Y - source Thyra::MultiVectorBase
67// Y - destination Epetra_MultiVector
68//
69void BasicMappingStrategy::copyThyraIntoTpetra(
70 const RCP<const Thyra::MultiVectorBase<ST> >& thyra_Y,
71 Tpetra::MultiVector<ST, LO, GO, NT>& Y) const {
72 RCP<const Tpetra::MultiVector<ST, LO, GO, NT> > tSrc =
73 Thyra::TpetraOperatorVectorExtraction<ST, LO, GO, NT>::getConstTpetraMultiVector(thyra_Y);
74
75 Y = *tSrc;
76}
77
78} // namespace TpetraHelpers
79} // end namespace Teko