Intrepid2
Intrepid2_Basis.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Intrepid2 Package
4//
5// Copyright 2007 NTESS and the Intrepid2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
15
16#ifndef __INTREPID2_BASIS_HPP__
17#define __INTREPID2_BASIS_HPP__
18
19#include "Intrepid2_ConfigDefs.hpp"
20#include "Intrepid2_Types.hpp"
21#include "Intrepid2_Utils.hpp"
22
26#include "Shards_CellTopology.hpp"
28#include <Teuchos_RCPDecl.hpp>
29#include <Kokkos_Core.hpp>
30
31#include <memory>
32#include <vector>
33
34namespace Intrepid2 {
35
36template<typename DeviceType = void,
37 typename OutputType = double,
38 typename PointType = double>
39class Basis;
40
43template <typename DeviceType = void, typename OutputType = double, typename PointType = double>
44using BasisPtr = Teuchos::RCP<Basis<DeviceType,OutputType,PointType> >;
45
48template <typename OutputType = double, typename PointType = double>
50
87 template<typename Device,
88 typename outputValueType,
89 typename pointValueType>
90 class Basis {
91 public:
94 using DeviceType = Device;
95
98 using ExecutionSpace = typename DeviceType::execution_space;
99
100
103 using OutputValueType = outputValueType;
104
107 using PointValueType = pointValueType;
108
111 using OrdinalViewType = Kokkos::View<ordinal_type,DeviceType>;
112
115 using EBasisViewType = Kokkos::View<EBasis,DeviceType>;
116
119 using ECoordinatesViewType = Kokkos::View<ECoordinates,DeviceType>;
120
121 // ** tag interface
122 // - tag interface is not decorated with Kokkos inline so it should be allocated on hostspace
123
126 using OrdinalTypeArray1DHost = Kokkos::View<ordinal_type*,typename ExecutionSpace::array_layout,Kokkos::HostSpace>;
127
130 using OrdinalTypeArray2DHost = Kokkos::View<ordinal_type**,typename ExecutionSpace::array_layout,Kokkos::HostSpace>;
131
134 using OrdinalTypeArray3DHost = Kokkos::View<ordinal_type***,typename ExecutionSpace::array_layout,Kokkos::HostSpace>;
135
138 using OrdinalTypeArrayStride1DHost = Kokkos::View<ordinal_type*, Kokkos::LayoutStride, Kokkos::HostSpace>;
139
142 using OrdinalTypeArray1D = Kokkos::View<ordinal_type*,DeviceType>;
143
146 using OrdinalTypeArray2D = Kokkos::View<ordinal_type**,DeviceType>;
147
150 using OrdinalTypeArray3D = Kokkos::View<ordinal_type***,DeviceType>;
151
154 using OrdinalTypeArrayStride1D = Kokkos::View<ordinal_type*, Kokkos::LayoutStride, DeviceType>;
155
158 typedef typename ScalarTraits<pointValueType>::scalar_type scalarType;
159 protected:
160
163 ordinal_type basisCardinality_;
164
167 ordinal_type basisDegree_;
168
177
181
184 ECoordinates basisCoordinates_;
185
188 EFunctionSpace functionSpace_ = FUNCTION_SPACE_MAX;
189
192 //Kokkos::View<bool,DeviceType> basisTagsAreSet_;
193
206
219
229 virtual void requireTags() const {}
230
242 template<typename OrdinalTypeView3D,
243 typename OrdinalTypeView2D,
244 typename OrdinalTypeView1D>
245 void setOrdinalTagData( OrdinalTypeView3D &tagToOrdinal,
246 OrdinalTypeView2D &ordinalToTag,
247 const OrdinalTypeView1D tags,
248 const ordinal_type basisCard,
249 const ordinal_type tagSize,
250 const ordinal_type posScDim,
251 const ordinal_type posScOrd,
252 const ordinal_type posDfOrd ) {
253 // The tables are host views, filled here with plain loops rather than with Kokkos::deep_copy(): Basis_TensorBasis
254 // calls this lazily from const queries, which may come from inside an OpenMP parallel region, where dispatching a
255 // kernel on the OpenMP execution space (as deep_copy() of a nonzero value does) aborts.
256
257 // Create ordinalToTag; every entry is set below
258 ordinalToTag = OrdinalTypeView2D(Kokkos::view_alloc("ordinalToTag", Kokkos::WithoutInitializing), basisCard, tagSize);
259
260 // Copy tags
261 for (ordinal_type i=0;i<basisCard;++i)
262 for (ordinal_type j=0;j<tagSize;++j)
263 ordinalToTag(i, j) = tags(i*tagSize + j);
264
265 // Find out dimension of tagToOrdinal
266 auto maxScDim = 0; // first dimension of tagToOrdinal
267 for (ordinal_type i=0;i<basisCard;++i)
268 if (maxScDim < tags(i*tagSize + posScDim))
269 maxScDim = tags(i*tagSize + posScDim);
270 ++maxScDim;
271
272 auto maxScOrd = 0; // second dimension of tagToOrdinal
273 for (ordinal_type i=0;i<basisCard;++i)
274 if (maxScOrd < tags(i*tagSize + posScOrd))
275 maxScOrd = tags(i*tagSize + posScOrd);
276 ++maxScOrd;
277
278 auto maxDfOrd = 0; // third dimension of tagToOrdinal
279 for (ordinal_type i=0;i<basisCard;++i)
280 if (maxDfOrd < tags(i*tagSize + posDfOrd))
281 maxDfOrd = tags(i*tagSize + posDfOrd);
282 ++maxDfOrd;
283
284 // Create tagToOrdinal, and initialize with -1
285 tagToOrdinal = OrdinalTypeView3D(Kokkos::view_alloc("tagToOrdinal", Kokkos::WithoutInitializing), maxScDim, maxScOrd, maxDfOrd);
286 for (ordinal_type i=0;i<maxScDim;++i)
287 for (ordinal_type j=0;j<maxScOrd;++j)
288 for (ordinal_type k=0;k<maxDfOrd;++k)
289 tagToOrdinal(i, j, k) = -1;
290
291 // Overwrite elements of the array corresponding to tags with local DoF Id's, leave all other = -1
292 for (ordinal_type i=0;i<basisCard;++i)
293 tagToOrdinal(tags(i*tagSize), tags(i*tagSize+1), tags(i*tagSize+2)) = i;
294 }
295
296 // dof coords
299 Kokkos::DynRankView<scalarType,DeviceType> dofCoords_;
300
301 // dof coeffs
309 Kokkos::DynRankView<scalarType,DeviceType> dofCoeffs_;
310
319
332 public:
333
334 Basis() = default;
335 virtual~Basis() = default;
336
337 // receives input arguments
340 OutputValueType getDummyOutputValue() { return outputValueType(); }
341
344 PointValueType getDummyPointValue() { return pointValueType(); }
345
348 using OutputViewType = Kokkos::DynRankView<OutputValueType,Kokkos::LayoutStride,DeviceType>;
349
352 using PointViewType = Kokkos::DynRankView<PointValueType,Kokkos::LayoutStride,DeviceType>;
353
356 using ScalarViewType = Kokkos::DynRankView<scalarType,Kokkos::LayoutStride,DeviceType>;
357
362 Kokkos::DynRankView<OutputValueType,DeviceType> allocateOutputView( const int numPoints, const EOperator operatorType = OPERATOR_VALUE) const;
363
369 virtual BasisValues<OutputValueType,DeviceType> allocateBasisValues( TensorPoints<PointValueType,DeviceType> points, const EOperator operatorType = OPERATOR_VALUE) const
370 {
371 const bool operatorIsDk = (operatorType >= OPERATOR_D1) && (operatorType <= OPERATOR_D10);
372 const bool operatorSupported = (operatorType == OPERATOR_VALUE) || (operatorType == OPERATOR_GRAD) || (operatorType == OPERATOR_CURL) || (operatorType == OPERATOR_DIV) || operatorIsDk;
373 INTREPID2_TEST_FOR_EXCEPTION(!operatorSupported, std::invalid_argument, "operator is not supported by allocateBasisValues");
374
375 const int numPoints = points.extent_int(0);
376
377 using Scalar = OutputValueType;
378
379 auto dataView = allocateOutputView(numPoints, operatorType);
380 Data<Scalar,DeviceType> data(dataView);
381
382 bool useVectorData = (rank(dataView) == 3);
383
384 if (useVectorData)
385 {
386 VectorData<Scalar,DeviceType> vectorData(data);
387 return BasisValues<Scalar,DeviceType>(vectorData);
388 }
389 else
390 {
391 TensorData<Scalar,DeviceType> tensorData(data);
392 return BasisValues<Scalar,DeviceType>(tensorData);
393 }
394 }
395
396
409 virtual
410 void getScratchSpaceSize( ordinal_type& perThreadSpaceSize,
411 const PointViewType inputPoints,
412 const EOperator operatorType = OPERATOR_VALUE) const {
413 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE( true, std::logic_error,
414 ">>> ERROR (Basis::getValuesScratchSpace): this method is not supported or should be overridden accordingly by derived classes.");
415 }
416
417
438 KOKKOS_INLINE_FUNCTION
439 virtual
440 void getValues( OutputViewType /* outputValues */,
441 const PointViewType /* inputPoints */,
442 const EOperator /* operatorType */,
443 const typename Kokkos::TeamPolicy<ExecutionSpace>::member_type& teamMember,
444 const int threadScratchLevel,
445 const ordinal_type subcellDim=-1,
446 const ordinal_type subcellOrdinal=-1) const {
447 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE( true, std::logic_error,
448 ">>> ERROR (Basis::getValues): this method is not supported or should be overridden accordingly by derived classes.");
449 }
450
470 virtual
471 void
472 getValues( const ExecutionSpace& /* space */,
473 OutputViewType /* outputValues */,
474 const PointViewType /* inputPoints */,
475 const EOperator /* operatorType */ = OPERATOR_VALUE ) const {
476 INTREPID2_TEST_FOR_EXCEPTION( true, std::logic_error,
477 ">>> ERROR (Basis::getValues): this method (FEM) is not supported or should be overridden accordingly by derived classes.");
478 }
479
481 virtual void getValues(
482 OutputViewType outputValues,
483 const PointViewType inputPoints,
484 const EOperator operatorType = OPERATOR_VALUE
485 ) const {
486 this->getValues(ExecutionSpace{}, outputValues, inputPoints, operatorType);
487 }
488
500 virtual
501 void
504 const EOperator operatorType = OPERATOR_VALUE ) const {
505 // note the extra allocation/copy here (this is one reason, among several, to override this method):
506 auto rawExpandedPoints = inputPoints.allocateAndFillExpandedRawPointView();
507
508 OutputViewType rawOutputView;
510 if (outputValues.numTensorDataFamilies() > 0)
511 {
512 INTREPID2_TEST_FOR_EXCEPTION(outputValues.tensorData(0).numTensorComponents() != 1, std::invalid_argument, "default implementation of getValues() only supports outputValues with trivial tensor-product structure");
513 outputData = outputValues.tensorData().getTensorComponent(0);
514 }
515 else if (outputValues.vectorData().isValid())
516 {
517 INTREPID2_TEST_FOR_EXCEPTION(outputValues.vectorData().numComponents() != 1, std::invalid_argument, "default implementation of getValues() only supports outputValues with trivial tensor-product structure");
518 INTREPID2_TEST_FOR_EXCEPTION(outputValues.vectorData().getComponent(0).numTensorComponents() != 1, std::invalid_argument, "default implementation of getValues() only supports outputValues with trivial tensor-product structure");
519 outputData = outputValues.vectorData().getComponent(0).getTensorComponent(0);
520 }
521
522 this->getValues(outputData.getUnderlyingView(), rawExpandedPoints, operatorType);
523 }
524
544 virtual
545 void
546 getValues( OutputViewType /* outputValues */,
547 const PointViewType /* inputPoints */,
548 const PointViewType /* cellVertices */,
549 const EOperator /* operatorType */ = OPERATOR_VALUE ) const {
550 INTREPID2_TEST_FOR_EXCEPTION( true, std::logic_error,
551 ">>> ERROR (Basis::getValues): this method (FVM) is not supported or should be overridden accordingly by derived classes.");
552 }
553
554
557
558 virtual
559 void
560 getDofCoords( ScalarViewType /* dofCoords */ ) const {
561 INTREPID2_TEST_FOR_EXCEPTION( true, std::logic_error,
562 ">>> ERROR (Basis::getDofCoords): this method is not supported or should be overridden accordingly by derived classes.");
563 }
564
572
573 virtual
574 void
575 getDofCoeffs( ScalarViewType /* dofCoeffs */ ) const {
576 INTREPID2_TEST_FOR_EXCEPTION( true, std::logic_error,
577 ">>> ERROR (Basis::getDofCoeffs): this method is not supported or should be overridden accordingly by derived classes.");
578 }
579
588 {
589 INTREPID2_TEST_FOR_EXCEPTION( basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
590 ">>> ERROR (Basis::getFieldOrdinalsForDegree): this method is not supported for non-hierarchical bases.");
591 int degreeEntryLength = fieldOrdinalPolynomialDegree_.extent_int(1);
592 int requestedDegreeLength = degrees.extent_int(0);
593 INTREPID2_TEST_FOR_EXCEPTION(degreeEntryLength != requestedDegreeLength, std::invalid_argument, "length of degrees does not match the entries in fieldOrdinalPolynomialDegree_");
594 std::vector<int> fieldOrdinalsVector;
595 for (int basisOrdinal=0; basisOrdinal<fieldOrdinalPolynomialDegree_.extent_int(0); basisOrdinal++)
596 {
597 bool matches = true;
598 for (int d=0; d<degreeEntryLength; d++)
599 {
600 if (fieldOrdinalPolynomialDegree_(basisOrdinal,d) > degrees(d)) matches = false;
601 }
602 if (matches) fieldOrdinalsVector.push_back(basisOrdinal);
603 }
604 OrdinalTypeArray1DHost fieldOrdinals("fieldOrdinalsForDegree",fieldOrdinalsVector.size());
605 for (unsigned i=0; i<fieldOrdinalsVector.size(); i++)
606 {
607 fieldOrdinals(i) = fieldOrdinalsVector[i];
608 }
609 return fieldOrdinals;
610 }
611
620 {
621 INTREPID2_TEST_FOR_EXCEPTION( basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
622 ">>> ERROR (Basis::getFieldOrdinalsForDegree): this method is not supported for non-hierarchical bases.");
623 int degreeEntryLength = fieldOrdinalH1PolynomialDegree_.extent_int(1);
624 int requestedDegreeLength = degrees.extent_int(0);
625 INTREPID2_TEST_FOR_EXCEPTION(degreeEntryLength != requestedDegreeLength, std::invalid_argument, "length of degrees does not match the entries in fieldOrdinalPolynomialDegree_");
626 std::vector<int> fieldOrdinalsVector;
627 for (int basisOrdinal=0; basisOrdinal<fieldOrdinalH1PolynomialDegree_.extent_int(0); basisOrdinal++)
628 {
629 bool matches = true;
630 for (int d=0; d<degreeEntryLength; d++)
631 {
632 if (fieldOrdinalH1PolynomialDegree_(basisOrdinal,d) > degrees(d)) matches = false;
633 }
634 if (matches) fieldOrdinalsVector.push_back(basisOrdinal);
635 }
636 OrdinalTypeArray1DHost fieldOrdinals("fieldOrdinalsForH1Degree",fieldOrdinalsVector.size());
637 for (unsigned i=0; i<fieldOrdinalsVector.size(); i++)
638 {
639 fieldOrdinals(i) = fieldOrdinalsVector[i];
640 }
641 return fieldOrdinals;
642 }
643
655 std::vector<int> getFieldOrdinalsForDegree(std::vector<int> &degrees) const
656 {
657 INTREPID2_TEST_FOR_EXCEPTION( basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
658 ">>> ERROR (Basis::getFieldOrdinalsForDegree): this method is not supported for non-hierarchical bases.");
659 OrdinalTypeArray1DHost degreesView("degrees",degrees.size());
660 for (unsigned d=0; d<degrees.size(); d++)
661 {
662 degreesView(d) = degrees[d];
663 }
664 auto fieldOrdinalsView = getFieldOrdinalsForDegree(degreesView);
665 std::vector<int> fieldOrdinalsVector(fieldOrdinalsView.extent_int(0));
666 for (int i=0; i<fieldOrdinalsView.extent_int(0); i++)
667 {
668 fieldOrdinalsVector[i] = fieldOrdinalsView(i);
669 }
670 return fieldOrdinalsVector;
671 }
672
683 std::vector<int> getFieldOrdinalsForH1Degree(std::vector<int> &degrees) const
684 {
685 INTREPID2_TEST_FOR_EXCEPTION( basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
686 ">>> ERROR (Basis::getFieldOrdinalsForDegree): this method is not supported for non-hierarchical bases.");
687 OrdinalTypeArray1DHost degreesView("degrees",degrees.size());
688 for (unsigned d=0; d<degrees.size(); d++)
689 {
690 degreesView(d) = degrees[d];
691 }
692 auto fieldOrdinalsView = getFieldOrdinalsForH1Degree(degreesView);
693 std::vector<int> fieldOrdinalsVector(fieldOrdinalsView.extent_int(0));
694 for (int i=0; i<fieldOrdinalsView.extent_int(0); i++)
695 {
696 fieldOrdinalsVector[i] = fieldOrdinalsView(i);
697 }
698 return fieldOrdinalsVector;
699 }
700
708 {
709 INTREPID2_TEST_FOR_EXCEPTION( basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
710 ">>> ERROR (Basis::getPolynomialDegreeOfField): this method is not supported for non-hierarchical bases.");
711 INTREPID2_TEST_FOR_EXCEPTION(fieldOrdinal < 0, std::invalid_argument, "field ordinal must be non-negative");
712 INTREPID2_TEST_FOR_EXCEPTION(fieldOrdinal >= fieldOrdinalPolynomialDegree_.extent_int(0), std::invalid_argument, "field ordinal out of bounds");
713
714 int polyDegreeLength = getPolynomialDegreeLength();
715 OrdinalTypeArray1DHost polyDegree("polynomial degree", polyDegreeLength);
716 for (int d=0; d<polyDegreeLength; d++)
717 {
718 polyDegree(d) = fieldOrdinalPolynomialDegree_(fieldOrdinal,d);
719 }
720 return polyDegree;
721 }
722
730 {
731 INTREPID2_TEST_FOR_EXCEPTION( basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
732 ">>> ERROR (Basis::getPolynomialDegreeOfField): this method is not supported for non-hierarchical bases.");
733 INTREPID2_TEST_FOR_EXCEPTION(fieldOrdinal < 0, std::invalid_argument, "field ordinal must be non-negative");
734 INTREPID2_TEST_FOR_EXCEPTION(fieldOrdinal >= fieldOrdinalH1PolynomialDegree_.extent_int(0), std::invalid_argument, "field ordinal out of bounds");
735
736 int polyDegreeLength = getPolynomialDegreeLength();
737 OrdinalTypeArray1DHost polyDegree("polynomial degree", polyDegreeLength);
738 for (int d=0; d<polyDegreeLength; d++)
739 {
740 polyDegree(d) = fieldOrdinalH1PolynomialDegree_(fieldOrdinal,d);
741 }
742 return polyDegree;
743 }
744
752 std::vector<int> getPolynomialDegreeOfFieldAsVector(int fieldOrdinal) const
753 {
754 INTREPID2_TEST_FOR_EXCEPTION( basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
755 ">>> ERROR (Basis::getPolynomialDegreeOfFieldAsVector): this method is not supported for non-hierarchical bases.");
756 auto polynomialDegreeView = getPolynomialDegreeOfField(fieldOrdinal);
757 std::vector<int> polynomialDegree(polynomialDegreeView.extent_int(0));
758
759 for (unsigned d=0; d<polynomialDegree.size(); d++)
760 {
761 polynomialDegree[d] = polynomialDegreeView(d);
762 }
763 return polynomialDegree;
764 }
765
773 std::vector<int> getH1PolynomialDegreeOfFieldAsVector(int fieldOrdinal) const
774 {
775 INTREPID2_TEST_FOR_EXCEPTION( basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
776 ">>> ERROR (Basis::getPolynomialDegreeOfFieldAsVector): this method is not supported for non-hierarchical bases.");
777 auto polynomialDegreeView = getH1PolynomialDegreeOfField(fieldOrdinal);
778 std::vector<int> polynomialDegree(polynomialDegreeView.extent_int(0));
779
780 for (unsigned d=0; d<polynomialDegree.size(); d++)
781 {
782 polynomialDegree[d] = polynomialDegreeView(d);
783 }
784 return polynomialDegree;
785 }
786
790 {
791 INTREPID2_TEST_FOR_EXCEPTION( basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
792 ">>> ERROR (Basis::getPolynomialDegreeLength): this method is not supported for non-hierarchical bases.");
793 return fieldOrdinalPolynomialDegree_.extent_int(1);
794 }
795
800 virtual
801 const char*
802 getName() const {
803 return "Intrepid2_Basis";
804 }
805
808 virtual
809 bool
811 return false;
812 }
813
818 ordinal_type
820 return basisCardinality_;
821 }
822
823
828 ordinal_type
829 getDegree() const {
830 return basisDegree_;
831 }
832
837 EFunctionSpace
839 return functionSpace_;
840 }
841
847 shards::CellTopology
849 return getCellTopologyData(basisCellTopologyKey_);
850 }
851
852
857 EBasis
858 getBasisType() const {
859 return basisType_;
860 }
861
862
867 ECoordinates
869 return basisCoordinates_;
870 }
871
879 virtual ordinal_type
880 getDofCount( const ordinal_type subcDim,
881 const ordinal_type subcOrd ) const {
882 this->requireTags();
883 if ( subcDim >= 0 && subcDim < static_cast<ordinal_type>(tagToOrdinal_.extent(0)) &&
884 subcOrd >= 0 && subcOrd < static_cast<ordinal_type>(tagToOrdinal_.extent(1)) )
885 {
886 int firstDofOrdinal = tagToOrdinal_(subcDim, subcOrd, 0); // will be -1 if no dofs for subcell
887 if (firstDofOrdinal == -1) return static_cast<ordinal_type>(0);
888 // otherwise, lookup its tag and return the dof count stored there
889 return static_cast<ordinal_type>(this->getDofTag(firstDofOrdinal)[3]);
890 }
891 else
892 {
893 // subcDim and/or subcOrd out of bounds -> no dofs associated with subcell
894 return static_cast<ordinal_type>(0);
895 }
896 }
897
906 virtual ordinal_type
907 getDofOrdinal( const ordinal_type subcDim,
908 const ordinal_type subcOrd,
909 const ordinal_type subcDofOrd ) const {
910 this->requireTags();
911 // this should be abort and able to be called as a device function
912#ifdef HAVE_INTREPID2_DEBUG
913 INTREPID2_TEST_FOR_EXCEPTION( subcDim < 0 || subcDim >= static_cast<ordinal_type>(tagToOrdinal_.extent(0)), std::out_of_range,
914 ">>> ERROR (Basis::getDofOrdinal): subcDim is out of range");
915 INTREPID2_TEST_FOR_EXCEPTION( subcOrd < 0 || subcOrd >= static_cast<ordinal_type>(tagToOrdinal_.extent(1)), std::out_of_range,
916 ">>> ERROR (Basis::getDofOrdinal): subcOrd is out of range");
917 INTREPID2_TEST_FOR_EXCEPTION( subcDofOrd < 0 || subcDofOrd >= static_cast<ordinal_type>(tagToOrdinal_.extent(2)), std::out_of_range,
918 ">>> ERROR (Basis::getDofOrdinal): subcDofOrd is out of range");
919#endif
920 ordinal_type r_val = -1;
921 if ( subcDim < static_cast<ordinal_type>(tagToOrdinal_.extent(0)) &&
922 subcOrd < static_cast<ordinal_type>(tagToOrdinal_.extent(1)) &&
923 subcDofOrd < static_cast<ordinal_type>(tagToOrdinal_.extent(2)) )
924 r_val = tagToOrdinal_(subcDim, subcOrd, subcDofOrd);
925#ifdef HAVE_INTREPID2_DEBUG
926 INTREPID2_TEST_FOR_EXCEPTION( r_val == -1, std::runtime_error,
927 ">>> ERROR (Basis::getDofOrdinal): Invalid DoF tag is found.");
928#endif
929 return r_val;
930 }
931
934 virtual int getNumTensorialExtrusions() const
935 {
936 return 0;
937 }
938
942 requireTags();
943 return tagToOrdinal_;
944 }
945
946
957 virtual const OrdinalTypeArrayStride1DHost
958 getDofTag( const ordinal_type dofOrd ) const {
959 this->requireTags();
960#ifdef HAVE_INTREPID2_DEBUG
961 INTREPID2_TEST_FOR_EXCEPTION( dofOrd < 0 || dofOrd >= static_cast<ordinal_type>(ordinalToTag_.extent(0)), std::out_of_range,
962 ">>> ERROR (Basis::getDofTag): dofOrd is out of range");
963#endif
964 return Kokkos::subview(ordinalToTag_, dofOrd, Kokkos::ALL());
965 }
966
967
976 virtual const OrdinalTypeArray2DHost
978 this->requireTags();
979 return ordinalToTag_;
980 }
981
997 getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const {
998 INTREPID2_TEST_FOR_EXCEPTION( true, std::logic_error,
999 ">>> ERROR (Basis::getSubCellRefBasis): this method is not supported or should be overridden accordingly by derived classes.");
1000 }
1001
1006 ordinal_type getDomainDimension() const
1007 {
1008 return this->getBaseCellTopology().getDimension() + this->getNumTensorialExtrusions();
1009 }
1010
1017 INTREPID2_TEST_FOR_EXCEPTION( true, std::logic_error,
1018 ">>> ERROR (Basis::getHostBasis): this method is not supported or should be overridden accordingly by derived classes.");
1019 }
1020
1021 }; // class Basis
1022
1023 //--------------------------------------------------------------------------------------------//
1024 // //
1025 // Helper functions of the Basis class //
1026 // //
1027 //--------------------------------------------------------------------------------------------//
1028
1029 //
1030 // functions for orders, cardinality, etc.
1031 //
1032
1033
1045 KOKKOS_INLINE_FUNCTION
1046 ordinal_type getFieldRank(const EFunctionSpace spaceType);
1047
1083 KOKKOS_INLINE_FUNCTION
1084 ordinal_type getOperatorRank(const EFunctionSpace spaceType,
1085 const EOperator operatorType,
1086 const ordinal_type spaceDim);
1087
1093 KOKKOS_INLINE_FUNCTION
1094 ordinal_type getOperatorOrder(const EOperator operatorType);
1095
1096 template<EOperator operatorType>
1097 KOKKOS_INLINE_FUNCTION
1098 constexpr ordinal_type getOperatorOrder();
1099
1123 template<ordinal_type spaceDim>
1124 KOKKOS_INLINE_FUNCTION
1125 ordinal_type getDkEnumeration(const ordinal_type xMult,
1126 const ordinal_type yMult = -1,
1127 const ordinal_type zMult = -1);
1128
1129
1140 template<ordinal_type spaceDim>
1141 KOKKOS_INLINE_FUNCTION
1142 ordinal_type getPnEnumeration(const ordinal_type p,
1143 const ordinal_type q = 0,
1144 const ordinal_type r = 0);
1145
1146
1147
1165
1166template<typename value_type>
1167KOKKOS_INLINE_FUNCTION
1168void getJacobyRecurrenceCoeffs (
1169 value_type &an,
1170 value_type &bn,
1171 value_type &cn,
1172 const ordinal_type alpha,
1173 const ordinal_type beta ,
1174 const ordinal_type n);
1175
1176
1177
1178
1179
1180 // /** \brief Returns multiplicities of dx, dy, and dz based on the enumeration of the partial
1181 // derivative, its order and the space dimension. Inverse of the getDkEnumeration() method.
1182
1183 // \param partialMult [out] - array with the multiplicities f dx, dy and dz
1184 // \param derivativeEnum [in] - enumeration of the partial derivative
1185 // \param operatorType [in] - k-th partial derivative Dk
1186 // \param spaceDim [in] - space dimension
1187 // */
1188 // template<typename OrdinalArrayType>
1189 // KOKKOS_INLINE_FUNCTION
1190 // void getDkMultiplicities(OrdinalArrayType partialMult,
1191 // const ordinal_type derivativeEnum,
1192 // const EOperator operatorType,
1193 // const ordinal_type spaceDim);
1194
1213 KOKKOS_INLINE_FUNCTION
1214 ordinal_type getDkCardinality(const EOperator operatorType,
1215 const ordinal_type spaceDim);
1216
1217 template<EOperator operatorType, ordinal_type spaceDim>
1218 KOKKOS_INLINE_FUNCTION
1219 constexpr ordinal_type getDkCardinality();
1220
1221
1222
1232 template<ordinal_type spaceDim>
1233 KOKKOS_INLINE_FUNCTION
1234 ordinal_type getPnCardinality (ordinal_type n);
1235
1236 template<ordinal_type spaceDim, ordinal_type n>
1237 KOKKOS_INLINE_FUNCTION
1238 constexpr ordinal_type getPnCardinality ();
1239
1240
1241
1242 //
1243 // Argument check
1244 //
1245
1246
1257 template<typename outputValueViewType,
1258 typename inputPointViewType>
1259 void getValues_HGRAD_Args( const outputValueViewType outputValues,
1260 const inputPointViewType inputPoints,
1261 const EOperator operatorType,
1262 const shards::CellTopology cellTopo,
1263 const ordinal_type basisCard );
1264
1275 template<typename outputValueViewType,
1276 typename inputPointViewType>
1277 void getValues_HCURL_Args( const outputValueViewType outputValues,
1278 const inputPointViewType inputPoints,
1279 const EOperator operatorType,
1280 const shards::CellTopology cellTopo,
1281 const ordinal_type basisCard );
1282
1293 template<typename outputValueViewType,
1294 typename inputPointViewType>
1295 void getValues_HDIV_Args( const outputValueViewType outputValues,
1296 const inputPointViewType inputPoints,
1297 const EOperator operatorType,
1298 const shards::CellTopology cellTopo,
1299 const ordinal_type basisCard );
1300
1311 template<typename outputValueViewType,
1312 typename inputPointViewType>
1313 void getValues_HVOL_Args( const outputValueViewType outputValues,
1314 const inputPointViewType inputPoints,
1315 const EOperator operatorType,
1316 const shards::CellTopology cellTopo,
1317 const ordinal_type basisCard );
1318
1319}// namespace Intrepid2
1320
1321#include <Intrepid2_BasisDef.hpp>
1322
1323//--------------------------------------------------------------------------------------------//
1324// //
1325// D O C U M E N T A T I O N P A G E S //
1326// //
1327//--------------------------------------------------------------------------------------------//
1429#endif
BasisPtr< typename Kokkos::HostSpace::device_type, OutputType, PointType > HostBasisPtr
Pointer to a Basis whose device type is on the host (Kokkos::HostSpace::device_type),...
Teuchos::RCP< Basis< DeviceType, OutputType, PointType > > BasisPtr
Basis Pointer.
Implementation file for the abstract base class Intrepid2::Basis.
Header file for the data-wrapper class Intrepid2::BasisValues.
Header file for the classes: Intrepid2::RefSubcellParametrization, Intrepid2::RefCellNodes,...
Definition of cell topology information.
View-like interface to tensor points; point components are stored separately; the appropriate coordin...
Contains definitions of custom data types in Intrepid2.
Header function for Intrepid2::Util class and other utility functions.
#define INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(test, x, msg)
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
virtual void requireTags() const
Ensures that the dense tag tables (ordinalToTag_, tagToOrdinal_) are filled.
OrdinalTypeArray1DHost getFieldOrdinalsForDegree(OrdinalTypeArray1DHost &degrees) const
For hierarchical bases, returns the field ordinals that have at most the specified degree in each dim...
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
OrdinalTypeArray1DHost getFieldOrdinalsForH1Degree(OrdinalTypeArray1DHost &degrees) const
For hierarchical bases, returns the field ordinals that have at most the specified H^1 degree in each...
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
outputValueType OutputValueType
Output value type for basis; default is double.
virtual const OrdinalTypeArrayStride1DHost getDofTag(const ordinal_type dofOrd) const
DoF ordinal to DoF tag lookup.
Kokkos::View< ordinal_type ***, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray3DHost
View type for 3d host array.
std::vector< int > getFieldOrdinalsForH1Degree(std::vector< int > &degrees) const
For hierarchical bases, returns the field ordinals that have at most the specified H^1 degree in each...
std::vector< int > getH1PolynomialDegreeOfFieldAsVector(int fieldOrdinal) const
For hierarchical bases, returns the polynomial degree (which may have multiple values in higher spati...
Kokkos::View< ordinal_type *, Kokkos::LayoutStride, DeviceType > OrdinalTypeArrayStride1D
View type for 1d device array.
virtual void getScratchSpaceSize(ordinal_type &perThreadSpaceSize, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const
Return the size of the scratch space, in bytes, needed for using the team-level implementation of get...
Kokkos::View< ordinal_type *, Kokkos::LayoutStride, Kokkos::HostSpace > OrdinalTypeArrayStride1DHost
View type for 1d host array.
ordinal_type getDegree() const
Returns the degree of the basis.
void setOrdinalTagData(OrdinalTypeView3D &tagToOrdinal, OrdinalTypeView2D &ordinalToTag, const OrdinalTypeView1D tags, const ordinal_type basisCard, const ordinal_type tagSize, const ordinal_type posScDim, const ordinal_type posScOrd, const ordinal_type posDfOrd)
Fills ordinalToTag_ and tagToOrdinal_ by basis-specific tag data.
virtual HostBasisPtr< OutputValueType, PointValueType > getHostBasis() const
Creates and returns a Basis object whose DeviceType template argument is Kokkos::HostSpace::device_ty...
ordinal_type getCardinality() const
Returns cardinality of the basis.
virtual BasisValues< OutputValueType, DeviceType > allocateBasisValues(TensorPoints< PointValueType, DeviceType > points, const EOperator operatorType=OPERATOR_VALUE) const
Allocate BasisValues container suitable for passing to the getValues() variant that takes a TensorPoi...
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, DeviceType > ScalarViewType
View type for scalars.
virtual const OrdinalTypeArray2DHost getAllDofTags() const
Retrieves all DoF tags.
OutputValueType getDummyOutputValue()
Dummy array to receive input arguments.
virtual ordinal_type getDofCount(const ordinal_type subcDim, const ordinal_type subcOrd) const
DoF count for specified subcell.
ECoordinates getCoordinateSystem() const
Returns the type of coordinate system for which the basis is defined.
PointValueType getDummyPointValue()
Dummy array to receive input arguments.
int getPolynomialDegreeLength() const
For hierarchical bases, returns the number of entries required to specify the polynomial degree of a ...
virtual ordinal_type getDofOrdinal(const ordinal_type subcDim, const ordinal_type subcOrd, const ordinal_type subcDofOrd) const
DoF tag to ordinal lookup.
virtual bool requireOrientation() const
True if orientation is required.
Kokkos::View< ordinal_type, DeviceType > OrdinalViewType
View type for ordinal.
virtual KOKKOS_INLINE_FUNCTION void getValues(OutputViewType, const PointViewType, const EOperator, const typename Kokkos::TeamPolicy< ExecutionSpace >::member_type &teamMember, const int threadScratchLevel, const ordinal_type subcellDim=-1, const ordinal_type subcellOrdinal=-1) const
Team-level evaluation of basis functions on a reference cell.
const OrdinalTypeArray3DHost getAllDofOrdinal() const
DoF tag to ordinal data structure.
Device DeviceType
(Kokkos) Device type on which Basis is templated. Does not necessarily return true for Kokkos::is_dev...
virtual void getValues(const ExecutionSpace &, OutputViewType, const PointViewType, const EOperator=OPERATOR_VALUE) const
Evaluation of a FEM basis on a reference cell.
Kokkos::DynRankView< scalarType, DeviceType > dofCoords_
Kokkos::View< ECoordinates, DeviceType > ECoordinatesViewType
View for coordinate system type.
ordinal_type getDomainDimension() const
Returns the spatial dimension of the domain of the basis; this is equal to getBaseCellTopology()....
virtual void getValues(BasisValues< OutputValueType, DeviceType > outputValues, const TensorPoints< PointValueType, DeviceType > inputPoints, const EOperator operatorType=OPERATOR_VALUE) const
Evaluation of a FEM basis on a reference cell, using point and output value containers that allow pre...
pointValueType PointValueType
Point value type for basis; default is double.
Kokkos::View< ordinal_type **, DeviceType > OrdinalTypeArray2D
View type for 2d device array.
Kokkos::DynRankView< scalarType, DeviceType > dofCoeffs_
OrdinalTypeArray1DHost getPolynomialDegreeOfField(int fieldOrdinal) const
For hierarchical bases, returns the polynomial degree (which may have multiple values in higher spati...
Kokkos::View< ordinal_type **, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
View type for 2d host array.
virtual void getDofCoords(ScalarViewType) const
Returns spatial locations (coordinates) of degrees of freedom on the reference cell.
EFunctionSpace getFunctionSpace() const
Returns the function space for the basis.
Kokkos::DynRankView< OutputValueType, DeviceType > allocateOutputView(const int numPoints, const EOperator operatorType=OPERATOR_VALUE) const
Allocate a View container suitable for passing to the getValues() variant that accepts Kokkos DynRank...
virtual void getDofCoeffs(ScalarViewType) const
Coefficients for computing degrees of freedom for Lagrangian basis If P is an element of the space sp...
EBasis getBasisType() const
Returns the basis type.
OrdinalTypeArray1DHost getH1PolynomialDegreeOfField(int fieldOrdinal) const
For hierarchical bases, returns the polynomial degree (which may have multiple values in higher spati...
ScalarTraits< pointValueType >::scalar_type scalarType
Scalar type for point values.
Kokkos::View< ordinal_type ***, DeviceType > OrdinalTypeArray3D
View type for 3d device array.
shards::CellTopology getBaseCellTopology() const
Returns the base cell topology for which the basis is defined. See Shards documentation https://trili...
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Kokkos::View< ordinal_type *, DeviceType > OrdinalTypeArray1D
View type for 1d device array.
virtual void getValues(OutputViewType, const PointViewType, const PointViewType, const EOperator=OPERATOR_VALUE) const
Evaluation of an FVD basis evaluation on a physical cell.
typename DeviceType::execution_space ExecutionSpace
(Kokkos) Execution space for basis.
virtual const char * getName() const
Returns basis name.
std::vector< int > getFieldOrdinalsForDegree(std::vector< int > &degrees) const
For hierarchical bases, returns the field ordinals that have at most the specified degree in each dim...
virtual BasisPtr< DeviceType, OutputValueType, PointValueType > getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const
returns the basis associated to a subCell.
virtual int getNumTensorialExtrusions() const
returns the number of tensorial extrusions relative to the cell topology returned by getBaseCellTopol...
std::vector< int > getPolynomialDegreeOfFieldAsVector(int fieldOrdinal) const
For hierarchical bases, returns the polynomial degree (which may have multiple values in higher spati...
Kokkos::View< EBasis, DeviceType > EBasisViewType
View for basis type.
The data containers in Intrepid2 that support sum factorization and other reduced-data optimizations ...
const VectorDataType & vectorData() const
VectorData accessor.
TensorDataType & tensorData()
TensorData accessor for single-family scalar data.
Wrapper around a Kokkos::View that allows data that is constant or repeating in various logical dimen...
KOKKOS_INLINE_FUNCTION enable_if_t< rank==1, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 1.
View-like interface to tensor data; tensor components are stored separately and multiplied together a...
KOKKOS_INLINE_FUNCTION const Data< Scalar, DeviceType > & getTensorComponent(const ordinal_type &r) const
Returns the requested tensor component.
KOKKOS_INLINE_FUNCTION ordinal_type numTensorComponents() const
Return the number of tensorial components.
View-like interface to tensor points; point components are stored separately; the appropriate coordin...
KOKKOS_INLINE_FUNCTION std::enable_if< std::is_integral< iType >::value, int >::type extent_int(const iType &r) const
Returns the logical extent in the requested dimension.
ScalarView< PointScalar, DeviceType > allocateAndFillExpandedRawPointView() const
This method is for compatibility with existing methods that take raw point views. Note that in genera...
Reference-space field values for a basis, designed to support typical vector-valued bases.
KOKKOS_INLINE_FUNCTION int numComponents() const
returns the number of components
KOKKOS_INLINE_FUNCTION const TensorData< Scalar, DeviceType > & getComponent(const int &componentOrdinal) const
Single-argument component accessor for the axial-component or the single-family case; in this case,...
KOKKOS_INLINE_FUNCTION constexpr bool isValid() const
returns true for containers that have data; false for those that don't (e.g., those that have been co...