Intrepid2
Intrepid2_DerivedBasisFamily.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid2 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 Mauro Perego (mperego@sandia.gov) or
38 // Nate Roberts (nvrober@sandia.gov)
39 //
40 // ************************************************************************
41 // @HEADER
42 
48 #ifndef Intrepid2_DerivedBasisFamily_h
49 #define Intrepid2_DerivedBasisFamily_h
50 
51 #include "Intrepid2_Basis.hpp"
52 
55 #include "Intrepid2_DerivedBasis_HDIV_QUAD.hpp"
57 
62 
67 
68 #include "Intrepid2_SerendipityBasis.hpp"
69 
70 namespace Intrepid2
71 {
74  {
75  public:
76  using HGRAD = void;
77  using HCURL = void;
78  using HDIV = void;
79  using HVOL = void;
80  };
81 
87  template<class LineBasisHGRAD, class LineBasisHVOL, class TriangleBasisFamily = EmptyBasisFamily, class TetrahedronBasisFamily = EmptyBasisFamily, class PyramidBasisFamily = EmptyBasisFamily>
89  {
90  public:
91  using ExecutionSpace = typename LineBasisHGRAD::ExecutionSpace;
92  using OutputValueType = typename LineBasisHGRAD::OutputValueType;
93  using PointValueType = typename LineBasisHGRAD::PointValueType;
94 
95  using Basis = typename LineBasisHGRAD::BasisBase;
96  using BasisPtr = Teuchos::RCP<Basis>;
97  using DeviceType = typename Basis::DeviceType;
98 
99  // line bases
100  using HGRAD_LINE = LineBasisHGRAD;
101  using HVOL_LINE = LineBasisHVOL;
102 
103  // quadrilateral bases
108 
109  // hexahedron bases
114 
115  // triangle bases
116  using HGRAD_TRI = typename TriangleBasisFamily::HGRAD;
117  using HCURL_TRI = typename TriangleBasisFamily::HCURL;
118  using HDIV_TRI = typename TriangleBasisFamily::HDIV;
119  using HVOL_TRI = typename TriangleBasisFamily::HVOL;
120 
121  // tetrahedron bases
122  using HGRAD_TET = typename TetrahedronBasisFamily::HGRAD;
123  using HCURL_TET = typename TetrahedronBasisFamily::HCURL;
124  using HDIV_TET = typename TetrahedronBasisFamily::HDIV;
125  using HVOL_TET = typename TetrahedronBasisFamily::HVOL;
126 
127  // wedge bases
132 
133  // pyramid bases
134  using HGRAD_PYR = typename PyramidBasisFamily::HGRAD;
135  using HCURL_PYR = typename PyramidBasisFamily::HCURL;
136  using HDIV_PYR = typename PyramidBasisFamily::HDIV;
137  using HVOL_PYR = typename PyramidBasisFamily::HVOL;
138  };
139 
145  template<class BasisFamily>
146  static typename BasisFamily::BasisPtr getLineBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
147  {
148  using Teuchos::rcp;
149  switch (fs)
150  {
151  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_LINE (polyOrder,pointType));
152  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_LINE(polyOrder,pointType));
153  default:
154  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
155  }
156  }
157 
163  template<class BasisFamily>
164  static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
165  {
166  using Teuchos::rcp;
167  switch (fs)
168  {
169  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder,pointType));
170  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder,pointType));
171  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder,pointType));
172  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder,pointType));
173  default:
174  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
175  }
176  }
177 
184  template<class BasisFamily>
185  static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y, const EPointType pointType=POINTTYPE_DEFAULT)
186  {
187  using Teuchos::rcp;
188  switch (fs)
189  {
190  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder_x,polyOrder_y,pointType));
191  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder_x,polyOrder_y,pointType));
192  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder_x,polyOrder_y,pointType));
193  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder_x,polyOrder_y,pointType));
194  default:
195  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
196  }
197  }
198 
204  template<class BasisFamily>
205  static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
206  {
207  using Teuchos::rcp;
208  switch (fs)
209  {
210  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder,pointType));
211  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder,pointType));
212  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder,pointType));
213  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder,pointType));
214  default:
215  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
216  }
217  }
218 
224  template<class BasisFamily>
225  static typename BasisFamily::BasisPtr getHypercubeBasis_HGRAD(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
226  {
227  using Teuchos::rcp;
228 
229  using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
230  using BasisPtr = typename BasisFamily::BasisPtr;
231 
232  BasisPtr lineBasis = getLineBasis<BasisFamily>(FUNCTION_SPACE_HGRAD, polyOrder);
233  BasisPtr tensorBasis = lineBasis;
234 
235  for (int d=1; d<spaceDim; d++)
236  {
237  tensorBasis = Teuchos::rcp(new Basis_TensorBasis<BasisBase>(tensorBasis, lineBasis, FUNCTION_SPACE_HGRAD));
238  }
239 
240  return tensorBasis;
241  }
242 
248  template<class BasisFamily>
249  static typename BasisFamily::BasisPtr getHypercubeBasis_HVOL(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
250  {
251  using Teuchos::rcp;
252 
253  using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
254  using BasisPtr = typename BasisFamily::BasisPtr;
255 
256  BasisPtr lineBasis = getLineBasis<BasisFamily>(FUNCTION_SPACE_HVOL, polyOrder);
257  BasisPtr tensorBasis = lineBasis;
258 
259  for (int d=1; d<spaceDim; d++)
260  {
261  tensorBasis = Teuchos::rcp(new Basis_TensorBasis<BasisBase>(tensorBasis, lineBasis, FUNCTION_SPACE_HVOL));
262  }
263 
264  return tensorBasis;
265  }
266 
274  template<class BasisFamily>
275  static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y, int polyOrder_z, const EPointType pointType=POINTTYPE_DEFAULT)
276  {
277  using Teuchos::rcp;
278  switch (fs)
279  {
280  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder_x,polyOrder_y,polyOrder_z,pointType));
281  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder_x,polyOrder_y,polyOrder_z,pointType));
282  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder_x,polyOrder_y,polyOrder_z,pointType));
283  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder_x,polyOrder_y,polyOrder_z,pointType));
284  default:
285  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
286  }
287  }
288 
293  template<class BasisFamily>
294  static typename BasisFamily::BasisPtr getSerendipityBasis_HGRAD(int polyOrder, int spaceDim)
295  {
296  auto fullBasis = getHypercubeBasis_HGRAD<BasisFamily>(polyOrder, spaceDim);
297 
298  using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
299 
300  auto serendipityBasis = Teuchos::rcp( new SerendipityBasis<BasisBase>(fullBasis) );
301  return serendipityBasis;
302  }
303 
308  template<class BasisFamily>
309  static typename BasisFamily::BasisPtr getSerendipityBasis_HVOL(int polyOrder, int spaceDim)
310  {
311  auto fullBasis = getHypercubeBasis_HVOL<BasisFamily>(polyOrder, spaceDim);
312 
313  using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
314 
315  auto serendipityBasis = Teuchos::rcp( new SerendipityBasis<BasisBase>(fullBasis) );
316  return serendipityBasis;
317  }
318 
324  template<class BasisFamily>
325  static typename BasisFamily::BasisPtr getTetrahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
326  {
327  using Teuchos::rcp;
328  switch (fs)
329  {
330  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TET (polyOrder,pointType));
331  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TET(polyOrder,pointType));
332  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TET (polyOrder,pointType));
333  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TET(polyOrder,pointType));
334  default:
335  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
336  }
337  }
338 
344  template<class BasisFamily>
345  static typename BasisFamily::BasisPtr getTriangleBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
346  {
347  using Teuchos::rcp;
348  switch (fs)
349  {
350  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TRI (polyOrder,pointType));
351  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TRI(polyOrder,pointType));
352  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TRI (polyOrder,pointType));
353  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TRI(polyOrder,pointType));
354  default:
355  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
356  }
357  }
358 
364  template<class BasisFamily>
365  static typename BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
366  {
367  using Teuchos::rcp;
368  switch (fs)
369  {
370  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_WEDGE (polyOrder, pointType));
371  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_WEDGE(polyOrder, pointType));
372  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_WEDGE (polyOrder, pointType));
373  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_WEDGE(polyOrder, pointType));
374  default:
375  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
376  }
377  }
378 
384  template<class BasisFamily>
385  static typename BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, ordinal_type polyOrder_xy, ordinal_type polyOrder_z, const EPointType pointType=POINTTYPE_DEFAULT)
386  {
387  using Teuchos::rcp;
388  switch (fs)
389  {
390  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_WEDGE (polyOrder_xy, polyOrder_z, pointType));
391  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_WEDGE(polyOrder_xy, polyOrder_z, pointType));
392  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_WEDGE (polyOrder_xy, polyOrder_z, pointType));
393  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_WEDGE(polyOrder_xy, polyOrder_z, pointType));
394  default:
395  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
396  }
397  }
398 
404  template<class BasisFamily>
405  static typename BasisFamily::BasisPtr getPyramidBasis(Intrepid2::EFunctionSpace fs, ordinal_type polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
406  {
407  using Teuchos::rcp;
408  switch (fs)
409  {
410  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_PYR (polyOrder, pointType));
411 // case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_PYR(polyOrder, pointType));
412  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_PYR (polyOrder, pointType));
413  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_PYR(polyOrder, pointType));
414  default:
415  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
416  }
417  }
418 
428  template<class BasisFamily>
429  static typename BasisFamily::BasisPtr getBasis(const shards::CellTopology &cellTopo, Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType = POINTTYPE_DEFAULT)
430  {
431  using Teuchos::rcp;
432  switch (cellTopo.getBaseKey())
433  {
434  case shards::Line<>::key: return getLineBasis<BasisFamily>(fs,polyOrder, pointType);
435  case shards::Quadrilateral<>::key: return getQuadrilateralBasis<BasisFamily>(fs,polyOrder,pointType);
436  case shards::Triangle<>::key: return getTriangleBasis<BasisFamily>(fs,polyOrder,pointType);
437  case shards::Hexahedron<>::key: return getHexahedronBasis<BasisFamily>(fs,polyOrder,pointType);
438  case shards::Tetrahedron<>::key: return getTetrahedronBasis<BasisFamily>(fs,polyOrder,pointType);
439  default:
440  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported cell topology");
441  }
442  }
443 } // end namespace Intrepid2
444 
445 #endif /* Intrepid2_DerivedBasisFamily_h */
EmptyBasisFamily allows us to set a default void family for a given topology.
Implementation of H(div) basis on the hexahedron that is templated on H(vol) and H(grad) on the line...
Implementation of H(vol) basis on the quadrilateral that is templated on H(vol) on the line...
Implementation of H(curl) basis on the quadrilateral that is templated on H(vol) and H(grad) on the l...
Device DeviceType
(Kokkos) Device type on which Basis is templated. Does not necessarily return true for Kokkos::is_dev...
Implementation of H(curl) basis on the hexahedron that is templated on H(vol) and H(grad) on the line...
Implementation of H(vol) basis on the wedge that is templated on H(grad) on the line, and H(grad) on the triangle.
Implementation of H(grad) basis on the quadrilateral that is templated on H(grad) on the line...
Implementation of H(vol) basis on the hexahedron that is templated on H(vol) on the line...
Implementation of H(div) basis on the wedge that is templated on H(div,tri), H(vol,tri), H(grad,line), and H(vol,line).
Implementation of H(vol) basis on the quadrilateral that is templated on H(vol) on the line...
A family of basis functions, constructed from H(vol) and H(grad) bases on the line.
Implementation of H(grad) basis on the hexahedron that is templated on H(grad) on the line...
Implementation of H(vol) basis on the quadrilateral that is templated on H(vol) on the line...
Implementation of H(curl) basis on the wedge that is templated on H(grad,tri), H(curl,tri), H(grad,line), and H(vol,line).
Implementation of H(grad) basis on the wedge that is templated on H(grad) on the line, and H(grad) on the triangle.
Header file for the abstract base class Intrepid2::Basis.