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 //
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_ResponseScatterEvaluator_Probe_hpp__
44 #define __Panzer_ResponseScatterEvaluator_Probe_hpp__
45 
46 #include <iostream>
47 #include <string>
48 
49 #include "PanzerDiscFE_config.hpp"
50 #include "Panzer_Dimension.hpp"
53 #include "Panzer_GlobalIndexer.hpp"
54 
55 #include "Phalanx_Evaluator_Macros.hpp"
56 #include "Phalanx_MDField.hpp"
57 
59 
60 namespace panzer {
61 
63 public:
64  virtual ~ProbeScatterBase() {}
65 
66  virtual void scatterDerivative(
67  const panzer::Traits::Jacobian::ScalarT& probeValue,
68  const size_t cell_index,
69  const bool has_probe,
72  Teuchos::ArrayRCP<double> & dgdx) const = 0;
73 };
74 
75 template <typename LO,typename GO>
77 public:
79  : globalIndexer_(globalIndexer) { }
80 
81  void scatterDerivative(
82  const panzer::Traits::Jacobian::ScalarT& probeValue,
83  const size_t cell_index,
84  const bool has_probe,
87  Teuchos::ArrayRCP<double> & dgdx) const;
88 
89 private:
90 
92 };
93 
96 template<typename EvalT, typename Traits, typename LO, typename GO>
98  public panzer::EvaluatorWithBaseImpl<Traits>,
99  public PHX::EvaluatorDerived<EvalT, Traits> {
100 public:
101 
104  const std::string & responseName,
105  const std::string & fieldName,
106  const int fieldComponent,
107  const Teuchos::Array<double>& point,
108  const IntegrationRule & ir,
109  const Teuchos::RCP<const PureBasis>& basis,
111  const Teuchos::RCP<ProbeScatterBase> & probeScatter);
112 
113  void evaluateFields(typename Traits::EvalData d);
114 
115  void preEvaluate(typename Traits::PreEvalData d);
116 
117 protected:
118  typedef typename EvalT::ScalarT ScalarT;
119 
120  std::string responseName_;
121  std::string fieldName_;
128 
130  PHX::MDField<const ScalarT,Cell,BASIS> field_; // holds field values
132 
135  Kokkos::DynRankView<double,PHX::Device> basis_values_;
136 
137  bool computeBasisValues(typename Traits::EvalData d);
138 };
139 
142 template<typename EvalT, typename Traits, typename LO, typename GO>
144  public ResponseScatterEvaluator_ProbeBase<EvalT,Traits,LO,GO> {
145 public:
146 
148 
151  const std::string & responseName,
152  const std::string & fieldName,
153  const int fieldComponent,
154  const Teuchos::Array<double>& point,
155  const IntegrationRule & ir,
156  const Teuchos::RCP<const PureBasis>& basis,
158  const Teuchos::RCP<ProbeScatterBase> & probeScatter) :
159  Base(responseName, fieldName, fieldComponent, point,
160  ir, basis, indexer, probeScatter) {}
161 };
162 
165 template<typename LO, typename GO>
167  public ResponseScatterEvaluator_ProbeBase<panzer::Traits::Jacobian,panzer::Traits,LO,GO> {
168 public:
169 
171 
174  const std::string & responseName,
175  const std::string & fieldName,
176  const int fieldComponent,
177  const Teuchos::Array<double>& point,
178  const IntegrationRule & ir,
179  const Teuchos::RCP<const PureBasis>& basis,
181  const Teuchos::RCP<ProbeScatterBase> & probeScatter) :
182  Base(responseName, fieldName, fieldComponent, point,
183  ir, basis, indexer, probeScatter) {}
184 
185  void evaluateFields(typename panzer::Traits::EvalData d);
186 };
187 
188 template <typename LO,typename GO>
190  const panzer::Traits::Jacobian::ScalarT& probeValue,
191  const size_t cell_index,
192  const bool has_probe,
193  panzer::Traits::EvalData workset,
195  Teuchos::ArrayRCP<double> & dgdx) const
196 {
197 
198  if (has_probe) {
199  Kokkos::View<const LO*, PHX::Device> LIDs = globalIndexer_->getElementLIDs(cell_index);
200 
201  // loop over basis functions
202  for(std::size_t i=0; i<LIDs.size(); ++i) {
203  dgdx[LIDs[i]] += probeValue.dx(i);
204  }
205  }
206 }
207 
208 }
209 
210 #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
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