Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_ResponseScatterEvaluator_Probe.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_ResponseScatterEvaluator_Probe_hpp__
12 #define __Panzer_ResponseScatterEvaluator_Probe_hpp__
13 
14 #include <iostream>
15 #include <string>
16 
17 #include "PanzerDiscFE_config.hpp"
18 #include "Panzer_Dimension.hpp"
21 #include "Panzer_GlobalIndexer.hpp"
22 
23 #include "Phalanx_Evaluator_Macros.hpp"
24 #include "Phalanx_MDField.hpp"
25 
27 
28 namespace panzer {
29 
31 public:
32  virtual ~ProbeScatterBase() {}
33 
34  virtual void scatterDerivative(
35  const panzer::Traits::Jacobian::ScalarT& probeValue,
36  const size_t cell_index,
37  const bool has_probe,
40  Teuchos::ArrayRCP<double> & dgdx) const = 0;
41 };
42 
43 template <typename LO,typename GO>
45 public:
47  : globalIndexer_(globalIndexer) { }
48 
49  void scatterDerivative(
50  const panzer::Traits::Jacobian::ScalarT& probeValue,
51  const size_t cell_index,
52  const bool has_probe,
55  Teuchos::ArrayRCP<double> & dgdx) const;
56 
57 private:
58 
60 };
61 
64 template<typename EvalT, typename Traits, typename LO, typename GO>
66  public panzer::EvaluatorWithBaseImpl<Traits>,
67  public PHX::EvaluatorDerived<EvalT, Traits> {
68 public:
69 
72  const std::string & responseName,
73  const std::string & fieldName,
74  const int fieldComponent,
75  const Teuchos::Array<double>& point,
76  const IntegrationRule & ir,
77  const Teuchos::RCP<const PureBasis>& basis,
79  const Teuchos::RCP<ProbeScatterBase> & probeScatter);
80 
81  void evaluateFields(typename Traits::EvalData d);
82 
85 
86  void preEvaluate(typename Traits::PreEvalData d);
87 
88  // Should be protected, but is public for cuda lambda support
90 
91 protected:
92  typedef typename EvalT::ScalarT ScalarT;
93 
94  std::string responseName_;
95  std::string fieldName_;
102 
106 
109  size_t workset_id_;
111  Kokkos::DynRankView<double,PHX::Device> basis_values_;
112 };
113 
116 template<typename EvalT, typename Traits, typename LO, typename GO>
118  public ResponseScatterEvaluator_ProbeBase<EvalT,Traits,LO,GO> {
119 public:
120 
122 
125  const std::string & responseName,
126  const std::string & fieldName,
127  const int fieldComponent,
128  const Teuchos::Array<double>& point,
129  const IntegrationRule & ir,
130  const Teuchos::RCP<const PureBasis>& basis,
132  const Teuchos::RCP<ProbeScatterBase> & probeScatter) :
133  Base(responseName, fieldName, fieldComponent, point,
134  ir, basis, indexer, probeScatter) {}
135 };
136 
139 template<typename LO, typename GO>
141  public ResponseScatterEvaluator_ProbeBase<panzer::Traits::Jacobian,panzer::Traits,LO,GO> {
142 public:
143 
145 
148  const std::string & responseName,
149  const std::string & fieldName,
150  const int fieldComponent,
151  const Teuchos::Array<double>& point,
152  const IntegrationRule & ir,
153  const Teuchos::RCP<const PureBasis>& basis,
155  const Teuchos::RCP<ProbeScatterBase> & probeScatter) :
156  Base(responseName, fieldName, fieldComponent, point,
157  ir, basis, indexer, probeScatter) {}
158 
159  void evaluateFields(typename panzer::Traits::EvalData d);
160 };
161 
162 template <typename LO,typename GO>
164  const panzer::Traits::Jacobian::ScalarT& probeValue,
165  const size_t cell_index,
166  const bool has_probe,
167  panzer::Traits::EvalData workset,
169  Teuchos::ArrayRCP<double> & dgdx) const
170 {
171 
172  if (has_probe) {
173  PHX::View<const LO*> LIDs = globalIndexer_->getElementLIDs(cell_index);
174 
175  // loop over basis functions
176  for(std::size_t i=0; i<LIDs.size(); ++i) {
177  dgdx[LIDs[i]] += probeValue.dx(i);
178  }
179  }
180 }
181 
182 }
183 
184 #endif
ResponseScatterEvaluator_ProbeBase< panzer::Traits::Jacobian, panzer::Traits, LO, GO > Base
virtual void scatterDerivative(const panzer::Traits::Jacobian::ScalarT &probeValue, const size_t cell_index, const bool has_probe, panzer::Traits::EvalData workset, WorksetDetailsAccessor &wda, Teuchos::ArrayRCP< double > &dgdx) const =0
Teuchos::RCP< const panzer::GlobalIndexer > globalIndexer_
ResponseScatterEvaluator_Probe(const std::string &responseName, const std::string &fieldName, const int fieldComponent, const Teuchos::Array< double > &point, const IntegrationRule &ir, const Teuchos::RCP< const PureBasis > &basis, const Teuchos::RCP< const panzer::GlobalIndexer > &indexer, const Teuchos::RCP< ProbeScatterBase > &probeScatter)
A constructor with concrete arguments instead of a parameter list.
ResponseScatterEvaluator_ProbeBase< EvalT, Traits, LO, GO > Base
void postRegistrationSetup(typename Traits::SetupData, PHX::FieldManager< Traits > &)
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Teuchos::RCP< const panzer::GlobalIndexer > globalIndexer_
Kokkos::DynRankView< double, PHX::Device > basis_values_
ResponseScatterEvaluator_ProbeBase(const std::string &responseName, const std::string &fieldName, const int fieldComponent, const Teuchos::Array< double > &point, const IntegrationRule &ir, const Teuchos::RCP< const PureBasis > &basis, const Teuchos::RCP< const panzer::GlobalIndexer > &indexer, const Teuchos::RCP< ProbeScatterBase > &probeScatter)
A constructor with concrete arguments instead of a parameter list.
ProbeScatter(const Teuchos::RCP< const panzer::GlobalIndexer > &globalIndexer)
ResponseScatterEvaluator_Probe(const std::string &responseName, const std::string &fieldName, const int fieldComponent, const Teuchos::Array< double > &point, const IntegrationRule &ir, const Teuchos::RCP< const PureBasis > &basis, const Teuchos::RCP< const panzer::GlobalIndexer > &indexer, const Teuchos::RCP< ProbeScatterBase > &probeScatter)
A constructor with concrete arguments instead of a parameter list.
void scatterDerivative(const panzer::Traits::Jacobian::ScalarT &probeValue, const size_t cell_index, const bool has_probe, panzer::Traits::EvalData workset, WorksetDetailsAccessor &wda, Teuchos::ArrayRCP< double > &dgdx) const