43 #ifndef PANZER_DOF_CURL_IMPL_HPP 44 #define PANZER_DOF_CURL_IMPL_HPP 49 #include "Intrepid2_FunctionSpaceTools.hpp" 50 #include "Phalanx_KokkosDeviceTypes.hpp" 57 template <
typename ScalarT,
typename Array,
int spaceDim>
58 class EvaluateCurlWithSens_Vector {
67 typedef typename PHX::Device execution_space;
69 EvaluateCurlWithSens_Vector(PHX::MDField<const ScalarT,Cell,Point> in_dof_value,
70 PHX::MDField<ScalarT,Cell,Point,Dim> in_dof_curl,
77 KOKKOS_INLINE_FUNCTION
78 void operator()(
const unsigned int cell)
const 81 for (
int d=0; d<spaceDim; d++) {
92 template <
typename ScalarT,
typename ArrayT>
93 void evaluateCurl_withSens_vector(
int numCells,
94 PHX::MDField<ScalarT,Cell,Point,Dim> &
dof_curl,
95 PHX::MDField<const ScalarT,Cell,Point> &
dof_value,
104 for (
int cell=0; cell<numCells; cell++) {
106 for (
int d=0; d<spaceDim; d++) {
119 template <
typename ScalarT,
typename Array>
120 class EvaluateCurlWithSens_Scalar {
121 PHX::MDField<const ScalarT,Cell,Point>
dof_value;
122 PHX::MDField<ScalarT,Cell,Point>
dof_curl;
129 typedef typename PHX::Device execution_space;
131 EvaluateCurlWithSens_Scalar(PHX::MDField<const ScalarT,Cell,Point> in_dof_value,
132 PHX::MDField<ScalarT,Cell,Point> in_dof_curl,
139 KOKKOS_INLINE_FUNCTION
140 void operator()(
const unsigned int cell)
const 152 template <
typename ScalarT,
typename ArrayT>
153 void evaluateCurl_withSens_scalar(
int numCells,
154 PHX::MDField<ScalarT,Cell,Point> &
dof_curl,
155 PHX::MDField<const ScalarT,Cell,Point> &
dof_value,
163 for (
int cell=0; cell<numCells; cell++) {
176 template <
typename ScalarT,
typename Array,
int spaceDim>
177 class EvaluateCurlFastSens_Vector {
178 PHX::MDField<const ScalarT,Cell,Point>
dof_value;
179 PHX::MDField<ScalarT,Cell,Point,Dim>
dof_curl;
187 typedef typename PHX::Device execution_space;
189 EvaluateCurlFastSens_Vector(PHX::MDField<const ScalarT,Cell,Point> in_dof_value,
190 PHX::MDField<ScalarT,Cell,Point,Dim> in_dof_curl,
191 Kokkos::View<const int*,PHX::Device> in_offsets,
198 KOKKOS_INLINE_FUNCTION
199 void operator()(
const unsigned int cell)
const 202 for (
int d=0; d<spaceDim; d++) {
215 template <
typename ScalarT,
typename ArrayT>
216 void evaluateCurl_fastSens_vector(
int numCells,
217 PHX::MDField<ScalarT,Cell,Point,Dim> &
dof_curl,
218 PHX::MDField<const ScalarT,Cell,Point> &
dof_value,
219 const std::vector<int> &
offsets,
227 for (
int cell=0; cell<numCells; cell++) {
229 for (
int d=0; d<spaceDim; d++) {
245 template <
typename ScalarT,
typename Array>
246 class EvaluateCurlFastSens_Scalar {
247 PHX::MDField<const ScalarT,Cell,Point>
dof_value;
248 PHX::MDField<ScalarT,Cell,Point>
dof_curl;
249 Kokkos::View<const int*,PHX::Device>
offsets;
256 typedef typename PHX::Device execution_space;
258 EvaluateCurlFastSens_Scalar(PHX::MDField<const ScalarT,Cell,Point> in_dof_value,
259 PHX::MDField<ScalarT,Cell,Point> in_dof_curl,
260 Kokkos::View<const int*,PHX::Device> in_offsets,
267 KOKKOS_INLINE_FUNCTION
268 void operator()(
const unsigned int cell)
const 282 template <
typename ScalarT,
typename ArrayT>
283 void evaluateCurl_fastSens_scalar(
int numCells,
284 PHX::MDField<ScalarT,Cell,Point> &
dof_curl,
285 PHX::MDField<const ScalarT,Cell,Point> &
dof_value,
286 const std::vector<int> &
offsets,
293 for (
int cell=0; cell<numCells; cell++) {
317 template<
typename EvalT,
typename TRAITS>
320 use_descriptors_(false),
325 Teuchos::RCP<const PureBasis> basis
326 = p.get< Teuchos::RCP<BasisIRLayout> >(
"Basis")->getBasis();
329 TEUCHOS_TEST_FOR_EXCEPTION(!basis->supportsCurl(),std::logic_error,
330 "DOFCurl: Basis of type \"" << basis->name() <<
"\" does not support CURL");
331 TEUCHOS_TEST_FOR_EXCEPTION(!basis->requiresOrientations(),std::logic_error,
332 "DOFCurl: Basis of type \"" << basis->name() <<
"\" in DOF Curl should require orientations. So we are throwing.");
337 dof_curl_scalar = PHX::MDField<ScalarT,Cell,Point>(p.get<std::string>(
"Curl Name"),
338 p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR")->dl_scalar );
342 dof_curl_vector = PHX::MDField<ScalarT,Cell,Point,Dim>(p.get<std::string>(
"Curl Name"),
343 p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR")->dl_vector );
347 { TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"DOFCurl only works for 2D and 3D basis functions"); }
357 template<
typename EvalT,
typename TRAITS>
360 const PHX::FieldTag & output,
364 : use_descriptors_(true)
383 { TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"DOFCurl only works for 2D and 3D basis functions"); }
393 template<
typename EvalT,
typename TRAITS>
399 if(basis_dimension==3)
400 this->utils.setFieldData(dof_curl_vector,fm);
402 this->utils.setFieldData(dof_curl_scalar,fm);
404 if(not use_descriptors_)
409 template<
typename EvalT,
typename TRAITS>
414 : *this->wda(workset).bases[basis_index];
416 if(basis_dimension==3) {
417 EvaluateCurlWithSens_Vector<ScalarT,typename BasisValues2<double>::Array_CellBasisIPDim,3> functor(
dof_value,dof_curl_vector,basisValues.
curl_basis_vector);
418 Kokkos::parallel_for(workset.num_cells,functor);
421 EvaluateCurlWithSens_Scalar<ScalarT,typename BasisValues2<double>::Array_CellBasisIP> functor(
dof_value,dof_curl_scalar,basisValues.
curl_basis_scalar);
422 Kokkos::parallel_for(workset.num_cells,functor);
433 template<
typename TRAITS>
436 use_descriptors_(false),
441 Teuchos::RCP<const PureBasis> basis
442 = p.get< Teuchos::RCP<BasisIRLayout> >(
"Basis")->getBasis();
446 if(p.isType<Teuchos::RCP<
const std::vector<int> > >(
"Jacobian Offsets Vector")) {
447 offsets = *p.get<Teuchos::RCP<const std::vector<int> > >(
"Jacobian Offsets Vector");
450 Kokkos::View<int*,PHX::Device> offsets_array_nc
451 = Kokkos::View<int*,PHX::Device>(
"offsets",
offsets.size());
452 for(std::size_t i=0;i<
offsets.size();i++)
453 offsets_array_nc(i) =
offsets[i];
454 offsets_array = offsets_array_nc;
456 accelerate_jacobian =
true;
459 accelerate_jacobian =
false;
462 TEUCHOS_TEST_FOR_EXCEPTION(!basis->supportsCurl(),std::logic_error,
463 "DOFCurl: Basis of type \"" << basis->name() <<
"\" does not support CURL");
464 TEUCHOS_TEST_FOR_EXCEPTION(!basis->requiresOrientations(),std::logic_error,
465 "DOFCurl: Basis of type \"" << basis->name() <<
"\" in DOF Curl should require orientations. So we are throwing.");
470 dof_curl_scalar = PHX::MDField<ScalarT,Cell,Point>(p.get<std::string>(
"Curl Name"),
471 p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR")->dl_scalar );
475 dof_curl_vector = PHX::MDField<ScalarT,Cell,Point,Dim>(p.get<std::string>(
"Curl Name"),
476 p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR")->dl_vector );
480 { TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"DOFCurl only works for 2D and 3D basis functions"); }
490 template<
typename TRAITS>
493 const PHX::FieldTag & output,
497 : use_descriptors_(true)
506 accelerate_jacobian =
false;
518 { TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"DOFCurl only works for 2D and 3D basis functions"); }
528 template<
typename TRAITS>
543 template<
typename TRAITS>
550 if(!accelerate_jacobian) {
553 Kokkos::parallel_for(workset.num_cells,functor);
557 Kokkos::parallel_for(workset.num_cells,functor);
566 Kokkos::parallel_for(workset.num_cells,functor);
570 Kokkos::parallel_for(workset.num_cells,functor);
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &fm)
panzer::BasisDescriptor bd_
Array_CellBasisIPDim curl_basis_vector
PHX::MDField< ScalarT, Cell, Point > dof_curl_scalar
PHX::MDField< ScalarT, Cell, Point, Dim > dof_curl_vector
std::vector< std::string >::size_type getBasisIndex(std::string basis_name, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
Returns the index in the workset bases for a particular BasisIRLayout name.
DOFCurl(const Teuchos::ParameterList &p)
panzer::IntegrationDescriptor id_
WorksetDetailsAccessor wda
void evaluateFields(typename TRAITS::EvalData d)
PHX::MDField< const ScalarT, Cell, Point > dof_value
PHX::MDField< ScalarT, Cell, Point, Dim > dof_curl
const std::string & getType() const
Get type of basis.
Kokkos::View< const int *, PHX::Device > offsets
PHX::MDField< const ScalarT, Cell, Point > dof_value
Array_CellBasisIP curl_basis_scalar