Intrepid
Intrepid_ProductTopologyDef.hpp
Go to the documentation of this file.
1// @HEADER
2// ************************************************************************
3//
4// Intrepid Package
5// Copyright (2007) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Pavel Bochev (pbboche@sandia.gov)
38// Denis Ridzal (dridzal@sandia.gov), or
39// Kara Peterson (kjpeter@sandia.gov)
40//
41// ************************************************************************
42// @HEADER
43
49namespace Intrepid
50{
51 void ProductTopology::lineProduct2d( const int dim0 ,
52 const int entity0 ,
53 const int dim1 ,
54 const int entity1 ,
55 int &resultdim ,
56 int &resultentity )
57 {
58 // two vertices
59 if (dim0 == 0 && dim1 == 0) {
60 resultdim = 0;
61 if (entity0 == 0 && entity1 == 0) {
62 resultentity = 0;
63 }
64 else if (entity0 == 0 && entity1 == 1) {
65 resultentity = 3;
66 }
67 else if (entity0 == 1 && entity1 == 0) {
68 resultentity = 1;
69 }
70 else if (entity0 == 1 && entity1 == 1) {
71 resultentity = 2;
72 }
73 else {
74 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
75 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
76 }
77 }
78 else if (dim0 == 0 && dim1 == 1) {
79 resultdim = 1;
80 if (entity0 == 0 && entity1 == 0) {
81 resultentity = 3;
82 }
83 else if (entity0 == 1 && entity1 == 0) {
84 resultentity = 1;
85 }
86 else {
87 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
88 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
89 }
90 }
91 else if (dim0 == 1 && dim1 == 0) {
92 resultdim = 1;
93 if (entity0 == 0 && entity1 == 0) {
94 resultentity = 0;
95 }
96 else if (entity0 == 0 && entity1 == 1) {
97 resultentity = 2;
98 }
99 else {
100 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
101 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
102 }
103 }
104 else if (dim0 == 1 && dim1 == 1) {
105 resultdim = 2;
106 if (entity0 == 0 && entity1 == 0) {
107 resultentity = 0;
108 }
109 else {
110 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
111 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
112 }
113 }
114 else {
115 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
116 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
117 }
118
119 }
120
121 void ProductTopology::lineProduct3d( const int dim0 ,
122 const int entity0 ,
123 const int dim1 ,
124 const int entity1 ,
125 const int dim2 ,
126 const int entity2 ,
127 int &resultdim ,
128 int &resultentity )
129 {
130 // on vertex
131 if (dim0 == 0 && dim1 == 0 && dim2 == 0) {
132 resultdim = 0;
133 if (entity0 == 0 && entity1 == 0 && entity2 == 0 ) {
134 resultentity = 0;
135 }
136 else if (entity0 == 0 && entity1 == 0 && entity2 == 1 ) {
137 resultentity = 4;
138 }
139 else if (entity0 == 0 && entity1 == 1 && entity2 == 0 ) {
140 resultentity = 3;
141 }
142 else if (entity0 == 0 && entity1 == 1 && entity2 == 1 ) {
143 resultentity = 7;
144 }
145 else if (entity0 == 1 && entity1 == 0 && entity2 == 0) {
146 resultentity = 1;
147 }
148 else if (entity0 == 1 && entity1 == 0 && entity2 == 1) {
149 resultentity = 5;
150 }
151 else if (entity0 == 1 && entity1 == 1 && entity2 == 0) {
152 resultentity = 2;
153 }
154 else if (entity0 == 1 && entity1 == 1 && entity2 == 1) {
155 resultentity = 6;
156 }
157 else {
158 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
159 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
160 }
161 }
162 // LINES
163 // z coord is on line, other two on vertex, this makes an ascending vertical edge
164 else if (dim0 == 0 && dim1 == 0 && dim2 == 1) {
165 resultdim = 1;
166 if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
167 resultentity = 8;
168 }
169 else if (entity0 == 0 && entity1 == 1 && entity2 == 0) {
170 resultentity = 11;
171 }
172 else if (entity0 == 1 && entity1 == 0 && entity2 == 0) {
173 resultentity = 9;
174 }
175 else if (entity0 == 1 && entity1 == 1 && entity2 == 0) {
176 resultentity = 10;
177 }
178 else {
179 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
180 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
181 }
182 }
183 // only y coord is on line, other two on vertex, this makes line along y axis
184 else if (dim0 == 0 && dim1 == 1 && dim2 == 0) {
185 resultdim = 1;
186 if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
187 resultentity = 3;
188 }
189 else if (entity0 == 0 && entity1 == 0 && entity2 == 1) {
190 resultentity = 7;
191 }
192 else if (entity0 == 1 && entity1 == 0 && entity2 == 0) {
193 resultentity = 1;
194 }
195 else if (entity0 == 1 && entity1 == 0 && entity2 == 1) {
196 resultentity = 5;
197 }
198 else {
199 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
200 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
201 }
202 }
203 // x dof is on line, others on vertex.
204 else if (dim0 == 1 && dim1 == 0 && dim2 == 0) {
205 resultdim = 1;
206 if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
207 resultentity = 0;
208 }
209 else if (entity0 == 0 && entity1 == 0 && entity2 == 1) {
210 resultentity = 4;
211 }
212 else if (entity0 == 0 && entity1 == 1 && entity2 == 0) {
213 resultentity = 2;
214 }
215 else if (entity0 == 0 && entity1 == 1 && entity2 == 1) {
216 resultentity = 6;
217 }
218 else {
219 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
220 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
221 }
222 }
223 // FACES, these require two of the line dimensions to be 1
224 else if (dim0 == 0 && dim1 == 1 && dim2 == 1) {
225 resultdim = 2;
226 if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
227 resultentity = 3;
228 }
229 else if (entity0 == 1 && entity1 == 0 && entity2 == 0) {
230 resultentity = 1;
231 }
232 else {
233 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
234 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
235 }
236 }
237 else if (dim0 == 1 && dim1 == 0 && dim2 == 1) {
238 resultdim = 2;
239 if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
240 resultentity = 0;
241 }
242 else if (entity0 == 0 && entity1 == 1 && entity2 == 0) {
243 resultentity = 2;
244 }
245 else {
246 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
247 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
248 }
249 }
250 else if (dim0 == 1 && dim1 == 1 && dim2 == 0) {
251 resultdim = 2;
252 if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
253 resultentity = 4;
254 }
255 else if (entity0 == 0 && entity1 == 0 && entity2 == 1) {
256 resultentity = 5;
257 }
258 else {
259 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
260 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
261 }
262 }
263 // CELL ITSELF
264 else if (dim0 == 1 && dim1 == 1 && dim2 == 1) {
265 resultdim = 3;
266 if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
267 resultentity = 0;
268 }
269 else {
270 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
271 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
272 }
273 }
274 }
275}
static void lineProduct3d(const int dim0, const int entity0, const int dim1, const int entity1, const int dim2, const int entity2, int &resultdim, int &resultentity)
static void lineProduct2d(const int dim0, const int entity0, const int dim1, const int entity1, int &resultdim, int &resultentity)