11 #ifndef PANZER_DOF_CURL_IMPL_HPP
12 #define PANZER_DOF_CURL_IMPL_HPP
17 #include "Intrepid2_FunctionSpaceTools.hpp"
18 #include "Phalanx_KokkosDeviceTypes.hpp"
25 template <
typename ScalarT,
typename Array,
int spaceDim>
26 class EvaluateCurlWithSens_Vector {
35 typedef typename PHX::Device execution_space;
45 KOKKOS_INLINE_FUNCTION
46 void operator()(
const unsigned int cell)
const
49 for (
int d=0; d<spaceDim; d++) {
60 template <
typename ScalarT,
typename ArrayT>
61 void evaluateCurl_withSens_vector(
int numCells,
69 int numPoints = curl_basis.extent(2);
70 int spaceDim = curl_basis.extent(3);
72 for (
int cell=0; cell<numCells; cell++) {
74 for (
int d=0; d<spaceDim; d++) {
87 template <
typename ScalarT,
typename Array>
88 class EvaluateCurlWithSens_Scalar {
97 typedef typename PHX::Device execution_space;
102 : dof_value(in_dof_value), dof_curl(in_dof_curl), curl_basis(in_curl_basis)
104 numFields = curl_basis.extent(1);
105 numPoints = curl_basis.extent(2);
107 KOKKOS_INLINE_FUNCTION
108 void operator()(
const unsigned int cell)
const
120 template <
typename ScalarT,
typename ArrayT>
121 void evaluateCurl_withSens_scalar(
int numCells,
124 const ArrayT & curl_basis)
128 int numFields = curl_basis.extent(1);
129 int numPoints = curl_basis.extent(2);
131 for (
int cell=0; cell<numCells; cell++) {
144 template <
typename ScalarT,
typename Array,
int spaceDim>
145 class EvaluateCurlFastSens_Vector {
155 typedef typename PHX::Device execution_space;
159 PHX::View<const int*> in_offsets,
161 : dof_value(in_dof_value), dof_curl(in_dof_curl),
offsets(in_offsets), curl_basis(in_curl_basis)
163 numFields = curl_basis.extent(1);
164 numPoints = curl_basis.extent(2);
166 KOKKOS_INLINE_FUNCTION
167 void operator()(
const unsigned int cell)
const
170 for (
int d=0; d<spaceDim; d++) {
183 template <
typename ScalarT,
typename ArrayT>
184 void evaluateCurl_fastSens_vector(
int numCells,
187 const std::vector<int> &
offsets,
188 const ArrayT & curl_basis)
191 int numFields = curl_basis.extent(1);
192 int numPoints = curl_basis.extent(2);
193 int spaceDim = curl_basis.extent(3);
195 for (
int cell=0; cell<numCells; cell++) {
197 for (
int d=0; d<spaceDim; d++) {
213 template <
typename ScalarT,
typename Array>
214 class EvaluateCurlFastSens_Scalar {
224 typedef typename PHX::Device execution_space;
228 PHX::View<const int*> in_offsets,
230 : dof_value(in_dof_value), dof_curl(in_dof_curl), offsets(in_offsets), curl_basis(in_curl_basis)
232 numFields = curl_basis.extent(1);
233 numPoints = curl_basis.extent(2);
235 KOKKOS_INLINE_FUNCTION
236 void operator()(
const unsigned int cell)
const
250 template <
typename ScalarT,
typename ArrayT>
251 void evaluateCurl_fastSens_scalar(
int numCells,
254 const std::vector<int> & offsets,
255 const ArrayT & curl_basis)
258 int numFields = curl_basis.extent(1);
259 int numPoints = curl_basis.extent(2);
261 for (
int cell=0; cell<numCells; cell++) {
285 template<
typename EvalT,
typename TRAITS>
288 use_descriptors_(false),
289 dof_value( p.get<std::string>(
"Name"),
298 "DOFCurl: Basis of type \"" << basis->name() <<
"\" does not support CURL");
300 "DOFCurl: Basis of type \"" << basis->name() <<
"\" in DOF Curl should require orientations. So we are throwing.");
304 if(basis_dimension==2) {
309 else if(basis_dimension==3) {
318 this->addDependentField(dof_value);
325 template<
typename EvalT,
typename TRAITS>
332 : use_descriptors_(true)
342 if(basis_dimension==2) {
346 else if(basis_dimension==3) {
354 this->addDependentField(dof_value);
361 template<
typename EvalT,
typename TRAITS>
366 this->utils.setFieldData(dof_value,fm);
367 if(basis_dimension==3)
368 this->utils.setFieldData(dof_curl_vector,fm);
370 this->utils.setFieldData(dof_curl_scalar,fm);
372 if(not use_descriptors_)
377 template<
typename EvalT,
typename TRAITS>
382 : *this->wda(workset).bases[basis_index];
384 if(basis_dimension==3) {
385 EvaluateCurlWithSens_Vector<ScalarT,typename BasisValues2<double>::Array_CellBasisIPDim,3> functor(dof_value,dof_curl_vector,basisValues.
curl_basis_vector);
386 Kokkos::parallel_for(workset.num_cells,functor);
389 EvaluateCurlWithSens_Scalar<ScalarT,typename BasisValues2<double>::Array_CellBasisIP> functor(dof_value,dof_curl_scalar,basisValues.
curl_basis_scalar);
390 Kokkos::parallel_for(workset.num_cells,functor);
401 template<
typename TRAITS>
404 use_descriptors_(false),
405 dof_value( p.get<std::string>(
"Name"),
418 PHX::View<int*> offsets_array_nc(
"offsets",offsets.size());
419 auto offsets_array_nc_h = Kokkos::create_mirror_view(offsets_array_nc);
420 for(std::size_t i=0;i<offsets.size();i++)
421 offsets_array_nc_h(i) = offsets[i];
422 Kokkos::deep_copy(offsets_array_nc, offsets_array_nc_h);
423 offsets_array = offsets_array_nc;
425 accelerate_jacobian =
true;
428 accelerate_jacobian =
false;
432 "DOFCurl: Basis of type \"" << basis->name() <<
"\" does not support CURL");
434 "DOFCurl: Basis of type \"" << basis->name() <<
"\" in DOF Curl should require orientations. So we are throwing.");
438 if(basis_dimension==2) {
443 else if(basis_dimension==3) {
452 this->addDependentField(dof_value);
459 template<
typename TRAITS>
466 : use_descriptors_(true)
475 accelerate_jacobian =
false;
478 if(basis_dimension==2) {
482 else if(basis_dimension==3) {
490 this->addDependentField(dof_value);
497 template<
typename TRAITS>
502 this->utils.setFieldData(dof_value,fm);
512 template<
typename TRAITS>
519 if(!accelerate_jacobian) {
523 EvaluateCurlWithSens_Vector<ScalarT,Array,3> functor(dof_value,
dof_curl_vector,curl_basis_vector);
524 Kokkos::parallel_for(workset.num_cells,functor);
529 EvaluateCurlWithSens_Scalar<ScalarT,Array> functor(dof_value,
dof_curl_scalar,curl_basis_scalar);
530 Kokkos::parallel_for(workset.num_cells,functor);
540 EvaluateCurlFastSens_Vector<ScalarT,Array,3> functor(dof_value,
dof_curl_vector,offsets_array,curl_basis_vector);
541 Kokkos::parallel_for(workset.num_cells,functor);
546 EvaluateCurlFastSens_Scalar<ScalarT,Array> functor(dof_value,
dof_curl_scalar,offsets_array,curl_basis_scalar);
547 Kokkos::parallel_for(workset.num_cells,functor);
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &fm)
panzer::BasisDescriptor bd_
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Array_CellBasisIPDim curl_basis_vector
ConstArray_CellBasisIPDim getCurlVectorBasis(const bool weighted, const bool cache=true, const bool force=false) const
Get the curl of a 3D vector basis evaluated at mesh points.
PHX::MDField< ScalarT, Cell, Point > dof_curl_scalar
PHX::MDField< ScalarT, Cell, Point, Dim > dof_curl_vector
PHX::View< const int * > offsets
const std::string & getType() const
Get type of basis.
ConstArray_CellBasisIP getBasisValues(const bool weighted, const bool cache=true, const bool force=false) const
Get the basis values evaluated at mesh points.
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_
bool isType(const std::string &name) const
WorksetDetailsAccessor wda
#define TEUCHOS_ASSERT(assertion_test)
void evaluateFields(typename TRAITS::EvalData d)
PHX::MDField< const ScalarT, Cell, Point > dof_value
PHX::MDField< ScalarT, Cell, Point, Dim > dof_curl
ConstArray_CellBasisIP getCurl2DVectorBasis(const bool weighted, const bool cache=true, const bool force=false) const
Get the curl of a 2D vector basis evaluated at mesh points.
Array_CellBasisIP curl_basis_scalar