Panzer  Version of the Day
Panzer_Response_Functional.hpp
Go to the documentation of this file.
1 #ifndef __Panzer_Response_Functional_hpp__
2 #define __Panzer_Response_Functional_hpp__
3 
4 #include <string>
5 
6 
7 #include <mpi.h> // need for comm
8 
9 #include "Teuchos_RCP.hpp"
10 
11 #include "Thyra_VectorBase.hpp"
12 #include "Thyra_VectorSpaceBase.hpp"
13 
14 #include "Epetra_Map.h"
15 #include "Epetra_Vector.h"
16 #include "Epetra_MpiComm.h"
17 
23 
24 
25 namespace panzer {
26 
31 template <typename EvalT>
34 public:
35  typedef typename EvalT::ScalarT ScalarT;
36 
37  Response_Functional(const std::string & responseName,MPI_Comm comm,
38  const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > & linObjFact=Teuchos::null)
39  : ResponseMESupport_Default<EvalT>(responseName,comm), value(0.0), linObjFactory_(linObjFact)
40  {
41  if(linObjFactory_!=Teuchos::null) {
42  // requires thyra object factory
43  thyraObjFactory_ = Teuchos::rcp_dynamic_cast<const panzer::ThyraObjFactory<double> >(linObjFactory_,true);
44  setSolnVectorSpace(thyraObjFactory_->getThyraDomainSpace());
45 
46  // build a ghosted container, with a solution vector
47  ghostedContainer_ = linObjFactory_->buildGhostedLinearObjContainer();
48 
49  // set ghosted container (work space for assembly)
51 
52  using Teuchos::rcp_dynamic_cast;
53  }
54  }
55 
58 
60  virtual void scatterResponse();
61 
62  virtual void initializeResponse()
63  { value = 0.0; if(ghostedContainer_!=Teuchos::null) ghostedContainer_->initialize(); }
64 
65  // from ResponseMESupport_Default
66 
68  virtual std::size_t localSizeRequired() const { return 1; }
69 
71  virtual bool vectorIsDistributed() const { return false; }
72 
74  Teuchos::RCP<Thyra::VectorBase<double> > getGhostedVector() const
75  { return Teuchos::rcp_dynamic_cast<const ThyraObjContainer<double> >(ghostedContainer_)->get_x_th(); }
76 
77  void adjustForDirichletConditions(const GlobalEvaluationData & localBCRows,const GlobalEvaluationData & globalBCRows);
78 
79 private:
81  void setSolnVectorSpace(const Teuchos::RCP<const Thyra::VectorSpaceBase<double> > & soln_vs);
82 
83  // hide these methods
86 
87  Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > linObjFactory_;
88  Teuchos::RCP<const panzer::ThyraObjFactory<double> > thyraObjFactory_;
89 
90  Teuchos::RCP<LinearObjContainer> uniqueContainer_;
91  Teuchos::RCP<LinearObjContainer> ghostedContainer_;
92 };
93 
94 }
95 
96 #endif
Response_Functional(const std::string &responseName, MPI_Comm comm, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &linObjFact=Teuchos::null)
ScalarT value
provide direct access, this thing is pretty simple
Teuchos::RCP< LinearObjContainer > ghostedContainer_
virtual void scatterResponse()
This simply does global summation, then shoves the result into a vector.
Teuchos::RCP< const panzer::ThyraObjFactory< double > > thyraObjFactory_
Teuchos::RCP< LinearObjContainer > uniqueContainer_
virtual std::size_t localSizeRequired() const
What is the number of values you need locally.
virtual bool vectorIsDistributed() const
Is the vector distributed (or replicated)
Teuchos::RCP< const Teuchos::Comm< int > > comm
void setSolnVectorSpace(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &soln_vs)
Set solution vector space.
Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > linObjFactory_
Teuchos::RCP< Thyra::VectorBase< double > > getGhostedVector() const
Get ghosted responses (this will be filled by the evaluator)
void adjustForDirichletConditions(const GlobalEvaluationData &localBCRows, const GlobalEvaluationData &globalBCRows)