| 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 POINT_EVALUATOR |
| 12 |
#define POINT_EVALUATOR |
| 13 |
|
| 14 |
#include <string> |
| 15 |
#include "Phalanx_Evaluator_Macros.hpp" |
| 16 |
#include "Phalanx_MDField.hpp" |
| 17 |
#include "Panzer_IntegrationRule.hpp" |
| 18 |
#include "Panzer_Workset_Utilities.hpp" |
| 19 |
#include "Panzer_Evaluator_Macros.hpp" |
| 20 |
|
| 21 |
template <typename ScalarT> |
| 22 |
class PointEvaluation { |
| 23 |
public: |
| 24 |
// virtual void evaluateContainer(const Kokkos::DynRankView<double,PHX::Device> & points, |
| 25 |
virtual void evaluateContainer(const PHX::MDField<ScalarT,panzer::Cell,panzer::IP,panzer::Dim> & points, |
| 26 |
PHX::MDField<ScalarT> & field) const = 0; |
| 27 |
}; |
| 28 |
|
| 29 |
template<typename EvalT, typename Traits> |
| 30 |
class PointEvaluator |
| 31 |
: |
| 32 |
public panzer::EvaluatorWithBaseImpl<Traits>, |
| 33 |
public PHX::EvaluatorDerived<EvalT, Traits> |
| 34 |
{ |
| 35 |
public: |
| 36 |
|
| 37 |
PointEvaluator( |
| 38 |
const Teuchos::ParameterList& p); |
| 39 |
|
| 40 |
void |
| 41 |
postRegistrationSetup( |
| 42 |
typename Traits::SetupData d, |
| 43 |
PHX::FieldManager<Traits>& fm); |
| 44 |
|
| 45 |
void |
| 46 |
evaluateFields( |
| 47 |
typename Traits::EvalData d); |
| 48 |
|
| 49 |
private: |
| 50 |
|
| 51 |
using ScalarT = typename EvalT::ScalarT; |
| 52 |
|
| 53 |
PHX::MDField<ScalarT> scalar; |
| 54 |
PHX::MDField<ScalarT> vectorField; |
| 55 |
|
| 56 |
bool isVector; |
| 57 |
int quad_order; |
| 58 |
int quad_index; |
| 59 |
Teuchos::RCP<const PointEvaluation<ScalarT> > function; |
| 60 |
}; // end of class PointEvaluator |
| 61 |
|
| 62 |
|
| 63 |
//********************************************************************** |
| 64 |
template<typename EvalT, typename Traits> |
| 65 |
PointEvaluator<EvalT, Traits>:: |
| 66 |
PointEvaluator( |
| 67 |
const Teuchos::ParameterList& p) |
| 68 |
{ |
| 69 |
// Read from parameters |
| 70 |
const std::string name = p.get<std::string>("Name"); |
| 71 |
Teuchos::RCP<panzer::IntegrationRule> ir |
| 72 |
= p.get< Teuchos::RCP<panzer::IntegrationRule> >("IR"); |
| 73 |
isVector = p.get<bool>("Is Vector"); |
| 74 |
function = p.get<Teuchos::RCP<const PointEvaluation<ScalarT> > >("Point Evaluator"); |
| 75 |
|
| 76 |
quad_order = ir->cubature_degree; |
| 77 |
|
| 78 |
// grab information from quadrature rule |
| 79 |
if(isVector) { |
| 80 |
vectorField = PHX::MDField<ScalarT>(name, ir->dl_vector); |
| 81 |
this->addEvaluatedField(vectorField); |
| 82 |
} |
| 83 |
else { |
| 84 |
scalar = PHX::MDField<ScalarT>(name, ir->dl_scalar); |
| 85 |
this->addEvaluatedField(scalar); |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
std::string n = "PointEvaluator: " + name; |
| 90 |
this->setName(n); |
| 91 |
} |
| 92 |
|
| 93 |
//********************************************************************** |
| 94 |
template<typename EvalT, typename Traits> |
| 95 |
void |
| 96 |
PointEvaluator<EvalT, Traits>:: |
| 97 |
postRegistrationSetup( |
| 98 |
typename Traits::SetupData sd, |
| 99 |
PHX::FieldManager<Traits>& /* fm */) |
| 100 |
{ |
| 101 |
quad_index = panzer::getIntegrationRuleIndex(quad_order,(*sd.worksets_)[0], this->wda); |
| 102 |
} |
| 103 |
|
| 104 |
//********************************************************************** |
| 105 |
template<typename EvalT, typename Traits> |
| 106 |
void |
| 107 |
PointEvaluator<EvalT, Traits>:: |
| 108 |
evaluateFields( |
| 109 |
typename Traits::EvalData workset) |
| 110 |
{ |
| 111 |
if(isVector) |
| 112 |
function->evaluateContainer(this->wda(workset).int_rules[quad_index]->ip_coordinates,vectorField); |
| 113 |
else |
| 114 |
function->evaluateContainer(this->wda(workset).int_rules[quad_index]->ip_coordinates,vectorField); |
| 115 |
} |
| 116 |
|
| 117 |
//********************************************************************** |
| 118 |
|
| 119 |
#endif |