Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
51 #include "Panzer_PhysicsBlock.hpp"
52 #include "Panzer_Integrator_Scalar.hpp"
57 
58 namespace panzer {
59 
60 template <typename EvalT,typename LO,typename GO>
62 buildResponseObject(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 
70 template <typename EvalT,typename LO,typename GO>
72 buildAndRegisterEvaluators(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 
89  pl.set("Integral Name", field);
90  pl.set("Integrand Name",field);
91  pl.set("IR",ir);
92 
95 
96  this->template registerEvaluator<EvalT>(fm, eval);
97  }
98 
99 
100  // build scatter evaluator
101  {
103  if(linearObjFactory_!=Teuchos::null) {
104 
105  TEUCHOS_ASSERT(linearObjFactory_->getDomainGlobalIndexer()!=Teuchos::null);
106 
107  auto ugi = Teuchos::rcp_dynamic_cast<const UniqueGlobalIndexer<LO,GO> >(linearObjFactory_->getDomainGlobalIndexer());
108  auto bugi = Teuchos::rcp_dynamic_cast<const BlockedDOFManager<LO,GO> >(linearObjFactory_->getDomainGlobalIndexer());
109 
110  if(ugi!=Teuchos::null) {
111  std::vector<Teuchos::RCP<const UniqueGlobalIndexer<LO,GO> > > 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
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 
137 template <typename EvalT,typename LO,typename GO>
140 {
141  if( PHX::typeAsString<EvalT>()==PHX::typeAsString<panzer::Traits::Residual>() ||
142  PHX::typeAsString<EvalT>()==PHX::typeAsString<panzer::Traits::Tangent>()
143  )
144  return true;
145 
146  if(PHX::typeAsString<EvalT>()==PHX::typeAsString<panzer::Traits::Jacobian>())
147  return linearObjFactory_!=Teuchos::null;
148 
149 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
150  if(PHX::typeAsString<EvalT>()==PHX::typeAsString<panzer::Traits::Hessian>()) {
151  return linearObjFactory_!=Teuchos::null;
152  }
153 #endif
154 
155  return false;
156 }
157 
158 }
159 
160 #endif
Object that contains information on the physics and discretization of a block of elements with the SA...
const panzer::CellData & cellData() const
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
std::vector< Teuchos::RCP< const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > > > nc2c_vector(const std::vector< Teuchos::RCP< UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > > > &ugis)
virtual Teuchos::RCP< ResponseBase > buildResponseObject(const std::string &responseName) const
virtual void buildAndRegisterEvaluators(const std::string &responseName, PHX::FieldManager< panzer::Traits > &fm, const panzer::PhysicsBlock &physicsBlock, const Teuchos::ParameterList &user_data) const
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we&#39;ll contribute, or in which we&#39;ll store, the result of computing this integral...
#define TEUCHOS_ASSERT(assertion_test)