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 
64 namespace Intrepid2
65 {
68  {
69  public:
70  using HGRAD = void;
71  using HCURL = void;
72  using HDIV = void;
73  using HVOL = void;
74  };
75 
81  template<class LineBasisHGRAD, class LineBasisHVOL, class TriangleBasisFamily = EmptyBasisFamily, class TetrahedronBasisFamily = EmptyBasisFamily>
83  {
84  public:
85  using ExecutionSpace = typename LineBasisHGRAD::ExecutionSpace;
86  using OutputValueType = typename LineBasisHGRAD::OutputValueType;
87  using PointValueType = typename LineBasisHGRAD::PointValueType;
88 
90  using BasisPtr = Teuchos::RCP<Basis>;
91 
92  // line bases
93  using HGRAD_LINE = LineBasisHGRAD;
94  using HVOL_LINE = LineBasisHVOL;
95 
96  // quadrilateral bases
101 
102  // hexahedron bases
107 
108  // triangle bases
109  using HGRAD_TRI = typename TriangleBasisFamily::HGRAD;
110 
111  // tetrahedron bases
112  using HGRAD_TET = typename TetrahedronBasisFamily::HGRAD;
113  };
114 
119  template<class BasisFamily>
120  static typename BasisFamily::BasisPtr getLineBasis(Intrepid2::EFunctionSpace fs, int polyOrder)
121  {
122  using Teuchos::rcp;
123  switch (fs)
124  {
125  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_LINE (polyOrder));
126  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_LINE(polyOrder));
127  default:
128  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
129  }
130  }
131 
136  template<class BasisFamily>
137  static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder)
138  {
139  using Teuchos::rcp;
140  switch (fs)
141  {
142  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder));
143  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder));
144  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder));
145  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder));
146  default:
147  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
148  }
149  }
150 
156  template<class BasisFamily>
157  static typename BasisFamily::BasisPtr getQuadrilateralBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y)
158  {
159  using Teuchos::rcp;
160  switch (fs)
161  {
162  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_QUAD (polyOrder_x,polyOrder_y));
163  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_QUAD(polyOrder_x,polyOrder_y));
164  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_QUAD (polyOrder_x,polyOrder_y));
165  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_QUAD(polyOrder_x,polyOrder_y));
166  default:
167  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
168  }
169  }
170 
175  template<class BasisFamily>
176  static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder)
177  {
178  using Teuchos::rcp;
179  switch (fs)
180  {
181  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder));
182  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder));
183  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder));
184  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder));
185  default:
186  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
187  }
188  }
189 
196  template<class BasisFamily>
197  static typename BasisFamily::BasisPtr getHexahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder_x, int polyOrder_y, int polyOrder_z)
198  {
199  using Teuchos::rcp;
200  switch (fs)
201  {
202  case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_HEX (polyOrder_x,polyOrder_y,polyOrder_z));
203  case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_HEX(polyOrder_x,polyOrder_y,polyOrder_z));
204  case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_HEX (polyOrder_x,polyOrder_y,polyOrder_z));
205  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_HEX(polyOrder_x,polyOrder_y,polyOrder_z));
206  default:
207  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
208  }
209  }
210 
215  template<class BasisFamily>
216  static typename BasisFamily::BasisPtr getTetrahedronBasis(Intrepid2::EFunctionSpace fs, int polyOrder)
217  {
218  using Teuchos::rcp;
219  switch (fs)
220  {
221 // case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TET (polyOrder));
222 // case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TET(polyOrder));
223 // case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TET (polyOrder));
224  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TET(polyOrder));
225  default:
226  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
227  }
228  }
229 
234  template<class BasisFamily>
235  static typename BasisFamily::BasisPtr getTriangleBasis(Intrepid2::EFunctionSpace fs, int polyOrder)
236  {
237  using Teuchos::rcp;
238  switch (fs)
239  {
240 // case FUNCTION_SPACE_HVOL: return rcp(new typename BasisFamily::HVOL_TRI (polyOrder));
241 // case FUNCTION_SPACE_HCURL: return rcp(new typename BasisFamily::HCURL_TRI(polyOrder));
242 // case FUNCTION_SPACE_HDIV: return rcp(new typename BasisFamily::HDIV_TRI (polyOrder));
243  case FUNCTION_SPACE_HGRAD: return rcp(new typename BasisFamily::HGRAD_TRI(polyOrder));
244  default:
245  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported function space");
246  }
247  }
248 
257  template<class BasisFamily>
258  static typename BasisFamily::BasisPtr getBasis(shards::CellTopology &cellTopo, Intrepid2::EFunctionSpace fs, int polyOrder)
259  {
260  using Teuchos::rcp;
261  switch (cellTopo.getBaseKey())
262  {
263  case shards::Line<>::key: return getLineBasis<BasisFamily>(fs,polyOrder);
264  case shards::Quadrilateral<>::key: return getQuadrilateralBasis<BasisFamily>(fs,polyOrder);
265  case shards::Triangle<>::key: return getTriangleBasis<BasisFamily>(fs,polyOrder);
266  case shards::Hexahedron<>::key: return getHexahedronBasis<BasisFamily>(fs,polyOrder);
267  case shards::Tetrahedron<>::key: return getTetrahedronBasis<BasisFamily>(fs,polyOrder);
268  default:
269  INTREPID2_TEST_FOR_EXCEPTION(true, std::invalid_argument, "Unsupported cell topology");
270  }
271  }
272 } // end namespace Intrepid2
273 
274 #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...
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
Implementation of H(curl) basis on the hexahedron that is templated on H(vol) and 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(vol) basis on the hexahedron 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...
Header file for the abstract base class Intrepid2::Basis.