18 #ifndef Intrepid2_BasisValues_h
19 #define Intrepid2_BasisValues_h
34 template<
class Scalar,
typename DeviceType>
40 Kokkos::Array<TensorDataType,Parameters::MaxTensorComponents> tensorDataFamilies_;
43 int numTensorDataFamilies_ = -1;
45 Kokkos::View<ordinal_type*,DeviceType> ordinalFilter_;
50 tensorDataFamilies_({tensorData}),
51 numTensorDataFamilies_(1)
57 numTensorDataFamilies_(tensorDataFamilies.size())
59 for (
int family=0; family<numTensorDataFamilies_; family++)
61 tensorDataFamilies_[family] = tensorDataFamilies[family];
68 vectorData_(vectorData)
74 numTensorDataFamilies_(0)
79 template<typename OtherDeviceType, class = typename std::enable_if<!std::is_same<DeviceType, OtherDeviceType>::value>::type>
83 numTensorDataFamilies_(basisValues.numTensorDataFamilies())
86 for (
int family=0; family<numTensorDataFamilies_; family++)
90 auto otherOrdinalFilter = basisValues.ordinalFilter();
91 ordinalFilter_ = Kokkos::View<ordinal_type*,DeviceType>(
"BasisValues::ordinalFilter_",otherOrdinalFilter.extent(0));
93 Kokkos::deep_copy(ordinalFilter_, otherOrdinalFilter);
99 int familyStartOrdinal = -1, familyEndOrdinal = -1;
102 for (
int i=0; i<familyCount; i++)
104 const bool startMatches = (fieldsSoFar == fieldStartOrdinal);
105 familyStartOrdinal = startMatches ? i : familyStartOrdinal;
106 fieldsSoFar += numFieldsInFamily(i);
107 const bool endMatches = (fieldsSoFar - fieldStartOrdinal == numFields);
108 familyEndOrdinal = endMatches ? i : familyEndOrdinal;
110 INTREPID2_TEST_FOR_EXCEPTION(familyStartOrdinal == -1, std::invalid_argument,
"fieldStartOrdinal does not align with the start of a family.");
111 INTREPID2_TEST_FOR_EXCEPTION(familyEndOrdinal == -1, std::invalid_argument,
"fieldStartOrdinal + numFields does not align with the end of a family.");
113 const int numFamiliesInFieldSpan = familyEndOrdinal - familyStartOrdinal + 1;
114 if (numTensorDataFamilies_ > 0)
117 for (
int i=familyStartOrdinal; i<=familyEndOrdinal; i++)
119 tensorDataFamilies[i-familyStartOrdinal] = tensorDataFamilies_[i];
126 std::vector< std::vector<TensorData<Scalar,DeviceType> > > vectorComponents(numFamiliesInFieldSpan, std::vector<
TensorData<Scalar,DeviceType> >(componentCount));
127 for (
int i=familyStartOrdinal; i<=familyEndOrdinal; i++)
129 for (
int j=0; j<componentCount; j++)
131 vectorComponents[i-familyStartOrdinal][j] = vectorData_.
getComponent(i,j);
139 KOKKOS_INLINE_FUNCTION
149 for (
int i=0; i<familyOrdinal; i++)
151 offset += tensorDataFamilies_[i].extent_int(0);
161 return tensorDataFamilies_[0];
169 return tensorDataFamilies_[familyOrdinal];
173 KOKKOS_INLINE_FUNCTION
182 return numTensorDataFamilies_;
186 KOKKOS_INLINE_FUNCTION
187 int numTensorDataFamilies()
const
189 return numTensorDataFamilies_;
192 KOKKOS_INLINE_FUNCTION
193 int numFieldsInFamily(
int familyOrdinal)
const
201 return tensorDataFamilies_[familyOrdinal].extent_int(0);
208 return tensorDataFamilies_;
218 KOKKOS_INLINE_FUNCTION
219 Scalar
operator()(
const int &fieldOrdinal,
const int &pointOrdinal)
const
221 const int &tensorFieldOrdinal = (ordinalFilter_.extent(0) > 0) ? ordinalFilter_(fieldOrdinal) : fieldOrdinal;
222 if (numTensorDataFamilies_ == 1)
224 #ifdef HAVE_INTREPID2_DEBUG
227 return tensorDataFamilies_[0](tensorFieldOrdinal, pointOrdinal);
231 int familyForField = -1;
232 int previousFamilyEnd = -1;
233 int fieldAdjustment = 0;
235 for (
int family=0; family<numTensorDataFamilies_; family++)
237 const int familyFieldCount = tensorDataFamilies_[family].extent_int(0);
238 const bool fieldInRange = (tensorFieldOrdinal > previousFamilyEnd) && (tensorFieldOrdinal <= previousFamilyEnd + familyFieldCount);
239 familyForField = fieldInRange ? family : familyForField;
240 fieldAdjustment = fieldInRange ? previousFamilyEnd + 1 : fieldAdjustment;
241 previousFamilyEnd += familyFieldCount;
243 #ifdef HAVE_INTREPID2_DEBUG
246 return tensorDataFamilies_[familyForField](tensorFieldOrdinal-fieldAdjustment,pointOrdinal);
251 KOKKOS_INLINE_FUNCTION
252 Scalar
operator()(
const int &fieldOrdinal,
const int &pointOrdinal,
const int &dim)
const
254 #ifdef HAVE_INTREPID2_DEBUG
257 const int &tensorFieldOrdinal = (ordinalFilter_.extent(0) > 0) ? ordinalFilter_(fieldOrdinal) : fieldOrdinal;
258 return vectorData_(tensorFieldOrdinal, pointOrdinal, dim);
262 KOKKOS_INLINE_FUNCTION
263 Scalar
operator()(
const int &cellOrdinal,
const int &fieldOrdinal,
const int &pointOrdinal,
const int &dim)
const
269 KOKKOS_INLINE_FUNCTION
270 int extent_int(
const int &i)
const
275 if (ordinalFilter_.extent_int(0) == 0)
278 for (
int familyOrdinal=0; familyOrdinal<
numFamilies(); familyOrdinal++)
280 numFields += numFieldsInFamily(familyOrdinal);
286 return ordinalFilter_.extent_int(0);
295 else if (tensorDataFamilies_[0].isValid())
297 return tensorDataFamilies_[0].extent_int(i);
307 KOKKOS_INLINE_FUNCTION
308 size_t extent(
const int &i)
const
310 return static_cast<size_t>(extent_int(i));
313 KOKKOS_INLINE_FUNCTION
318 return vectorData_.
rank();
320 else if (tensorDataFamilies_[0].isValid())
322 return tensorDataFamilies_[0].rank();
330 void setOrdinalFilter(Kokkos::View<ordinal_type*,DeviceType> ordinalFilter)
332 ordinalFilter_ = ordinalFilter;
335 Kokkos::View<ordinal_type*,DeviceType> ordinalFilter()
const
337 return ordinalFilter_;
341 template<
class Scalar,
typename DeviceType>
342 KOKKOS_INLINE_FUNCTION
unsigned rank(
const BasisValues<Scalar,DeviceType> &basisValues)
344 return basisValues.rank();
KOKKOS_INLINE_FUNCTION int familyFieldOrdinalOffset(const int &familyOrdinal) const
Returns the field ordinal offset for the specified family.
KOKKOS_INLINE_FUNCTION int numFieldsInFamily(const unsigned &familyOrdinal) const
returns the number of fields in the specified family
BasisValues()
Default constructor.
#define INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(test, x, msg)
BasisValues< Scalar, DeviceType > basisValuesForFields(const int &fieldStartOrdinal, const int &numFields)
field start and length must align with families in vectorData_ or tensorDataFamilies_ (whichever is v...
const VectorDataType & vectorData() const
VectorData accessor.
BasisValues(const BasisValues< Scalar, OtherDeviceType > &basisValues)
copy-like constructor for differing execution spaces. This does a deep copy of underlying views...
KOKKOS_INLINE_FUNCTION int numFamilies() const
returns the number of families
TensorDataType & tensorData()
TensorData accessor for single-family scalar data.
KOKKOS_INLINE_FUNCTION Scalar operator()(const int &fieldOrdinal, const int &pointOrdinal, const int &dim) const
operator() for (F,P,D) vector data; throws an exception if this is not a vector-valued container ...
The data containers in Intrepid2 that support sum factorization and other reduced-data optimizations ...
BasisValues(TensorDataType tensorData)
Constructor for scalar-valued BasisValues with a single family of values.
KOKKOS_INLINE_FUNCTION Scalar operator()(const int &fieldOrdinal, const int &pointOrdinal) const
operator() for (F,P) scalar data; throws an exception if this is not a scalar-valued container ...
Reference-space field values for a basis, designed to support typical vector-valued bases...
KOKKOS_INLINE_FUNCTION int numFamilies() const
For valid vectorData, returns the number of families in vectorData; otherwise, returns number of Tens...
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 int extent_int(const int &r) const
Returns the extent in the specified dimension as an int.
const TensorDataType & tensorData(const int &familyOrdinal) const
TensorData accessor for multi-family scalar data.
BasisValues(std::vector< TensorDataType > tensorDataFamilies)
Constructor for scalar-valued BasisValues, with potentially multiple families of values. (Used, e.g., for op = DIV and functionSpace = HDIV.)
BasisValues(VectorDataType vectorData)
Constructor for vector-valued BasisValues.
const Kokkos::Array< TensorDataType, Parameters::MaxTensorComponents > & tensorDataFamilies() const
TensorDataFamilies accessor.
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...
KOKKOS_INLINE_FUNCTION int familyFieldOrdinalOffset(const int &familyOrdinal) const
Returns the field ordinal offset for the specified family.
KOKKOS_INLINE_FUNCTION unsigned rank() const
Returns the rank of this container, which is 3.
View-like interface to tensor data; tensor components are stored separately and multiplied together a...
KOKKOS_INLINE_FUNCTION Scalar operator()(const int &cellOrdinal, const int &fieldOrdinal, const int &pointOrdinal, const int &dim) const
operator() for (C,F,P,D) data, which arises in CVFEM; at present unimplemented, and only declared her...
View-like interface to tensor data; tensor components are stored separately and multiplied together a...
KOKKOS_INLINE_FUNCTION int numComponents() const
returns the number of components
Reference-space field values for a basis, designed to support typical vector-valued bases...