Panzer  Version of the Day
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 
52 #include "Teuchos_RCP.hpp"
53 #include "Intrepid2_Basis.hpp"
54 
55 #include "Shards_CellTopology.hpp"
56 
57 #include "Intrepid2_HGRAD_QUAD_C1_FEM.hpp"
58 #include "Intrepid2_HGRAD_QUAD_C2_FEM.hpp"
59 #include "Intrepid2_HGRAD_QUAD_Cn_FEM.hpp"
60 
61 #include "Intrepid2_HGRAD_HEX_C1_FEM.hpp"
62 #include "Intrepid2_HGRAD_HEX_C2_FEM.hpp"
63 #include "Intrepid2_HGRAD_HEX_Cn_FEM.hpp"
64 
65 #include "Intrepid2_HGRAD_TET_C1_FEM.hpp"
66 #include "Intrepid2_HGRAD_TET_C2_FEM.hpp"
67 #include "Intrepid2_HGRAD_TET_Cn_FEM.hpp"
68 
69 #include "Intrepid2_HGRAD_TRI_C1_FEM.hpp"
70 #include "Intrepid2_HGRAD_TRI_C2_FEM.hpp"
71 #include "Intrepid2_HGRAD_TRI_Cn_FEM.hpp"
72 
73 #include "Intrepid2_HGRAD_LINE_C1_FEM.hpp"
74 #include "Intrepid2_HGRAD_LINE_Cn_FEM.hpp"
75 
76 #include "Intrepid2_HCURL_TRI_I1_FEM.hpp"
77 #include "Intrepid2_HCURL_TRI_In_FEM.hpp"
78 
79 #include "Intrepid2_HCURL_TET_I1_FEM.hpp"
80 #include "Intrepid2_HCURL_TET_In_FEM.hpp"
81 
82 #include "Intrepid2_HCURL_QUAD_I1_FEM.hpp"
83 #include "Intrepid2_HCURL_QUAD_In_FEM.hpp"
84 
85 #include "Intrepid2_HCURL_HEX_I1_FEM.hpp"
86 #include "Intrepid2_HCURL_HEX_In_FEM.hpp"
87 
88 #include "Intrepid2_HDIV_TRI_I1_FEM.hpp"
89 #include "Intrepid2_HDIV_TRI_In_FEM.hpp"
90 
91 #include "Intrepid2_HDIV_QUAD_I1_FEM.hpp"
92 #include "Intrepid2_HDIV_QUAD_In_FEM.hpp"
93 
94 #include "Intrepid2_HDIV_TET_I1_FEM.hpp"
95 #include "Intrepid2_HDIV_TET_In_FEM.hpp"
96 
97 #include "Intrepid2_HDIV_HEX_I1_FEM.hpp"
98 #include "Intrepid2_HDIV_HEX_In_FEM.hpp"
99 
100 
101 namespace panzer {
102 
103 
117  template <typename ExecutionSpace, typename OutputValueType, typename PointValueType>
118  Teuchos::RCP<Intrepid2::Basis<ExecutionSpace,OutputValueType,PointValueType> >
119  createIntrepid2Basis(const std::string basis_type, int basis_order,
120  const shards::CellTopology & cell_topology)
121  {
122  // Shards supports extended topologies so the names have a "size"
123  // associated with the number of nodes. We prune the size to
124  // avoid combinatorial explosion of checks.
125  std::string cell_topology_type = cell_topology.getName();
126  std::size_t end_position = 0;
127  end_position = cell_topology_type.find("_");
128  std::string cell_type = cell_topology_type.substr(0,end_position);
129 
130  Teuchos::RCP<Intrepid2::Basis<ExecutionSpace,OutputValueType,PointValueType> > basis;
131 
132  // high order point distribution type;
133  // for now equispaced only; to get a permutation map with different orientation,
134  // orientation coeff matrix should have the same point distribution.
135  const Intrepid2::EPointType point_type = Intrepid2::POINTTYPE_EQUISPACED;
136 
137  if ( (basis_type == "Const") && (basis_order == 0) )
138  basis = Teuchos::rcp( new Intrepid2::Basis_HVOL_C0_FEM<ExecutionSpace,OutputValueType,PointValueType>(cell_topology) );
139 
140  else if ( (basis_type == "HGrad") && (cell_type == "Hexahedron") && (basis_order == 1) )
141  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_HEX_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
142 
143  else if ( (basis_type == "HGrad") && (cell_type == "Hexahedron") && (basis_order == 2) )
144  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_HEX_C2_FEM<ExecutionSpace,OutputValueType,PointValueType> );
145 
146  else if ( (basis_type == "HGrad") && (cell_type == "Hexahedron") && (basis_order > 2) )
147  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_HEX_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
148 
149  else if ( (basis_type == "HCurl") && (cell_type == "Hexahedron") && (basis_order == 1) )
150  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_HEX_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
151 
152  else if ( (basis_type == "HCurl") && (cell_type == "Hexahedron") && (basis_order > 1) )
153  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_HEX_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
154 
155  else if ( (basis_type == "HDiv") && (cell_type == "Hexahedron") && (basis_order == 1) )
156  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_HEX_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
157 
158  else if ( (basis_type == "HDiv") && (cell_type == "Hexahedron") && (basis_order > 1) )
159  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_HEX_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
160 
161  else if ( (basis_type == "HGrad") && (cell_type == "Tetrahedron") && (basis_order == 1) )
162  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TET_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
163 
164  else if ( (basis_type == "HGrad") && (cell_type == "Tetrahedron") && (basis_order == 2) )
165  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TET_C2_FEM<ExecutionSpace,OutputValueType,PointValueType> );
166 
167  else if ( (basis_type == "HGrad") && (cell_type == "Tetrahedron") && (basis_order > 2) )
168  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TET_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
169 
170  else if ( (basis_type == "HCurl") && (cell_type == "Tetrahedron") && (basis_order == 1) )
171  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_TET_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
172 
173  else if ( (basis_type == "HCurl") && (cell_type == "Tetrahedron") && (basis_order > 1) )
174  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_TET_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
175 
176  else if ( (basis_type == "HDiv") && (cell_type == "Tetrahedron") && (basis_order == 1) )
177  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_TET_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
178 
179  else if ( (basis_type == "HDiv") && (cell_type == "Tetrahedron") && (basis_order > 1) )
180  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_TET_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
181 
182  else if ( (basis_type == "HGrad") && (cell_type == "Quadrilateral") && (basis_order == 1) )
183  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_QUAD_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
184 
185  else if ( (basis_type == "HGrad") && (cell_type == "Quadrilateral") && (basis_order == 2) )
186  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_QUAD_C2_FEM<ExecutionSpace,OutputValueType,PointValueType> );
187 
188  else if ( (basis_type == "HGrad") && (cell_type == "Quadrilateral") && (basis_order > 2) )
189  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_QUAD_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
190 
191  else if ( (basis_type == "HCurl") && (cell_type == "Quadrilateral") && (basis_order == 1) )
192  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_QUAD_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
193 
194  else if ( (basis_type == "HCurl") && (cell_type == "Quadrilateral") && (basis_order > 1) )
195  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_QUAD_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
196 
197  else if ( (basis_type == "HDiv") && (cell_type == "Quadrilateral") && (basis_order == 1) )
198  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_QUAD_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
199 
200  else if ( (basis_type == "HDiv") && (cell_type == "Quadrilateral") && (basis_order > 1) )
201  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_QUAD_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
202 
203  else if ( (basis_type == "HGrad") && (cell_type == "Triangle") && (basis_order == 1) )
204  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TRI_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
205 
206  else if ( (basis_type == "HGrad") && (cell_type == "Triangle") && (basis_order == 2) )
207  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TRI_C2_FEM<ExecutionSpace,OutputValueType,PointValueType> );
208 
209  else if ( (basis_type == "HGrad") && (cell_type == "Triangle") && (basis_order > 2) )
210  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_TRI_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
211 
212  else if ( (basis_type == "HCurl") && (cell_type == "Triangle") && (basis_order == 1) )
213  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_TRI_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
214 
215  else if ( (basis_type == "HCurl") && (cell_type == "Triangle") && (basis_order > 1) )
216  basis = Teuchos::rcp( new Intrepid2::Basis_HCURL_TRI_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
217 
218  else if ( (basis_type == "HDiv") && (cell_type == "Triangle") && (basis_order == 1) )
219  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_TRI_I1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
220 
221  else if ( (basis_type == "HDiv") && (cell_type == "Triangle") && (basis_order > 1) )
222  basis = Teuchos::rcp( new Intrepid2::Basis_HDIV_TRI_In_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
223 
224  else if ( (basis_type == "HGrad") && (cell_type == "Line") && (basis_order == 1) )
225  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_LINE_C1_FEM<ExecutionSpace,OutputValueType,PointValueType> );
226 
227  else if ( (basis_type == "HGrad") && (cell_type == "Line") && (basis_order >= 2) )
228  basis = Teuchos::rcp( new Intrepid2::Basis_HGRAD_LINE_Cn_FEM<ExecutionSpace,OutputValueType,PointValueType>(basis_order, point_type) );
229 
230  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(basis), std::runtime_error,
231  "Failed to create the requestedbasis with basis_type=\"" << basis_type <<
232  "\", basis_order=\"" << basis_order << "\", and cell_type=\"" << cell_type << "\"!\n");
233 
234  TEUCHOS_TEST_FOR_EXCEPTION(cell_topology!=basis->getBaseCellTopology(),
235  std::runtime_error,
236  "Failed to create basis. Intrepid2 basis topology does not match mesh cell topology!");
237 
238  return basis;
239  }
240 
254  template <typename ExecutionSpace, typename OutputValueType, typename PointValueType>
255  Teuchos::RCP<Intrepid2::Basis<ExecutionSpace,OutputValueType,PointValueType> >
256  createIntrepid2Basis(const std::string basis_type, int basis_order,
257  const Teuchos::RCP<const shards::CellTopology> & cell_topology)
258  {
259  return createIntrepid2Basis<ExecutionSpace,OutputValueType,PointValueType>(basis_type,basis_order,*cell_topology);
260  }
261 
262 }
263 
264 
265 #endif
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.