Intrepid2
Intrepid2_DerivedBasisFamily.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
15#ifndef Intrepid2_DerivedBasisFamily_h
16#define Intrepid2_DerivedBasisFamily_h
17
18#include "Intrepid2_Basis.hpp"
19
22#include "Intrepid2_DerivedBasis_HDIV_QUAD.hpp"
24
29
34
35#include "Intrepid2_SerendipityBasis.hpp"
36
37namespace Intrepid2
38{
41 {
42 public:
43 using HGRAD = void;
44 using HCURL = void;
45 using HDIV = void;
46 using HVOL = void;
47 };
48
54 template<class LineBasisHGRAD, class LineBasisHVOL, class TriangleBasisFamily = EmptyBasisFamily, class TetrahedronBasisFamily = EmptyBasisFamily, class PyramidBasisFamily = EmptyBasisFamily>
56 {
57 public:
58 using ExecutionSpace = typename LineBasisHGRAD::ExecutionSpace;
59 using OutputValueType = typename LineBasisHGRAD::OutputValueType;
60 using PointValueType = typename LineBasisHGRAD::PointValueType;
61
62 using Basis = typename LineBasisHGRAD::BasisBase;
63 using BasisPtr = Teuchos::RCP<Basis>;
64 using DeviceType = typename Basis::DeviceType;
65
66 // line bases
67 using HGRAD_LINE = LineBasisHGRAD;
68 using HVOL_LINE = LineBasisHVOL;
69
70 // quadrilateral bases
73 using HDIV_QUAD = Basis_Derived_HDIV_QUAD <HGRAD_LINE, HVOL_LINE>;
74 using HVOL_QUAD = Basis_Derived_HVOL_QUAD <HVOL_LINE>;
75
76 // hexahedron bases
79 using HDIV_HEX = Basis_Derived_HDIV_HEX <HGRAD_LINE, HVOL_LINE>;
80 using HVOL_HEX = Basis_Derived_HVOL_HEX <HVOL_LINE>;
81
82 // triangle bases
83 using HGRAD_TRI = typename TriangleBasisFamily::HGRAD;
84 using HCURL_TRI = typename TriangleBasisFamily::HCURL;
85 using HDIV_TRI = typename TriangleBasisFamily::HDIV;
86 using HVOL_TRI = typename TriangleBasisFamily::HVOL;
87
88 // tetrahedron bases
89 using HGRAD_TET = typename TetrahedronBasisFamily::HGRAD;
90 using HCURL_TET = typename TetrahedronBasisFamily::HCURL;
91 using HDIV_TET = typename TetrahedronBasisFamily::HDIV;
92 using HVOL_TET = typename TetrahedronBasisFamily::HVOL;
93
94 // wedge bases
97 using HDIV_WEDGE = Basis_Derived_HDIV_WEDGE < HDIV_TRI, HVOL_TRI, HGRAD_LINE, HVOL_LINE>;
98 using HVOL_WEDGE = Basis_Derived_HVOL_WEDGE < HVOL_TRI, HVOL_LINE>;
99
100 // pyramid bases
101 using HGRAD_PYR = typename PyramidBasisFamily::HGRAD;
102 using HCURL_PYR = typename PyramidBasisFamily::HCURL;
103 using HDIV_PYR = typename PyramidBasisFamily::HDIV;
104 using HVOL_PYR = typename PyramidBasisFamily::HVOL;
105 };
106
112 template<class BasisFamily>
113 static typename BasisFamily::BasisPtr getLineBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
114 {
115 using Teuchos::rcp;
116 switch (fs)
117 {
118 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_LINE (polyOrder,pointType));
119 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_LINE(polyOrder,pointType));
120 default:
121 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
122 }
123 }
124
130 template<class BasisFamily>
131 static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
132 {
133 using Teuchos::rcp;
134 switch (fs)
135 {
136 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder,pointType));
137 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder,pointType));
138 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder,pointType));
139 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder,pointType));
140 default:
141 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
142 }
143 }
144
151 template<class BasisFamily>
152 static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y, const EPointType pointType=POINTTYPE_DEFAULT)
153 {
154 using Teuchos::rcp;
155 switch (fs)
156 {
157 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder_x,polyOrder_y,pointType));
158 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder_x,polyOrder_y,pointType));
159 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder_x,polyOrder_y,pointType));
160 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder_x,polyOrder_y,pointType));
161 default:
162 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
163 }
164 }
165
171 template<class BasisFamily>
172 static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
173 {
174 using Teuchos::rcp;
175 switch (fs)
176 {
177 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder,pointType));
178 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder,pointType));
179 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder,pointType));
180 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder,pointType));
181 default:
182 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
183 }
184 }
185
191 template<class BasisFamily>
192 static typename BasisFamily::BasisPtr getHypercubeBasis_HGRAD(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
193 {
194 using Teuchos::rcp;
195
196 using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
197 using BasisPtr = typename BasisFamily::BasisPtr;
198
199 BasisPtr lineBasis = getLineBasis<BasisFamily>(FUNCTION_SPACE_HGRAD, polyOrder);
200 BasisPtr tensorBasis = lineBasis;
201
202 for (int d=1; d<spaceDim; d++)
203 {
204 tensorBasis = Teuchos::rcp(new Basis_TensorBasis<BasisBase>(tensorBasis, lineBasis, FUNCTION_SPACE_HGRAD));
205 }
206
207 return tensorBasis;
208 }
209
215 template<class BasisFamily>
216 static typename BasisFamily::BasisPtr getHypercubeBasis_HVOL(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
217 {
218 using Teuchos::rcp;
219
220 using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
221 using BasisPtr = typename BasisFamily::BasisPtr;
222
223 BasisPtr lineBasis = getLineBasis<BasisFamily>(FUNCTION_SPACE_HVOL, polyOrder);
224 BasisPtr tensorBasis = lineBasis;
225
226 for (int d=1; d<spaceDim; d++)
227 {
228 tensorBasis = Teuchos::rcp(new Basis_TensorBasis<BasisBase>(tensorBasis, lineBasis, FUNCTION_SPACE_HVOL));
229 }
230
231 return tensorBasis;
232 }
233
241 template<class BasisFamily>
242 static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y, int polyOrder_z, const EPointType pointType=POINTTYPE_DEFAULT)
243 {
244 using Teuchos::rcp;
245 switch (fs)
246 {
247 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder_x,polyOrder_y,polyOrder_z,pointType));
248 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder_x,polyOrder_y,polyOrder_z,pointType));
249 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder_x,polyOrder_y,polyOrder_z,pointType));
250 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder_x,polyOrder_y,polyOrder_z,pointType));
251 default:
252 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
253 }
254 }
255
260 template<class BasisFamily>
261 static typename BasisFamily::BasisPtr getSerendipityBasis_HGRAD(int polyOrder, int spaceDim)
262 {
263 auto fullBasis = getHypercubeBasis_HGRAD<BasisFamily>(polyOrder, spaceDim);
264
265 using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
266
267 auto serendipityBasis = Teuchos::rcp( new SerendipityBasis<BasisBase>(fullBasis) );
268 return serendipityBasis;
269 }
270
275 template<class BasisFamily>
276 static typename BasisFamily::BasisPtr getSerendipityBasis_HVOL(int polyOrder, int spaceDim)
277 {
278 auto fullBasis = getHypercubeBasis_HVOL<BasisFamily>(polyOrder, spaceDim);
279
280 using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
281
282 auto serendipityBasis = Teuchos::rcp( new SerendipityBasis<BasisBase>(fullBasis) );
283 return serendipityBasis;
284 }
285
291 template<class BasisFamily>
292 static typename BasisFamily::BasisPtr getTetrahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
293 {
294 using Teuchos::rcp;
295 switch (fs)
296 {
297 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TET (polyOrder,pointType));
298 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TET(polyOrder,pointType));
299 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TET (polyOrder,pointType));
300 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TET(polyOrder,pointType));
301 default:
302 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
303 }
304 }
305
311 template<class BasisFamily>
312 static typename BasisFamily::BasisPtr getTriangleBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
313 {
314 using Teuchos::rcp;
315 switch (fs)
316 {
317 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TRI (polyOrder,pointType));
318 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TRI(polyOrder,pointType));
319 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TRI (polyOrder,pointType));
320 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TRI(polyOrder,pointType));
321 default:
322 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
323 }
324 }
325
331 template<class BasisFamily>
332 static typename BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
333 {
334 using Teuchos::rcp;
335 switch (fs)
336 {
337 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_WEDGE (polyOrder, pointType));
338 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_WEDGE(polyOrder, pointType));
339 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_WEDGE (polyOrder, pointType));
340 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_WEDGE(polyOrder, pointType));
341 default:
342 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
343 }
344 }
345
351 template<class BasisFamily>
352 static typename BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, ordinal_type polyOrder_xy, ordinal_type polyOrder_z, const EPointType pointType=POINTTYPE_DEFAULT)
353 {
354 using Teuchos::rcp;
355 switch (fs)
356 {
357 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_WEDGE (polyOrder_xy, polyOrder_z, pointType));
358 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_WEDGE(polyOrder_xy, polyOrder_z, pointType));
359 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_WEDGE (polyOrder_xy, polyOrder_z, pointType));
360 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_WEDGE(polyOrder_xy, polyOrder_z, pointType));
361 default:
362 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
363 }
364 }
365
371 template<class BasisFamily>
372 static typename BasisFamily::BasisPtr getPyramidBasis(Intrepid2::EFunctionSpace fs, ordinal_type polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
373 {
374 using Teuchos::rcp;
375 switch (fs)
376 {
377 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_PYR (polyOrder, pointType));
378// case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_PYR(polyOrder, pointType));
379 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_PYR (polyOrder, pointType));
380 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_PYR(polyOrder, pointType));
381 default:
382 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
383 }
384 }
385
395 template<class BasisFamily>
396 static typename BasisFamily::BasisPtr getBasis(const shards::CellTopology &cellTopo, Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType = POINTTYPE_DEFAULT)
397 {
398 using Teuchos::rcp;
399 switch (cellTopo.getBaseKey())
400 {
401 case shards::Line<>::key: return getLineBasis<BasisFamily>(fs,polyOrder, pointType);
402 case shards::Quadrilateral<>::key: return getQuadrilateralBasis<BasisFamily>(fs,polyOrder,pointType);
403 case shards::Triangle<>::key: return getTriangleBasis<BasisFamily>(fs,polyOrder,pointType);
404 case shards::Hexahedron<>::key: return getHexahedronBasis<BasisFamily>(fs,polyOrder,pointType);
405 case shards::Tetrahedron<>::key: return getTetrahedronBasis<BasisFamily>(fs,polyOrder,pointType);
406 default:
407 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported cell topology");
408 }
409 }
410} // end namespace Intrepid2
411
412#endif /* Intrepid2_DerivedBasisFamily_h */
Header file for the abstract base class Intrepid2::Basis.
Teuchos::RCP< Basis< DeviceType, OutputType, PointType > > BasisPtr
Basis Pointer.
static BasisFamily::BasisPtr getSerendipityBasis_HGRAD(int polyOrder, int spaceDim)
Factory method for isotropic HGRAD Serendipity bases on a hypercube for the given family....
static BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic wedge bases in the given family.
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 getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic bases on the hexahedron in the given family.
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 getTetrahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic tetrahedron 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.
static BasisFamily::BasisPtr getPyramidBasis(Intrepid2::EFunctionSpace fs, ordinal_type polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for pyramid bases in the given family.
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 getLineBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for line bases in the given family.
static BasisFamily::BasisPtr getSerendipityBasis_HVOL(int polyOrder, int spaceDim)
Factory method for isotropic HGRAD Serendipity bases on a hypercube for 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.
Implementation of H(curl) basis on the hexahedron that is templated on H(vol) and H(grad) on the line...
Implementation of H(curl) basis on the quadrilateral that is templated on H(vol) and H(grad) on the l...
Implementation of H(curl) basis on the wedge that is templated on H(grad,tri), H(curl,...
Implementation of H(div) basis on the hexahedron that is templated on H(vol) and H(grad) on the line.
Implementation of H(div) basis on the wedge that is templated on H(div,tri), H(vol,...
Implementation of H(grad) basis on the hexahedron that is templated on H(grad) on the line.
Implementation of H(grad) basis on the quadrilateral that is templated on H(grad) on the line.
Implementation of H(grad) basis on the wedge 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(vol) basis on the quadrilateral that is templated on H(vol) on the line.
Implementation of H(vol) basis on the wedge 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(vol) basis on the quadrilateral that is templated on H(vol) on the line.
Basis defined as the tensor product of two component bases.
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.
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...