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
47
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
70namespace 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
104 using HGRAD_QUAD = Basis_Derived_HGRAD_QUAD<HGRAD_LINE>;
106 using HDIV_QUAD = Basis_Derived_HDIV_QUAD <HGRAD_LINE, HVOL_LINE>;
107 using HVOL_QUAD = Basis_Derived_HVOL_QUAD <HVOL_LINE>;
108
109 // hexahedron bases
110 using HGRAD_HEX = Basis_Derived_HGRAD_HEX<HGRAD_LINE>;
112 using HDIV_HEX = Basis_Derived_HDIV_HEX <HGRAD_LINE, HVOL_LINE>;
113 using HVOL_HEX = Basis_Derived_HVOL_HEX <HVOL_LINE>;
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
130 using HDIV_WEDGE = Basis_Derived_HDIV_WEDGE < HDIV_TRI, HVOL_TRI, HGRAD_LINE, HVOL_LINE>;
131 using HVOL_WEDGE = Basis_Derived_HVOL_WEDGE < HVOL_TRI, HVOL_LINE>;
132
133
134 // pyramid bases
135 using HGRAD_PYR = typename PyramidBasisFamily::HGRAD;
136 using HCURL_PYR = typename PyramidBasisFamily::HCURL;
137 using HDIV_PYR = typename PyramidBasisFamily::HDIV;
138 using HVOL_PYR = typename PyramidBasisFamily::HVOL;
139 };
140
146 template<class BasisFamily>
147 static typename BasisFamily::BasisPtr getLineBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
148 {
149 using Teuchos::rcp;
150 switch (fs)
151 {
152 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_LINE (polyOrder,pointType));
153 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_LINE(polyOrder,pointType));
154 default:
155 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
156 }
157 }
158
164 template<class BasisFamily>
165 static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
166 {
167 using Teuchos::rcp;
168 switch (fs)
169 {
170 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder,pointType));
171 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder,pointType));
172 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder,pointType));
173 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder,pointType));
174 default:
175 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
176 }
177 }
178
185 template<class BasisFamily>
186 static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y, const EPointType pointType=POINTTYPE_DEFAULT)
187 {
188 using Teuchos::rcp;
189 switch (fs)
190 {
191 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder_x,polyOrder_y,pointType));
192 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder_x,polyOrder_y,pointType));
193 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder_x,polyOrder_y,pointType));
194 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder_x,polyOrder_y,pointType));
195 default:
196 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
197 }
198 }
199
205 template<class BasisFamily>
206 static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
207 {
208 using Teuchos::rcp;
209 switch (fs)
210 {
211 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder,pointType));
212 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder,pointType));
213 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder,pointType));
214 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder,pointType));
215 default:
216 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
217 }
218 }
219
225 template<class BasisFamily>
226 static typename BasisFamily::BasisPtr getHypercubeBasis_HGRAD(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
227 {
228 using Teuchos::rcp;
229
230 using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
231 using BasisPtr = typename BasisFamily::BasisPtr;
232
233 BasisPtr lineBasis = getLineBasis<BasisFamily>(FUNCTION_SPACE_HGRAD, polyOrder);
234 BasisPtr tensorBasis = lineBasis;
235
236 for (int d=1; d<spaceDim; d++)
237 {
238 tensorBasis = Teuchos::rcp(new Basis_TensorBasis<BasisBase>(tensorBasis, lineBasis, FUNCTION_SPACE_HGRAD));
239 }
240
241 return tensorBasis;
242 }
243
249 template<class BasisFamily>
250 static typename BasisFamily::BasisPtr getHypercubeBasis_HVOL(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
251 {
252 using Teuchos::rcp;
253
254 using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
255 using BasisPtr = typename BasisFamily::BasisPtr;
256
257 BasisPtr lineBasis = getLineBasis<BasisFamily>(FUNCTION_SPACE_HVOL, polyOrder);
258 BasisPtr tensorBasis = lineBasis;
259
260 for (int d=1; d<spaceDim; d++)
261 {
262 tensorBasis = Teuchos::rcp(new Basis_TensorBasis<BasisBase>(tensorBasis, lineBasis, FUNCTION_SPACE_HVOL));
263 }
264
265 return tensorBasis;
266 }
267
275 template<class BasisFamily>
276 static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y, int polyOrder_z, const EPointType pointType=POINTTYPE_DEFAULT)
277 {
278 using Teuchos::rcp;
279 switch (fs)
280 {
281 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder_x,polyOrder_y,polyOrder_z,pointType));
282 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder_x,polyOrder_y,polyOrder_z,pointType));
283 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder_x,polyOrder_y,polyOrder_z,pointType));
284 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder_x,polyOrder_y,polyOrder_z,pointType));
285 default:
286 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
287 }
288 }
289
294 template<class BasisFamily>
295 static typename BasisFamily::BasisPtr getSerendipityBasis_HGRAD(int polyOrder, int spaceDim)
296 {
297 auto fullBasis = getHypercubeBasis_HGRAD<BasisFamily>(polyOrder, spaceDim);
298
299 using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
300
301 auto serendipityBasis = Teuchos::rcp( new SerendipityBasis<BasisBase>(fullBasis) );
302 return serendipityBasis;
303 }
304
309 template<class BasisFamily>
310 static typename BasisFamily::BasisPtr getSerendipityBasis_HVOL(int polyOrder, int spaceDim)
311 {
312 auto fullBasis = getHypercubeBasis_HVOL<BasisFamily>(polyOrder, spaceDim);
313
314 using BasisBase = typename BasisFamily::HGRAD_LINE::BasisBase;
315
316 auto serendipityBasis = Teuchos::rcp( new SerendipityBasis<BasisBase>(fullBasis) );
317 return serendipityBasis;
318 }
319
325 template<class BasisFamily>
326 static typename BasisFamily::BasisPtr getTetrahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
327 {
328 using Teuchos::rcp;
329 switch (fs)
330 {
331 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TET (polyOrder,pointType));
332 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TET(polyOrder,pointType));
333 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TET (polyOrder,pointType));
334 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TET(polyOrder,pointType));
335 default:
336 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
337 }
338 }
339
345 template<class BasisFamily>
346 static typename BasisFamily::BasisPtr getTriangleBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
347 {
348 using Teuchos::rcp;
349 switch (fs)
350 {
351 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TRI (polyOrder,pointType));
352 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TRI(polyOrder,pointType));
353 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TRI (polyOrder,pointType));
354 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TRI(polyOrder,pointType));
355 default:
356 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
357 }
358 }
359
365 template<class BasisFamily>
366 static typename BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
367 {
368 using Teuchos::rcp;
369 switch (fs)
370 {
371 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_WEDGE (polyOrder, pointType));
372 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_WEDGE(polyOrder, pointType));
373 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_WEDGE (polyOrder, pointType));
374 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_WEDGE(polyOrder, pointType));
375 default:
376 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
377 }
378 }
379
385 template<class BasisFamily>
386 static typename BasisFamily::BasisPtr getWedgeBasis(Intrepid2::EFunctionSpace fs, ordinal_type polyOrder_xy, ordinal_type polyOrder_z, const EPointType pointType=POINTTYPE_DEFAULT)
387 {
388 using Teuchos::rcp;
389 switch (fs)
390 {
391 case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_WEDGE (polyOrder_xy, polyOrder_z, pointType));
392 case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_WEDGE(polyOrder_xy, polyOrder_z, pointType));
393 case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_WEDGE (polyOrder_xy, polyOrder_z, pointType));
394 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_WEDGE(polyOrder_xy, polyOrder_z, pointType));
395 default:
396 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
397 }
398 }
399
405 template<class BasisFamily>
406 static typename BasisFamily::BasisPtr getPyramidBasis(Intrepid2::EFunctionSpace fs, ordinal_type polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
407 {
408 using Teuchos::rcp;
409 switch (fs)
410 {
411// case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_PYR (polyOrder, pointType));
412// case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_PYR(polyOrder, pointType));
413// case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_PYR (polyOrder, pointType));
414 case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_PYR(polyOrder, pointType));
415 default:
416 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
417 }
418 }
419
429 template<class BasisFamily>
430 static typename BasisFamily::BasisPtr getBasis(const shards::CellTopology &cellTopo, Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType = POINTTYPE_DEFAULT)
431 {
432 using Teuchos::rcp;
433 switch (cellTopo.getBaseKey())
434 {
435 case shards::Line<>::key: return getLineBasis<BasisFamily>(fs,polyOrder, pointType);
436 case shards::Quadrilateral<>::key: return getQuadrilateralBasis<BasisFamily>(fs,polyOrder,pointType);
437 case shards::Triangle<>::key: return getTriangleBasis<BasisFamily>(fs,polyOrder,pointType);
438 case shards::Hexahedron<>::key: return getHexahedronBasis<BasisFamily>(fs,polyOrder,pointType);
439 case shards::Tetrahedron<>::key: return getTetrahedronBasis<BasisFamily>(fs,polyOrder,pointType);
440 default:
441 INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported cell topology");
442 }
443 }
444} // end namespace Intrepid2
445
446#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,...
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...