Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_ResponseEvaluatorFactory_Functional_impl.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_ResponseEvaluatorFactory_Functional_impl_hpp__
12#define __Panzer_ResponseEvaluatorFactory_Functional_impl_hpp__
13
15#include <string>
16
17#include "PanzerDiscFE_config.hpp"
18
21#include "Panzer_Integrator_Scalar.hpp"
26
27namespace panzer {
28
29template <typename EvalT,typename LO,typename GO>
31buildResponseObject(const std::string & responseName) const
32{
33 Teuchos::RCP<ResponseBase> response = Teuchos::rcp(new Response_Functional<EvalT>(responseName,comm_,linearObjFactory_));
34 response->setRequiresDirichletAdjustment(applyDirichletToDerivative_);
35
36 return response;
37}
38
39template <typename EvalT,typename LO,typename GO>
41buildAndRegisterEvaluators(const std::string & responseName,
43 const panzer::PhysicsBlock & physicsBlock,
44 const Teuchos::ParameterList & /* user_data */) const
45{
46 using Teuchos::RCP;
47 using Teuchos::rcp;
48
49
50 // build integration evaluator (integrate over element)
51 if(requiresCellIntegral_) {
52 std::string field = (quadPointField_=="" ? responseName : quadPointField_);
53
54 // build integration rule to use in cell integral
55 RCP<IntegrationRule> ir = rcp(new IntegrationRule(cubatureDegree_,physicsBlock.cellData()));
56
57 Teuchos::ParameterList pl;
58 pl.set("Integral Name", field);
59 pl.set("Integrand Name",field);
60 pl.set("IR",ir);
61
62 Teuchos::RCP<PHX::Evaluator<panzer::Traits> > eval
63 = Teuchos::rcp(new Integrator_Scalar<EvalT,panzer::Traits>(pl));
64
65 this->template registerEvaluator<EvalT>(fm, eval);
66 }
67
68
69 // build scatter evaluator
70 {
71 Teuchos::RCP<FunctionalScatterBase> scatterObj;
72 if(linearObjFactory_!=Teuchos::null) {
73
74 TEUCHOS_ASSERT(linearObjFactory_->getDomainGlobalIndexer()!=Teuchos::null);
75
76 auto ugi = Teuchos::rcp_dynamic_cast<const GlobalIndexer>(linearObjFactory_->getDomainGlobalIndexer());
77 auto bugi = Teuchos::rcp_dynamic_cast<const BlockedDOFManager>(linearObjFactory_->getDomainGlobalIndexer());
78
79 if(bugi!=Teuchos::null) {
80 scatterObj = Teuchos::rcp(new FunctionalScatter<LO,GO>(nc2c_vector(bugi->getFieldDOFManagers())));
81 }
82 else if(ugi!=Teuchos::null) { // this needs to be second since a BlockedDOFManager is a child of GlobalIndexer
83 scatterObj = Teuchos::rcp(new FunctionalScatter<LO,GO>(ugi));
84 }
85 else {
86 TEUCHOS_ASSERT(false); // no real global indexer to use
87 }
88 }
89
90 std::string field = (quadPointField_=="" ? responseName : quadPointField_);
91
92 // build useful evaluator
93 Teuchos::RCP<PHX::Evaluator<panzer::Traits> > eval
94 = Teuchos::rcp(new ResponseScatterEvaluator_Functional<EvalT,panzer::Traits>(field,responseName,physicsBlock.cellData(),scatterObj));
95
96 this->template registerEvaluator<EvalT>(fm, eval);
97
98 // require last field
99 fm.template requireField<EvalT>(*eval->evaluatedFields()[0]);
100 }
101}
102
103template <typename EvalT,typename LO,typename GO>
105typeSupported() const
106{
107 // A Tangent response accumulates Fad-valued scalars and needs no linear
108 // object factory, so it must not be gated on one: responses registered
109 // through the plain addResponse() path never get a factory, and gating it
110 // there silently drops DgDp instead of failing.
111 if( PHX::print<EvalT>()==PHX::print<panzer::Traits::Residual>() ||
112 PHX::print<EvalT>()==PHX::print<panzer::Traits::Tangent>()
113 )
114 return true;
115
116 if(PHX::print<EvalT>()==PHX::print<panzer::Traits::Jacobian>())
117 return linearObjFactory_!=Teuchos::null;
118
119#ifdef Panzer_BUILD_HESSIAN_SUPPORT
120 if(PHX::print<EvalT>()==PHX::print<panzer::Traits::Hessian>()) {
121 return linearObjFactory_!=Teuchos::null;
122 }
123#endif
124
125 return false;
126}
127
128}
129
130#endif
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral.
Concrete FunctionalScatterBase that scatters using one or more panzer::GlobalIndexer objects.
Object that contains information on the physics and discretization of a block of elements with the SA...
const panzer::CellData & cellData() const
virtual void buildAndRegisterEvaluators(const std::string &responseName, PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &physicsBlock, const Teuchos::ParameterList &user_data) const
virtual Teuchos::RCP< ResponseBase > buildResponseObject(const std::string &responseName) const
std::vector< Teuchos::RCP< const GlobalIndexer > > nc2c_vector(const std::vector< Teuchos::RCP< GlobalIndexer > > &ugis)