// @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_TpetraLinearObjContainer_hpp__ #define __Panzer_TpetraLinearObjContainer_hpp__ #include "PanzerDiscFE_config.hpp" #include // Tpetra includes #include "Tpetra_Vector.hpp" #include "Tpetra_CrsMatrix.hpp" #include "Thyra_TpetraThyraWrappers.hpp" #include "Panzer_LinearObjFactory.hpp" #include "Panzer_ThyraObjContainer.hpp" #include "Panzer_NodeType.hpp" #include "Teuchos_RCP.hpp" namespace panzer { template class TpetraLinearObjContainer : public LinearObjContainer , public ThyraObjContainer { TpetraLinearObjContainer(); public: typedef LinearObjContainer::Members Members; typedef Tpetra::Vector VectorType; typedef Tpetra::CrsMatrix CrsMatrixType; typedef Tpetra::CrsGraph CrsGraphType; typedef Tpetra::Map MapType; typedef Tpetra::Import ImportType; typedef Tpetra::Export ExportType; TpetraLinearObjContainer(const Teuchos::RCP > & domain, const Teuchos::RCP > & range) { domainSpace = Thyra::createVectorSpace(domain); rangeSpace = Thyra::createVectorSpace(range); } 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) { Teuchos::RCP mat = get_A(); mat->setAllToScalar(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(ScalarT value) { A->setAllToScalar(value); } virtual void set_x_th(const Teuchos::RCP > & in) { if(in==Teuchos::null) { x = Teuchos::null; return; } Teuchos::RCP > x_const = TOE::getConstTpetraVector(in); x = Teuchos::rcp_const_cast >(x_const); } virtual Teuchos::RCP > get_x_th() const { return (x==Teuchos::null) ? Teuchos::null : Thyra::createVector(x,domainSpace); } virtual void set_dxdt_th(const Teuchos::RCP > & in) { if(in==Teuchos::null) { dxdt = Teuchos::null; return; } Teuchos::RCP > dxdt_const = TOE::getConstTpetraVector(in); dxdt = Teuchos::rcp_const_cast >(dxdt_const); } virtual Teuchos::RCP > get_dxdt_th() const { return (dxdt==Teuchos::null) ? Teuchos::null : Thyra::createVector(dxdt,domainSpace); } virtual void set_f_th(const Teuchos::RCP > & in) { f = (in==Teuchos::null) ? Teuchos::null : TOE::getTpetraVector(in); } virtual Teuchos::RCP > get_f_th() const { return (f==Teuchos::null) ? Teuchos::null : Thyra::createVector(f,rangeSpace); } virtual void set_A_th(const Teuchos::RCP > & in) { A = (in==Teuchos::null) ? Teuchos::null : Teuchos::rcp_dynamic_cast(TOE::getTpetraOperator(in),true); } virtual Teuchos::RCP > get_A_th() const { return (A==Teuchos::null) ? Teuchos::null : Thyra::createLinearOp(A,rangeSpace,domainSpace); } private: typedef Thyra::TpetraOperatorVectorExtraction TOE; Teuchos::RCP > domainSpace; Teuchos::RCP > rangeSpace; Teuchos::RCP > x, dxdt, f; Teuchos::RCP > A; }; } #endif