Intrepid2
Intrepid2_DataDimensionInfo.hpp
Go to the documentation of this file.
1//
2// Intrepid2_DataDimensionInfo.hpp
3// Trilinos
4//
5// Created by Roberts, Nathan V on 5/31/23.
6//
7
8#ifndef Intrepid2_DataDimensionInfo_hpp
9#define Intrepid2_DataDimensionInfo_hpp
10
15
17
18namespace Intrepid2
19{
24 {
25 int logicalExtent;
26 DataVariationType variationType;
27 int dataExtent;
28 int variationModulus; // should be equal to dataExtent variationType other than MODULAR and CONSTANT
29 int blockPlusDiagonalLastNonDiagonal = -1; // only relevant for variationType == BLOCK_PLUS_DIAGONAL
30 };
31
33 KOKKOS_INLINE_FUNCTION
35 {
36 const int myNominalExtent = myData.logicalExtent;
37#ifdef HAVE_INTREPID2_DEBUG
38 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(myNominalExtent != otherData.logicalExtent, std::invalid_argument, "both Data objects must match in their logical extent in the specified dimension");
39#endif
40 const DataVariationType & myVariation = myData.variationType;
41 const DataVariationType & otherVariation = otherData.variationType;
42
43 const int & myVariationModulus = myData.variationModulus;
44 const int & otherVariationModulus = otherData.variationModulus;
45
46 int myDataExtent = myData.dataExtent;
47 int otherDataExtent = otherData.dataExtent;
48
50 combinedDimensionInfo.logicalExtent = myNominalExtent;
51
52 switch (myVariation)
53 {
54 case CONSTANT:
55 switch (otherVariation)
56 {
57 case CONSTANT:
58 case MODULAR:
59 case GENERAL:
61 combinedDimensionInfo = otherData;
62 }
63 break;
64 case MODULAR:
65 switch (otherVariation)
66 {
67 case CONSTANT:
68 combinedDimensionInfo = myData;
69 break;
70 case MODULAR:
71 if (myVariationModulus == otherVariationModulus)
72 {
73 // in this case, expect both to have the same data extent
74 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(myDataExtent != otherDataExtent, std::logic_error, "Unexpected data extent/modulus combination");
75 combinedDimensionInfo.variationType = MODULAR;
76 combinedDimensionInfo.dataExtent = myDataExtent;
77 combinedDimensionInfo.variationModulus = myVariationModulus;
78 }
79 else
80 {
81 // both modular with two different moduli
82 // we could do something clever with e.g. least common multiples, but for now we just use GENERAL
83 // (this is not a use case we anticipate being a common one)
84 combinedDimensionInfo.variationType = GENERAL;
85 combinedDimensionInfo.dataExtent = myNominalExtent;
86 combinedDimensionInfo.variationModulus = myNominalExtent;
87 }
88 break;
90 combinedDimensionInfo.variationType = GENERAL;
91 combinedDimensionInfo.dataExtent = myNominalExtent;
92 combinedDimensionInfo.variationModulus = myNominalExtent;
93 break;
94 case GENERAL:
95 // otherData is GENERAL: its info dominates
96 combinedDimensionInfo = otherData;
97 break;
98 }
99 break;
101 switch (otherVariation)
102 {
103 case CONSTANT:
104 combinedDimensionInfo = myData;
105 break;
106 case MODULAR:
107 combinedDimensionInfo.variationType = GENERAL;
108 combinedDimensionInfo.dataExtent = myNominalExtent;
109 combinedDimensionInfo.variationModulus = myNominalExtent;
110 break;
111 case GENERAL:
112 // otherData is GENERAL: its info dominates
113 combinedDimensionInfo = otherData;
114 break;
116 combinedDimensionInfo.variationType = GENERAL;
117 combinedDimensionInfo.dataExtent = max(myDataExtent,otherDataExtent);
118 combinedDimensionInfo.variationModulus = combinedDimensionInfo.dataExtent;
119 // for this case, we want to take the minimum of the two Data objects' blockPlusDiagonalLastNonDiagonal as the combined object's blockPlusDiagonalLastNonDiagonal
120 combinedDimensionInfo.blockPlusDiagonalLastNonDiagonal = min(myData.blockPlusDiagonalLastNonDiagonal, otherData.blockPlusDiagonalLastNonDiagonal);
121 }
122 break;
123 case GENERAL:
124 switch (otherVariation)
125 {
126 case CONSTANT:
127 case MODULAR:
128 case GENERAL:
130 combinedDimensionInfo = myData;
131 }
132 }
134 }
135
136} // end namespace Intrepid2
137
138#endif /* Intrepid2_DataDimensionInfo_hpp */
KOKKOS_INLINE_FUNCTION DimensionInfo combinedDimensionInfo(const DimensionInfo &myData, const DimensionInfo &otherData)
Returns DimensionInfo for a Data container that combines (through multiplication, say,...
Defines DataVariationType enum that specifies the types of variation possible within a Data object.
@ GENERAL
arbitrary variation
@ BLOCK_PLUS_DIAGONAL
one of two dimensions in a matrix; bottom-right part of matrix is diagonal
@ MODULAR
varies according to modulus of the index
#define INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(test, x, msg)
Struct expressing all variation information about a Data object in a single dimension,...