Panzer  Version of the Day
Panzer_Response_ExtremeValue.hpp
Go to the documentation of this file.
1 #ifndef __Panzer_Response_ExtremeValue_hpp__
2 #define __Panzer_Response_ExtremeValue_hpp__
3 
4 #include <string>
5 #include <limits>
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_ExtremeValue(const std::string & responseName,MPI_Comm comm,bool useMax,
38  const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > & linObjFact=Teuchos::null)
39  : ResponseMESupport_Default<EvalT>(responseName,comm), value(0.0), linObjFactory_(linObjFact), useMax_(useMax)
40  {
41  if(linObjFactory_!=Teuchos::null) {
42  // requires thyra object factory
43  thyraObjFactory_ = Teuchos::rcp_dynamic_cast<const panzer::ThyraObjFactory<double> >(linObjFactory_,true);
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  { if(useMax_)
64  value = -std::numeric_limits<ScalarT>::max();
65  else
66  value = std::numeric_limits<ScalarT>::max();
67 
68  if(ghostedContainer_!=Teuchos::null) ghostedContainer_->initialize(); }
69 
70  // from ResponseMESupport_Default
71 
73  virtual std::size_t localSizeRequired() const { return 1; }
74 
76  virtual bool vectorIsDistributed() const { return false; }
77 
80  { return Teuchos::rcp_dynamic_cast<const ThyraObjContainer<double> >(ghostedContainer_)->get_x_th(); }
81 
82  void adjustForDirichletConditions(const GlobalEvaluationData & localBCRows,const GlobalEvaluationData & globalBCRows);
83 
84 private:
87 
88  // hide these methods
91 
94 
97 
98  bool useMax_;
99 };
100 
101 }
102 
103 #endif
Teuchos::RCP< Thyra::VectorBase< double > > getGhostedVector() const
Get ghosted responses (this will be filled by the evaluator)
Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > linObjFactory_
Teuchos::RCP< const panzer::ThyraObjFactory< double > > thyraObjFactory_
virtual void scatterResponse()
This simply does global summation, then shoves the result into a vector.
Response_ExtremeValue(const std::string &responseName, MPI_Comm comm, bool useMax, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &linObjFact=Teuchos::null)
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)
ScalarT value
provide direct access, this thing is pretty simple
virtual Teuchos::RCP< const Thyra::VectorSpaceBase< ScalarT > > getThyraDomainSpace() const =0
Get the domain space.
void setSolnVectorSpace(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &soln_vs)
Set solution vector space.
Teuchos::RCP< LinearObjContainer > uniqueContainer_
Teuchos::RCP< LinearObjContainer > ghostedContainer_
Teuchos::RCP< const Teuchos::Comm< int > > comm
void adjustForDirichletConditions(const GlobalEvaluationData &localBCRows, const GlobalEvaluationData &globalBCRows)