Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_EpetraLinearObjContainer.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef __Panzer_EpetraLinearObjContainer_hpp__
44 #define __Panzer_EpetraLinearObjContainer_hpp__
45 
46 #include "PanzerDiscFE_config.hpp"
47 
48 #include <map>
49 
50 // Epetra includes
51 #include "Epetra_Vector.h"
52 #include "Epetra_CrsMatrix.h"
53 
56 
57 #include "Teuchos_RCP.hpp"
58 
59 #include "Thyra_VectorBase.hpp"
60 #include "Thyra_LinearOpBase.hpp"
61 #include "Thyra_EpetraLinearOp.hpp"
62 #include "Thyra_EpetraThyraWrappers.hpp"
63 #include "Thyra_get_Epetra_Operator.hpp"
64 
65 namespace panzer {
66 
68  , public ThyraObjContainer<double> {
69 
71 
72 public:
74 
77 
79  const Teuchos::RCP<const Epetra_Map> & range)
80  : domainMap(domain), rangeMap(range)
81  {
82  domainSpace = Thyra::create_VectorSpace(domainMap);
83  rangeSpace = Thyra::create_VectorSpace(rangeMap);
84  }
85 
87  const Teuchos::RCP<const Thyra::VectorSpaceBase<double> > & domainS,
88  const Teuchos::RCP<const Epetra_Map> & range,
89  const Teuchos::RCP<const Thyra::VectorSpaceBase<double> > & rangeS)
90  : domainMap(domain), rangeMap(range)
91  {
92  domainSpace = domainS;
93  rangeSpace = rangeS;
94  }
95 
96  virtual void initialize()
97  {
98  if(get_x()!=Teuchos::null) get_x()->PutScalar(0.0);
99  if(get_dxdt()!=Teuchos::null) get_dxdt()->PutScalar(0.0);
100  if(get_f()!=Teuchos::null) get_f()->PutScalar(0.0);
101  if(get_A()!=Teuchos::null) get_A()->PutScalar(0.0);
102  }
103 
105  void clear()
106  {
107  set_x(Teuchos::null);
108  set_dxdt(Teuchos::null);
109  set_f(Teuchos::null);
110  set_A(Teuchos::null);
111  }
112 
113  inline void set_x(const Teuchos::RCP<Epetra_Vector> & in) { x = in; }
114  inline const Teuchos::RCP<Epetra_Vector> get_x() const { return x; }
115 
116  inline void set_dxdt(const Teuchos::RCP<Epetra_Vector> & in) { dxdt = in; }
117  inline const Teuchos::RCP<Epetra_Vector> get_dxdt() const { return dxdt; }
118 
119  inline void set_f(const Teuchos::RCP<Epetra_Vector> & in) { f = in; }
120  inline const Teuchos::RCP<Epetra_Vector> get_f() const { return f; }
121 
122  inline void set_A(const Teuchos::RCP<Epetra_CrsMatrix> & in) { A = in; }
123  inline const Teuchos::RCP<Epetra_CrsMatrix> get_A() const { return A; }
124 
125  void initializeMatrix(double value)
126  { A->PutScalar(value); }
127 
128  virtual void set_x_th(const Teuchos::RCP<Thyra::VectorBase<double> > & in)
129  { x = (in==Teuchos::null) ? Teuchos::null : Thyra::get_Epetra_Vector(*domainMap,in); }
131  { return (x==Teuchos::null) ? Teuchos::null : Thyra::create_Vector(x,domainSpace); }
132 
134  { dxdt = (in==Teuchos::null) ? Teuchos::null : Thyra::get_Epetra_Vector(*domainMap,in); }
136  { return (dxdt==Teuchos::null) ? Teuchos::null : Thyra::create_Vector(dxdt,domainSpace); }
137 
139  { f = (in==Teuchos::null) ? Teuchos::null : Thyra::get_Epetra_Vector(*rangeMap,in); }
141  { return (f==Teuchos::null) ? Teuchos::null : Thyra::create_Vector(f,rangeSpace); }
142 
144  { A = (in==Teuchos::null) ? Teuchos::null : Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(Thyra::get_Epetra_Operator(*in),true); }
146  { return (A==Teuchos::null) ? Teuchos::null : Thyra::nonconstEpetraLinearOp(A); }
147 
148 private:
155 };
156 
157 }
158 
159 #endif
virtual void set_dxdt_th(const Teuchos::RCP< Thyra::VectorBase< double > > &in)
EpetraLinearObjContainer(const Teuchos::RCP< const Epetra_Map > &domain, const Teuchos::RCP< const Epetra_Map > &range)
void set_f(const Teuchos::RCP< Epetra_Vector > &in)
const Teuchos::RCP< Epetra_Vector > get_x() const
virtual void set_x_th(const Teuchos::RCP< Thyra::VectorBase< double > > &in)
virtual Teuchos::RCP< Thyra::VectorBase< double > > get_x_th() const
void set_A(const Teuchos::RCP< Epetra_CrsMatrix > &in)
virtual void set_A_th(const Teuchos::RCP< Thyra::LinearOpBase< double > > &in)
const Teuchos::RCP< Epetra_CrsMatrix > get_A() const
void set_dxdt(const Teuchos::RCP< Epetra_Vector > &in)
int PutScalar(double ScalarConstant)
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > domainSpace
virtual Teuchos::RCP< Thyra::LinearOpBase< double > > get_A_th() const
virtual void set_f_th(const Teuchos::RCP< Thyra::VectorBase< double > > &in)
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > rangeSpace
const Teuchos::RCP< Epetra_Vector > get_f() const
virtual Teuchos::RCP< Thyra::VectorBase< double > > get_dxdt_th() const
void set_x(const Teuchos::RCP< Epetra_Vector > &in)
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 initializeMatrix(double value)
Put a particular scalar in the matrix.
const Teuchos::RCP< Epetra_Vector > get_dxdt() const
virtual Teuchos::RCP< Thyra::VectorBase< double > > get_f_th() const