49 #ifndef __INTREPID2_HDIV_TET_IN_FEM_DEF_HPP__ 
   50 #define __INTREPID2_HDIV_TET_IN_FEM_DEF_HPP__ 
   61 template<EOperator opType>
 
   62 template<
typename OutputViewType,
 
   63 typename inputViewType,
 
   64 typename workViewType,
 
   65 typename vinvViewType>
 
   66 KOKKOS_INLINE_FUNCTION
 
   68 Basis_HDIV_TET_In_FEM::Serial<opType>::
 
   69 getValues(       OutputViewType output,
 
   70     const inputViewType  input,
 
   72     const vinvViewType   coeffs ) {
 
   74   constexpr ordinal_type spaceDim = 3;
 
   76   cardPn = coeffs.extent(0)/spaceDim,
 
   77   card = coeffs.extent(1),
 
   78   npts = input.extent(0);
 
   81   ordinal_type order = 0;
 
   83     if (card == CardinalityHDivTet(p)) {
 
   89   typedef typename Kokkos::DynRankView<typename workViewType::value_type, typename workViewType::memory_space> viewType;
 
   90   auto vcprop = Kokkos::common_view_alloc_prop(work);
 
   91   auto ptr = work.data();
 
   94   case OPERATOR_VALUE: {
 
   95     const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts);
 
   96     workViewType dummyView;
 
   98     Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
 
   99     Serial<opType>::getValues(phis, input, dummyView, order);
 
  101     for (ordinal_type i=0;i<card;++i)
 
  102       for (ordinal_type j=0;j<npts;++j)
 
  103         for (ordinal_type d=0;d<spaceDim;++d) {
 
  104           output.access(i,j,d) = 0.0;
 
  105           for (ordinal_type k=0;k<cardPn;++k)
 
  106             output.access(i,j,d) += coeffs(k+d*cardPn,i) * phis.access(k,j);
 
  111     const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim);
 
  112     ptr += card*npts*spaceDim*get_dimension_scalar(work);
 
  113     const viewType workView(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim+1);
 
  115     Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
 
  116     Serial<OPERATOR_GRAD>::getValues(phis, input, workView, order);
 
  118     for (ordinal_type i=0;i<card;++i)
 
  119       for (ordinal_type j=0;j<npts;++j) {
 
  120         output.access(i,j) = 0.0;
 
  121         for (ordinal_type k=0; k<cardPn; ++k)
 
  122           for (ordinal_type d=0; d<spaceDim; ++d)
 
  123             output.access(i,j) += coeffs(k+d*cardPn,i)*phis.access(k,j,d);
 
  128     INTREPID2_TEST_FOR_ABORT( 
true,
 
  129         ">>> ERROR (Basis_HDIV_TET_In_FEM): Operator type not implemented");
 
  134 template<
typename SpT, ordinal_type numPtsPerEval,
 
  135 typename outputValueValueType, 
class ...outputValueProperties,
 
  136 typename inputPointValueType,  
class ...inputPointProperties,
 
  137 typename vinvValueType,        
class ...vinvProperties>
 
  139 Basis_HDIV_TET_In_FEM::
 
  140 getValues(  Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
 
  141     const Kokkos::DynRankView<inputPointValueType, inputPointProperties...>  inputPoints,
 
  142     const Kokkos::DynRankView<vinvValueType,       vinvProperties...>        coeffs,
 
  143     const EOperator operatorType) {
 
  144   typedef          Kokkos::DynRankView<outputValueValueType,outputValueProperties...>         outputValueViewType;
 
  145   typedef          Kokkos::DynRankView<inputPointValueType, inputPointProperties...>          inputPointViewType;
 
  146   typedef          Kokkos::DynRankView<vinvValueType,       vinvProperties...>                vinvViewType;
 
  147   typedef typename ExecSpace<typename inputPointViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
 
  150   const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
 
  151   const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
 
  152   const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
 
  153   Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
 
  155   typedef typename inputPointViewType::value_type inputPointType;
 
  157   const ordinal_type cardinality = outputValues.extent(0);
 
  158   const ordinal_type spaceDim = 3;
 
  160   auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
 
  161   typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
 
  163   switch (operatorType) {
 
  164   case OPERATOR_VALUE: {
 
  165     workViewType  work(Kokkos::view_alloc(
"Basis_HDIV_TET_In_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
 
  166     typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
 
  167         OPERATOR_VALUE,numPtsPerEval> FunctorType;
 
  168     Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, coeffs, work) );
 
  172     workViewType  work(Kokkos::view_alloc(
"Basis_HDIV_TET_In_FEM::getValues::work", vcprop), cardinality*(2*spaceDim+1), inputPoints.extent(0));
 
  173     typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
 
  174         OPERATOR_DIV,numPtsPerEval> FunctorType;
 
  175     Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, coeffs, work) );
 
  179     INTREPID2_TEST_FOR_EXCEPTION( 
true , std::invalid_argument,
 
  180         ">>> ERROR (Basis_HDIV_TET_In_FEM): Operator type not implemented" );
 
  187 template<
typename SpT, 
typename OT, 
typename PT>
 
  190     const EPointType   pointType ) {
 
  192   constexpr ordinal_type spaceDim = 3;
 
  193   this->basisCardinality_  = CardinalityHDivTet(order);
 
  194   this->basisDegree_       = order; 
 
  195   this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Tetrahedron<4> >() );
 
  196   this->basisType_         = BASIS_FEM_FIAT;
 
  197   this->basisCoordinates_  = COORDINATES_CARTESIAN;
 
  198   this->functionSpace_     = FUNCTION_SPACE_HDIV;
 
  200   const ordinal_type card = this->basisCardinality_;
 
  202   const ordinal_type  cardPn = Intrepid2::getPnCardinality<spaceDim>(order); 
 
  203   const ordinal_type  cardPnm1 = Intrepid2::getPnCardinality<spaceDim>(order-1);  
 
  204   const ordinal_type  cardPnm2 = Intrepid2::getPnCardinality<spaceDim>(order-2); 
 
  205   const ordinal_type  cardVecPn = spaceDim*cardPn;  
 
  206   const ordinal_type  cardVecPnm1 = spaceDim*cardPnm1;   
 
  207   const ordinal_type  dim_PkH = cardPnm1 - cardPnm2;
 
  211   constexpr ordinal_type tagSize  = 4;        
 
  213   ordinal_type tags[maxCard][tagSize];
 
  216   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
 
  217   dofCoords(
"Hdiv::Tet::In::dofCoords", card, spaceDim);
 
  219   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
 
  220   dofCoeffs(
"Hdiv::Tet::In::dofCoeffs", card, spaceDim);
 
  222   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
 
  223   coeffs(
"Hdiv::Tet::In::coeffs", cardVecPn, card);
 
  229   const ordinal_type lwork = card*card;
 
  230   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
 
  231   V1(
"Hdiv::Tet::In::V1", cardVecPn, card);
 
  242   for (ordinal_type i=0;i<cardPnm1;i++) {
 
  243     for (ordinal_type k=0; k<3;k++) {
 
  244       V1(k*cardPn+i,k*cardPnm1+i) = 1.0;
 
  251   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> cubPoints(
"Hdiv::Tet::In::cubPoints", myCub.
getNumPoints() , spaceDim );
 
  252   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> cubWeights(
"Hdiv::Tet::In::cubWeights", myCub.
getNumPoints() );
 
  256   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> phisAtCubPoints(
"Hdiv::Tet::In::phisAtCubPoints", cardPn , myCub.
getNumPoints() );
 
  257   Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(phisAtCubPoints, cubPoints, order, OPERATOR_VALUE);
 
  260   for (ordinal_type i=0;i<dim_PkH;i++) {
 
  261     for (ordinal_type j=0;j<cardPn;j++) { 
 
  262       V1(j,cardVecPnm1+i) = 0.0;
 
  263       for (ordinal_type d=0; d< spaceDim; ++d)
 
  265           V1(j+d*cardPn,cardVecPnm1+i) +=
 
  266               cubWeights(k) * cubPoints(k,d)
 
  267               * phisAtCubPoints(cardPnm2+i,k)
 
  268               * phisAtCubPoints(j,k);
 
  274   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
 
  275   V2(
"Hdiv::Tet::In::V2", card ,cardVecPn);
 
  277   const ordinal_type numFaces = this->basisCellTopology_.getFaceCount();
 
  279   shards::CellTopology faceTop(shards::getCellTopologyData<shards::Triangle<3> >() );
 
  286   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> triPts(
"Hdiv::Tet::In::triPts", numPtsPerFace , 2 );
 
  289   const ordinal_type offset = 1;
 
  297   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> facePts(
"Hdiv::Tet::In::facePts", numPtsPerFace , spaceDim );
 
  298   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> phisAtFacePoints(
"Hdiv::Tet::In::phisAtFacePoints", cardPn , numPtsPerFace );
 
  299   Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> faceNormal(
"Hcurl::Tet::In::faceNormal", spaceDim );
 
  302   for (ordinal_type face=0;face<numFaces;face++) {  
 
  307         this->basisCellTopology_ );
 
  310     const scalarType refTriangleMeasure = 0.5;
 
  311     for (ordinal_type j=0;j<spaceDim;j++)
 
  312       faceNormal(j) *= refTriangleMeasure;
 
  319         this->basisCellTopology_ );
 
  322     Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(phisAtFacePoints, facePts, order, OPERATOR_VALUE);
 
  325     for (ordinal_type j=0;j<numPtsPerFace;j++) {
 
  327       const ordinal_type i_card = numPtsPerFace*face+j;
 
  330       for (ordinal_type k=0;k<cardPn;k++) {
 
  332         for (ordinal_type l=0; l<spaceDim; l++)
 
  333           V2(i_card,k+l*cardPn) = faceNormal(l) * phisAtFacePoints(k,j);
 
  337       for(ordinal_type l=0; l<spaceDim; ++l) {
 
  338         dofCoords(i_card,l) = facePts(j,l);
 
  339         dofCoeffs(i_card,l) = faceNormal(l);
 
  343       tags[i_card][1] = face; 
 
  345       tags[i_card][3] = numPtsPerFace; 
 
  358   if (numPtsPerCell > 0) {
 
  359     Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
 
  360     internalPoints( 
"Hdiv::Tet::In::internalPoints", numPtsPerCell , spaceDim );
 
  362         this->basisCellTopology_ ,
 
  367     Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
 
  368     phisAtInternalPoints(
"Hdiv::Tet::In::phisAtInternalPoints", cardPn , numPtsPerCell );
 
  369     Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>( phisAtInternalPoints , internalPoints , order, OPERATOR_VALUE );
 
  372     for (ordinal_type j=0;j<numPtsPerCell;j++) {
 
  374       const ordinal_type i_card = numFaces*numPtsPerFace+spaceDim*j;
 
  376       for (ordinal_type k=0;k<cardPn;k++) {
 
  377         for (ordinal_type l=0;l<spaceDim;l++) {
 
  378           V2(i_card+l,l*cardPn+k) = phisAtInternalPoints(k,j);
 
  383       for(ordinal_type d=0; d<spaceDim; ++d) {
 
  384         for(ordinal_type l=0; l<spaceDim; ++l) {
 
  385           dofCoords(i_card+d,l) = internalPoints(j,l);
 
  386           dofCoeffs(i_card+d,l) = (l==d);
 
  389         tags[i_card+d][0] = spaceDim; 
 
  390         tags[i_card+d][1] = 0; 
 
  391         tags[i_card+d][2] = spaceDim*j+d; 
 
  392         tags[i_card+d][3] = spaceDim*numPtsPerCell; 
 
  399   Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
 
  400   vmat(
"Hdiv::Tet::In::vmat", card, card),
 
  401   work(
"Hdiv::Tet::In::work", lwork),
 
  402   ipiv(
"Hdiv::Tet::In::ipiv", card);
 
  405   for(ordinal_type i=0; i< card; ++i) {
 
  406     for(ordinal_type j=0; j< card; ++j) {
 
  408       for(ordinal_type k=0; k< cardVecPn; ++k)
 
  409         s += V2(i,k)*V1(k,j);
 
  414   ordinal_type info = 0;
 
  415   Teuchos::LAPACK<ordinal_type,scalarType> lapack;
 
  417   lapack.GETRF(card, card,
 
  418       vmat.data(), vmat.stride_1(),
 
  419       (ordinal_type*)ipiv.data(),
 
  422   INTREPID2_TEST_FOR_EXCEPTION( info != 0,
 
  424       ">>> ERROR: (Intrepid2::Basis_HDIV_TET_In_FEM) lapack.GETRF returns nonzero info." );
 
  427       vmat.data(), vmat.stride_1(),
 
  428       (ordinal_type*)ipiv.data(),
 
  432   INTREPID2_TEST_FOR_EXCEPTION( info != 0,
 
  434       ">>> ERROR: (Intrepid2::Basis_HDIV_TET_In_FEM) lapack.GETRI returns nonzero info." );
 
  436   for (ordinal_type i=0;i<cardVecPn;++i)
 
  437     for (ordinal_type j=0;j<card;++j){
 
  439       for(ordinal_type k=0; k< card; ++k)
 
  440         s += V1(i,k)*vmat(k,j);
 
  444   this->coeffs_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), coeffs);
 
  445   Kokkos::deep_copy(this->coeffs_ , coeffs);
 
  447   this->dofCoords_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), dofCoords);
 
  448   Kokkos::deep_copy(this->dofCoords_, dofCoords);
 
  450   this->dofCoeffs_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), dofCoeffs);
 
  451   Kokkos::deep_copy(this->dofCoeffs_, dofCoeffs);
 
  457     const ordinal_type posScDim = 0;        
 
  458     const ordinal_type posScOrd = 1;        
 
  459     const ordinal_type posDfOrd = 2;        
 
  465     this->setOrdinalTagData(this->tagToOrdinal_,
 
  468         this->basisCardinality_,
 
Kokkos::View< ordinal_type *, typename ExecSpaceType::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array. 
 
virtual void getCubature(PointViewType cubPoints, weightViewType cubWeights) const 
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated). 
 
Header file for the Intrepid2::CubatureDirectTetDefault class. 
 
Basis_HDIV_TET_In_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor. 
 
Defines direct integration rules on a tetrahedron. 
 
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM_ORTH class. 
 
static constexpr ordinal_type MaxOrder
The maximum reconstruction order. 
 
virtual ordinal_type getNumPoints() const 
Returns the number of cubature points.