Intrepid2
Intrepid2_CellDataDef.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 
19 #ifndef __INTREPID2_CELLDATA_DEF_HPP__
20 #define __INTREPID2_CELLDATA_DEF_HPP__
21 
22 namespace Intrepid2 {
23 
24 template<typename DeviceType>
25 inline bool
27 isSupported( const unsigned cellTopoKey ) {
28  switch ( cellTopoKey ) {
29  case shards::Line<2>::key:
30  case shards::Line<3>::key:
31  case shards::ShellLine<2>::key:
32  case shards::ShellLine<3>::key:
33  case shards::Beam<2>::key:
34  case shards::Beam<3>::key:
35  case shards::Triangle<3>::key:
36  case shards::Triangle<4>::key:
37  case shards::Triangle<6>::key:
38  // case shards::ShellTriangle<3>::key:
39  // case shards::ShellTriangle<6>::key:
40  case shards::Quadrilateral<4>::key:
41  case shards::Quadrilateral<8>::key:
42  case shards::Quadrilateral<9>::key:
43  // case shards::ShellQuadrilateral<4>::key:
44  // case shards::ShellQuadrilateral<8>::key:
45  // case shards::ShellQuadrilateral<9>::key:
46  case shards::Tetrahedron<4>::key:
47  case shards::Tetrahedron<8>::key:
48  case shards::Tetrahedron<10>::key:
49  case shards::Tetrahedron<11>::key:
50  case shards::Hexahedron<8>::key:
51  case shards::Hexahedron<20>::key:
52  case shards::Hexahedron<27>::key:
53  case shards::Pyramid<5>::key:
54  case shards::Pyramid<13>::key:
55  case shards::Pyramid<14>::key:
56  case shards::Wedge<6>::key:
57  case shards::Wedge<15>::key:
58  case shards::Wedge<18>::key:
59  return true;
60  default:
61  return false;
62  }
63 }
64 
65 template<typename DeviceType>
66 inline
67 typename RefSubcellParametrization<DeviceType>::ConstViewType
69 get( const ordinal_type subcellDim,
70  const unsigned parentCellKey ) {
71 
72  if(!isSubcellParametrizationSet_)
73  set();
74 
75  ViewType subcellParam;
76 
77  switch (parentCellKey ) {
78  case shards::Tetrahedron<4>::key:
79  case shards::Tetrahedron<8>::key:
80  case shards::Tetrahedron<10>::key:
81  case shards::Tetrahedron<11>::key: subcellParam = ( subcellDim == 2 ? tetFacesParam : tetEdgesParam ); break;
82 
83  case shards::Hexahedron<8>::key:
84  case shards::Hexahedron<20>::key:
85  case shards::Hexahedron<27>::key: subcellParam = ( subcellDim == 2 ? hexFacesParam : hexEdgesParam ); break;
86 
87  case shards::Pyramid<5>::key:
88  case shards::Pyramid<13>::key:
89  case shards::Pyramid<14>::key: subcellParam = ( subcellDim == 2 ? pyrFacesParam : pyrEdgesParam ); break;
90 
91  case shards::Wedge<6>::key:
92  case shards::Wedge<15>::key:
93  case shards::Wedge<18>::key: subcellParam = ( subcellDim == 2 ? wedgeFacesParam : wedgeEdgesParam ); break;
94 
95  case shards::Triangle<3>::key:
96  case shards::Triangle<4>::key:
97  case shards::Triangle<6>::key: subcellParam = triEdgesParam; break;
98 
99  case shards::Quadrilateral<4>::key:
100  case shards::Quadrilateral<8>::key:
101  case shards::Quadrilateral<9>::key: subcellParam = quadEdgesParam; break;
102 
103  // case shards::ShellTriangle<3>::key:
104  // case shards::ShellTriangle<6>::key: subcellParam = ( subcellDim == 2 ? shellTriFacesParam : shellTriEdgesParam ); break;
105 
106  // case shards::ShellQuadrilateral<4>::key:
107  // case shards::ShellQuadrilateral<8>::key:
108  // case shards::ShellQuadrilateral<9>::key: subcellParam = ( subcellDim == 2 ? shellQuadFacesParam : shellQuadEdgesParam ); break;
109 
110  case shards::ShellLine<2>::key:
111  case shards::ShellLine<3>::key:
112  case shards::Beam<2>::key:
113  case shards::Beam<3>::key: subcellParam = lineEdgesParam; break;
114  default: {
115  INTREPID2_TEST_FOR_EXCEPTION( true, std::invalid_argument,
116  ">>> ERROR (Intrepid2::RefSubcellParametrization::get): invalid cell topology.");
117  }
118  }
119  return subcellParam;
120 }
121 
122 template<typename DeviceType>
123 void
125 
126  if(isSubcellParametrizationSet_)
127  return;
128 
129  ordinal_type subcellDim;
130  {
131  const auto tet = shards::CellTopology(shards::getCellTopologyData<shards::Tetrahedron<4> >());
132 
133  subcellDim = 2;
134  tetFacesParam = ViewType("CellTools::SubcellParametrization::tetFaces", tet.getSubcellCount(subcellDim), tet.getDimension(), subcellDim+1);
135  auto subcell2dParamHost = Kokkos::create_mirror_view(tetFacesParam);
136  set( subcell2dParamHost, subcellDim, tet );
137  deep_copy(tetFacesParam,subcell2dParamHost);
138 
139  subcellDim = 1;
140  tetEdgesParam = ViewType("CellTools::SubcellParametrization::tetEdges", tet.getSubcellCount(subcellDim), tet.getDimension(), subcellDim+1);
141  auto subcellParamHost = Kokkos::create_mirror_view(tetEdgesParam);
142  set( subcellParamHost, subcellDim, tet );
143  deep_copy(tetEdgesParam,subcellParamHost);
144  }
145  {
146  const auto hex = shards::CellTopology(shards::getCellTopologyData<shards::Hexahedron<8> >());
147 
148  subcellDim = 2;
149  hexFacesParam = ViewType("CellTools::SubcellParametrization::hexFaces", hex.getSubcellCount(subcellDim), hex.getDimension(), subcellDim+1);
150  auto subcell2dParamHost = Kokkos::create_mirror_view(hexFacesParam);
151  set( subcell2dParamHost, subcellDim, hex );
152  deep_copy(hexFacesParam,subcell2dParamHost);
153 
154  subcellDim = 1;
155  hexEdgesParam = ViewType("CellTools::SubcellParametrization::hexEdges", hex.getSubcellCount(subcellDim), hex.getDimension(), subcellDim+1);
156  auto subcellParamHost = Kokkos::create_mirror_view(hexEdgesParam);
157  set( subcellParamHost, subcellDim, hex );
158  deep_copy(hexEdgesParam,subcellParamHost);
159  }
160  {
161  const auto pyr = shards::CellTopology(shards::getCellTopologyData<shards::Pyramid<5> >());
162 
163  subcellDim = 2;
164  pyrFacesParam = ViewType("CellTools::SubcellParametrization::pyrFaces", pyr.getSubcellCount(subcellDim), pyr.getDimension(), subcellDim+1);
165  auto subcell2dParamHost = Kokkos::create_mirror_view(pyrFacesParam);
166  set( subcell2dParamHost, subcellDim, pyr );
167  deep_copy(pyrFacesParam,subcell2dParamHost);
168 
169  subcellDim = 1;
170  pyrEdgesParam = ViewType("CellTools::SubcellParametrization::pyrEdges", pyr.getSubcellCount(subcellDim), pyr.getDimension(), subcellDim+1);
171  auto subcellParamHost = Kokkos::create_mirror_view(pyrEdgesParam);
172  set( subcellParamHost, subcellDim, pyr );
173  deep_copy(pyrEdgesParam,subcellParamHost);
174  }
175  {
176  const auto wedge = shards::CellTopology(shards::getCellTopologyData<shards::Wedge<6> >());
177 
178  subcellDim = 2;
179  wedgeFacesParam = ViewType("CellTools::SubcellParametrization::wedgeFaces", wedge.getSubcellCount(subcellDim), wedge.getDimension(), subcellDim+1);
180  auto subcell2dParamHost = Kokkos::create_mirror_view(wedgeFacesParam);
181  set( subcell2dParamHost, subcellDim, wedge );
182  deep_copy(wedgeFacesParam,subcell2dParamHost);
183 
184  subcellDim = 1;
185  wedgeEdgesParam = ViewType("CellTools::SubcellParametrization::wedgeEdges", wedge.getSubcellCount(subcellDim), wedge.getDimension(), subcellDim+1);
186  auto subcellParamHost = Kokkos::create_mirror_view(wedgeEdgesParam);
187  set( subcellParamHost, subcellDim, wedge );
188  deep_copy(wedgeEdgesParam,subcellParamHost);
189  }
190  {
191  const auto tri = shards::CellTopology(shards::getCellTopologyData<shards::Triangle<3> >());
192 
193  subcellDim = 1;
194  triEdgesParam = ViewType("CellTools::SubcellParametrization::triEdges", tri.getSubcellCount(subcellDim), tri.getDimension(), subcellDim+1);
195  auto subcellParamHost = Kokkos::create_mirror_view(triEdgesParam);
196  set( subcellParamHost, subcellDim, tri );
197  deep_copy(triEdgesParam,subcellParamHost);
198  }
199  {
200  const auto quad = shards::CellTopology(shards::getCellTopologyData<shards::Quadrilateral<4> >());
201 
202  subcellDim = 1;
203  quadEdgesParam = ViewType("CellTools::SubcellParametrization::quadEdges", quad.getSubcellCount(subcellDim), quad.getDimension(), subcellDim+1);
204  auto subcellParamHost = Kokkos::create_mirror_view(quadEdgesParam);
205  set( subcellParamHost, subcellDim, quad );
206  deep_copy(quadEdgesParam,subcellParamHost);
207 
208  }
209  {
210  const auto line = shards::CellTopology(shards::getCellTopologyData<shards::ShellLine<2> >());
211 
212  subcellDim = 1;
213  lineEdgesParam = ViewType("CellTools::SubcellParametrization::lineEdges", line.getSubcellCount(subcellDim), line.getDimension(), subcellDim+1);
214  auto subcellParamHost = Kokkos::create_mirror_view(lineEdgesParam);
215  set( subcellParamHost, subcellDim, line );
216  deep_copy(lineEdgesParam,subcellParamHost);
217  }
218 
219  Kokkos::push_finalize_hook( [=] {
220  lineEdgesParam = ViewType();
221  triEdgesParam = ViewType();
222  quadEdgesParam = ViewType();
223  shellTriEdgesParam = ViewType();
224  shellQuadEdgesParam = ViewType();
225  tetEdgesParam = ViewType();
226  hexEdgesParam = ViewType();
227  pyrEdgesParam = ViewType();
228  wedgeEdgesParam = ViewType();
229  shellTriFacesParam = ViewType();
230  shellQuadFacesParam = ViewType();
231  tetFacesParam = ViewType();
232  hexFacesParam = ViewType();
233  pyrFacesParam = ViewType();
234  wedgeFacesParam = ViewType();
235  });
236 
237  isSubcellParametrizationSet_= true;
238 }
239 
240 template<typename DeviceType>
241 template <typename HostViewType>
242 void
244 set( HostViewType subcellParam,
245  const ordinal_type subcellDim,
246  const shards::CellTopology parentCell ) {
247  // subcellParametrization is rank-3 FieldContainer with dimensions (SC, PCD, COEF) where:
248  // - SC is the subcell count of subcells with the specified dimension in the parent cell
249  // - PCD is Parent Cell Dimension, which gives the number of coordinate functions in the map
250  // PCD = 2 for standard 2D cells and non-standard 2D cells: shell line and beam
251  // PCD = 3 for standard 3D cells and non-standard 3D cells: shell Tri and Quad
252  // - COEF is number of coefficients needed to specify a coordinate function:
253  // COEFF = 2 for edge parametrizations
254  // COEFF = 3 for both Quad and Tri face parametrizations. Because all Quad reference faces
255  // are affine, the coefficient of the bilinear term u*v is zero and is not stored, i.e.,
256  // 3 coefficients are sufficient to store Quad face parameterization maps.
257  //
258  // Edge parametrization maps [-1,1] to edge defined by (v0, v1)
259  // Face parametrization maps [-1,1]^2 to quadrilateral face (v0, v1, v2, v3), or
260  // standard 2-simplex {(0,0),(1,0),(0,1)} to traingle face (v0, v1, v2).
261  // This defines orientation-preserving parametrizations with respect to reference edge and
262  // face orientations induced by their vertex order.
263 
264  // get subcellParametrization dimensions: (sc, pcd, coeff)
265  const auto sc = parentCell.getSubcellCount(subcellDim);
266  const auto pcd = parentCell.getDimension();
267 
268  INTREPID2_TEST_FOR_EXCEPTION( subcellDim < 1 || subcellDim > static_cast<ordinal_type>(pcd-1), std::invalid_argument,
269  ">>> ERROR (Intrepid2::RefSubcellParametrization::set): Parametrizations defined in a range between 1 and (dim-1)");
270 
271  const auto refNodes = RefCellNodes<Kokkos::HostSpace>::get(parentCell.getKey());
272 
273  if (subcellDim == 1) {
274  // Edge parametrizations of 2D and 3D cells (shell lines and beams are 2D cells with edges)
275  for (size_type subcellOrd=0;subcellOrd<sc;++subcellOrd) {
276  // vertexK[0] = x_k; vertexK[1] = y_k; vertexK[2] = z_k; z_k = 0 for 2D cells
277  // Note that ShellLine and Beam are 2D cells!
278  const auto v0ord = parentCell.getNodeMap(subcellDim, subcellOrd, 0);
279  const auto v1ord = parentCell.getNodeMap(subcellDim, subcellOrd, 1);
280 
281  const auto v0 = Kokkos::subview(refNodes, v0ord, Kokkos::ALL());
282  const auto v1 = Kokkos::subview(refNodes, v1ord, Kokkos::ALL());
283 
284  // x(t) = (x0 + x1)/2 + t*(x1 - x0)/2
285  subcellParam(subcellOrd, 0, 0) = (v0(0) + v1(0))/2.0;
286  subcellParam(subcellOrd, 0, 1) = (v1(0) - v0(0))/2.0;
287 
288  // y(t) = (y0 + y1)/2 + t*(y1 - y0)/2
289  subcellParam(subcellOrd, 1, 0) = (v0(1) + v1(1))/2.0;
290  subcellParam(subcellOrd, 1, 1) = (v1(1) - v0(1))/2.0;
291 
292  if( pcd == 3 ) {
293  // z(t) = (z0 + z1)/2 + t*(z1 - z0)/2
294  subcellParam(subcellOrd, 2, 0) = (v0(2) + v1(2))/2.0;
295  subcellParam(subcellOrd, 2, 1) = (v1(2) - v0(2))/2.0;
296  }
297  }
298  }
299  else if (subcellDim == 2) {
300  // Face parametrizations of 3D cells: (shell Tri and Quad are 3D cells with faces)
301  // A 3D cell can have both Tri and Quad faces, but because they are affine images of the
302  // parametrization domain, 3 coefficients are enough to store them in both cases.
303  for (size_type subcellOrd=0;subcellOrd<sc;++subcellOrd) {
304 
305  switch (parentCell.getKey(subcellDim,subcellOrd)) {
306 
307  case shards::Triangle<3>::key:
308  case shards::Triangle<4>::key:
309  case shards::Triangle<6>::key: {
310  const auto v0ord = parentCell.getNodeMap(subcellDim, subcellOrd, 0);
311  const auto v1ord = parentCell.getNodeMap(subcellDim, subcellOrd, 1);
312  const auto v2ord = parentCell.getNodeMap(subcellDim, subcellOrd, 2);
313 
314  const auto v0 = Kokkos::subview(refNodes, v0ord, Kokkos::ALL());
315  const auto v1 = Kokkos::subview(refNodes, v1ord, Kokkos::ALL());
316  const auto v2 = Kokkos::subview(refNodes, v2ord, Kokkos::ALL());
317 
318  // x(u,v) = x0 + (x1 - x0)*u + (x2 - x0)*v
319  subcellParam(subcellOrd, 0, 0) = v0(0);
320  subcellParam(subcellOrd, 0, 1) = v1(0) - v0(0);
321  subcellParam(subcellOrd, 0, 2) = v2(0) - v0(0);
322 
323  // y(u,v) = y0 + (y1 - y0)*u + (y2 - y0)*v
324  subcellParam(subcellOrd, 1, 0) = v0(1);
325  subcellParam(subcellOrd, 1, 1) = v1(1) - v0(1);
326  subcellParam(subcellOrd, 1, 2) = v2(1) - v0(1);
327 
328  // z(u,v) = z0 + (z1 - z0)*u + (z2 - z0)*v
329  subcellParam(subcellOrd, 2, 0) = v0(2);
330  subcellParam(subcellOrd, 2, 1) = v1(2) - v0(2);
331  subcellParam(subcellOrd, 2, 2) = v2(2) - v0(2);
332  break;
333  }
334  case shards::Quadrilateral<4>::key:
335  case shards::Quadrilateral<8>::key:
336  case shards::Quadrilateral<9>::key: {
337  const auto v0ord = parentCell.getNodeMap(subcellDim, subcellOrd, 0);
338  const auto v1ord = parentCell.getNodeMap(subcellDim, subcellOrd, 1);
339  const auto v2ord = parentCell.getNodeMap(subcellDim, subcellOrd, 2);
340  const auto v3ord = parentCell.getNodeMap(subcellDim, subcellOrd, 3);
341 
342  const auto v0 = Kokkos::subview(refNodes, v0ord, Kokkos::ALL());
343  const auto v1 = Kokkos::subview(refNodes, v1ord, Kokkos::ALL());
344  const auto v2 = Kokkos::subview(refNodes, v2ord, Kokkos::ALL());
345  const auto v3 = Kokkos::subview(refNodes, v3ord, Kokkos::ALL());
346 
347  // x(u,v) = (x0+x1+x2+x3)/4+u*(-x0+x1+x2-x3)/4+v*(-x0-x1+x2+x3)/4+uv*(0=x0-x1+x2-x3)/4
348  subcellParam(subcellOrd, 0, 0) = ( v0(0) + v1(0) + v2(0) + v3(0))/4.0;
349  subcellParam(subcellOrd, 0, 1) = (-v0(0) + v1(0) + v2(0) - v3(0))/4.0;
350  subcellParam(subcellOrd, 0, 2) = (-v0(0) - v1(0) + v2(0) + v3(0))/4.0;
351 
352  // y(u,v) = (y0+y1+y2+y3)/4+u*(-y0+y1+y2-y3)/4+v*(-y0-y1+y2+y3)/4+uv*(0=y0-y1+y2-y3)/4
353  subcellParam(subcellOrd, 1, 0) = ( v0(1) + v1(1) + v2(1) + v3(1))/4.0;
354  subcellParam(subcellOrd, 1, 1) = (-v0(1) + v1(1) + v2(1) - v3(1))/4.0;
355  subcellParam(subcellOrd, 1, 2) = (-v0(1) - v1(1) + v2(1) + v3(1))/4.0;
356 
357  // z(u,v) = (z0+z1+z2+z3)/4+u*(-z0+z1+z2-z3)/4+v*(-z0-z1+z2+z3)/4+uv*(0=z0-z1+z2-z3)/4
358  subcellParam(subcellOrd, 2, 0) = ( v0(2) + v1(2) + v2(2) + v3(2))/4.0;
359  subcellParam(subcellOrd, 2, 1) = (-v0(2) + v1(2) + v2(2) - v3(2))/4.0;
360  subcellParam(subcellOrd, 2, 2) = (-v0(2) - v1(2) + v2(2) + v3(2))/4.0;
361  break;
362  }
363  default: {
364  INTREPID2_TEST_FOR_EXCEPTION( true, std::invalid_argument,
365  ">>> ERROR (Intrepid2::RefSubcellParametrization::set): parametrization not defined for the specified face topology.");
366  }
367  }
368  }
369  }
370 }
371 
372 
373 
374 template<typename DeviceType>
375 bool
377 isSubcellParametrizationSet_ = false;
378 
379 #define DefineStaticRefParametrization(obj) template<typename DeviceType> \
380  typename RefSubcellParametrization<DeviceType>::ViewType \
381  RefSubcellParametrization<DeviceType>:: \
382  obj = typename RefSubcellParametrization<DeviceType>::ViewType();
383 
384 DefineStaticRefParametrization(lineEdgesParam)
385 DefineStaticRefParametrization(triEdgesParam)
386 DefineStaticRefParametrization(quadEdgesParam)
387 DefineStaticRefParametrization(shellTriEdgesParam)
388 DefineStaticRefParametrization(shellQuadEdgesParam)
389 DefineStaticRefParametrization(tetEdgesParam)
390 DefineStaticRefParametrization(hexEdgesParam)
391 DefineStaticRefParametrization(pyrEdgesParam)
392 DefineStaticRefParametrization(wedgeEdgesParam)
393 DefineStaticRefParametrization(shellTriFacesParam)
394 DefineStaticRefParametrization(shellQuadFacesParam)
395 DefineStaticRefParametrization(tetFacesParam)
396 DefineStaticRefParametrization(hexFacesParam)
397 DefineStaticRefParametrization(pyrFacesParam)
398 DefineStaticRefParametrization(wedgeFacesParam)
399 
400 
401 template<typename DeviceType>
402 void
403 RefCellNodes<DeviceType>::set() {
404 
405  if(isReferenceNodeDataSet_)
406  return;
407 
408  auto createDataViewFromHostArray = [](const std::string& view_name, double const * source_array, ordinal_type dim){
409  ViewType dest_view(view_name, dim, 3);
410  auto host_view = Kokkos::create_mirror_view(dest_view);
411  for(ordinal_type i=0; i<dim; ++i)
412  for(ordinal_type j=0; j<3; ++j)
413  host_view(i,j) = source_array[3*i+j];
414  Kokkos::deep_copy(dest_view,host_view);
415  return dest_view;
416  };
417 
418  {
419  // create memory on devices
420  lineNodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::line", &refNodeDataStatic_.line[0][0], 2);
421  line3Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::line_3", &refNodeDataStatic_.line_3[0][0], 3);
422 
423  triangleNodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::triangle", &refNodeDataStatic_.triangle[0][0], 3);
424  triangle4Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::triangle_4", &refNodeDataStatic_.triangle_4[0][0], 4);
425  triangle6Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::triangle_6", &refNodeDataStatic_.triangle_6[0][0], 6);
426 
427  quadrilateralNodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::quad", &refNodeDataStatic_.quadrilateral[0][0], 4);
428  quadrilateral8Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::quad_8", &refNodeDataStatic_.quadrilateral_8[0][0], 8);
429  quadrilateral9Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::quad_9", &refNodeDataStatic_.quadrilateral_9[0][0], 9);
430 
431  tetrahedronNodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::tet", &refNodeDataStatic_.tetrahedron[0][0], 4);
432  tetrahedron8Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::tet_8", &refNodeDataStatic_.tetrahedron_8[0][0], 8);
433  tetrahedron10Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::tet_10", &refNodeDataStatic_.tetrahedron_10[0][0], 10);
434  tetrahedron11Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::tet_11", &refNodeDataStatic_.tetrahedron_11[0][0], 11);
435 
436  hexahedronNodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::hex", &refNodeDataStatic_.hexahedron[0][0], 8);
437  hexahedron20Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::hex_20", &refNodeDataStatic_.hexahedron_20[0][0], 20);
438  hexahedron27Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::hex_27", &refNodeDataStatic_.hexahedron_27[0][0], 27);
439 
440  pyramidNodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::pyr", &refNodeDataStatic_.pyramid[0][0], 5);
441  pyramid13Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::pyr_13", &refNodeDataStatic_.pyramid_13[0][0], 13);
442  pyramid14Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::pyr_14", &refNodeDataStatic_.pyramid_14[0][0], 14);
443 
444  wedgeNodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::wedge", &refNodeDataStatic_.wedge[0][0], 6);
445  wedge15Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::wedge_15", &refNodeDataStatic_.wedge_15[0][0], 15);
446  wedge18Nodes = createDataViewFromHostArray("CellTools::ReferenceNodeData::wedge_18", &refNodeDataStatic_.wedge_18[0][0], 18);
447  }
448 
449  Kokkos::push_finalize_hook( [=] {
450 
451  lineNodes = ViewType();
452  line3Nodes = ViewType();
453 
454  triangleNodes = ViewType();
455  triangle4Nodes = ViewType();
456  triangle6Nodes = ViewType();
457 
458  quadrilateralNodes = ViewType();
459  quadrilateral8Nodes = ViewType();
460  quadrilateral9Nodes = ViewType();
461 
462  tetrahedronNodes = ViewType();
463  tetrahedron8Nodes = ViewType();
464  tetrahedron10Nodes = ViewType();
465  tetrahedron11Nodes = ViewType();
466 
467  hexahedronNodes = ViewType();
468  hexahedron20Nodes = ViewType();
469  hexahedron27Nodes = ViewType();
470 
471  pyramidNodes = ViewType();
472  pyramid13Nodes = ViewType();
473  pyramid14Nodes = ViewType();
474 
475  wedgeNodes = ViewType();
476  wedge15Nodes = ViewType();
477  wedge18Nodes = ViewType();
478  } );
479 
480  isReferenceNodeDataSet_ = true;
481 }
482 
483 template<typename DeviceType>
484 inline
485 typename RefCellNodes<DeviceType>::ConstViewType
486 RefCellNodes<DeviceType>::get(const unsigned cellTopoKey){
487 
488  if(!isReferenceNodeDataSet_)
489  set();
490 
491  ViewType refNodes;
492 
493  switch (cellTopoKey ) {
494  case shards::Line<2>::key:
495  case shards::ShellLine<2>::key:
496  case shards::Beam<2>::key: refNodes = lineNodes; break;
497  case shards::Line<3>::key:
498  case shards::ShellLine<3>::key:
499  case shards::Beam<3>::key: refNodes = line3Nodes; break;
500 
501  case shards::Triangle<3>::key:
502  case shards::ShellTriangle<3>::key: refNodes = triangleNodes; break;
503  case shards::Triangle<4>::key: refNodes = triangle4Nodes; break;
504  case shards::Triangle<6>::key:
505  case shards::ShellTriangle<6>::key: refNodes = triangle6Nodes; break;
506 
507  case shards::Quadrilateral<4>::key:
508  case shards::ShellQuadrilateral<4>::key: refNodes = quadrilateralNodes; break;
509  case shards::Quadrilateral<8>::key:
510  case shards::ShellQuadrilateral<8>::key: refNodes = quadrilateral8Nodes; break;
511  case shards::Quadrilateral<9>::key:
512  case shards::ShellQuadrilateral<9>::key: refNodes = quadrilateral9Nodes; break;
513 
514  case shards::Tetrahedron<4>::key: refNodes = tetrahedronNodes; break;
515  case shards::Tetrahedron<8>::key: refNodes = tetrahedron8Nodes; break;
516  case shards::Tetrahedron<10>::key: refNodes = tetrahedron10Nodes; break;
517  case shards::Tetrahedron<11>::key: refNodes = tetrahedron11Nodes; break;
518 
519  case shards::Hexahedron<8>::key: refNodes = hexahedronNodes; break;
520  case shards::Hexahedron<20>::key: refNodes = hexahedron20Nodes; break;
521  case shards::Hexahedron<27>::key: refNodes = hexahedron27Nodes; break;
522 
523  case shards::Pyramid<5>::key: refNodes = pyramidNodes; break;
524  case shards::Pyramid<13>::key: refNodes = pyramid13Nodes; break;
525  case shards::Pyramid<14>::key: refNodes = pyramid14Nodes; break;
526 
527  case shards::Wedge<6>::key: refNodes = wedgeNodes; break;
528  case shards::Wedge<15>::key: refNodes = wedge15Nodes; break;
529  case shards::Wedge<18>::key: refNodes = wedge18Nodes; break;
530 
531  default: {
532  INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE( true, std::invalid_argument,
533  ">>> ERROR (Intrepid2::CellTools::getReferenceNode): invalid cell topology.");
534  }
535  }
536  return refNodes;
537 }
538 
539 template<typename DeviceType>
540 bool
542 isReferenceNodeDataSet_ = false;
543 
544 #define DefineStaticRefNodes(obj) template<typename DeviceType> \
545  typename RefCellNodes<DeviceType>::ViewType \
546  RefCellNodes<DeviceType>:: \
547  obj = typename RefCellNodes<DeviceType>::ViewType();
548 
549 DefineStaticRefNodes(lineNodes)
550 DefineStaticRefNodes(line3Nodes)
551 
552 DefineStaticRefNodes(triangleNodes)
553 DefineStaticRefNodes(triangle4Nodes)
554 DefineStaticRefNodes(triangle6Nodes)
555 
556 DefineStaticRefNodes(quadrilateralNodes)
557 DefineStaticRefNodes(quadrilateral8Nodes)
558 DefineStaticRefNodes(quadrilateral9Nodes)
559 
560 DefineStaticRefNodes(tetrahedronNodes)
561 DefineStaticRefNodes(tetrahedron8Nodes)
562 DefineStaticRefNodes(tetrahedron10Nodes)
563 DefineStaticRefNodes(tetrahedron11Nodes)
564 
565 DefineStaticRefNodes(hexahedronNodes)
566 DefineStaticRefNodes(hexahedron20Nodes)
567 DefineStaticRefNodes(hexahedron27Nodes)
568 
569 DefineStaticRefNodes(pyramidNodes)
570 DefineStaticRefNodes(pyramid13Nodes)
571 DefineStaticRefNodes(pyramid14Nodes)
572 
573 DefineStaticRefNodes(wedgeNodes)
574 DefineStaticRefNodes(wedge15Nodes)
575 DefineStaticRefNodes(wedge18Nodes)
576 
577 template<typename DeviceType>
578 const typename RefCellNodes<DeviceType>::ReferenceNodeDataStatic
579 RefCellNodes<DeviceType>::
580 refNodeDataStatic_ = {
581  // line
582  { // 2
583  {-1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}
584  },
585  { // 3
586  {-1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 0.0, 0.0}
587  },
588  // triangle
589  { // 3
590  { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}
591  },
592  { // 4
593  { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 1.0/3.0, 1.0/3.0, 0.0}
594  },
595  { // 6
596  { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0},
597  { 0.5, 0.0, 0.0}, { 0.5, 0.5, 0.0}, { 0.0, 0.5, 0.0}
598  },
599  // quad
600  { // 4
601  {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}
602  },
603  { // 8
604  {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0},
605  { 0.0,-1.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0}
606  },
607  { // 9
608  {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0},
609  { 0.0,-1.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0}, { 0.0, 0.0, 0.0}
610  },
611  // tet
612  { // 4
613  { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, 1.0}
614  },
615  { // 8
616  { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
617  { 1.0/3.0, 0.0, 1.0/3.0}, { 1.0/3.0, 1.0/3.0, 1.0/3.0}, { 1.0/3.0, 1.0/3.0, 0.0}, { 0.0, 1.0/3.0, 1.0/3.0}
618  },
619  { // 10
620  { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
621  { 0.5, 0.0, 0.0}, { 0.5, 0.5, 0.0}, { 0.0, 0.5, 0.0}, { 0.0, 0.0, 0.5}, { 0.5, 0.0, 0.5}, { 0.0, 0.5, 0.5}
622  },
623  { // 11
624  { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
625  { 0.5, 0.0, 0.0}, { 0.5, 0.5, 0.0}, { 0.0, 0.5, 0.0}, { 0.0, 0.0, 0.5}, { 0.5, 0.0, 0.5}, { 0.0, 0.5, 0.5}
626  },
627  // hex
628  { // 8
629  {-1.0,-1.0,-1.0}, { 1.0,-1.0,-1.0}, { 1.0, 1.0,-1.0}, {-1.0, 1.0,-1.0},
630  {-1.0,-1.0, 1.0}, { 1.0,-1.0, 1.0}, { 1.0, 1.0, 1.0}, {-1.0, 1.0, 1.0}
631  },
632  { // 20
633  {-1.0,-1.0,-1.0}, { 1.0,-1.0,-1.0}, { 1.0, 1.0,-1.0}, {-1.0, 1.0,-1.0},
634  {-1.0,-1.0, 1.0}, { 1.0,-1.0, 1.0}, { 1.0, 1.0, 1.0}, {-1.0, 1.0, 1.0},
635  { 0.0,-1.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, {-1.0, 0.0,-1.0},
636  {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0},
637  { 0.0,-1.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0}, {-1.0, 0.0, 1.0}
638  },
639  { // 27
640  {-1.0,-1.0,-1.0}, { 1.0,-1.0,-1.0}, { 1.0, 1.0,-1.0}, {-1.0, 1.0,-1.0},
641  {-1.0,-1.0, 1.0}, { 1.0,-1.0, 1.0}, { 1.0, 1.0, 1.0}, {-1.0, 1.0, 1.0},
642  { 0.0,-1.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, {-1.0, 0.0,-1.0},
643  {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0},
644  { 0.0,-1.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0}, {-1.0, 0.0, 1.0},
645  { 0.0, 0.0, 0.0},
646  { 0.0, 0.0,-1.0}, { 0.0, 0.0, 1.0}, {-1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, {0.0,-1.0, 0.0}, {0.0, 1.0, 0.0}
647  },
648  // pyramid
649  { // 5
650  {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}, { 0.0, 0.0, 1.0}
651  },
652  { // 13
653  {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
654  { 0.0,-1.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0},
655  {-0.5,-0.5, 0.5}, { 0.5,-0.5, 0.5}, { 0.5, 0.5, 0.5}, {-0.5, 0.5, 0.5}
656  },
657  { // 14
658  {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
659  { 0.0,-1.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0},
660  {-0.5,-0.5, 0.5}, { 0.5,-0.5, 0.5}, { 0.5, 0.5, 0.5}, {-0.5, 0.5, 0.5}, { 0.0, 0.0, 0.0}
661  },
662  // wedge
663  { // 6
664  { 0.0, 0.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, { 0.0, 0.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0}
665  },
666  { // 15
667  { 0.0, 0.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, { 0.0, 0.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0},
668  { 0.5, 0.0,-1.0}, { 0.5, 0.5,-1.0}, { 0.0, 0.5,-1.0}, { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0},
669  { 0.5, 0.0, 1.0}, { 0.5, 0.5, 1.0}, { 0.0, 0.5, 1.0}
670  },
671  { // 18
672  { 0.0, 0.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, { 0.0, 0.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0},
673  { 0.5, 0.0,-1.0}, { 0.5, 0.5,-1.0}, { 0.0, 0.5,-1.0}, { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0},
674  { 0.5, 0.0, 1.0}, { 0.5, 0.5, 1.0}, { 0.0, 0.5, 1.0},
675  { 0.5, 0.0, 0.0}, { 0.5, 0.5, 0.0}, { 0.0, 0.5, 0.0}
676  }
677 };
678 
679 template<typename DeviceType>
680 void
682 
683  if(isReferenceCellCenterDataSet_)
684  return;
685 
686  auto createDataViewFromHostArray = [](const std::string& view_name, double const * source_array){
687  ViewType dest_view(view_name, 3);
688  auto host_view = Kokkos::create_mirror_view(dest_view);
689  for(ordinal_type i=0; i<3; ++i) host_view[i] = source_array[i];
690  Kokkos::deep_copy(dest_view, host_view);
691  return dest_view;
692  };
693 
694  {
695  // create memory on devices
696  lineCenter = createDataViewFromHostArray("CellTools::ReferenceCenterData::line", &refCenterDataStatic_.line[0]);
697 
698  triangleCenter = createDataViewFromHostArray("CellTools::ReferenceCenterData::triangle", &refCenterDataStatic_.triangle[0]);
699 
700  quadrilateralCenter = createDataViewFromHostArray("CellTools::ReferenceCenterData::quad", &refCenterDataStatic_.quadrilateral[0]);
701 
702  tetrahedronCenter = createDataViewFromHostArray("CellTools::ReferenceCenterData::tet", &refCenterDataStatic_.tetrahedron[0]);
703 
704  hexahedronCenter = createDataViewFromHostArray("CellTools::ReferenceCenterData::hex", &refCenterDataStatic_.hexahedron[0]);
705 
706  pyramidCenter = createDataViewFromHostArray("CellTools::ReferenceCenterData::pyr", &refCenterDataStatic_.pyramid[0]);
707 
708  wedgeCenter = createDataViewFromHostArray("CellTools::ReferenceCenterData::wedge", &refCenterDataStatic_.wedge[0]);
709  }
710 
711  Kokkos::push_finalize_hook( [=] {
712 
713  lineCenter = ViewType();
714 
715  triangleCenter = ViewType();
716 
717  quadrilateralCenter = ViewType();
718 
719  tetrahedronCenter = ViewType();
720 
721  hexahedronCenter = ViewType();
722 
723  pyramidCenter = ViewType();
724 
725  wedgeCenter = ViewType();
726  } );
727 
728  isReferenceCellCenterDataSet_ = true;
729 }
730 
731 template<typename DeviceType>
732 inline
733 typename RefCellCenter<DeviceType>::ConstViewType
734 RefCellCenter<DeviceType>::get(const unsigned cellTopoKey){
735 
736  if(!isReferenceCellCenterDataSet_)
737  set();
738 
739  ViewType cellCenter;
740 
741  switch (cellTopoKey ) {
742  case shards::Line<2>::key:
743  case shards::ShellLine<2>::key:
744  case shards::Beam<2>::key:
745  case shards::Line<3>::key:
746  case shards::ShellLine<3>::key:
747  case shards::Beam<3>::key: cellCenter = lineCenter; break;
748 
749  case shards::Triangle<3>::key:
750  case shards::ShellTriangle<3>::key:
751  case shards::Triangle<4>::key:
752  case shards::Triangle<6>::key:
753  case shards::ShellTriangle<6>::key: cellCenter = triangleCenter; break;
754 
755  case shards::Quadrilateral<4>::key:
756  case shards::ShellQuadrilateral<4>::key:
757  case shards::Quadrilateral<8>::key:
758  case shards::ShellQuadrilateral<8>::key:
759  case shards::Quadrilateral<9>::key:
760  case shards::ShellQuadrilateral<9>::key: cellCenter = quadrilateralCenter; break;
761 
762  case shards::Tetrahedron<4>::key:
763  case shards::Tetrahedron<8>::key:
764  case shards::Tetrahedron<10>::key:
765  case shards::Tetrahedron<11>::key: cellCenter = tetrahedronCenter; break;
766 
767  case shards::Hexahedron<8>::key:
768  case shards::Hexahedron<20>::key:
769  case shards::Hexahedron<27>::key: cellCenter = hexahedronCenter; break;
770 
771  case shards::Pyramid<5>::key:
772  case shards::Pyramid<13>::key:
773  case shards::Pyramid<14>::key: cellCenter = pyramidCenter; break;
774 
775  case shards::Wedge<6>::key:
776  case shards::Wedge<15>::key:
777  case shards::Wedge<18>::key: cellCenter = wedgeCenter; break;
778 
779  default: {
780  INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE( true, std::invalid_argument,
781  ">>> ERROR (Intrepid2::CellTools::getReferenceCellCenter): invalid cell topology.");
782  }
783  }
784  return cellCenter;
785 }
786 
787 template<typename DeviceType>
788 bool
790 isReferenceCellCenterDataSet_ = false;
791 
792 #define DefineStaticRefCenter(obj) template<typename DeviceType> \
793  typename RefCellCenter<DeviceType>::ViewType \
794  RefCellCenter<DeviceType>:: \
795  obj = typename RefCellCenter<DeviceType>::ViewType();
796 
797 DefineStaticRefCenter(lineCenter)
798 DefineStaticRefCenter(triangleCenter)
799 DefineStaticRefCenter(quadrilateralCenter)
800 DefineStaticRefCenter(tetrahedronCenter)
801 DefineStaticRefCenter(hexahedronCenter)
802 DefineStaticRefCenter(pyramidCenter)
803 DefineStaticRefCenter(wedgeCenter)
804 
805 template<typename DeviceType>
806 const typename RefCellCenter<DeviceType>::ReferenceCenterDataStatic
807 RefCellCenter<DeviceType>::
808 refCenterDataStatic_ = {
809  // line
810  {0.0, 0.0, 0.0},
811  // triangle
812  { 1.0/3.0, 1.0/3.0, 0.0},
813  // quad
814  {0.0, 0.0, 0.0},
815  // tet
816  { 0.25, 0.25, 0.25},
817  // hex
818  { 0.0, 0.0, 0.0},
819  // pyramid
820  { 0.0, 0.0, 0.25},
821  // wedge
822  { 1.0/3.0, 1.0/3.0, 0.0},
823 };
824 
825 
826 // Point Inclusion
827 
828 
829  template<typename PointViewType, typename ScalarType>
830  KOKKOS_INLINE_FUNCTION
831  bool
832  PointInclusion<shards::Line<>::key>::
833  check(const PointViewType &point, const ScalarType threshold) {
834  //this implementation should work when PointType is a Sacado Fad<ScalarType>
835  const ScalarType minus_one = -1.0 - threshold, plus_one = 1.0 + threshold;
836  return (minus_one <= point(0) && point(0) <= plus_one);
837  }
838 
839  template<typename PointViewType, typename ScalarType>
840  KOKKOS_INLINE_FUNCTION
841  bool
842  PointInclusion<shards::Triangle<>::key>::
843  check(const PointViewType &point, const ScalarType threshold) {
844  //this implementation should work when PointType is a Sacado Fad<ScalarType>
845  using PointType = typename PointViewType::value_type;
846  const PointType one = 1.0;
847  const PointType distance = max( max( -point(0), -point(1) ), point(0) + point(1) - one );
848  return distance < threshold;
849  }
850 
851  template<typename PointViewType, typename ScalarType>
852  KOKKOS_INLINE_FUNCTION
853  bool
854  PointInclusion<shards::Quadrilateral<>::key>::
855  check(const PointViewType &point, const ScalarType threshold) {
856  //this implementation should work when PointType is a Sacado Fad<ScalarType>
857  const ScalarType minus_one = -1.0 - threshold, plus_one = 1.0 + threshold;
858  return ((minus_one <= point(0) && point(0) <= plus_one) &&
859  (minus_one <= point(1) && point(1) <= plus_one));
860  }
861 
862  template<typename PointViewType, typename ScalarType>
863  KOKKOS_INLINE_FUNCTION
864  bool
865  PointInclusion<shards::Tetrahedron<>::key>::
866  check(const PointViewType &point, const ScalarType threshold) {
867  //this implementation should work when PointType is a Sacado Fad<ScalarType>
868  using PointType = typename PointViewType::value_type;
869  const PointType one = 1.0;
870  const PointType distance = max( max(-point(0),-point(1)),
871  max(-point(2), point(0) + point(1) + point(2) - one) );
872  return distance < threshold;
873  }
874 
875  template<typename PointViewType, typename ScalarType>
876  KOKKOS_INLINE_FUNCTION
877  bool
878  PointInclusion<shards::Hexahedron<>::key>::
879  check(const PointViewType &point, const ScalarType threshold) {
880  //this implementation should work when PointType is a Sacado Fad<ScalarType>
881  const ScalarType minus_one = -1.0 - threshold, plus_one = 1.0 + threshold;
882  return ((minus_one <= point(0) && point(0) <= plus_one) &&
883  (minus_one <= point(1) && point(1) <= plus_one) &&
884  (minus_one <= point(2) && point(2) <= plus_one));
885  }
886 
887  template<typename PointViewType, typename ScalarType>
888  KOKKOS_INLINE_FUNCTION
889  bool
890  PointInclusion<shards::Pyramid<>::key>::
891  check(const PointViewType &point, const ScalarType threshold) {
892  //this implementation should work when PointType is a Sacado Fad<ScalarType>
893  using PointType = typename PointViewType::value_type;
894  const PointType minus_one = -1.0 - threshold, plus_one = 1.0 + threshold, minus_zero = -threshold;
895  const PointType left = minus_one + point(2);
896  const PointType right = plus_one - point(2);
897  return ((left <= point(0) && point(0) <= right) &&
898  (left <= point(1) && point(1) <= right) &&
899  (minus_zero <= point(2) && point(2) <= plus_one));
900  }
901 
902  template<typename PointViewType, typename ScalarType>
903  KOKKOS_INLINE_FUNCTION
904  bool
905  PointInclusion<shards::Wedge<>::key>::
906  check(const PointViewType &point, const ScalarType threshold) {
907  //this implementation should work when PointType is a Sacado Fad<ScalarType>
908  using PointType = typename PointViewType::value_type;
909  const ScalarType minus_one = -1.0 - threshold, plus_one = 1.0 + threshold;
910  const PointType one = 1.0;
911  const PointType distance = max( max( -point(0), -point(1) ), point(0) + point(1) - one );
912  return (distance < threshold && (minus_one <= point(2) && point(2) <= plus_one));
913  }
914 
915 } // Intrepid2 namespace
916 
917 #endif
918 
This class defines the coordinates of the barycenter of the supported reference cells. The barycenter coordinates are stored in static views. The class is templated on the Kokkos::Device Type which is used to determine layout and memory space of the views.
Kokkos::DynRankView< double, DeviceType > ViewType
static views containing the center coordinates allocated on DeviceType::memory_space ...
static ConstViewType get(const unsigned cellTopoKey)
Retrieves the Cartesian coordinates of reference cell nodes.
#define INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(test, x, msg)
static ConstViewType get(const ordinal_type subcellDim, const unsigned parentCellKey)
Returns a Kokkos view with the coefficients of the parametrization maps for the edges or faces of a r...
Kokkos::DynRankView< double, DeviceType > ViewType
static views containing the parametrization maps, allocated on DeviceType::memory_space ...
This class defines the coordinates of the nodes of reference cells according for supported cell topol...
static bool isSupported(const unsigned cellTopoKey)
Checks if a cell topology has a reference parametrization.
static void set()
Computes and stores static views containing the parametrizations maps of edges and faces of all refer...
static ConstViewType get(const unsigned cellTopoKey)
Retrieves the Cartesian coordinates of a reference cell barycenter.
Kokkos::DynRankView< double, DeviceType > ViewType
static views containing the node coordinates allocated on DeviceType::memory_space ...
This class defines the parametrizations of edges and faces of supported reference cells...
static void set()
Set center coordinates of reference cell for supported topologies.