15 #ifndef __INTREPID2_HVOL_TET_CN_FEM_DEF_HPP__
16 #define __INTREPID2_HVOL_TET_CN_FEM_DEF_HPP__
26 template<EOperator OpType>
27 template<
typename OutputViewType,
28 typename InputViewType,
29 typename WorkViewType,
30 typename VinvViewType>
31 KOKKOS_INLINE_FUNCTION
33 Basis_HVOL_TET_Cn_FEM::Serial<OpType>::
34 getValues( OutputViewType output,
35 const InputViewType input,
37 const VinvViewType vinv ) {
39 constexpr ordinal_type spaceDim = 3;
41 card = vinv.extent(0),
42 npts = input.extent(0);
45 ordinal_type order = 0;
47 if (card == Intrepid2::getPnCardinality<spaceDim>(p)) {
53 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
54 auto vcprop = Kokkos::common_view_alloc_prop(input);
55 auto ptr = work.data();
58 case OPERATOR_VALUE: {
59 const ViewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts);
62 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
63 Serial<OpType>::getValues(phis, input, dummyView, order);
65 for (ordinal_type i=0;i<card;++i)
66 for (ordinal_type j=0;j<npts;++j) {
67 output.access(i,j) = 0.0;
68 for (ordinal_type k=0;k<card;++k)
69 output.access(i,j) += vinv(k,i)*phis.access(k,j);
75 const ViewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim);
76 ptr += card*npts*spaceDim*get_dimension_scalar(input);
77 const ViewType workView(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim+1);
78 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
79 Serial<OpType>::getValues(phis, input, workView, order);
81 for (ordinal_type i=0;i<card;++i)
82 for (ordinal_type j=0;j<npts;++j)
83 for (ordinal_type k=0;k<spaceDim;++k) {
84 output.access(i,j,k) = 0.0;
85 for (ordinal_type l=0;l<card;++l)
86 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
99 const ordinal_type dkcard = getDkCardinality<OpType,spaceDim>();
101 ViewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, dkcard);
104 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
105 Serial<OpType>::getValues(phis, input, dummyView, order);
107 for (ordinal_type i=0;i<card;++i)
108 for (ordinal_type j=0;j<npts;++j)
109 for (ordinal_type k=0;k<dkcard;++k) {
110 output.access(i,j,k) = 0.0;
111 for (ordinal_type l=0;l<card;++l)
112 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
117 INTREPID2_TEST_FOR_ABORT(
true,
118 ">>> ERROR (Basis_HVOL_TET_Cn_FEM): Operator type not implemented");
123 template<
typename DT, ordinal_type numPtsPerEval,
124 typename outputValueValueType,
class ...outputValueProperties,
125 typename inputPointValueType,
class ...inputPointProperties,
126 typename vinvValueType,
class ...vinvProperties>
128 Basis_HVOL_TET_Cn_FEM::
129 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
130 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
131 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
132 const EOperator operatorType) {
133 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
134 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
135 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
136 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
139 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
140 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
141 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
142 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
144 typedef typename inputPointViewType::value_type inputPointType;
146 const ordinal_type cardinality = outputValues.extent(0);
147 const ordinal_type spaceDim = 3;
149 ordinal_type order = 0;
150 while((Intrepid2::getPnCardinality<spaceDim>(++order) != cardinality) && (order !=
Parameters::MaxOrder));
152 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
153 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
155 switch (operatorType) {
156 case OPERATOR_VALUE: {
157 auto bufferSize = Basis_HVOL_TET_Cn_FEM::Serial<OPERATOR_VALUE>::getWorkSizePerPoint(order);
158 workViewType work(Kokkos::view_alloc(
"Basis_HVOL_TET_Cn_FEM::getValues::work", vcprop), bufferSize, inputPoints.extent(0));
159 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
160 OPERATOR_VALUE,numPtsPerEval> FunctorType;
161 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
166 auto bufferSize = Basis_HVOL_TET_Cn_FEM::Serial<OPERATOR_D1>::getWorkSizePerPoint(order);
167 workViewType work(Kokkos::view_alloc(
"Basis_HVOL_TET_Cn_FEM::getValues::work", vcprop), bufferSize, inputPoints.extent(0));
168 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
169 OPERATOR_D1,numPtsPerEval> FunctorType;
170 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
174 auto bufferSize = Basis_HVOL_TET_Cn_FEM::Serial<OPERATOR_D2>::getWorkSizePerPoint(order);
175 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
176 OPERATOR_D2,numPtsPerEval> FunctorType;
177 workViewType work(Kokkos::view_alloc(
"Basis_HVOL_TET_Cn_FEM::getValues::work", vcprop), bufferSize, inputPoints.extent(0));
178 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
189 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
190 ">>> ERROR (Basis_HVOL_TET_Cn_FEM): Operator type not implemented" );
197 template<
typename DT,
typename OT,
typename PT>
200 const EPointType pointType ) {
201 constexpr ordinal_type spaceDim = 3;
203 this->pointType_ = pointType;
204 this->basisCardinality_ = Intrepid2::getPnCardinality<spaceDim>(order);
205 this->basisDegree_ = order;
206 this->basisCellTopologyKey_ = shards::Tetrahedron<4>::key;
207 this->basisType_ = BASIS_FEM_LAGRANGIAN;
208 this->basisCoordinates_ = COORDINATES_CARTESIAN;
209 this->functionSpace_ = FUNCTION_SPACE_HVOL;
211 const ordinal_type card = this->basisCardinality_;
214 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
215 dofCoords(
"HVOL::Tet::Cn::dofCoords", card, spaceDim);
218 const ordinal_type offset = 1;
219 const shards::CellTopology cellTopo(shards::getCellTopologyData<shards::Tetrahedron<4> >());
222 order+spaceDim+offset, offset,
225 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
226 Kokkos::deep_copy(this->dofCoords_, dofCoords);
230 const ordinal_type lwork = card*card;
231 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
232 vmat(
"HVOL::Tet::Cn::vmat", card, card),
233 work(
"HVOL::Tet::Cn::work", lwork),
234 ipiv(
"HVOL::Tet::Cn::ipiv", card);
236 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
242 ordinal_type info = 0;
243 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
245 lapack.GETRF(card, card,
246 vmat.data(), vmat.stride_1(),
247 (ordinal_type*)ipiv.data(),
250 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
252 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM) lapack.GETRF returns nonzero info." );
255 vmat.data(), vmat.stride_1(),
256 (ordinal_type*)ipiv.data(),
260 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
262 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM) lapack.GETRI returns nonzero info." );
265 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
266 vinv(
"HVOL::Line::Cn::vinv", card, card);
268 for (ordinal_type i=0;i<card;++i)
269 for (ordinal_type j=0;j<card;++j)
270 vinv(i,j) = vmat(j,i);
272 this->vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
273 Kokkos::deep_copy(this->vinv_ , vinv);
278 constexpr ordinal_type tagSize = 4;
279 const ordinal_type posScDim = 0;
280 const ordinal_type posScOrd = 1;
281 const ordinal_type posDfOrd = 2;
283 constexpr ordinal_type maxCard = Intrepid2::getPnCardinality<spaceDim, Parameters::MaxOrder>();
284 ordinal_type tags[maxCard][tagSize];
287 numElemDof = this->basisCardinality_;
290 ordinal_type elemId = 0;
291 for (ordinal_type i=0;i<this->basisCardinality_;++i) {
293 tags[i][0] = spaceDim;
295 tags[i][2] = elemId++;
296 tags[i][3] = numElemDof;
303 this->setOrdinalTagData(this->tagToOrdinal_,
306 this->basisCardinality_,
314 template<
typename DT,
typename OT,
typename PT>
317 ordinal_type& perTeamSpaceSize,
318 ordinal_type& perThreadSpaceSize,
320 const EOperator operatorType)
const {
321 perTeamSpaceSize = 0;
322 perThreadSpaceSize = this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
325 template<
typename DT,
typename OT,
typename PT>
326 KOKKOS_INLINE_FUNCTION
329 OutputViewType outputValues,
330 const PointViewType inputPoints,
331 const EOperator operatorType,
332 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
333 const typename DT::execution_space::scratch_memory_space & scratchStorage,
334 const ordinal_type subcellDim,
335 const ordinal_type subcellOrdinal)
const {
337 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
338 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
340 const int numPoints = inputPoints.extent(0);
341 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
342 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
343 auto sizePerPoint = this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
344 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
345 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
346 switch(operatorType) {
348 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
349 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
350 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
351 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
356 INTREPID2_TEST_FOR_ABORT(
true,
357 ">>> ERROR (Basis_HVOL_TET_Cn_FEM): getValues not implemented for this operator");
ScalarTraits< pointValueType >::scalar_type scalarType
Scalar type for point values.
virtual void getValues(OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
virtual void getScratchSpaceSize(ordinal_type &perTeamSpaceSize, ordinal_type &perThreadSpaceSize, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Return the size of the scratch space, in bytes, needed for using the team-level implementation of get...
See Intrepid2::Basis_HVOL_TET_Cn_FEM.
Basis_HVOL_TET_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM_ORTH class.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.