Intrepid
Intrepid_ProductTopology.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
50#ifndef INTREPID_PRODUCTTOPOLOGY_HPP
51#define INTREPID_PRODUCTTOPOLOGY_HPP
52
53#include "Shards_CellTopology.hpp"
54#include "Teuchos_Assert.hpp"
55#include <stdexcept>
56#include <map>
57
58namespace Intrepid {
59
65 class ProductTopology {
66 public:
75 static void lineProduct2d( const int dim0 ,
76 const int entity0 ,
77 const int dim1 ,
78 const int entity1 ,
79 int &resultdim ,
80 int &resultentity )
81 {
82 // two vertices
83 if (dim0 == 0 && dim1 == 0)
84 {
85 resultdim = 0;
86 if (entity0 == 0 && entity1 == 0)
87 {
88 resultentity = 0;
89 }
90 else if (entity0 == 0 && entity1 == 1)
91 {
92 resultentity = 3;
93 }
94 else if (entity0 == 1 && entity1 == 0)
95 {
96 resultentity = 1;
97 }
98 else if (entity0 == 1 && entity1 == 1)
99 {
100 resultentity = 2;
101 }
102 else
103 {
104 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
105 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
106 }
107 }
108 else if (dim0 == 0 && dim1 == 1)
109 {
110 resultdim = 1;
111 if (entity0 == 0 && entity1 == 0)
112 {
113 resultentity = 3;
114 }
115 else if (entity0 == 1 && entity1 == 0)
116 {
117 resultentity = 1;
118 }
119 else
120 {
121 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
122 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
123 }
124 }
125 else if (dim0 == 1 && dim1 == 0)
126 {
127 resultdim = 1;
128 if (entity0 == 0 && entity1 == 0)
129 {
130 resultentity = 0;
131 }
132 else if (entity0 == 0 && entity1 == 1)
133 {
134 resultentity = 2;
135 }
136 else
137 {
138 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
139 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
140 }
141 }
142 else if (dim0 == 1 && dim1 == 1)
143 {
144 resultdim = 2;
145 if (entity0 == 0 && entity1 == 0)
146 {
147 resultentity = 0;
148 }
149 else
150 {
151 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
152 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
153 }
154 }
155 else
156 {
157 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
158 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
159 }
160
161 }
162
173 static void lineProduct3d( const int dim0 ,
174 const int entity0 ,
175 const int dim1 ,
176 const int entity1 ,
177 const int dim2 ,
178 const int entity2 ,
179 int &resultdim ,
180 int &resultentity )
181 {
182 // on vertex
183 if (dim0 == 0 && dim1 == 0 && dim2 == 0)
184 {
185 resultdim = 0;
186 if (entity0 == 0 && entity1 == 0 && entity2 == 0 )
187 {
188 resultentity = 0;
189 }
190 else if (entity0 == 0 && entity1 == 0 && entity2 == 1 )
191 {
192 resultentity = 4;
193 }
194 else if (entity0 == 0 && entity1 == 1 && entity2 == 0 )
195 {
196 resultentity = 3;
197 }
198 else if (entity0 == 0 && entity1 == 1 && entity2 == 1 )
199 {
200 resultentity = 7;
201 }
202 else if (entity0 == 1 && entity1 == 0 && entity2 == 0)
203 {
204 resultentity = 1;
205 }
206 else if (entity0 == 1 && entity1 == 0 && entity2 == 1)
207 {
208 resultentity = 5;
209 }
210 else if (entity0 == 1 && entity1 == 1 && entity2 == 0)
211 {
212 resultentity = 2;
213 }
214 else if (entity0 == 1 && entity1 == 1 && entity2 == 1)
215 {
216 resultentity = 6;
217 }
218 else
219 {
220 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
221 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
222 }
223 }
224 // LINES
225 // z coord is on line, other two on vertex, this makes an ascending vertical edge
226 else if (dim0 == 0 && dim1 == 0 && dim2 == 1)
227 {
228 resultdim = 1;
229 if (entity0 == 0 && entity1 == 0 && entity2 == 0)
230 {
231 resultentity = 8;
232 }
233 else if (entity0 == 0 && entity1 == 1 && entity2 == 0)
234 {
235 resultentity = 11;
236 }
237 else if (entity0 == 1 && entity1 == 0 && entity2 == 0)
238 {
239 resultentity = 9;
240 }
241 else if (entity0 == 1 && entity1 == 1 && entity2 == 0)
242 {
243 resultentity = 10;
244 }
245 else
246 {
247 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
248 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
249 }
250 }
251 // only y coord is on line, other two on vertex, this makes line along y axis
252 else if (dim0 == 0 && dim1 == 1 && dim2 == 0)
253 {
254 resultdim = 1;
255 if (entity0 == 0 && entity1 == 0 && entity2 == 0)
256 {
257 resultentity = 3;
258 }
259 else if (entity0 == 0 && entity1 == 0 && entity2 == 1)
260 {
261 resultentity = 7;
262 }
263 else if (entity0 == 1 && entity1 == 0 && entity2 == 0)
264 {
265 resultentity = 1;
266 }
267 else if (entity0 == 1 && entity1 == 0 && entity2 == 1)
268 {
269 resultentity = 5;
270 }
271 else
272 {
273 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
274 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
275 }
276 }
277 // x dof is on line, others on vertex.
278 else if (dim0 == 1 && dim1 == 0 && dim2 == 0)
279 {
280 resultdim = 1;
281 if (entity0 == 0 && entity1 == 0 && entity2 == 0)
282 {
283 resultentity = 0;
284 }
285 else if (entity0 == 0 && entity1 == 0 && entity2 == 1)
286 {
287 resultentity = 4;
288 }
289 else if (entity0 == 0 && entity1 == 1 && entity2 == 0)
290 {
291 resultentity = 2;
292 }
293 else if (entity0 == 0 && entity1 == 1 && entity2 == 1)
294 {
295 resultentity = 6;
296 }
297 else
298 {
299 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
300 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
301 }
302 }
303 // FACES, these require two of the line dimensions to be 1
304 else if (dim0 == 0 && dim1 == 1 && dim2 == 1)
305 {
306 resultdim = 2;
307 if (entity0 == 0 && entity1 == 0 && entity2 == 0)
308 {
309 resultentity = 3;
310 }
311 else if (entity0 == 1 && entity1 == 0 && entity2 == 0)
312 {
313 resultentity = 1;
314 }
315 else
316 {
317 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
318 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
319 }
320 }
321 else if (dim0 == 1 && dim1 == 0 && dim2 == 1)
322 {
323 resultdim = 2;
324 if (entity0 == 0 && entity1 == 0 && entity2 == 0)
325 {
326 resultentity = 0;
327 }
328 else if (entity0 == 0 && entity1 == 1 && entity2 == 0)
329 {
330 resultentity = 2;
331 }
332 else
333 {
334 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
335 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
336 }
337 }
338 else if (dim0 == 1 && dim1 == 1 && dim2 == 0)
339 {
340 resultdim = 2;
341 if (entity0 == 0 && entity1 == 0 && entity2 == 0)
342 {
343 resultentity = 4;
344 }
345 else if (entity0 == 0 && entity1 == 0 && entity2 == 1)
346 {
347 resultentity = 5;
348 }
349 else
350 {
351 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
352 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
353 }
354 }
355 // CELL ITSELF
356 else if (dim0 == 1 && dim1 == 1 && dim2 == 1)
357 {
358 resultdim = 3;
359 if (entity0 == 0 && entity1 == 0 && entity2 == 0)
360 {
361 resultentity = 0;
362 }
363 else
364 {
365 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
366 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
367 }
368 }
369 }
370
371 };
372}
373
374#endif
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)