49 #ifndef __INTREPID2_CELLTOOLS_DEF_HPP__ 
   50 #define __INTREPID2_CELLTOOLS_DEF_HPP__ 
   53 #if defined (__clang__) && !defined (__INTEL_COMPILER) 
   54 #pragma clang system_header 
   66   namespace FunctorCellTools {
 
   70     template<
typename jacobianViewType, 
 
   71              typename worksetCellType, 
 
   72              typename basisGradType>
 
   74             jacobianViewType _jacobian;
 
   75       const worksetCellType  _worksetCells;
 
   76       const basisGradType    _basisGrads;
 
   78       KOKKOS_INLINE_FUNCTION
 
   80                      worksetCellType  worksetCells_,
 
   81                      basisGradType    basisGrads_ )
 
   82         : _jacobian(jacobian_), _worksetCells(worksetCells_), _basisGrads(basisGrads_) {}
 
   84       KOKKOS_INLINE_FUNCTION
 
   85       void operator()(
const ordinal_type cl, 
 
   86                       const ordinal_type pt)
 const {
 
   87               auto jac  = Kokkos::subview( _jacobian,     cl, pt, Kokkos::ALL(), Kokkos::ALL());
 
   88         const auto dofs = Kokkos::subview( _worksetCells, cl,     Kokkos::ALL(), Kokkos::ALL());
 
   90         const ordinal_type gradRank = _basisGrads.rank(); 
 
   91         const auto grad = ( gradRank == 3 ? Kokkos::subdynrankview( _basisGrads,     Kokkos::ALL(), pt, Kokkos::ALL()) :
 
   92                                             Kokkos::subdynrankview( _basisGrads, cl, Kokkos::ALL(), pt, Kokkos::ALL()));
 
   94         const ordinal_type dim = jac.extent(0); 
 
   95         const ordinal_type cardinality = grad.extent(0);
 
   97         for (ordinal_type i=0;i<dim;++i)
 
   98           for (ordinal_type j=0;j<dim;++j) {
 
  100             for (ordinal_type bf=0;bf<cardinality;++bf) 
 
  101               jac(i, j) += dofs(bf, i)*grad(bf, j);
 
  107   template<
typename SpT>
 
  108   template<
typename jacobianValueType,    
class ...jacobianProperties,
 
  109            typename pointValueType,       
class ...pointProperties,
 
  110            typename worksetCellValueType, 
class ...worksetCellProperties,
 
  111            typename HGradBasisPtrType>
 
  114   setJacobian(       Kokkos::DynRankView<jacobianValueType,jacobianProperties...>       jacobian,
 
  115                const Kokkos::DynRankView<pointValueType,pointProperties...>             points,
 
  116                const Kokkos::DynRankView<worksetCellValueType,worksetCellProperties...> worksetCell,
 
  117                const HGradBasisPtrType basis ) {
 
  118 #ifdef HAVE_INTREPID2_DEBUG     
  119     CellTools_setJacobianArgs(jacobian, points, worksetCell, basis->getBaseCellTopology());
 
  122     const auto cellTopo = basis->getBaseCellTopology();
 
  123     const ordinal_type spaceDim = cellTopo.getDimension();
 
  124     const ordinal_type numCells = worksetCell.extent(0);
 
  127     const ordinal_type pointRank = points.rank();
 
  128     const ordinal_type numPoints = (pointRank == 2 ? points.extent(0) : points.extent(1));
 
  129     const ordinal_type basisCardinality = basis->getCardinality();    
 
  131     typedef Kokkos::DynRankView<jacobianValueType,jacobianProperties...> jacobianViewType;
 
  137     auto vcprop = Kokkos::common_view_alloc_prop(points);
 
  138     typedef Kokkos::DynRankView<typename decltype(vcprop)::value_type,SpT> gradViewType;
 
  142     typedef Kokkos::DynRankView<worksetCellValueType,worksetCellProperties...> worksetCellViewType;
 
  143     typedef typename ExecSpace<typename worksetCellViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
 
  148       grads = gradViewType(Kokkos::view_alloc(
"CellTools::setJacobian::grads", vcprop),basisCardinality, numPoints, spaceDim);
 
  149       basis->getValues(grads, 
 
  156       grads = gradViewType(Kokkos::view_alloc(
"CellTools::setJacobian::grads", vcprop), numCells, basisCardinality, numPoints, spaceDim);
 
  157       for (ordinal_type cell=0;cell<numCells;++cell) 
 
  158         basis->getValues(Kokkos::subview( grads,  cell, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() ),  
 
  159                          Kokkos::subview( points, cell, Kokkos::ALL(), Kokkos::ALL() ),  
 
  165     typedef Kokkos::DynRankView<worksetCellValueType,worksetCellProperties...> worksetCellViewType;
 
  167     typedef typename ExecSpace<typename worksetCellViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
 
  169     using range_policy_type = Kokkos::Experimental::MDRangePolicy
 
  170       < ExecSpaceType, Kokkos::Experimental::Rank<2>, Kokkos::IndexType<ordinal_type> >;
 
  171     range_policy_type policy( { 0, 0 },
 
  172                               { jacobian.extent(0), jacobian.extent(1) } );
 
  173     Kokkos::parallel_for( policy, FunctorType(jacobian, worksetCell, grads) );
 
  176   template<
typename SpT>
 
  177   template<
typename jacobianInvValueType, 
class ...jacobianInvProperties,                                   
 
  178            typename jacobianValueType,    
class ...jacobianProperties>                                      
 
  181   setJacobianInv(       Kokkos::DynRankView<jacobianInvValueType,jacobianInvProperties...> jacobianInv,     
 
  182                   const Kokkos::DynRankView<jacobianValueType,jacobianProperties...>       jacobian ) {
 
  183 #ifdef HAVE_INTREPID2_DEBUG 
  184     CellTools_setJacobianInvArgs(jacobianInv, jacobian);
 
  189   template<
typename SpT>
 
  190   template<
typename jacobianDetValueType, 
class ...jacobianDetProperties,                                   
 
  191            typename jacobianValueType,    
class ...jacobianProperties>                                      
 
  194   setJacobianDet(       Kokkos::DynRankView<jacobianDetValueType,jacobianDetProperties...>  jacobianDet,    
 
  195                   const Kokkos::DynRankView<jacobianValueType,jacobianProperties...>        jacobian ) {
 
  196 #ifdef HAVE_INTREPID2_DEBUG 
  197     CellTools_setJacobianDetArgs(jacobianDet, jacobian);