Debian Codegraph @

packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_SchwarzOperator_def.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // ShyLU: Scalable Hybrid LU Preconditioner and Solver
4 //
5 // Copyright 2011 NTESS and the ShyLU contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef _FROSCH_SCHWARZOPERATOR_DEF_HPP
11 #define _FROSCH_SCHWARZOPERATOR_DEF_HPP
12
13 #include <FROSch_SchwarzOperator_decl.hpp>
14
15
16 namespace FROSch {
17
18 using namespace Teuchos;
19 using namespace Xpetra;
20
21 template<class SC,class LO,class GO,class NO>
22 SchwarzOperator<SC,LO,GO,NO>::SchwarzOperator(CommPtr comm) :
23 MpiComm_ (comm),
24 Verbose_ (comm->getRank()==0)
25 {
26
27 }
28
29 template<class SC,class LO,class GO,class NO>
30 SchwarzOperator<SC,LO,GO,NO>::SchwarzOperator(ConstXMatrixPtr k,
31 ParameterListPtr parameterList) :
32 MpiComm_ (k->getRangeMap()->getComm()),
33 K_ (k),
34 ParameterList_ (parameterList),
35 Verbose_ (MpiComm_->getRank()==0),
36 LevelID_ (ParameterList_->get("Level ID",UN(1)))
37 {
38 FROSCH_ASSERT(getDomainMap()->isSameAs(*getRangeMap()),"SchwarzOperator assumes DomainMap==RangeMap");
39 }
40
41 template<class SC,class LO,class GO,class NO>
42 SchwarzOperator<SC,LO,GO,NO>::~SchwarzOperator()
43 {
44
45 }
46
47 template<class SC,class LO,class GO,class NO>
48 void SchwarzOperator<SC,LO,GO,NO>::apply(const XMultiVector &x,
49 XMultiVector &y,
50 ETransp mode,
51 SC alpha,
52 SC beta) const
53 {
54 return apply(x,y,false,mode,alpha,beta);
55 }
56
57 template<class SC,class LO,class GO,class NO>
58 const typename SchwarzOperator<SC,LO,GO,NO>::ConstXMapPtr SchwarzOperator<SC,LO,GO,NO>::getDomainMap() const
59 {
60 return K_->getDomainMap();
61 }
62
63 template<class SC,class LO,class GO,class NO>
64 const typename SchwarzOperator<SC,LO,GO,NO>::ConstXMapPtr SchwarzOperator<SC,LO,GO,NO>::getRangeMap() const
65 {
66 return K_->getRangeMap();
67 }
68
69 template<class SC,class LO,class GO,class NO>
70 bool SchwarzOperator<SC,LO,GO,NO>::isInitialized() const
71 {
72 return IsInitialized_;
73 }
74
75 template<class SC,class LO,class GO,class NO>
76 bool SchwarzOperator<SC,LO,GO,NO>::isComputed() const
77 {
78 return IsComputed_;
79 }
80
81 template<class SC,class LO,class GO,class NO>
82 int SchwarzOperator<SC,LO,GO,NO>::resetMatrix(ConstXMatrixPtr &k) {
83 // Maybe set IsComputed_ = false ? -> Go through code to be saver/cleaner
84 // This function must be actively called by the user, and is only for recycling purposes.
85 // The preconditioner is still computed and this point or the preconditioner was never computed and can now be computed with the matrix k now.
86 K_ = k;
87 return 0;
88 }
89
90 template<class SC,class LO,class GO,class NO>
91 void SchwarzOperator<SC,LO,GO,NO>::residual(const XMultiVector & X,
92 const XMultiVector & B,
93 XMultiVector& R) const
94 {
95 SC one = ScalarTraits<SC>::one(), negone = -one;
96 apply(X,R);
97 R.update(one,B,negone);
98 }
99 }
100
101 #endif