Intrepid2
Intrepid2_DataDimensionInfo.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//
10// Intrepid2_DataDimensionInfo.hpp
11// Trilinos
12//
13// Created by Roberts, Nathan V on 5/31/23.
14//
15
16#ifndef Intrepid2_DataDimensionInfo_hpp
17#define Intrepid2_DataDimensionInfo_hpp
18
25
26namespace Intrepid2
27{
32 {
33 int logicalExtent;
34 DataVariationType variationType;
35 int dataExtent;
36 int variationModulus; // should be equal to dataExtent variationType other than MODULAR and CONSTANT
37 int blockPlusDiagonalLastNonDiagonal = -1; // only relevant for variationType == BLOCK_PLUS_DIAGONAL
38 };
39
41 KOKKOS_INLINE_FUNCTION
43 {
44 const int myNominalExtent = myData.logicalExtent;
45#ifdef HAVE_INTREPID2_DEBUG
46 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");
47#endif
48 const DataVariationType & myVariation = myData.variationType;
49 const DataVariationType & otherVariation = otherData.variationType;
50
51 const int & myVariationModulus = myData.variationModulus;
52 const int & otherVariationModulus = otherData.variationModulus;
53
54 int myDataExtent = myData.dataExtent;
55 int otherDataExtent = otherData.dataExtent;
56
58 combinedDimensionInfo.logicalExtent = myNominalExtent;
59
60 switch (myVariation)
61 {
62 case CONSTANT:
63 switch (otherVariation)
64 {
65 case CONSTANT:
66 case MODULAR:
67 case GENERAL:
69 combinedDimensionInfo = otherData;
70 }
71 break;
72 case MODULAR:
73 switch (otherVariation)
74 {
75 case CONSTANT:
76 combinedDimensionInfo = myData;
77 break;
78 case MODULAR:
79 if (myVariationModulus == otherVariationModulus)
80 {
81 // in this case, expect both to have the same data extent
82 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(myDataExtent != otherDataExtent, std::logic_error, "Unexpected data extent/modulus combination");
83 combinedDimensionInfo.variationType = MODULAR;
84 combinedDimensionInfo.dataExtent = myDataExtent;
85 combinedDimensionInfo.variationModulus = myVariationModulus;
86 }
87 else
88 {
89 // both modular with two different moduli
90 // we could do something clever with e.g. least common multiples, but for now we just use GENERAL
91 // (this is not a use case we anticipate being a common one)
92 combinedDimensionInfo.variationType = GENERAL;
93 combinedDimensionInfo.dataExtent = myNominalExtent;
94 combinedDimensionInfo.variationModulus = myNominalExtent;
95 }
96 break;
98 combinedDimensionInfo.variationType = GENERAL;
99 combinedDimensionInfo.dataExtent = myNominalExtent;
100 combinedDimensionInfo.variationModulus = myNominalExtent;
101 break;
102 case GENERAL:
103 // otherData is GENERAL: its info dominates
104 combinedDimensionInfo = otherData;
105 break;
106 }
107 break;
109 switch (otherVariation)
110 {
111 case CONSTANT:
112 combinedDimensionInfo = myData;
113 break;
114 case MODULAR:
115 combinedDimensionInfo.variationType = GENERAL;
116 combinedDimensionInfo.dataExtent = myNominalExtent;
117 combinedDimensionInfo.variationModulus = myNominalExtent;
118 break;
119 case GENERAL:
120 // otherData is GENERAL: its info dominates
121 combinedDimensionInfo = otherData;
122 break;
124 combinedDimensionInfo.variationType = GENERAL;
125 combinedDimensionInfo.dataExtent = max(myDataExtent,otherDataExtent);
126 combinedDimensionInfo.variationModulus = combinedDimensionInfo.dataExtent;
127 // for this case, we want to take the minimum of the two Data objects' blockPlusDiagonalLastNonDiagonal as the combined object's blockPlusDiagonalLastNonDiagonal
128 combinedDimensionInfo.blockPlusDiagonalLastNonDiagonal = min(myData.blockPlusDiagonalLastNonDiagonal, otherData.blockPlusDiagonalLastNonDiagonal);
129 }
130 break;
131 case GENERAL:
132 switch (otherVariation)
133 {
134 case CONSTANT:
135 case MODULAR:
136 case GENERAL:
138 combinedDimensionInfo = myData;
139 }
140 }
142 }
143
144} // end namespace Intrepid2
145
146#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,...