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//
4// Panzer: A partial differential equation assembly
5// engine for strongly coupled complex multiphysics systems
6// Copyright (2011) Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39// Eric C. Cyr (eccyr@sandia.gov)
40// ***********************************************************************
41// @HEADER
42
43#ifndef __Panzer_ResponseEvaluatorFactory_Functional_impl_hpp__
44#define __Panzer_ResponseEvaluatorFactory_Functional_impl_hpp__
45
46#include <string>
47
48#include "PanzerDiscFE_config.hpp"
49
52#include "Panzer_Integrator_Scalar.hpp"
57
58namespace panzer {
59
60template <typename EvalT,typename LO,typename GO>
62buildResponseObject(const std::string & responseName) const
63{
64 Teuchos::RCP<ResponseBase> response = Teuchos::rcp(new Response_Functional<EvalT>(responseName,comm_,linearObjFactory_));
65 response->setRequiresDirichletAdjustment(applyDirichletToDerivative_);
66
67 return response;
68}
69
70template <typename EvalT,typename LO,typename GO>
72buildAndRegisterEvaluators(const std::string & responseName,
74 const panzer::PhysicsBlock & physicsBlock,
75 const Teuchos::ParameterList & /* user_data */) const
76{
77 using Teuchos::RCP;
78 using Teuchos::rcp;
79
80
81 // build integration evaluator (integrate over element)
82 if(requiresCellIntegral_) {
83 std::string field = (quadPointField_=="" ? responseName : quadPointField_);
84
85 // build integration rule to use in cell integral
86 RCP<IntegrationRule> ir = rcp(new IntegrationRule(cubatureDegree_,physicsBlock.cellData()));
87
88 Teuchos::ParameterList pl;
89 pl.set("Integral Name", field);
90 pl.set("Integrand Name",field);
91 pl.set("IR",ir);
92
93 Teuchos::RCP<PHX::Evaluator<panzer::Traits> > eval
94 = Teuchos::rcp(new Integrator_Scalar<EvalT,panzer::Traits>(pl));
95
96 this->template registerEvaluator<EvalT>(fm, eval);
97 }
98
99
100 // build scatter evaluator
101 {
102 Teuchos::RCP<FunctionalScatterBase> scatterObj;
103 if(linearObjFactory_!=Teuchos::null) {
104
105 TEUCHOS_ASSERT(linearObjFactory_->getDomainGlobalIndexer()!=Teuchos::null);
106
107 auto ugi = Teuchos::rcp_dynamic_cast<const GlobalIndexer>(linearObjFactory_->getDomainGlobalIndexer());
108 auto bugi = Teuchos::rcp_dynamic_cast<const BlockedDOFManager>(linearObjFactory_->getDomainGlobalIndexer());
109
110 if(ugi!=Teuchos::null) {
111 std::vector<Teuchos::RCP<const GlobalIndexer> > ugis;
112 ugis.push_back(ugi);
113
114 scatterObj = Teuchos::rcp(new FunctionalScatter<LO,GO>(ugis));
115 }
116 else if(bugi!=Teuchos::null) {
117 scatterObj = Teuchos::rcp(new FunctionalScatter<LO,GO>(nc2c_vector(bugi->getFieldDOFManagers())));
118 }
119 else {
120 TEUCHOS_ASSERT(false); // no real global indexer to use
121 }
122 }
123
124 std::string field = (quadPointField_=="" ? responseName : quadPointField_);
125
126 // build useful evaluator
127 Teuchos::RCP<PHX::Evaluator<panzer::Traits> > eval
128 = Teuchos::rcp(new ResponseScatterEvaluator_Functional<EvalT,panzer::Traits>(field,responseName,physicsBlock.cellData(),scatterObj));
129
130 this->template registerEvaluator<EvalT>(fm, eval);
131
132 // require last field
133 fm.template requireField<EvalT>(*eval->evaluatedFields()[0]);
134 }
135}
136
137template <typename EvalT,typename LO,typename GO>
139typeSupported() const
140{
141 if( PHX::print<EvalT>()==PHX::print<panzer::Traits::Residual>() ||
142 PHX::print<EvalT>()==PHX::print<panzer::Traits::Tangent>()
143 )
144 return true;
145
146 if(PHX::print<EvalT>()==PHX::print<panzer::Traits::Jacobian>())
147 return linearObjFactory_!=Teuchos::null;
148
149#ifdef Panzer_BUILD_HESSIAN_SUPPORT
150 if(PHX::print<EvalT>()==PHX::print<panzer::Traits::Hessian>()) {
151 return linearObjFactory_!=Teuchos::null;
152 }
153#endif
154
155 return false;
156}
157
158}
159
160#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.
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)