MueLu
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
MueLu_AMGXOperator_def.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// MueLu: A package for multigrid based preconditioning
4
//
5
// Copyright 2012 NTESS and the MueLu contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef MUELU_AMGXOPERATOR_DEF_HPP
11
#define MUELU_AMGXOPERATOR_DEF_HPP
12
13
#if defined(HAVE_MUELU_AMGX)
14
#include "
MueLu_AMGXOperator_decl.hpp
"
15
16
namespace
MueLu
{
17
18
template
<
class
Node>
19
Teuchos::RCP<const Tpetra::Map<int, int, Node> >
20
AMGXOperator<double, int, int, Node>::getDomainMap
()
const
{
21
return
domainMap_
;
22
}
23
24
template
<
class
Node>
25
Teuchos::RCP<const Tpetra::Map<int, int, Node> >
AMGXOperator<double, int, int, Node>::getRangeMap
()
const
{
26
return
rangeMap_
;
27
}
28
29
template
<
class
Node>
30
void
AMGXOperator<double, int, int, Node>::apply
(
const
Tpetra::MultiVector<double, int, int, Node>& X,
31
Tpetra::MultiVector<double, int, int, Node>& Y,
32
Teuchos::ETransp mode,
double
alpha,
double
beta)
const
{
33
RCP<const Teuchos::Comm<int> > comm = Y.getMap()->getComm();
34
35
ArrayRCP<const double> mueluXdata, amgxXdata;
36
ArrayRCP<double> mueluYdata, amgxYdata;
37
38
try
{
39
for
(
int
i = 0; i < (int)Y.getNumVectors(); i++) {
40
{
41
vectorTimer1_
->start();
42
43
mueluXdata = X.getData(i);
44
mueluYdata = Y.getDataNonConst(i);
45
46
if
(comm->getSize() == 1) {
47
amgxXdata = mueluXdata;
48
amgxYdata = mueluYdata;
49
50
}
else
{
51
int
n = mueluXdata.size();
52
53
amgxXdata.resize(n);
54
amgxYdata.resize(n);
55
56
ArrayRCP<double> amgxXdata_nonConst = Teuchos::arcp_const_cast<double>(amgxXdata);
57
for
(
int
j = 0; j < n; j++) {
58
amgxXdata_nonConst[
muelu2amgx_
[j]] = mueluXdata[j];
59
amgxYdata[
muelu2amgx_
[j]] = mueluYdata[j];
60
}
61
}
62
63
AMGX_vector_upload(
X_
,
N_
, 1, &amgxXdata[0]);
64
AMGX_vector_upload(
Y_
,
N_
, 1, &amgxYdata[0]);
65
66
vectorTimer1_
->stop();
67
vectorTimer1_
->incrementNumCalls();
68
}
69
70
// Solve the system and time.
71
solverTimer_
->start();
72
AMGX_solver_solve(
Solver_
,
X_
,
Y_
);
73
solverTimer_
->stop();
74
solverTimer_
->incrementNumCalls();
75
76
{
77
vectorTimer2_
->start();
78
79
AMGX_vector_download(
Y_
, &amgxYdata[0]);
80
81
if
(comm->getSize() > 1) {
82
int
n = mueluYdata.size();
83
84
for
(
int
j = 0; j < n; j++)
85
mueluYdata[j] = amgxYdata[
muelu2amgx_
[j]];
86
}
87
88
vectorTimer2_
->stop();
89
vectorTimer2_
->incrementNumCalls();
90
}
91
}
92
93
}
catch
(std::exception& e) {
94
std::string errMsg = std::string(
"Caught an exception in MueLu::AMGXOperator::Apply():\n"
) + e.what() +
"\n"
;
95
throw
Exceptions::RuntimeError
(errMsg);
96
}
97
}
98
99
template
<
class
Node>
100
bool
AMGXOperator<double, int, int, Node>::hasTransposeApply
()
const
{
101
return
false
;
102
}
103
104
}
// namespace MueLu
105
#endif
// if defined(HAVE_MUELU_AMGX)
106
107
#endif
// ifdef MUELU_AMGXOPERATOR_DEF_HPP
MueLu_AMGXOperator_decl.hpp
MueLu::AMGXOperator< double, int, int, Node >::Solver_
AMGX_solver_handle Solver_
Definition
MueLu_AMGXOperator_decl.hpp:470
MueLu::AMGXOperator< double, int, int, Node >::vectorTimer1_
RCP< Teuchos::Time > vectorTimer1_
Definition
MueLu_AMGXOperator_decl.hpp:483
MueLu::AMGXOperator< double, int, int, Node >::Y_
AMGX_vector_handle Y_
Definition
MueLu_AMGXOperator_decl.hpp:475
MueLu::AMGXOperator< double, int, int, Node >::domainMap_
RCP< const Map > domainMap_
Definition
MueLu_AMGXOperator_decl.hpp:478
MueLu::AMGXOperator< double, int, int, Node >::N_
int N_
Definition
MueLu_AMGXOperator_decl.hpp:476
MueLu::AMGXOperator< double, int, int, Node >::muelu2amgx_
std::vector< int > muelu2amgx_
Definition
MueLu_AMGXOperator_decl.hpp:481
MueLu::AMGXOperator< double, int, int, Node >::rangeMap_
RCP< const Map > rangeMap_
Definition
MueLu_AMGXOperator_decl.hpp:479
MueLu::AMGXOperator< double, int, int, Node >::solverTimer_
RCP< Teuchos::Time > solverTimer_
Definition
MueLu_AMGXOperator_decl.hpp:485
MueLu::AMGXOperator< double, int, int, Node >::vectorTimer2_
RCP< Teuchos::Time > vectorTimer2_
Definition
MueLu_AMGXOperator_decl.hpp:484
MueLu::AMGXOperator< double, int, int, Node >::X_
AMGX_vector_handle X_
Definition
MueLu_AMGXOperator_decl.hpp:474
MueLu::AMGXOperator::apply
void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Returns a solution for the linear system AX=Y in the Tpetra::MultiVector X.
Definition
MueLu_AMGXOperator_decl.hpp:81
MueLu::AMGXOperator::getRangeMap
Teuchos::RCP< const Map > getRangeMap() const
Returns the Tpetra::Map object associated with the range of this operator.
Definition
MueLu_AMGXOperator_decl.hpp:72
MueLu::AMGXOperator::hasTransposeApply
bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Definition
MueLu_AMGXOperator_decl.hpp:87
MueLu::AMGXOperator::getDomainMap
Teuchos::RCP< const Map > getDomainMap() const
Returns the Tpetra::Map object associated with the domain of this operator.
Definition
MueLu_AMGXOperator_decl.hpp:67
MueLu::Exceptions::RuntimeError
Exception throws to report errors in the internal logical of the program.
Definition
MueLu_Exceptions.hpp:36
MueLu
Namespace for MueLu classes and methods.
Definition
MueLu_BrickAggregationFactory_decl.hpp:42
adapters
amgx
MueLu_AMGXOperator_def.hpp
Generated by
1.17.0