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 Kyungjoo Kim (kyukim@sandia.gov),
38 // Mauro Perego (mperego@sandia.gov), or
39 // Nate Roberts (nvrober@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
49 #ifndef Intrepid2_DerivedBasisFamily_h
50 #define Intrepid2_DerivedBasisFamily_h
51 
52 #include "Intrepid2_Basis.hpp"
53 
56 #include "Intrepid2_DerivedBasis_HDIV_QUAD.hpp"
58 
63 
68 
69 #include "Intrepid2_SerendipityBasis.hpp"
70 
71 namespace Intrepid2
72 {
75  {
76  public:
77  using HGRAD = void;
78  using HCURL = void;
79  using HDIV = void;
80  using HVOL = void;
81  };
82 
88  template<class LineBasisHGRAD, class LineBasisHVOL, class TriangleBasisFamily = EmptyBasisFamily, class TetrahedronBasisFamily = EmptyBasisFamily>
90  {
91  public:
92  using ExecutionSpace = typename LineBasisHGRAD::ExecutionSpace;
93  using OutputValueType = typename LineBasisHGRAD::OutputValueType;
94  using PointValueType = typename LineBasisHGRAD::PointValueType;
95 
96  using Basis = typename LineBasisHGRAD::BasisBase;
97  using BasisPtr = Teuchos::RCP<Basis>;
98  using DeviceType = typename Basis::DeviceType;
99 
100  // line bases
101  using HGRAD_LINE = LineBasisHGRAD;
102  using HVOL_LINE = LineBasisHVOL;
103 
104  // quadrilateral bases
109 
110  // hexahedron bases
115 
116  // triangle bases
117  using HGRAD_TRI = typename TriangleBasisFamily::HGRAD;
118  using HCURL_TRI = typename TriangleBasisFamily::HCURL;
119  using HDIV_TRI = typename TriangleBasisFamily::HDIV;
120  using HVOL_TRI = typename TriangleBasisFamily::HVOL;
121 
122  // tetrahedron bases
123  using HGRAD_TET = typename TetrahedronBasisFamily::HGRAD;
124  using HCURL_TET = typename TetrahedronBasisFamily::HCURL;
125  using HDIV_TET = typename TetrahedronBasisFamily::HDIV;
126  using HVOL_TET = typename TetrahedronBasisFamily::HVOL;
127 
128  // wedge bases
133  };
134 
140  template<class BasisFamily>
141  static typename BasisFamily::BasisPtr getLineBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
142  {
143  using Teuchos::rcp;
144  switch (fs)
145  {
146  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_LINE (polyOrder,pointType));
147  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_LINE(polyOrder,pointType));
148  default:
149  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
150  }
151  }
152 
158  template<class BasisFamily>
159  static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
160  {
161  using Teuchos::rcp;
162  switch (fs)
163  {
164  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder,pointType));
165  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder,pointType));
166  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder,pointType));
167  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder,pointType));
168  default:
169  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
170  }
171  }
172 
179  template<class BasisFamily>
180  static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y, const EPointType pointType=POINTTYPE_DEFAULT)
181  {
182  using Teuchos::rcp;
183  switch (fs)
184  {
185  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder_x,polyOrder_y,pointType));
186  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder_x,polyOrder_y,pointType));
187  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder_x,polyOrder_y,pointType));
188  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder_x,polyOrder_y,pointType));
189  default:
190  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
191  }
192  }
193 
199  template<class BasisFamily>
200  static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
201  {
202  using Teuchos::rcp;
203  switch (fs)
204  {
205  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder,pointType));
206  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder,pointType));
207  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder,pointType));
208  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder,pointType));
209  default:
210  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
211  }
212  }
213 
219  template<class BasisFamily>
220  static typename BasisFamily::BasisPtr getHypercubeBasis_HGRAD(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
221  {
222  using Teuchos::rcp;
223 
224  using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
225  using BasisPtr = typename BasisFamily::BasisPtr;
226 
227  BasisPtr lineBasis = getLineBasis<BasisFamily>(FUNCTION_SPACE_HGRAD, polyOrder);
228  BasisPtr tensorBasis = lineBasis;
229 
230  for (int d=1; d<spaceDim; d++)
231  {
232  tensorBasis = Teuchos::rcp(new Basis_TensorBasis<BasisBase>(tensorBasis, lineBasis, FUNCTION_SPACE_HGRAD));
233  }
234 
235  return tensorBasis;
236  }
237 
243  template<class BasisFamily>
244  static typename BasisFamily::BasisPtr getHypercubeBasis_HVOL(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
245  {
246  using Teuchos::rcp;
247 
248  using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
249  using BasisPtr = typename BasisFamily::BasisPtr;
250 
251  BasisPtr lineBasis = getLineBasis<BasisFamily>(FUNCTION_SPACE_HVOL, polyOrder);
252  BasisPtr tensorBasis = lineBasis;
253 
254  for (int d=1; d<spaceDim; d++)
255  {
256  tensorBasis = Teuchos::rcp(new Basis_TensorBasis<BasisBase>(tensorBasis, lineBasis, FUNCTION_SPACE_HVOL));
257  }
258 
259  return tensorBasis;
260  }
261 
269  template<class BasisFamily>
270  static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y, int polyOrder_z, const EPointType pointType=POINTTYPE_DEFAULT)
271  {
272  using Teuchos::rcp;
273  switch (fs)
274  {
275  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder_x,polyOrder_y,polyOrder_z,pointType));
276  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder_x,polyOrder_y,polyOrder_z,pointType));
277  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder_x,polyOrder_y,polyOrder_z,pointType));
278  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder_x,polyOrder_y,polyOrder_z,pointType));
279  default:
280  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
281  }
282  }
283 
288  template<class BasisFamily>
289  static typename BasisFamily::BasisPtr getSerendipityBasis_HGRAD(int polyOrder, int spaceDim)
290  {
291  auto fullBasis = getHypercubeBasis_HGRAD<BasisFamily>(polyOrder, spaceDim);
292 
293  using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
294 
295  auto serendipityBasis = Teuchos::rcp( new SerendipityBasis<BasisBase>(fullBasis) );
296  return serendipityBasis;
297  }
298 
303  template<class BasisFamily>
304  static typename BasisFamily::BasisPtr getSerendipityBasis_HVOL(int polyOrder, int spaceDim)
305  {
306  auto fullBasis = getHypercubeBasis_HVOL<BasisFamily>(polyOrder, spaceDim);
307 
308  using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
309 
310  auto serendipityBasis = Teuchos::rcp( new SerendipityBasis<BasisBase>(fullBasis) );
311  return serendipityBasis;
312  }
313 
319  template<class BasisFamily>
320  static typename BasisFamily::BasisPtr getTetrahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
321  {
322  using Teuchos::rcp;
323  switch (fs)
324  {
325  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TET (polyOrder,pointType));
326  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TET(polyOrder,pointType));
327  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TET (polyOrder,pointType));
328  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TET(polyOrder,pointType));
329  default:
330  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
331  }
332  }
333 
339  template<class BasisFamily>
340  static typename BasisFamily::BasisPtr getTriangleBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
341  {
342  using Teuchos::rcp;
343  switch (fs)
344  {
345  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TRI (polyOrder,pointType));
346  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TRI(polyOrder,pointType));
347  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TRI (polyOrder,pointType));
348  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TRI(polyOrder,pointType));
349  default:
350  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
351  }
352  }
353 
359  template<class BasisFamily>
360  static typename BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
361  {
362  using Teuchos::rcp;
363  switch (fs)
364  {
365  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_WEDGE (polyOrder, pointType));
366  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_WEDGE(polyOrder, pointType));
367  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_WEDGE (polyOrder, pointType));
368  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_WEDGE(polyOrder, pointType));
369  default:
370  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
371  }
372  }
373 
379  template<class BasisFamily>
380  static typename BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, ordinal_type polyOrder_xy, ordinal_type polyOrder_z, const EPointType pointType=POINTTYPE_DEFAULT)
381  {
382  using Teuchos::rcp;
383  switch (fs)
384  {
385  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_WEDGE (polyOrder_xy, polyOrder_z, pointType));
386  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_WEDGE(polyOrder_xy, polyOrder_z, pointType));
387  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_WEDGE (polyOrder_xy, polyOrder_z, pointType));
388  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_WEDGE(polyOrder_xy, polyOrder_z, pointType));
389  default:
390  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
391  }
392  }
393 
403  template<class BasisFamily>
404  static typename BasisFamily::BasisPtr getBasis(const shards::CellTopology &cellTopo, Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType = POINTTYPE_DEFAULT)
405  {
406  using Teuchos::rcp;
407  switch (cellTopo.getBaseKey())
408  {
409  case shards::Line<>::key: return getLineBasis<BasisFamily>(fs,polyOrder, pointType);
410  case shards::Quadrilateral<>::key: return getQuadrilateralBasis<BasisFamily>(fs,polyOrder,pointType);
411  case shards::Triangle<>::key: return getTriangleBasis<BasisFamily>(fs,polyOrder,pointType);
412  case shards::Hexahedron<>::key: return getHexahedronBasis<BasisFamily>(fs,polyOrder,pointType);
413  case shards::Tetrahedron<>::key: return getTetrahedronBasis<BasisFamily>(fs,polyOrder,pointType);
414  default:
415  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported cell topology");
416  }
417  }
418 } // end namespace Intrepid2
419 
420 #endif /* Intrepid2_DerivedBasisFamily_h */
Teuchos::RCP< Basis< DeviceType, OutputType, PointType > > BasisPtr
Basis Pointer.
EmptyBasisFamily allows us to set a default void family for a given topology.
Serendipity Basis, defined as the sub-basis of a provided basis, consisting of basis elements for whi...
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...
static BasisFamily::BasisPtr getLineBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for line bases in the given family.
static BasisFamily::BasisPtr getTetrahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic tetrahedron bases in the given family.
static BasisFamily::BasisPtr getBasis(const shards::CellTopology &cellTopo, Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic bases in the given family on the specified cell topology.
static BasisFamily::BasisPtr getHypercubeBasis_HGRAD(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic HGRAD bases on a hypercube for the given family. Note that this will ret...
static BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic bases on the hexahedron in the given family.
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...
static BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic quadrilateral bases in the given family.
static BasisFamily::BasisPtr getTriangleBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic triangle bases in the given family.
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...
Device DeviceType
(Kokkos) Device type on which Basis is templated. Does not necessarily return true for Kokkos::is_dev...
A family of basis functions, constructed from H(vol) and H(grad) bases on the line.
EPointType
Enumeration of types of point distributions in Intrepid.
Implementation of H(grad) basis on the hexahedron that is templated on H(grad) on the line...
static BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic wedge bases in the given family.
Implementation of H(vol) basis on the quadrilateral that is templated on H(vol) on the line...
static BasisFamily::BasisPtr getHypercubeBasis_HVOL(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic HVOL bases on a hypercube for the given family. Note that this will retu...
static BasisFamily::BasisPtr getSerendipityBasis_HGRAD(int polyOrder, int spaceDim)
Factory method for isotropic HGRAD Serendipity bases on a hypercube for the given family...
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.
static BasisFamily::BasisPtr getSerendipityBasis_HVOL(int polyOrder, int spaceDim)
Factory method for isotropic HGRAD Serendipity bases on a hypercube for the given family...
Basis defined as the tensor product of two component bases.
Header file for the abstract base class Intrepid2::Basis.