Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_Response_ExtremeValue.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_Response_ExtremeValue_hpp__
12#define __Panzer_Response_ExtremeValue_hpp__
13
14#include <string>
15#include <limits>
16
17#include <mpi.h> // need for comm
18
19#include "Teuchos_RCP.hpp"
20
21#include "Thyra_VectorBase.hpp"
22#include "Thyra_VectorSpaceBase.hpp"
23
24#include "PanzerDiscFE_config.hpp"
25#ifdef PANZER_HAVE_EPETRA_STACK
26#include "Epetra_Map.h"
27#include "Epetra_Vector.h"
28#include "Epetra_MpiComm.h"
29#endif
30
36
37
38namespace panzer {
39
44template <typename EvalT>
47public:
48 typedef typename EvalT::ScalarT ScalarT;
49
50 Response_ExtremeValue(const std::string & responseName,MPI_Comm comm,bool useMax,
51 const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > & linObjFact=Teuchos::null)
52 : ResponseMESupport_Default<EvalT>(responseName,comm), value(0.0), linObjFactory_(linObjFact), useMax_(useMax)
53 {
54 if(linObjFactory_!=Teuchos::null) {
55 // requires thyra object factory
56 thyraObjFactory_ = Teuchos::rcp_dynamic_cast<const panzer::ThyraObjFactory<double> >(linObjFactory_,true);
57 setSolnVectorSpace(thyraObjFactory_->getThyraDomainSpace());
58
59 // build a ghosted container, with a solution vector
60 ghostedContainer_ = linObjFactory_->buildGhostedLinearObjContainer();
61
62 // set ghosted container (work space for assembly)
64
65 // No derivative vector space is set here on purpose. There is no
66 // Jacobian scatter evaluator for an extreme value response, and
67 // ResponseEvaluatorFactory_ExtremeValue::typeSupported() returns false
68 // for the Jacobian type, so a Response_ExtremeValue<Jacobian> is never
69 // built. Setting one would make supportsDerivative() true and the model
70 // evaluator would advertise DgDx for a response nothing can fill.
71 }
72 }
73
76
78 virtual void scatterResponse();
79
80 virtual void initializeResponse()
81 { if(useMax_)
82 value = -std::numeric_limits<ScalarT>::max();
83 else
84 value = std::numeric_limits<ScalarT>::max();
85
86 if(ghostedContainer_!=Teuchos::null) ghostedContainer_->initialize(); }
87
88 // from ResponseMESupport_Default
89
91 virtual std::size_t localSizeRequired() const { return 1; }
92
94 virtual bool vectorIsDistributed() const { return false; }
95
97 Teuchos::RCP<Thyra::VectorBase<double> > getGhostedVector() const
98 { return Teuchos::rcp_dynamic_cast<const ThyraObjContainer<double> >(ghostedContainer_)->get_x_th(); }
99
100 void adjustForDirichletConditions(const GlobalEvaluationData & localBCRows,const GlobalEvaluationData & globalBCRows);
101
102private:
104 void setSolnVectorSpace(const Teuchos::RCP<const Thyra::VectorSpaceBase<double> > & soln_vs);
105
106 // hide these methods
109
110 Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > linObjFactory_;
111 Teuchos::RCP<const panzer::ThyraObjFactory<double> > thyraObjFactory_;
112
113 Teuchos::RCP<LinearObjContainer> uniqueContainer_;
114 Teuchos::RCP<LinearObjContainer> ghostedContainer_;
115
117};
118
119}
120
121#endif
void setSolnVectorSpace(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &soln_vs)
Set solution vector space.
virtual std::size_t localSizeRequired() const
What is the number of values you need locally.
ScalarT value
provide direct access, this thing is pretty simple
Teuchos::RCP< LinearObjContainer > ghostedContainer_
void adjustForDirichletConditions(const GlobalEvaluationData &localBCRows, const GlobalEvaluationData &globalBCRows)
Response_ExtremeValue(const Response_ExtremeValue &)
Response_ExtremeValue(const std::string &responseName, MPI_Comm comm, bool useMax, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &linObjFact=Teuchos::null)
virtual void scatterResponse()
This simply does global summation, then shoves the result into a vector.
virtual bool vectorIsDistributed() const
Is the vector distributed (or replicated)
Teuchos::RCP< LinearObjContainer > uniqueContainer_
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_