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" 61 #include "Intrepid2_FunctionSpaceTools.hpp" 63 #include "Thyra_SpmdVectorBase.hpp" 64 #include "Teuchos_ArrayRCP.hpp" 66 #include "Kokkos_ViewFactory.hpp" 70 template<
typename EvalT,
typename Traits,
typename LO,
typename GO>
73 const std::string & responseName,
74 const std::string & fieldName,
75 const int fieldComponent,
76 const Teuchos::Array<double>& point,
78 const Teuchos::RCP<const PureBasis>&
basis,
80 const Teuchos::RCP<ProbeScatterBase> & probeScatter)
81 : responseName_(responseName)
82 , fieldName_(fieldName)
83 , fieldComponent_(fieldComponent)
86 , topology_(ir.topology)
87 , globalIndexer_(indexer)
88 , scatterObj_(probeScatter)
95 field_ = PHX::MDField<const ScalarT,Cell,BASIS>(fieldName,basis_->functional);
96 this->addDependentField(field_);
98 num_basis =
basis->cardinality();
100 TEUCHOS_ASSERT(
num_dim == static_cast<size_t>(point_.size()));
102 basis_values_ = Kokkos::DynRankView<double,PHX::Device>(
103 "basis_values", 1, num_basis, 1);
106 std::string dummyName =
107 ResponseBase::buildLookupName(responseName) +
" dummy target";
108 RCP<PHX::DataLayout> dl_dummy = rcp(
new PHX::MDALayout<panzer::Dummy>(0));
109 scatterHolder_ = rcp(
new PHX::Tag<ScalarT>(dummyName,dl_dummy));
110 this->addEvaluatedField(*scatterHolder_);
112 std::string n =
"Probe Response Scatter: " + responseName;
116 template<
typename EvalT,
typename Traits,
typename LO,
typename GO>
128 template<
typename EvalT,
typename Traits,
typename LO,
typename GO>
133 this->utils.setFieldData(field_,fm);
136 template<
typename EvalT,
typename Traits,
typename LO,
typename GO>
140 typedef Intrepid2::CellTools<double> CTD;
141 typedef Intrepid2::FunctionSpaceTools FST;
143 Kokkos::DynRankView<int,PHX::Device> inCell(
"inCell", 1);
144 Kokkos::DynRankView<double,PHX::Device> physical_points_cell(
145 "physical_points_cell", 1,
num_dim);
146 for (
size_t i=0; i<
num_dim; ++i)
147 physical_points_cell(0,i) = point_[i];
151 bool haveProbe =
false;
152 for (index_t cell=0; cell<static_cast<int>(d.
num_cells); ++cell) {
153 CTD::checkPointwiseInclusion(inCell,
154 physical_points_cell,
155 this->wda(d).cell_vertex_coordinates,
158 if (inCell(0) == 1) {
171 const size_t num_vertex = this->wda(d).cell_vertex_coordinates.dimension_1();
172 Kokkos::DynRankView<double,PHX::Device> cell_coords(
173 "cell_coords", 1, num_vertex,
num_dim);
174 for (
size_t i=0; i<num_vertex; ++i) {
175 for (
size_t j=0; j<
num_dim; ++j) {
176 cell_coords(0,i,j) = this->wda(d).cell_vertex_coordinates(cellIndex_,i,j);
179 Kokkos::DynRankView<double,PHX::Device> physical_points(
180 "physical_points", 1, 1,
num_dim);
181 for (
size_t i=0; i<
num_dim; ++i)
182 physical_points(0,0,i) = physical_points_cell(0,i);
183 Kokkos::DynRankView<double,PHX::Device> reference_points(
184 "reference_points", 1, 1,
num_dim);
185 CTD::mapToReferenceFrame(reference_points, physical_points, cell_coords,
187 Kokkos::DynRankView<double,PHX::Device> reference_points_cell(
188 "reference_points_cell", 1,
num_dim);
189 for (
size_t i=0; i<
num_dim; ++i)
190 reference_points_cell(0,i) = reference_points(0,0,i);
193 if (basis_->getElementSpace() == PureBasis::CONST ||
194 basis_->getElementSpace() == PureBasis::HGRAD) {
197 Kokkos::DynRankView<double,PHX::Device>
198 ref_basis_values(
"ref_basis_values", num_basis, 1);
199 basis_->getIntrepid2Basis()->getValues(ref_basis_values,
200 reference_points_cell,
201 Intrepid2::OPERATOR_VALUE);
204 FST::HGRADtransformVALUE<double>(basis_values_, ref_basis_values);
207 else if (basis_->getElementSpace() == PureBasis::HCURL ||
208 basis_->getElementSpace() == PureBasis::HDIV) {
211 Kokkos::DynRankView<double,PHX::Device> ref_basis_values(
212 "ref_basis_values", num_basis, 1,
num_dim);
213 basis_->getIntrepid2Basis()->getValues(ref_basis_values,
214 reference_points_cell,
215 Intrepid2::OPERATOR_VALUE);
218 Kokkos::DynRankView<double,PHX::Device>
jac 220 CTD::setJacobian(
jac, reference_points, cell_coords, *topology_);
221 Kokkos::DynRankView<double,PHX::Device> basis_values_vec(
222 "basis_values_vec", 1, num_basis, 1,
num_dim);
223 if (basis_->getElementSpace() == PureBasis::HCURL) {
224 Kokkos::DynRankView<double,PHX::Device> jac_inv(
226 CTD::setJacobianInv(jac_inv,
jac);
227 FST::HCURLtransformVALUE<double>(basis_values_vec, jac_inv,
231 Kokkos::DynRankView<double,PHX::Device> jac_det(
233 CTD::setJacobianDet(jac_det,
jac);
234 FST::HDIVtransformVALUE<double>(basis_values_vec,
jac, jac_det,
240 globalIndexer_->getElementOrientation(cellIndex_,
orientation);
241 std::string blockId = this->wda(d).block_id;
242 int fieldNum = globalIndexer_->getFieldNum(fieldName_);
243 const std::vector<int> & elmtOffset =
244 globalIndexer_->getGIDFieldOffsets(blockId,fieldNum);
247 for (
size_t i=0; i<num_basis; ++i) {
248 int offset = elmtOffset[i];
249 basis_values_(0,i,0) =
258 template<
typename EvalT,
typename Traits,
typename LO,
typename GO>
263 const bool haveProbe = computeBasisValues(d);
269 Kokkos::DynRankView<ScalarT,PHX::Device> field_coeffs =
272 for (
size_t i=0; i<num_basis; ++i)
273 field_coeffs(0,i) = field_(cellIndex_,i);
276 Kokkos::DynRankView<ScalarT,PHX::Device> field_val =
278 Intrepid2::FunctionSpaceTools::evaluate<ScalarT>(
279 field_val, field_coeffs, basis_values_);
280 responseObj_->value = field_val(0,0);
281 responseObj_->have_probe =
true;
284 template <
typename LO,
typename GO>
289 using Teuchos::rcp_dynamic_cast;
290 using Thyra::SpmdVectorBase;
292 TEUCHOS_ASSERT(this->scatterObj_!=Teuchos::null);
294 Base::evaluateFields(d);
297 Teuchos::ArrayRCP<double> local_dgdx;
298 RCP<SpmdVectorBase<double> > dgdx =
299 rcp_dynamic_cast<SpmdVectorBase<double> >(this->responseObj_->getGhostedVector());
300 dgdx->getNonconstLocalData(ptrFromRef(local_dgdx));
301 TEUCHOS_ASSERT(!local_dgdx.is_null());
303 this->scatterObj_->scatterDerivative(this->responseObj_->value,
305 this->responseObj_->have_probe,
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > orientation
Teuchos::RCP< GlobalEvaluationData > getDataObject(const std::string &key) const
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.
Teuchos::RCP< const panzer::PureBasis > basis
Interpolates basis DOF values to IP DOF values.
GlobalEvaluationDataContainer gedc
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::UniqueGlobalIndexer< LO, GO > > &indexer, const Teuchos::RCP< ProbeScatterBase > &probeScatter)
A constructor with concrete arguments instead of a parameter list.