43 #ifndef PANZER_RESPONSE_SCATTER_EVALUATOR_EXTREMEVALUE_IMPL_HPP
44 #define PANZER_RESPONSE_SCATTER_EVALUATOR_EXTREMEVALUE_IMPL_HPP
49 #include "PanzerDiscFE_config.hpp"
51 #include "Phalanx_Evaluator_Macros.hpp"
52 #include "Phalanx_MDField.hpp"
53 #include "Phalanx_DataLayout_MDALayout.hpp"
62 #include "Intrepid2_FunctionSpaceTools.hpp"
64 #include "Thyra_SpmdVectorBase.hpp"
65 #include "Teuchos_ArrayRCP.hpp"
67 #include "Kokkos_ViewFactory.hpp"
71 template<
typename EvalT,
typename Traits,
typename LO,
typename GO>
74 const std::string & responseName,
75 const std::string & fieldName,
76 const int fieldComponent,
82 : responseName_(responseName)
83 , fieldName_(fieldName)
84 , fieldComponent_(fieldComponent)
87 , topology_(ir.topology)
88 , globalIndexer_(indexer)
89 , scatterObj_(probeScatter)
97 this->addDependentField(
field_);
107 std::string dummyName =
113 std::string n =
"Probe Response Scatter: " + responseName;
117 template<
typename EvalT,
typename Traits,
typename LO,
typename GO>
129 template<
typename EvalT,
typename Traits,
typename LO,
typename GO>
133 typedef Intrepid2::CellTools<PHX::exec_space> CTD;
134 typedef Intrepid2::FunctionSpaceTools<PHX::exec_space> FST;
136 const int num_points = 1;
137 Kokkos::DynRankView<int,PHX::Device> inCell(
"inCell", this->wda(d).cell_vertex_coordinates.extent_int(0), num_points);
138 Kokkos::DynRankView<double,PHX::Device> physical_points_cell(
"physical_points_cell", this->wda(d).cell_vertex_coordinates.extent_int(0), num_points, num_dim);
139 for (panzer::index_t cell(0); cell < d.
num_cells; ++cell)
140 for (
size_t dim=0; dim<num_dim; ++dim)
141 physical_points_cell(cell,0,dim) = point_[dim];
143 const double tol = 1.0e-12;
144 CTD::checkPointwiseInclusion(inCell,
145 physical_points_cell,
146 this->wda(d).cell_vertex_coordinates.get_view(),
152 bool haveProbe =
false;
153 for (index_t cell=0; cell<static_cast<int>(d.
num_cells); ++cell) {
160 if (inCell(cell,0) == 1) {
173 const size_t num_vertex = this->wda(d).cell_vertex_coordinates.extent(1);
174 Kokkos::DynRankView<double,PHX::Device> cell_coords(
175 "cell_coords", 1, num_vertex, num_dim);
176 for (
size_t i=0; i<num_vertex; ++i) {
177 for (
size_t j=0; j<num_dim; ++j) {
178 cell_coords(0,i,j) = this->wda(d).cell_vertex_coordinates(cellIndex_,i,j);
181 Kokkos::DynRankView<double,PHX::Device> physical_points(
182 "physical_points", 1, 1, num_dim);
183 for (
size_t i=0; i<num_dim; ++i)
184 physical_points(0,0,i) = physical_points_cell(0,0,i);
185 Kokkos::DynRankView<double,PHX::Device> reference_points(
186 "reference_points", 1, 1, num_dim);
187 CTD::mapToReferenceFrame(reference_points, physical_points, cell_coords,
189 Kokkos::DynRankView<double,PHX::Device> reference_points_cell(
190 "reference_points_cell", 1, num_dim);
191 for (
size_t i=0; i<num_dim; ++i)
192 reference_points_cell(0,i) = reference_points(0,0,i);
199 Kokkos::DynRankView<double,PHX::Device>
200 ref_basis_values(
"ref_basis_values", num_basis, 1);
201 basis_->getIntrepid2Basis()->getValues(ref_basis_values,
202 reference_points_cell,
203 Intrepid2::OPERATOR_VALUE);
206 FST::HGRADtransformVALUE<double>(basis_values_, ref_basis_values);
213 Kokkos::DynRankView<double,PHX::Device> ref_basis_values(
214 "ref_basis_values", num_basis, 1, num_dim);
215 basis_->getIntrepid2Basis()->getValues(ref_basis_values,
216 reference_points_cell,
217 Intrepid2::OPERATOR_VALUE);
220 Kokkos::DynRankView<double,PHX::Device>
jac
221 (
"jac", 1, 1, num_dim, num_dim);
222 CTD::setJacobian(jac, reference_points, cell_coords, *topology_);
223 Kokkos::DynRankView<double,PHX::Device> basis_values_vec(
224 "basis_values_vec", 1, num_basis, 1, num_dim);
226 Kokkos::DynRankView<double,PHX::Device> jac_inv(
227 "jac_inv", 1, 1, num_dim, num_dim);
228 CTD::setJacobianInv(jac_inv, jac);
229 FST::HCURLtransformVALUE<double>(basis_values_vec, jac_inv,
233 Kokkos::DynRankView<double,PHX::Device> jac_det(
235 CTD::setJacobianDet(jac_det, jac);
236 FST::HDIVtransformVALUE<double>(basis_values_vec,
jac, jac_det,
241 std::vector<double> orientation;
242 globalIndexer_->getElementOrientation(cellIndex_, orientation);
243 std::string blockId = this->wda(d).block_id;
244 int fieldNum = globalIndexer_->getFieldNum(fieldName_);
245 const std::vector<int> & elmtOffset =
246 globalIndexer_->getGIDFieldOffsets(blockId,fieldNum);
249 for (
size_t i=0; i<num_basis; ++i) {
250 int offset = elmtOffset[i];
251 basis_values_(0,i,0) =
252 orientation[offset] * basis_values_vec(0,i,0,fieldComponent_);
260 template<
typename EvalT,
typename Traits,
typename LO,
typename GO>
265 const bool haveProbe = computeBasisValues(d);
271 Kokkos::DynRankView<ScalarT,typename PHX::DevLayout<ScalarT>::type,PHX::Device> field_coeffs =
274 for (
size_t i=0; i<num_basis; ++i)
275 field_coeffs(0,i) = field_(cellIndex_,i);
278 Kokkos::DynRankView<ScalarT,typename PHX::DevLayout<ScalarT>::type,PHX::Device> field_val =
280 Intrepid2::FunctionSpaceTools<PHX::exec_space>::evaluate(
281 field_val, field_coeffs, basis_values_);
282 responseObj_->value = field_val(0,0);
283 responseObj_->have_probe =
true;
286 template <
typename LO,
typename GO>
291 using Teuchos::rcp_dynamic_cast;
292 using Thyra::SpmdVectorBase;
301 rcp_dynamic_cast<SpmdVectorBase<double> >(this->
responseObj_->getGhostedVector());
302 dgdx->getNonconstLocalData(ptrFromRef(local_dgdx));
307 this->responseObj_->have_probe,
Teuchos::RCP< const panzer::PureBasis > basis_
Teuchos::RCP< GlobalEvaluationDataContainer > gedc
Kokkos::DynRankView< typename InputArray::value_type, PHX::Device > createDynRankView(const InputArray &a, const std::string &name, const DimensionPack...dims)
Wrapper to simplify Panzer use of Sacado ViewFactory.
PHX::MDField< const ScalarT, Cell, BASIS > field_
Teuchos::Array< double > point_
Teuchos::RCP< PHX::FieldTag > scatterHolder_
void preEvaluate(typename Traits::PreEvalData d)
bool computeBasisValues(typename Traits::EvalData d)
static std::string buildLookupName(const std::string &responseName)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void evaluateFields(typename Traits::EvalData d)
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.
Teuchos::RCP< Response_Probe< EvalT > > responseObj_
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::RCP< PHX::DataLayout > functional
<Cell,Basis> or <Cell,Basis>
Teuchos::RCP< ProbeScatterBase > scatterObj_