49 #ifndef __INTREPID2_FUNCTIONSPACETOOLS_DEF_HPP__ 50 #define __INTREPID2_FUNCTIONSPACETOOLS_DEF_HPP__ 55 template<
typename SpT>
56 template<
typename outputValueType,
class ...outputProperties,
57 typename inputValueType,
class ...inputProperties>
61 const Kokkos::DynRankView<inputValueType, inputProperties...> input ) {
67 namespace FunctorFunctionSpaceTools {
71 template <
typename outputViewType,
72 typename jacInverseViewType,
73 typename inputViewType,
74 ordinal_type spaceDim>
76 outputViewType _output;
77 const jacInverseViewType _jacInverse;
78 const inputViewType _input;
81 KOKKOS_INLINE_FUNCTION
83 jacInverseViewType jacInverse_,
86 _jacInverse(jacInverse_),
89 KOKKOS_INLINE_FUNCTION
90 void operator()(
const ordinal_type cl,
91 const ordinal_type bf,
92 const ordinal_type pt)
const {
93 auto y = Kokkos::subview(_output, cl, bf, pt, Kokkos::ALL());
94 const auto A = Kokkos::subview(_jacInverse, cl, pt, Kokkos::ALL(), Kokkos::ALL());
95 const auto x = Kokkos::subview(_input, bf, pt, Kokkos::ALL());
98 Kernels::Serial::matvec_trans_product_d2( y, A, x );
100 Kernels::Serial::matvec_trans_product_d3( y, A, x );
106 template<
typename SpT>
107 template<
typename outputValValueType,
class ...outputValProperties,
108 typename jacobianInverseValueType,
class ...jacobianInverseProperties,
109 typename inputValValueType,
class ...inputValProperties>
113 const Kokkos::DynRankView<jacobianInverseValueType,jacobianInverseProperties...> jacobianInverse,
114 const Kokkos::DynRankView<inputValValueType, inputValProperties...> inputVals ) {
115 #ifdef HAVE_INTREPID2_DEBUG 117 INTREPID2_TEST_FOR_EXCEPTION( inputVals.rank() != 3 ||
118 jacobianInverse.rank() != 4 ||
119 outputVals.rank() != 4, std::invalid_argument,
120 ">>> ERROR (FunctionSpaceTools::HGRADtransformGRAD): Ranks are not compatible.");
121 INTREPID2_TEST_FOR_EXCEPTION( outputVals.extent(0) != jacobianInverse.extent(0), std::invalid_argument,
122 ">>> ERROR (FunctionSpaceTools::HGRADtransformGRAD): Cell dimension does not match.");
123 INTREPID2_TEST_FOR_EXCEPTION( outputVals.extent(1) != inputVals.extent(0), std::invalid_argument,
124 ">>> ERROR (FunctionSpaceTools::HGRADtransformGRAD): Field dimension does not match.");
125 INTREPID2_TEST_FOR_EXCEPTION( outputVals.extent(2) != inputVals.extent(1) ||
126 jacobianInverse.extent(1) != inputVals.extent(1), std::invalid_argument,
127 ">>> ERROR (FunctionSpaceTools::HGRADtransformGRAD): Point dimension does not match.");
128 const auto spaceDim = outputVals.extent(3);
129 INTREPID2_TEST_FOR_EXCEPTION( jacobianInverse.extent(2) != spaceDim ||
130 jacobianInverse.extent(3) != spaceDim ||
131 inputVals.extent(2) != spaceDim , std::invalid_argument,
132 ">>> ERROR (FunctionSpaceTools::HGRADtransformGRAD): matvec dimensions are not compatible.");
176 template<
typename SpT>
177 template<
typename outputValValueType,
class ...outputValProperties,
178 typename jacobianInverseValueType,
class ...jacobianInverseProperties,
179 typename inputValValueType,
class ...inputValProperties>
183 const Kokkos::DynRankView<jacobianInverseValueType,jacobianInverseProperties...> jacobianInverse,
184 const Kokkos::DynRankView<inputValValueType, inputValProperties...> inputVals ) {
190 template<
typename SpT>
191 template<
typename outputValValueType,
class ...outputValProperties,
192 typename jacobianValueType,
class ...jacobianProperties,
193 typename jacobianDetValueType,
class ...jacobianDetProperties,
194 typename inputValValueType,
class ...inputValProperties>
198 const Kokkos::DynRankView<jacobianValueType, jacobianProperties...> jacobian,
199 const Kokkos::DynRankView<jacobianDetValueType,jacobianDetProperties...> jacobianDet,
200 const Kokkos::DynRankView<inputValValueType, inputValProperties...> inputVals ) {
207 template<
typename SpT>
208 template<
typename outputValValueType,
class ...outputValProperties,
209 typename jacobianValueType,
class ...jacobianProperties,
210 typename jacobianDetValueType,
class ...jacobianDetProperties,
211 typename inputValValueType,
class ...inputValProperties>
215 const Kokkos::DynRankView<jacobianValueType, jacobianProperties...> jacobian,
216 const Kokkos::DynRankView<jacobianDetValueType,jacobianDetProperties...> jacobianDet,
217 const Kokkos::DynRankView<inputValValueType, inputValProperties...> inputVals ) {
224 template<
typename SpT>
225 template<
typename outputValValueType,
class ...outputValProperties,
226 typename jacobianDetValueType,
class ...jacobianDetProperties,
227 typename inputValValueType,
class ...inputValProperties>
230 HDIVtransformDIV( Kokkos::DynRankView<outputValValueType, outputValProperties...> outputVals,
231 const Kokkos::DynRankView<jacobianDetValueType,jacobianDetProperties...> jacobianDet,
232 const Kokkos::DynRankView<inputValValueType, inputValProperties...> inputVals ) {
238 template<
typename SpT>
239 template<
typename outputValValueType,
class ...outputValProperties,
240 typename jacobianDetValueType,
class ...jacobianDetProperties,
241 typename inputValValueType,
class ...inputValProperties>
245 const Kokkos::DynRankView<jacobianDetValueType,jacobianDetProperties...> jacobianDet,
246 const Kokkos::DynRankView<inputValValueType, inputValProperties...> inputVals ) {
252 template<
typename SpT>
253 template<
typename outputValueValueType,
class ...outputValueProperties,
254 typename leftValueValueType,
class ...leftValueProperties,
255 typename rightValueValueType,
class ...rightValueProperties>
258 integrate( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
259 const Kokkos::DynRankView<leftValueValueType, leftValueProperties...> leftValues,
260 const Kokkos::DynRankView<rightValueValueType, rightValueProperties...> rightValues,
261 const bool sumInto ) {
263 #ifdef HAVE_INTREPID2_DEBUG 265 INTREPID2_TEST_FOR_EXCEPTION( leftValues.rank() < 2 ||
266 leftValues.rank() > 4, std::invalid_argument,
267 ">>> ERROR (FunctionSpaceTools::integrate): Left data must have rank 2, 3 or 4.");
268 INTREPID2_TEST_FOR_EXCEPTION( outputValues.rank() < 1 ||
269 outputValues.rank() > 3, std::invalid_argument,
270 ">>> ERROR (FunctionSpaceTools::integrate): Output values must have rank 1, 2 or 3.");
274 const ordinal_type outRank = outputValues.rank();
275 const ordinal_type leftRank = leftValues.rank();
276 const ordinal_type mode = outRank*10 + leftRank;
339 INTREPID2_TEST_FOR_EXCEPTION( outRank < 1 || outRank > 3, std::runtime_error,
340 ">>> ERROR (FunctionSpaceTools::integrate): outRank must be 1,2, or 3.");
341 INTREPID2_TEST_FOR_EXCEPTION( leftRank < 2 || leftRank > 4, std::runtime_error,
342 ">>> ERROR (FunctionSpaceTools::integrate): leftRank must be 1,2, 3 or 4.");
348 namespace FunctorFunctionSpaceTools {
352 template<
typename outputValViewType,
353 typename inputDetViewType,
354 typename inputWeightViewType>
356 outputValViewType _outputVals;
357 const inputDetViewType _inputDet;
358 const inputWeightViewType _inputWeight;
360 KOKKOS_INLINE_FUNCTION
362 inputDetViewType inputDet_,
363 inputWeightViewType inputWeight_)
364 : _outputVals(outputVals_),
365 _inputDet(inputDet_),
366 _inputWeight(inputWeight_) {}
368 typedef ordinal_type value_type;
381 KOKKOS_INLINE_FUNCTION
382 void operator()(
const size_type cl, value_type &dst)
const {
384 const bool hasNegativeDet = (_inputDet(cl, 0) < 0.0);
385 dst |= hasNegativeDet;
388 const auto sign = (hasNegativeDet ? -1.0 : 1.0);
389 const ordinal_type pt_end = _outputVals.extent(1);
390 for (ordinal_type pt=0;pt<pt_end;++pt)
391 _outputVals(cl, pt) = sign*_inputDet(cl, pt)*_inputWeight(pt);
396 template<
typename SpT>
397 template<
typename outputValValueType,
class ...outputValProperties,
398 typename inputDetValueType,
class ...inputDetProperties,
399 typename inputWeightValueType,
class ...inputWeightProperties>
403 const Kokkos::DynRankView<inputDetValueType, inputDetProperties...> inputDet,
404 const Kokkos::DynRankView<inputWeightValueType,inputWeightProperties...> inputWeights ) {
405 #ifdef HAVE_INTREPID2_DEBUG 407 INTREPID2_TEST_FOR_EXCEPTION( inputDet.rank() != 2 ||
408 inputWeights.rank() != 1 ||
409 outputVals.rank() != 2, std::invalid_argument,
410 ">>> ERROR (FunctionSpaceTools::computeCellMeasure): Ranks are not compatible.");
411 INTREPID2_TEST_FOR_EXCEPTION( outputVals.extent(0) != inputDet.extent(0), std::invalid_argument,
412 ">>> ERROR (FunctionSpaceTools::computeCellMeasure): Cell dimension does not match.");
413 INTREPID2_TEST_FOR_EXCEPTION( inputDet.extent(1) != outputVals.extent(1) ||
414 inputWeights.extent(0) != outputVals.extent(1), std::invalid_argument,
415 ">>> ERROR (FunctionSpaceTools::computeCellMeasure): Point dimension does not match.");
418 typedef Kokkos::DynRankView<outputValValueType, outputValProperties...> outputValViewType;
419 typedef Kokkos::DynRankView<inputDetValueType, inputDetProperties...> inputDetViewType;
420 typedef Kokkos::DynRankView<inputWeightValueType,inputWeightProperties...> inputWeightViewType;
422 <outputValViewType,inputDetViewType,inputWeightViewType> FunctorType;
424 const ordinal_type C = inputDet.extent(0);
425 Kokkos::RangePolicy<SpT,Kokkos::Schedule<Kokkos::Static> > policy(0, C);
427 typename FunctorType::value_type hasNegativeDet =
false;
428 Kokkos::parallel_reduce( policy, FunctorType(outputVals, inputDet, inputWeights), hasNegativeDet );
430 return hasNegativeDet;
435 template<
typename SpT>
436 template<
typename outputValValueType,
class ...outputValProperties,
437 typename inputJacValueType,
class ...inputJacProperties,
438 typename inputWeightValueType,
class ...inputWeightProperties,
439 typename scratchValueType,
class ...scratchProperties>
443 const Kokkos::DynRankView<inputJacValueType, inputJacProperties...> inputJac,
444 const Kokkos::DynRankView<inputWeightValueType,inputWeightProperties...> inputWeights,
445 const ordinal_type whichFace,
446 const shards::CellTopology parentCell,
447 const Kokkos::DynRankView<scratchValueType, scratchProperties...> scratch ) {
448 #ifdef HAVE_INTREPID2_DEBUG 449 INTREPID2_TEST_FOR_EXCEPTION( inputJac.rank() != 4, std::invalid_argument,
450 ">>> ERROR (FunctionSpaceTools::computeFaceMeasure): Input Jacobian container must have rank 4.");
451 INTREPID2_TEST_FOR_EXCEPTION( scratch.rank() != 1, std::invalid_argument,
452 ">>> ERROR (FunctionSpaceTools::computeFaceMeasure): Scratch view imust have rank 1.");
453 INTREPID2_TEST_FOR_EXCEPTION( scratch.span() < inputJac.span(), std::invalid_argument,
454 ">>> ERROR (FunctionSpaceTools::computeFaceMeasure): Scratch storage must be greater than or equal to inputJac's one.");
462 auto vcprop = Kokkos::common_view_alloc_prop(scratch);
464 typedef Kokkos::DynRankView<scratchValueType, SpT> viewType;
465 viewType faceNormals(Kokkos::view_wrap(scratch.data(), vcprop),
482 template<
typename SpT>
483 template<
typename outputValValueType,
class ...outputValProperties,
484 typename inputJacValueType,
class ...inputJacProperties,
485 typename inputWeightValueType,
class ...inputWeightProperties,
486 typename scratchValueType,
class ...scratchProperties>
490 const Kokkos::DynRankView<inputJacValueType, inputJacProperties...> inputJac,
491 const Kokkos::DynRankView<inputWeightValueType,inputWeightProperties...> inputWeights,
492 const ordinal_type whichEdge,
493 const shards::CellTopology parentCell,
494 const Kokkos::DynRankView<scratchValueType, scratchProperties...> scratch ) {
495 #ifdef HAVE_INTREPID2_DEBUG 496 INTREPID2_TEST_FOR_EXCEPTION( (inputJac.rank() != 4), std::invalid_argument,
497 ">>> ERROR (FunctionSpaceTools::computeEdgeMeasure): Input Jacobian container must have rank 4.");
498 INTREPID2_TEST_FOR_EXCEPTION( scratch.rank() != 1, std::invalid_argument,
499 ">>> ERROR (FunctionSpaceTools::computeEdgeMeasure): Scratch view must have a rank 1.");
500 INTREPID2_TEST_FOR_EXCEPTION( scratch.span() < inputJac.span(), std::invalid_argument,
501 ">>> ERROR (FunctionSpaceTools::computeEdgeMeasure): Scratch storage must be greater than or equal to inputJac'one.");
509 auto vcprop = Kokkos::common_view_alloc_prop(scratch);
511 typedef Kokkos::DynRankView<scratchValueType, SpT> viewType;
512 viewType edgeTangents(Kokkos::view_wrap(scratch.data(), vcprop),
529 template<
typename SpT>
530 template<
typename outputValValueType,
class ...outputValProperties,
531 typename inputMeasureValueType,
class ...inputMeasureProperties,
532 typename inputValValueType,
class ...inputValProperteis>
535 multiplyMeasure( Kokkos::DynRankView<outputValValueType, outputValProperties...> outputVals,
536 const Kokkos::DynRankView<inputMeasureValueType,inputMeasureProperties...> inputMeasure,
537 const Kokkos::DynRankView<inputValValueType, inputValProperteis...> inputVals ) {
538 scalarMultiplyDataField( outputVals,
545 template<
typename SpT>
546 template<
typename outputFieldValueType,
class ...outputFieldProperties,
547 typename inputDataValueType,
class ...inputDataProperties,
548 typename inputFieldValueType,
class ...inputFieldProperties>
552 const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
553 const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
554 const bool reciprocal ) {
563 template<
typename SpT>
564 template<
typename outputDataValuetype,
class ...outputDataProperties,
565 typename inputDataLeftValueType,
class ...inputDataLeftProperties,
566 typename inputDataRightValueType,
class ...inputDataRightProperties>
570 const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
571 const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
572 const bool reciprocal ) {
581 template<
typename SpT>
582 template<
typename outputFieldValueType,
class ...outputFieldProperties,
583 typename inputDataValueType,
class ...inputDataProperties,
584 typename inputFieldValueType,
class ...inputFieldProperties>
588 const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
589 const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields ) {
597 template<
typename SpT>
598 template<
typename outputDataValueType,
class ...outputDataProperties,
599 typename inputDataLeftValueType,
class ...inputDataLeftProperties,
600 typename inputDataRightValueType,
class ...inputDataRightProperties>
604 const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
605 const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight ) {
613 template<
typename SpT>
614 template<
typename outputFieldValueType,
class ...outputFieldProperties,
615 typename inputDataValueType,
class ...inputDataProperties,
616 typename inputFieldValueType,
class ...inputFieldProperties>
620 const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
621 const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields ) {
622 const auto outRank = outputFields.rank();
636 INTREPID2_TEST_FOR_EXCEPTION( outRank < 3 && outRank > 5, std::runtime_error,
637 ">>> ERROR (FunctionSpaceTools::vectorMultiplyDataField): Output container must have rank 3, 4 or 5.");
644 template<
typename SpT>
645 template<
typename outputDataValueType,
class ...outputDataProperties,
646 typename inputDataLeftValueType,
class ...inputDataLeftProperties,
647 typename inputDataRightValueType,
class ...inputDataRightProperties>
651 const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
652 const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight ) {
653 const auto outRank = outputData.rank();
667 INTREPID2_TEST_FOR_EXCEPTION( outRank < 2 && outRank > 4, std::runtime_error,
668 ">>> ERROR (FunctionSpaceTools::vectorMultiplyDataData): Output container must have rank 2, 3 or 4.");
675 template<
typename SpT>
676 template<
typename outputFieldValueType,
class ...outputFieldProperties,
677 typename inputDataValueType,
class ...inputDataProperties,
678 typename inputFieldValueType,
class ...inputFieldProperties>
682 const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
683 const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
684 const char transpose ) {
686 const auto outRank = outputFields.rank();
701 INTREPID2_TEST_FOR_EXCEPTION( outRank < 4 && outRank > 5, std::runtime_error,
702 ">>> ERROR (FunctionSpaceTools::tensorMultiplyDataField): Output container must have rank 4 or 5.");
709 template<
typename SpT>
710 template<
typename outputDataValueType,
class ...outputDataProperties,
711 typename inputDataLeftValueType,
class ...inputDataLeftProperties,
712 typename inputDataRightValueType,
class ...inputDataRightProperties>
716 const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
717 const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
718 const char transpose ) {
719 const auto outRank = outputData.rank();
734 INTREPID2_TEST_FOR_EXCEPTION( outRank < 4 && outRank > 5, std::runtime_error,
735 ">>> ERROR (FunctionSpaceTools::tensorMultiplyDataField): Output container must have rank 4 or 5.");
742 namespace FunctorFunctionSpaceTools {
747 template<
typename inoutOperatorViewType,
748 typename fieldSignViewType>
750 inoutOperatorViewType _inoutOperator;
751 const fieldSignViewType _fieldSigns;
753 KOKKOS_INLINE_FUNCTION
755 fieldSignViewType fieldSigns_ )
756 : _inoutOperator(inoutOperator_), _fieldSigns(fieldSigns_) {}
758 KOKKOS_INLINE_FUNCTION
759 void operator()(
const ordinal_type cl)
const {
760 const ordinal_type nlbf = _inoutOperator.extent(1);
761 const ordinal_type nrbf = _inoutOperator.extent(2);
763 for (ordinal_type lbf=0;lbf<nlbf;++lbf)
764 for (ordinal_type rbf=0;rbf<nrbf;++rbf)
765 _inoutOperator(cl, lbf, rbf) *= _fieldSigns(cl, lbf);
770 template<
typename SpT>
771 template<
typename inoutOperatorValueType,
class ...inoutOperatorProperties,
772 typename fieldSignValueType,
class ...fieldSignProperties>
775 applyLeftFieldSigns( Kokkos::DynRankView<inoutOperatorValueType,inoutOperatorProperties...> inoutOperator,
776 const Kokkos::DynRankView<fieldSignValueType, fieldSignProperties...> fieldSigns ) {
778 #ifdef HAVE_INTREPID2_DEBUG 779 INTREPID2_TEST_FOR_EXCEPTION( inoutOperator.rank() != 3, std::invalid_argument,
780 ">>> ERROR (FunctionSpaceTools::applyLeftFieldSigns): Input operator container must have rank 3.");
781 INTREPID2_TEST_FOR_EXCEPTION( fieldSigns.rank() != 2, std::invalid_argument,
782 ">>> ERROR (FunctionSpaceTools::applyLeftFieldSigns): Input field signs container must have rank 2.");
783 INTREPID2_TEST_FOR_EXCEPTION( inoutOperator.extent(0) != fieldSigns.extent(0), std::invalid_argument,
784 ">>> ERROR (FunctionSpaceTools::applyLeftFieldSigns): Zeroth dimensions (number of cells) of the operator and field signs containers must agree!");
785 INTREPID2_TEST_FOR_EXCEPTION( inoutOperator.extent(1) != fieldSigns.extent(1), std::invalid_argument,
786 ">>> ERROR (FunctionSpaceTools::applyLeftFieldSigns): First dimensions (number of left fields) of the operator and field signs containers must agree!");
789 typedef Kokkos::DynRankView<inoutOperatorValueType,inoutOperatorProperties...> inoutOperatorViewType;
790 typedef Kokkos::DynRankView<fieldSignValueType, fieldSignProperties...> fieldSignViewType;
792 <inoutOperatorViewType,fieldSignViewType> FunctorType;
793 typedef typename ExecSpace<typename inoutOperatorViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
795 const ordinal_type C = inoutOperator.extent(0);
796 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, C);
797 Kokkos::parallel_for( policy, FunctorType(inoutOperator, fieldSigns) );
802 namespace FunctorFunctionSpaceTools {
806 template<
typename inoutOperatorViewType,
807 typename fieldSignViewType>
809 inoutOperatorViewType _inoutOperator;
810 const fieldSignViewType _fieldSigns;
812 KOKKOS_INLINE_FUNCTION
814 fieldSignViewType fieldSigns_ )
815 : _inoutOperator(inoutOperator_), _fieldSigns(fieldSigns_) {}
817 KOKKOS_INLINE_FUNCTION
818 void operator()(
const ordinal_type cl)
const {
819 const ordinal_type nlbf = _inoutOperator.extent(1);
820 const ordinal_type nrbf = _inoutOperator.extent(2);
822 for (ordinal_type lbf=0;lbf<nlbf;++lbf)
823 for (ordinal_type rbf=0;rbf<nrbf;++rbf)
824 _inoutOperator(cl, lbf, rbf) *= _fieldSigns(cl, rbf);
829 template<
typename SpT>
830 template<
typename inoutOperatorValueType,
class ...inoutOperatorProperties,
831 typename fieldSignValueType,
class ...fieldSignProperties>
835 const Kokkos::DynRankView<fieldSignValueType, fieldSignProperties...> fieldSigns ) {
837 #ifdef HAVE_INTREPID2_DEBUG 838 INTREPID2_TEST_FOR_EXCEPTION( inoutOperator.rank() != 3, std::invalid_argument,
839 ">>> ERROR (FunctionSpaceTools::applyRightFieldSigns): Input operator container must have rank 3.");
840 INTREPID2_TEST_FOR_EXCEPTION( fieldSigns.rank() != 2, std::invalid_argument,
841 ">>> ERROR (FunctionSpaceTools::applyRightFieldSigns): Input field signs container must have rank 2.");
842 INTREPID2_TEST_FOR_EXCEPTION( inoutOperator.extent(0) != fieldSigns.extent(0), std::invalid_argument,
843 ">>> ERROR (FunctionSpaceTools::applyRightFieldSigns): Zeroth dimensions (number of cells) of the operator and field signs containers must agree!");
844 INTREPID2_TEST_FOR_EXCEPTION( inoutOperator.extent(2) != fieldSigns.extent(1), std::invalid_argument,
845 ">>> ERROR (FunctionSpaceTools::applyRightFieldSigns): Second dimension of the operator container and first dimension of the field signs container (number of right fields) must agree!");
848 typedef Kokkos::DynRankView<inoutOperatorValueType,inoutOperatorProperties...> inoutOperatorViewType;
849 typedef Kokkos::DynRankView<fieldSignValueType, fieldSignProperties...> fieldSignViewType;
851 <inoutOperatorViewType,fieldSignViewType> FunctorType;
852 typedef typename ExecSpace<typename inoutOperatorViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
854 const ordinal_type C = inoutOperator.extent(0);
855 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, C);
856 Kokkos::parallel_for( policy, FunctorType(inoutOperator, fieldSigns) );
861 namespace FunctorFunctionSpaceTools {
865 template<
typename inoutFunctionViewType,
866 typename fieldSignViewType>
868 inoutFunctionViewType _inoutFunction;
869 const fieldSignViewType _fieldSigns;
871 KOKKOS_INLINE_FUNCTION
873 fieldSignViewType fieldSigns_)
874 : _inoutFunction(inoutFunction_), _fieldSigns(fieldSigns_) {}
876 KOKKOS_INLINE_FUNCTION
877 void operator()(
const ordinal_type cl)
const {
878 const ordinal_type nbfs = _inoutFunction.extent(1);
879 const ordinal_type npts = _inoutFunction.extent(2);
880 const ordinal_type iend = _inoutFunction.extent(3);
881 const ordinal_type jend = _inoutFunction.extent(4);
883 for (ordinal_type bf=0;bf<nbfs;++bf)
884 for (ordinal_type pt=0;pt<npts;++pt)
885 for (ordinal_type i=0;i<iend;++i)
886 for (ordinal_type j=0;j<jend;++j)
887 _inoutFunction(cl, bf, pt, i, j) *= _fieldSigns(cl, bf);
892 template<
typename SpT>
893 template<
typename inoutFunctionValueType,
class ...inoutFunctionProperties,
894 typename fieldSignValueType,
class ...fieldSignProperties>
897 applyFieldSigns( Kokkos::DynRankView<inoutFunctionValueType,inoutFunctionProperties...> inoutFunction,
898 const Kokkos::DynRankView<fieldSignValueType, fieldSignProperties...> fieldSigns ) {
900 #ifdef HAVE_INTREPID2_DEBUG 901 INTREPID2_TEST_FOR_EXCEPTION( inoutFunction.rank() < 2 || inoutFunction.rank() > 5, std::invalid_argument,
902 ">>> ERROR (FunctionSpaceTools::applyFieldSigns): Input function container must have rank 2, 3, 4, or 5.");
903 INTREPID2_TEST_FOR_EXCEPTION( fieldSigns.rank() != 2, std::invalid_argument,
904 ">>> ERROR (FunctionSpaceTools::applyFieldSigns): Input field signs container must have rank 2.");
905 INTREPID2_TEST_FOR_EXCEPTION( inoutFunction.extent(0) != fieldSigns.extent(0), std::invalid_argument,
906 ">>> ERROR (FunctionSpaceTools::applyFieldSigns): Zeroth dimensions (number of integration domains) of the function and field signs containers must agree!");
907 INTREPID2_TEST_FOR_EXCEPTION( inoutFunction.extent(1) != fieldSigns.extent(1), std::invalid_argument,
908 ">>> ERROR (FunctionSpaceTools::applyFieldSigns): First dimensions (number of fields) of the function and field signs containers must agree!");
912 typedef Kokkos::DynRankView<inoutFunctionValueType,inoutFunctionProperties...> inoutFunctionViewType;
913 typedef Kokkos::DynRankView<fieldSignValueType, fieldSignProperties...> fieldSignViewType;
915 <inoutFunctionViewType,fieldSignViewType> FunctorType;
916 typedef typename ExecSpace<typename inoutFunctionViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
918 const ordinal_type C = inoutFunction.extent(0);
919 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, C);
920 Kokkos::parallel_for( policy, FunctorType(inoutFunction, fieldSigns) );
925 namespace FunctorFunctionSpaceTools {
930 template<
typename outputPointViewType,
931 typename inputCoeffViewType,
932 typename inputFieldViewType>
934 outputPointViewType _outputPointVals;
935 const inputCoeffViewType _inputCoeffs;
936 const inputFieldViewType _inputFields;
938 KOKKOS_INLINE_FUNCTION
939 F_evaluate( outputPointViewType outputPointVals_,
940 inputCoeffViewType inputCoeffs_,
941 inputFieldViewType inputFields_ )
942 : _outputPointVals(outputPointVals_), _inputCoeffs(inputCoeffs_), _inputFields(inputFields_) {}
944 KOKKOS_INLINE_FUNCTION
945 void operator()(
const ordinal_type cl)
const {
946 const ordinal_type nbfs = _inputFields.extent(1);
947 const ordinal_type npts = _inputFields.extent(2);
949 const ordinal_type iend = _inputFields.extent(3);
950 const ordinal_type jend = _inputFields.extent(4);
952 for (ordinal_type bf=0;bf<nbfs;++bf)
953 for (ordinal_type pt=0;pt<npts;++pt)
954 for (ordinal_type i=0;i<iend;++i)
955 for (ordinal_type j=0;j<jend;++j)
956 _outputPointVals(cl, pt, i, j) += _inputCoeffs(cl, bf) * _inputFields(cl, bf, pt, i, j);
961 template<
typename SpT>
962 template<
typename outputPointValueType,
class ...outputPointProperties,
963 typename inputCoeffValueType,
class ...inputCoeffProperties,
964 typename inputFieldValueType,
class ...inputFieldProperties>
967 evaluate( Kokkos::DynRankView<outputPointValueType,outputPointProperties...> outputPointVals,
968 const Kokkos::DynRankView<inputCoeffValueType, inputCoeffProperties...> inputCoeffs,
969 const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields ) {
971 #ifdef HAVE_INTREPID2_DEBUG 972 INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() < 3 || inputFields.rank() > 5, std::invalid_argument,
973 ">>> ERROR (FunctionSpaceTools::evaluate): Input fields container must have rank 3, 4, or 5.");
974 INTREPID2_TEST_FOR_EXCEPTION( inputCoeffs.rank() != 2, std::invalid_argument,
975 ">>> ERROR (FunctionSpaceTools::evaluate): Input coefficient container must have rank 2.");
976 INTREPID2_TEST_FOR_EXCEPTION( outputPointVals.rank() != (inputFields.rank()-1), std::invalid_argument,
977 ">>> ERROR (FunctionSpaceTools::evaluate): Output values container must have rank one less than the rank of the input fields container.");
978 INTREPID2_TEST_FOR_EXCEPTION( inputCoeffs.extent(0) != inputFields.extent(0), std::invalid_argument,
979 ">>> ERROR (FunctionSpaceTools::evaluate): Zeroth dimensions (number of cells) of the coefficient and fields input containers must agree!");
980 INTREPID2_TEST_FOR_EXCEPTION( inputCoeffs.extent(1) != inputFields.extent(1), std::invalid_argument,
981 ">>> ERROR (FunctionSpaceTools::evaluate): First dimensions (number of fields) of the coefficient and fields input containers must agree!");
982 INTREPID2_TEST_FOR_EXCEPTION( outputPointVals.extent(0) != inputFields.extent(0), std::invalid_argument,
983 ">>> ERROR (FunctionSpaceTools::evaluate): Zeroth dimensions (number of cells) of the input fields container and the output values container must agree!");
984 for (size_type i=1;i<outputPointVals.rank();++i)
985 INTREPID2_TEST_FOR_EXCEPTION( outputPointVals.extent(i) != inputFields.extent(i+1), std::invalid_argument,
986 ">>> ERROR (FunctionSpaceTools::evaluate): outputPointVals dimension(i) does not match to inputFields dimension(i+1).");
989 typedef Kokkos::DynRankView<outputPointValueType,outputPointProperties...> outputPointValViewType;
990 typedef Kokkos::DynRankView<inputCoeffValueType, inputCoeffProperties...> inputCoeffViewType;
991 typedef Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFieldViewType;
993 <outputPointValViewType,inputCoeffViewType,inputFieldViewType> FunctorType;
994 typedef typename ExecSpace<typename inputCoeffViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
996 const ordinal_type C = inputFields.extent(0);
997 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, C);
998 Kokkos::parallel_for( policy, FunctorType(outputPointVals, inputCoeffs, inputFields) );