Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_EpetraLinearObjContainer.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
11#ifndef __Panzer_EpetraLinearObjContainer_hpp__
12#define __Panzer_EpetraLinearObjContainer_hpp__
13
14#include "PanzerDiscFE_config.hpp"
15
16#include <map>
17
18// Epetra includes
19#include "Epetra_Vector.h"
20#include "Epetra_CrsMatrix.h"
21
24
25#include "Teuchos_RCP.hpp"
26
27#include "Thyra_VectorBase.hpp"
28#include "Thyra_LinearOpBase.hpp"
29#include "Thyra_EpetraLinearOp.hpp"
30#include "Thyra_EpetraThyraWrappers.hpp"
31#include "Thyra_get_Epetra_Operator.hpp"
32
33namespace panzer {
34
36 , public ThyraObjContainer<double> {
37
39
40public:
42
45
46 EpetraLinearObjContainer(const Teuchos::RCP<const Epetra_Map> & domain,
47 const Teuchos::RCP<const Epetra_Map> & range)
48 : domainMap(domain), rangeMap(range)
49 {
50 domainSpace = Thyra::create_VectorSpace(domainMap);
51 rangeSpace = Thyra::create_VectorSpace(rangeMap);
52 }
53
54 EpetraLinearObjContainer(const Teuchos::RCP<const Epetra_Map> & domain,
55 const Teuchos::RCP<const Thyra::VectorSpaceBase<double> > & domainS,
56 const Teuchos::RCP<const Epetra_Map> & range,
57 const Teuchos::RCP<const Thyra::VectorSpaceBase<double> > & rangeS)
58 : domainMap(domain), rangeMap(range)
59 {
60 domainSpace = domainS;
61 rangeSpace = rangeS;
62 }
63
64 virtual void initialize()
65 {
66 if(get_x()!=Teuchos::null) get_x()->PutScalar(0.0);
67 if(get_dxdt()!=Teuchos::null) get_dxdt()->PutScalar(0.0);
68 if(get_f()!=Teuchos::null) get_f()->PutScalar(0.0);
69 if(get_A()!=Teuchos::null) get_A()->PutScalar(0.0);
70 }
71
73 void clear()
74 {
75 set_x(Teuchos::null);
76 set_dxdt(Teuchos::null);
77 set_f(Teuchos::null);
78 set_A(Teuchos::null);
79 }
80
81 inline void set_x(const Teuchos::RCP<Epetra_Vector> & in) { x = in; }
82 inline const Teuchos::RCP<Epetra_Vector> get_x() const { return x; }
83
84 inline void set_dxdt(const Teuchos::RCP<Epetra_Vector> & in) { dxdt = in; }
85 inline const Teuchos::RCP<Epetra_Vector> get_dxdt() const { return dxdt; }
86
87 inline void set_f(const Teuchos::RCP<Epetra_Vector> & in) { f = in; }
88 inline const Teuchos::RCP<Epetra_Vector> get_f() const { return f; }
89
90 inline void set_A(const Teuchos::RCP<Epetra_CrsMatrix> & in) { A = in; }
91 inline const Teuchos::RCP<Epetra_CrsMatrix> get_A() const { return A; }
92
93 void initializeMatrix(double value)
94 { A->PutScalar(value); }
95
96 virtual void set_x_th(const Teuchos::RCP<Thyra::VectorBase<double> > & in)
97 { x = (in==Teuchos::null) ? Teuchos::null : Thyra::get_Epetra_Vector(*domainMap,in); }
98 virtual Teuchos::RCP<Thyra::VectorBase<double> > get_x_th() const
99 { return (x==Teuchos::null) ? Teuchos::null : Thyra::create_Vector(x,domainSpace); }
100
101 virtual void set_dxdt_th(const Teuchos::RCP<Thyra::VectorBase<double> > & in)
102 { dxdt = (in==Teuchos::null) ? Teuchos::null : Thyra::get_Epetra_Vector(*domainMap,in); }
103 virtual Teuchos::RCP<Thyra::VectorBase<double> > get_dxdt_th() const
104 { return (dxdt==Teuchos::null) ? Teuchos::null : Thyra::create_Vector(dxdt,domainSpace); }
105
106 virtual void set_f_th(const Teuchos::RCP<Thyra::VectorBase<double> > & in)
107 { f = (in==Teuchos::null) ? Teuchos::null : Thyra::get_Epetra_Vector(*rangeMap,in); }
108 virtual Teuchos::RCP<Thyra::VectorBase<double> > get_f_th() const
109 { return (f==Teuchos::null) ? Teuchos::null : Thyra::create_Vector(f,rangeSpace); }
110
111 virtual void set_A_th(const Teuchos::RCP<Thyra::LinearOpBase<double> > & in)
112 { A = (in==Teuchos::null) ? Teuchos::null : Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(Thyra::get_Epetra_Operator(*in),true); }
113 virtual Teuchos::RCP<Thyra::LinearOpBase<double> > get_A_th() const
114 { return (A==Teuchos::null) ? Teuchos::null : Thyra::nonconstEpetraLinearOp(A); }
115
116private:
117 Teuchos::RCP<const Epetra_Map> domainMap;
118 Teuchos::RCP<const Epetra_Map> rangeMap;
119 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > domainSpace;
120 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > rangeSpace;
121 Teuchos::RCP<Epetra_Vector> x, dxdt, f;
122 Teuchos::RCP<Epetra_CrsMatrix> A;
123};
124
125}
126
127#endif
virtual Teuchos::RCP< Thyra::VectorBase< double > > get_x_th() const
void set_f(const Teuchos::RCP< Epetra_Vector > &in)
virtual void set_f_th(const Teuchos::RCP< Thyra::VectorBase< double > > &in)
void set_x(const Teuchos::RCP< Epetra_Vector > &in)
EpetraLinearObjContainer(const Teuchos::RCP< const Epetra_Map > &domain, const Teuchos::RCP< const Epetra_Map > &range)
const Teuchos::RCP< Epetra_CrsMatrix > get_A() const
virtual void set_x_th(const Teuchos::RCP< Thyra::VectorBase< double > > &in)
virtual void set_dxdt_th(const Teuchos::RCP< Thyra::VectorBase< double > > &in)
const Teuchos::RCP< Epetra_Vector > get_dxdt() const
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > domainSpace
void initializeMatrix(double value)
Put a particular scalar in the matrix.
virtual Teuchos::RCP< Thyra::LinearOpBase< double > > get_A_th() const
EpetraLinearObjContainer(const Teuchos::RCP< const Epetra_Map > &domain, const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &domainS, const Teuchos::RCP< const Epetra_Map > &range, const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &rangeS)
void set_A(const Teuchos::RCP< Epetra_CrsMatrix > &in)
const Teuchos::RCP< Epetra_Vector > get_f() const
virtual void set_A_th(const Teuchos::RCP< Thyra::LinearOpBase< double > > &in)
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > rangeSpace
virtual Teuchos::RCP< Thyra::VectorBase< double > > get_dxdt_th() const
const Teuchos::RCP< Epetra_Vector > get_x() const
virtual Teuchos::RCP< Thyra::VectorBase< double > > get_f_th() const
void set_dxdt(const Teuchos::RCP< Epetra_Vector > &in)