// @HEADER // ***************************************************************************** // Panzer: A partial differential equation assembly // engine for strongly coupled complex multiphysics systems // // Copyright 2011 NTESS and the Panzer contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef __Panzer_EpetraLinearObjContainer_hpp__ #define __Panzer_EpetraLinearObjContainer_hpp__ #include "PanzerDiscFE_config.hpp" #include // Epetra includes #include "Epetra_Vector.h" #include "Epetra_CrsMatrix.h" #include "Panzer_LinearObjFactory.hpp" #include "Panzer_ThyraObjContainer.hpp" #include "Teuchos_RCP.hpp" #include "Thyra_VectorBase.hpp" #include "Thyra_LinearOpBase.hpp" #include "Thyra_EpetraLinearOp.hpp" #include "Thyra_EpetraThyraWrappers.hpp" #include "Thyra_get_Epetra_Operator.hpp" namespace panzer { class EpetraLinearObjContainer : public LinearObjContainer , public ThyraObjContainer { EpetraLinearObjContainer(); public: typedef LinearObjContainer::Members Members; typedef Epetra_Vector VectorType; typedef Epetra_CrsMatrix CrsMatrixType; EpetraLinearObjContainer(const Teuchos::RCP & domain, const Teuchos::RCP & range) : domainMap(domain), rangeMap(range) { domainSpace = Thyra::create_VectorSpace(domainMap); rangeSpace = Thyra::create_VectorSpace(rangeMap); } EpetraLinearObjContainer(const Teuchos::RCP & domain, const Teuchos::RCP > & domainS, const Teuchos::RCP & range, const Teuchos::RCP > & rangeS) : domainMap(domain), rangeMap(range) { domainSpace = domainS; rangeSpace = rangeS; } virtual void initialize() { if(get_x()!=Teuchos::null) get_x()->PutScalar(0.0); if(get_dxdt()!=Teuchos::null) get_dxdt()->PutScalar(0.0); if(get_f()!=Teuchos::null) get_f()->PutScalar(0.0); if(get_A()!=Teuchos::null) get_A()->PutScalar(0.0); } //! Wipe out stored data. void clear() { set_x(Teuchos::null); set_dxdt(Teuchos::null); set_f(Teuchos::null); set_A(Teuchos::null); } inline void set_x(const Teuchos::RCP & in) { x = in; } inline const Teuchos::RCP get_x() const { return x; } inline void set_dxdt(const Teuchos::RCP & in) { dxdt = in; } inline const Teuchos::RCP get_dxdt() const { return dxdt; } inline void set_f(const Teuchos::RCP & in) { f = in; } inline const Teuchos::RCP get_f() const { return f; } inline void set_A(const Teuchos::RCP & in) { A = in; } inline const Teuchos::RCP get_A() const { return A; } void initializeMatrix(double value) { A->PutScalar(value); } virtual void set_x_th(const Teuchos::RCP > & in) { x = (in==Teuchos::null) ? Teuchos::null : Thyra::get_Epetra_Vector(*domainMap,in); } virtual Teuchos::RCP > get_x_th() const { return (x==Teuchos::null) ? Teuchos::null : Thyra::create_Vector(x,domainSpace); } virtual void set_dxdt_th(const Teuchos::RCP > & in) { dxdt = (in==Teuchos::null) ? Teuchos::null : Thyra::get_Epetra_Vector(*domainMap,in); } virtual Teuchos::RCP > get_dxdt_th() const { return (dxdt==Teuchos::null) ? Teuchos::null : Thyra::create_Vector(dxdt,domainSpace); } virtual void set_f_th(const Teuchos::RCP > & in) { f = (in==Teuchos::null) ? Teuchos::null : Thyra::get_Epetra_Vector(*rangeMap,in); } virtual Teuchos::RCP > get_f_th() const { return (f==Teuchos::null) ? Teuchos::null : Thyra::create_Vector(f,rangeSpace); } virtual void set_A_th(const Teuchos::RCP > & in) { A = (in==Teuchos::null) ? Teuchos::null : Teuchos::rcp_dynamic_cast(Thyra::get_Epetra_Operator(*in),true); } virtual Teuchos::RCP > get_A_th() const { return (A==Teuchos::null) ? Teuchos::null : Thyra::nonconstEpetraLinearOp(A); } private: Teuchos::RCP domainMap; Teuchos::RCP rangeMap; Teuchos::RCP > domainSpace; Teuchos::RCP > rangeSpace; Teuchos::RCP x, dxdt, f; Teuchos::RCP A; }; } #endif