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