Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_TpetraLinearObjFactory_decl.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_TpetraLinearObjFactory_decl_hpp__
12 #define __Panzer_TpetraLinearObjFactory_decl_hpp__
13 
14 #include <map>
15 
16 // Tpetra includes
17 #include "Tpetra_Map.hpp"
18 #include "Tpetra_CrsGraph.hpp"
19 #include "Tpetra_CrsMatrix.hpp"
20 #include "Tpetra_Import.hpp"
21 #include "Tpetra_Export.hpp"
22 
23 #include "PanzerDiscFE_config.hpp"
24 #include "Panzer_GlobalIndexer.hpp"
27 #include "Panzer_ScatterResidual_Tpetra.hpp"
28 #include "Panzer_ScatterDirichletResidual_Tpetra.hpp"
29 #include "Panzer_GatherSolution_Tpetra.hpp"
30 #include "Panzer_GatherTangent_Tpetra.hpp"
31 #include "Panzer_GatherOrientation.hpp"
34 
35 #include"Panzer_NodeType.hpp"
36 
37 #include "Teuchos_RCP.hpp"
39 
40 namespace panzer {
41 
42 template <typename Traits,typename ScalarT,typename LocalOrdinalT,typename GlobalOrdinalT,typename NodeT=panzer::TpetraNodeType>
44  , public ThyraObjFactory<ScalarT> {
45 public:
47  typedef Tpetra::Vector<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> VectorType;
48  typedef Tpetra::CrsMatrix<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> CrsMatrixType;
49  typedef Tpetra::CrsGraph<LocalOrdinalT,GlobalOrdinalT,NodeT> CrsGraphType;
50  typedef Tpetra::Map<LocalOrdinalT,GlobalOrdinalT,NodeT> MapType;
51  typedef Tpetra::Import<LocalOrdinalT,GlobalOrdinalT,NodeT> ImportType;
52  typedef Tpetra::Export<LocalOrdinalT,GlobalOrdinalT,NodeT> ExportType;
53 
55  const Teuchos::RCP<const GlobalIndexer> & gidProvider);
56 
58  const Teuchos::RCP<const GlobalIndexer> & rowProvider,
59  const Teuchos::RCP<const GlobalIndexer> & colProvider);
60 
61  virtual ~TpetraLinearObjFactory();
62 
63 /*************** Linear object factory methods *******************/
64 
65  virtual void readVector(const std::string & /* identifier */, LinearObjContainer & /* loc */, int /* id */) const
66  { TEUCHOS_ASSERT(false); }
67 
68  virtual void writeVector(const std::string & /* identifier */, const LinearObjContainer & /* loc */, int /* id */) const
69  { TEUCHOS_ASSERT(false); }
70 
72 
74  { return buildLinearObjContainer(); }
75 
77 
79  { return buildGhostedLinearObjContainer(); }
80 
81  virtual void globalToGhostContainer(const LinearObjContainer & container,
82  LinearObjContainer & ghostContainer,int) const;
83  virtual void ghostToGlobalContainer(const LinearObjContainer & ghostContainer,
84  LinearObjContainer & container,int) const;
85 
92  virtual void adjustForDirichletConditions(const LinearObjContainer & localBCRows,
93  const LinearObjContainer & globalBCRows,
94  LinearObjContainer & ghostedObjs,
95  bool zeroVectorRows=false, bool adjustX=false) const;
96 
100  virtual void applyDirichletBCs(const LinearObjContainer & counter,
101  LinearObjContainer & result) const;
102 
108 
109 #ifdef PANZER_HAVE_EPETRA_STACK
110 
114  virtual Teuchos::RCP<WriteVector_GlobalEvaluationData> buildWriteDomainContainer() const;
115 #endif
116 
119  virtual Teuchos::MpiComm<int> getComm() const;
120 
122  template <typename EvalT>
125 
127  template <typename EvalT>
130 
132  template <typename EvalT>
135 
137  template <typename EvalT>
140 
142  template <typename EvalT>
145 
147  template <typename EvalT>
150 
151 /*************** From ThyraObjFactory *******************/
152 
155 
158 
161 
162 /*************** Tpetra construction functions *******************/
163 
170 
171 /*************** Generic helper functions for container setup *******************/
172 
178  void initializeContainer(int,LinearObjContainer & loc) const;
179 
186 
192  void initializeGhostedContainer(int,LinearObjContainer & loc) const;
193 
200 
201 /*************** Tpetra based methods *******************/
202 
206 
210 
213 
216 
220 
224 
227 
230  { return gidProvider_; }
231 
234  { return gidProvider_; }
235 
236  virtual void beginFill(LinearObjContainer & loc) const;
237  virtual void endFill(LinearObjContainer & loc) const;
238 
239 protected:
240 
241  void ghostToGlobalTpetraVector(const Tpetra::Vector<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> & in,
242  Tpetra::Vector<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> & out, bool col) const;
243  void ghostToGlobalTpetraMatrix(const Tpetra::CrsMatrix<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> & in,
244  Tpetra::CrsMatrix<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> & out) const;
245  void globalToGhostTpetraVector(const Tpetra::Vector<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>& in,
246  Tpetra::Vector<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> & out, bool col) const;
247 
248  // get the map from the matrix
253 
254  // get the graph of the crs matrix
257 
258  // storage for Tpetra graphs and maps
270 
273 
275 
278 };
279 
280 }
281 
282 #endif
Teuchos::RCP< panzer::CloneableEvaluator > buildGatherOrientation() const
Use preconstructed gather evaluators.
virtual const Teuchos::RCP< Tpetra::Export< LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedExport() const
get exporter for converting an overalapped object to a &quot;normal&quot; object
virtual void globalToGhostContainer(const LinearObjContainer &container, LinearObjContainer &ghostContainer, int) const
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > domainSpace_
Teuchos::RCP< Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > getTpetraVector() const
virtual const Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedColMap() const
Teuchos::RCP< const GlobalIndexer > gidProvider_
virtual Teuchos::MpiComm< int > getComm() const
Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > cGhostedMap_
virtual Teuchos::RCP< LinearObjContainer > buildGhostedLinearObjContainer() const
void initializeGhostedContainer(int, LinearObjContainer &loc) const
virtual Teuchos::RCP< ReadOnlyVector_GlobalEvaluationData > buildReadOnlyDomainContainer() const
Teuchos::RCP< panzer::CloneableEvaluator > buildGatherDomain() const
Use preconstructed gather evaluators.
Teuchos::RCP< Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedTpetraVector() const
virtual const Teuchos::RCP< Tpetra::CrsGraph< LocalOrdinalT, GlobalOrdinalT, NodeT > > buildGhostedGraph() const
virtual Teuchos::RCP< const Thyra::VectorSpaceBase< ScalarT > > getThyraDomainSpace() const
Get the domain space.
Teuchos::RCP< Tpetra::CrsMatrix< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > getTpetraMatrix() const
Teuchos::RCP< panzer::CloneableEvaluator > buildGatherTangent() const
Use preconstructed gather evaluators.
virtual const Teuchos::RCP< Tpetra::Import< LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedImport() const
get importer for converting an overalapped object to a &quot;normal&quot; object
Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > cMap_
void initializeContainer(int, LinearObjContainer &loc) const
Teuchos::RCP< Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > getTpetraColVector() const
Teuchos::RCP< const panzer::GlobalIndexer > getDomainGlobalIndexer() const
Get the domain global indexer this factory was created with.
virtual void endFill(LinearObjContainer &loc) const
Gathers tangent vectors dx/dp for computing df/dx*dx/dp + df/dp into the nodal fields of the field ma...
virtual const Teuchos::RCP< Tpetra::Import< LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedColImport() const
virtual void beginFill(LinearObjContainer &loc) const
Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > MapType
virtual const Teuchos::RCP< const Teuchos::Comm< int > > getTeuchosComm() const
get exporter for converting an overalapped object to a &quot;normal&quot; object
Tpetra::Import< LocalOrdinalT, GlobalOrdinalT, NodeT > ImportType
virtual const Teuchos::RCP< Tpetra::Export< LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedColExport() const
Teuchos::RCP< Tpetra::CrsMatrix< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedTpetraMatrix() const
virtual const Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > getColMap() const
virtual void adjustForDirichletConditions(const LinearObjContainer &localBCRows, const LinearObjContainer &globalBCRows, LinearObjContainer &ghostedObjs, bool zeroVectorRows=false, bool adjustX=false) const
void globalToGhostTpetraVector(const Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > &in, Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > &out, bool col) const
PHX::MDField< ScalarT, panzer::Cell, panzer::IP > result
A field that will be used to build up the result of the integral we&#39;re performing.
void ghostToGlobalTpetraMatrix(const Tpetra::CrsMatrix< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > &in, Tpetra::CrsMatrix< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > &out) const
Teuchos::RCP< panzer::CloneableEvaluator > buildGather() const
Use preconstructed gather evaluators.
Tpetra::Export< LocalOrdinalT, GlobalOrdinalT, NodeT > ExportType
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Tpetra::CrsMatrix< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > CrsMatrixType
virtual Teuchos::RCP< LinearObjContainer > buildLinearObjContainer() const
Teuchos::RCP< panzer::CloneableEvaluator > buildScatterDirichlet() const
Use preconstructed dirichlet scatter evaluators.
TpetraLinearObjContainer< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > ContainerType
Gathers solution values from the Newton solution vector into the nodal fields of the field manager...
virtual const Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedMap() const
get the ghosted map from the matrix
Pushes residual values into the residual vector for a Newton-based solve.
virtual const Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > buildColMap() const
virtual const Teuchos::RCP< Tpetra::CrsGraph< LocalOrdinalT, GlobalOrdinalT, NodeT > > buildGraph() const
Teuchos::RCP< Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedTpetraColVector() const
virtual const Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > getMap() const
get the map from the matrix
Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > ghostedMap_
Teuchos::RCP< Tpetra::CrsGraph< LocalOrdinalT, GlobalOrdinalT, NodeT > > graph_
virtual const Teuchos::RCP< Tpetra::CrsGraph< LocalOrdinalT, GlobalOrdinalT, NodeT > > getGraph() const
get the graph of the crs matrix
Teuchos::RCP< Tpetra::CrsGraph< LocalOrdinalT, GlobalOrdinalT, NodeT > > ghostedGraph_
Pushes residual values into the residual vector for a Newton-based solve.
TpetraLinearObjFactory(const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< const GlobalIndexer > &gidProvider)
virtual const Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > buildMap() const
Teuchos::RCP< const GlobalIndexer > colGidProvider_
virtual Teuchos::RCP< LinearObjContainer > buildPrimitiveGhostedLinearObjContainer() const
Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > map_
virtual Teuchos::RCP< const Thyra::VectorSpaceBase< ScalarT > > getThyraRangeSpace() const
Get the range space.
virtual const Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > buildGhostedColMap() const
virtual void ghostToGlobalContainer(const LinearObjContainer &ghostContainer, LinearObjContainer &container, int) const
Gathers orientations per field from the global indexer and stores them in the field manager...
virtual void readVector(const std::string &, LinearObjContainer &, int) const
virtual Teuchos::RCP< Thyra::LinearOpBase< ScalarT > > getThyraMatrix() const
Get a matrix operator.
Teuchos::RCP< const Teuchos::Comm< int > > comm_
#define TEUCHOS_ASSERT(assertion_test)
void ghostToGlobalTpetraVector(const Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > &in, Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > &out, bool col) const
Teuchos::RCP< panzer::CloneableEvaluator > buildScatter() const
Use preconstructed scatter evaluators.
virtual void writeVector(const std::string &, const LinearObjContainer &, int) const
virtual Teuchos::RCP< LinearObjContainer > buildPrimitiveLinearObjContainer() const
Tpetra::CrsGraph< LocalOrdinalT, GlobalOrdinalT, NodeT > CrsGraphType
Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > VectorType
Teuchos::RCP< const panzer::GlobalIndexer > getRangeGlobalIndexer() const
Get the domain global indexer this factory was created with.
virtual const Teuchos::RCP< Tpetra::CrsGraph< LocalOrdinalT, GlobalOrdinalT, NodeT > > getGhostedGraph() const
get the ghosted graph of the crs matrix
virtual const Teuchos::RCP< Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > buildGhostedMap() const
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > rangeSpace_
virtual void applyDirichletBCs(const LinearObjContainer &counter, LinearObjContainer &result) const