Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_IntrepidBasisFactory.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef PANZER_INTREPID_BASIS_FACTORY_H
44 #define PANZER_INTREPID_BASIS_FACTORY_H
45 
46 #include <sstream>
47 #include <string>
48 #include <map>
49 
50 #include "Intrepid2_HVOL_C0_FEM.hpp"
51 #include "Intrepid2_HVOL_TRI_Cn_FEM.hpp"
52 #include "Intrepid2_HVOL_QUAD_Cn_FEM.hpp"
53 
54 #include "Teuchos_RCP.hpp"
55 #include "Intrepid2_Basis.hpp"
56 
57 #include "Shards_CellTopology.hpp"
58 
59 #include "Intrepid2_HGRAD_QUAD_C1_FEM.hpp"
60 #include "Intrepid2_HGRAD_QUAD_C2_FEM.hpp"
61 #include "Intrepid2_HGRAD_QUAD_Cn_FEM.hpp"
62 
63 #include "Intrepid2_HGRAD_HEX_C1_FEM.hpp"
64 #include "Intrepid2_HGRAD_HEX_C2_FEM.hpp"
65 #include "Intrepid2_HGRAD_HEX_Cn_FEM.hpp"
66 
67 #include "Intrepid2_HGRAD_TET_C1_FEM.hpp"
68 #include "Intrepid2_HGRAD_TET_C2_FEM.hpp"
69 #include "Intrepid2_HGRAD_TET_Cn_FEM.hpp"
70 
71 #include "Intrepid2_HGRAD_TRI_C1_FEM.hpp"
72 #include "Intrepid2_HGRAD_TRI_C2_FEM.hpp"
73 #include "Intrepid2_HGRAD_TRI_Cn_FEM.hpp"
74 
75 #include "Intrepid2_HGRAD_LINE_C1_FEM.hpp"
76 #include "Intrepid2_HGRAD_LINE_Cn_FEM.hpp"
77 
78 #include "Intrepid2_HCURL_TRI_I1_FEM.hpp"
79 #include "Intrepid2_HCURL_TRI_In_FEM.hpp"
80 
81 #include "Intrepid2_HCURL_TET_I1_FEM.hpp"
82 #include "Intrepid2_HCURL_TET_In_FEM.hpp"
83 
84 #include "Intrepid2_HCURL_QUAD_I1_FEM.hpp"
85 #include "Intrepid2_HCURL_QUAD_In_FEM.hpp"
86 
87 #include "Intrepid2_HCURL_HEX_I1_FEM.hpp"
88 #include "Intrepid2_HCURL_HEX_In_FEM.hpp"
89 
90 #include "Intrepid2_HDIV_TRI_I1_FEM.hpp"
91 #include "Intrepid2_HDIV_TRI_In_FEM.hpp"
92 
93 #include "Intrepid2_HDIV_QUAD_I1_FEM.hpp"
94 #include "Intrepid2_HDIV_QUAD_In_FEM.hpp"
95 
96 #include "Intrepid2_HDIV_TET_I1_FEM.hpp"
97 #include "Intrepid2_HDIV_TET_In_FEM.hpp"
98 
99 #include "Intrepid2_HDIV_HEX_I1_FEM.hpp"
100 #include "Intrepid2_HDIV_HEX_In_FEM.hpp"
101 
102 
103 namespace panzer {
104 
105 
119  template <typename ExecutionSpace, typename OutputValueType, typename PointValueType>
121  createIntrepid2Basis(const std::string basis_type, int basis_order,
122  const shards::CellTopology & cell_topology)
123  {
124  // Shards supports extended topologies so the names have a "size"
125  // associated with the number of nodes. We prune the size to
126  // avoid combinatorial explosion of checks.
127  std::string cell_topology_type = cell_topology.getName();
128  std::size_t end_position = 0;
129  end_position = cell_topology_type.find("_");
130  std::string cell_type = cell_topology_type.substr(0,end_position);
131 
133 
134  // high order point distribution type;
135  // for now equispaced only; to get a permutation map with different orientation,
136  // orientation coeff matrix should have the same point distribution.
137  const Intrepid2::EPointType point_type = Intrepid2::POINTTYPE_EQUISPACED;
138 
139  if ( (basis_type == "Const") && (basis_order == 0) )
140  basis = Teuchos::rcp( new Intrepid2::Basis_HVOL_C0_FEM<ExecutionSpace,OutputValueType,PointValueType>(cell_topology) );
141 
142  else if ( (basis_type == "HVol") && (basis_order == 0) )
143  basis = Teuchos::rcp( new Intrepid2::Basis_HVOL_C0_FEM<ExecutionSpace,OutputValueType,PointValueType>(cell_topology) );
144 
145  else if ( (basis_type == "HVol") && (cell_type == "Quadrilateral") && (basis_order > 0) )
146  basis = Teuchos::rcp( new Intrepid2::Basis_HVOL_QUAD_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
147 
148  else if ( (basis_type == "HVol") && (cell_type == "Triangle") && (basis_order > 0) )
149  basis = Teuchos::rcp( new Intrepid2::Basis_HVOL_TRI_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
150 
151  else if ( (basis_type == "HGrad") && (cell_type == "Hexahedron") && (basis_order == 1) )
152  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_HEX_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
153 
154  else if ( (basis_type == "HGrad") && (cell_type == "Hexahedron") && (basis_order == 2) )
155  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_HEX_C2_FEM<ExecutionSpace,OutputValueType,PointValueType> );
156 
157  else if ( (basis_type == "HGrad") && (cell_type == "Hexahedron") && (basis_order > 2) )
158  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_HEX_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
159 
160  else if ( (basis_type == "HCurl") && (cell_type == "Hexahedron") && (basis_order == 1) )
161  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_HEX_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
162 
163  else if ( (basis_type == "HCurl") && (cell_type == "Hexahedron") && (basis_order > 1) )
164  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_HEX_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
165 
166  else if ( (basis_type == "HDiv") && (cell_type == "Hexahedron") && (basis_order == 1) )
167  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_HEX_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
168 
169  else if ( (basis_type == "HDiv") && (cell_type == "Hexahedron") && (basis_order > 1) )
170  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_HEX_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
171 
172  else if ( (basis_type == "HGrad") && (cell_type == "Tetrahedron") && (basis_order == 1) )
173  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TET_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
174 
175  else if ( (basis_type == "HGrad") && (cell_type == "Tetrahedron") && (basis_order == 2) )
176  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TET_C2_FEM<ExecutionSpace,OutputValueType,PointValueType> );
177 
178  else if ( (basis_type == "HGrad") && (cell_type == "Tetrahedron") && (basis_order > 2) )
179  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TET_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
180 
181  else if ( (basis_type == "HCurl") && (cell_type == "Tetrahedron") && (basis_order == 1) )
182  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_TET_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
183 
184  else if ( (basis_type == "HCurl") && (cell_type == "Tetrahedron") && (basis_order > 1) )
185  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_TET_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
186 
187  else if ( (basis_type == "HDiv") && (cell_type == "Tetrahedron") && (basis_order == 1) )
188  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_TET_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
189 
190  else if ( (basis_type == "HDiv") && (cell_type == "Tetrahedron") && (basis_order > 1) )
191  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_TET_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
192 
193  else if ( (basis_type == "HGrad") && (cell_type == "Quadrilateral") && (basis_order == 1) )
194  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_QUAD_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
195 
196  else if ( (basis_type == "HGrad") && (cell_type == "Quadrilateral") && (basis_order == 2) )
197  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_QUAD_C2_FEM<ExecutionSpace,OutputValueType,PointValueType> );
198 
199  else if ( (basis_type == "HGrad") && (cell_type == "Quadrilateral") && (basis_order > 2) )
200  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_QUAD_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
201 
202  else if ( (basis_type == "HCurl") && (cell_type == "Quadrilateral") && (basis_order == 1) )
203  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_QUAD_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
204 
205  else if ( (basis_type == "HCurl") && (cell_type == "Quadrilateral") && (basis_order > 1) )
206  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_QUAD_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
207 
208  else if ( (basis_type == "HDiv") && (cell_type == "Quadrilateral") && (basis_order == 1) )
209  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_QUAD_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
210 
211  else if ( (basis_type == "HDiv") && (cell_type == "Quadrilateral") && (basis_order > 1) )
212  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_QUAD_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
213 
214  else if ( (basis_type == "HGrad") && (cell_type == "Triangle") && (basis_order == 1) )
215  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TRI_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
216 
217  else if ( (basis_type == "HGrad") && (cell_type == "Triangle") && (basis_order == 2) )
218  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TRI_C2_FEM<ExecutionSpace,OutputValueType,PointValueType> );
219 
220  else if ( (basis_type == "HGrad") && (cell_type == "Triangle") && (basis_order > 2) )
221  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TRI_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
222 
223  else if ( (basis_type == "HCurl") && (cell_type == "Triangle") && (basis_order == 1) )
224  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_TRI_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
225 
226  else if ( (basis_type == "HCurl") && (cell_type == "Triangle") && (basis_order > 1) )
227  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_TRI_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
228 
229  else if ( (basis_type == "HDiv") && (cell_type == "Triangle") && (basis_order == 1) )
230  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_TRI_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
231 
232  else if ( (basis_type == "HDiv") && (cell_type == "Triangle") && (basis_order > 1) )
233  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_TRI_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
234 
235  else if ( (basis_type == "HGrad") && (cell_type == "Line") && (basis_order == 1) )
236  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_LINE_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
237 
238  else if ( (basis_type == "HGrad") && (cell_type == "Line") && (basis_order >= 2) )
239  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_LINE_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
240 
241  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(basis), std::runtime_error,
242  "Failed to create the requestedbasis with basis_type=\"" << basis_type <<
243  "\", basis_order=\"" << basis_order << "\", and cell_type=\"" << cell_type << "\"!\n");
244 
245  TEUCHOS_TEST_FOR_EXCEPTION(cell_topology!=basis->getBaseCellTopology(),
246  std::runtime_error,
247  "Failed to create basis. Intrepid2 basis topology does not match mesh cell topology!");
248 
249  return basis;
250  }
251 
265  template <typename ExecutionSpace, typename OutputValueType, typename PointValueType>
267  createIntrepid2Basis(const std::string basis_type, int basis_order,
268  const Teuchos::RCP<const shards::CellTopology> & cell_topology)
269  {
270  return createIntrepid2Basis<ExecutionSpace,OutputValueType,PointValueType>(basis_type,basis_order,*cell_topology);
271  }
272 
273 }
274 
275 
276 #endif
bool is_null(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< Intrepid2::Basis< ExecutionSpace, OutputValueType, PointValueType > > createIntrepid2Basis(const std::string basis_type, int basis_order, const shards::CellTopology &cell_topology)
Creates an Intrepid2::Basis object given the basis, order and cell topology.