16#ifndef __INTREPID2_DEFAULT_CUBATURE_FACTORY_DEF_HPP__
17#define __INTREPID2_DEFAULT_CUBATURE_FACTORY_DEF_HPP__
22 template<
typename DT,
typename PT,
typename WT>
23 Teuchos::RCP<Cubature<DT,PT,WT> >
25 create(
unsigned topologyKey,
26 const std::vector<ordinal_type> °ree,
27 const EPolyType polytype,
28 const bool symmetric ) {
31 Teuchos::RCP<Cubature<DT,PT,WT> > r_val;
33 switch (topologyKey) {
34 case shards::Line<>::key:
35 case shards::Beam<>::key:
36 case shards::ShellLine<>::key: {
37 INTREPID2_TEST_FOR_EXCEPTION( degree.size() < 1, std::invalid_argument,
38 ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
40 r_val = Teuchos::rcp(
new CubaturePolylib<DT,PT,WT>(degree[0], polytype));
42 r_val = Teuchos::rcp(
new CubatureDirectLineGauss<DT,PT,WT>(degree[0]));
45 case shards::Triangle<>::key:
46 case shards::ShellTriangle<>::key: {
47 INTREPID2_TEST_FOR_EXCEPTION( degree.size() < 1, std::invalid_argument,
48 ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
49 if(symmetric || (degree[0] > 20)) {
50 r_val = Teuchos::rcp(
new CubatureDirectTriSymmetric<DT,PT,WT>(degree[0])); }
52 r_val = Teuchos::rcp(
new CubatureDirectTriDefault<DT,PT,WT>(degree[0]));
55 case shards::Quadrilateral<>::key:
56 case shards::ShellQuadrilateral<>::key: {
57 INTREPID2_TEST_FOR_EXCEPTION( degree.size() < 2, std::invalid_argument,
58 ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
60 const auto x_line = CubaturePolylib<DT,PT,WT>(degree[0], polytype);
61 const auto y_line = ( degree[1] == degree[0] ? x_line : CubaturePolylib<DT,PT,WT>(degree[1], polytype) );
62 r_val = Teuchos::rcp(
new CubatureTensor<DT,PT,WT>( x_line, y_line ));
64 const auto x_line = CubatureDirectLineGauss<DT,PT,WT>(degree[0]);
65 const auto y_line = ( degree[1] == degree[0] ? x_line : CubatureDirectLineGauss<DT,PT,WT>(degree[1]) );
66 r_val = Teuchos::rcp(
new CubatureTensor<DT,PT,WT>( x_line, y_line ));
70 case shards::Tetrahedron<>::key: {
71 INTREPID2_TEST_FOR_EXCEPTION( degree.size() < 1, std::invalid_argument,
72 ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
74 r_val = Teuchos::rcp(
new CubatureDirectTetSymmetric<DT,PT,WT>(degree[0]));
76 r_val = Teuchos::rcp(
new CubatureDirectTetDefault<DT,PT,WT>(degree[0]));
80 case shards::Hexahedron<>::key: {
81 INTREPID2_TEST_FOR_EXCEPTION( degree.size() < 3, std::invalid_argument,
82 ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
84 const auto x_line = CubaturePolylib<DT,PT,WT>(degree[0], polytype);
85 const auto y_line = ( degree[1] == degree[0] ? x_line : CubaturePolylib<DT,PT,WT>(degree[1], polytype) );
86 const auto z_line = ( degree[2] == degree[0] ? x_line :
87 degree[2] == degree[1] ? y_line : CubaturePolylib<DT,PT,WT>(degree[2], polytype) );
89 r_val = Teuchos::rcp(
new CubatureTensor<DT,PT,WT>( x_line, y_line, z_line ));
91 const auto x_line = CubatureDirectLineGauss<DT,PT,WT>(degree[0]);
92 const auto y_line = ( degree[1] == degree[0] ? x_line : CubatureDirectLineGauss<DT,PT,WT>(degree[1]) );
93 const auto z_line = ( degree[2] == degree[0] ? x_line :
94 degree[2] == degree[1] ? y_line : CubatureDirectLineGauss<DT,PT,WT>(degree[2]) );
96 r_val = Teuchos::rcp(
new CubatureTensor<DT,PT,WT>( x_line, y_line, z_line ));
100 case shards::Wedge<>::key: {
101 INTREPID2_TEST_FOR_EXCEPTION( degree.size() < 2, std::invalid_argument,
102 ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.")
104 if(symmetric || (degree[0] > 20)) {
105 const auto xy_tri = CubatureDirectTriSymmetric<DT,PT,WT>(degree[0]);
106 const auto z_line = CubatureDirectLineGauss<DT,PT,WT>(degree[1]);
107 r_val = Teuchos::rcp(
new CubatureTensor<DT,PT,WT>( xy_tri, z_line ));
110 const auto xy_tri = CubatureDirectTriDefault<DT,PT,WT>(degree[0]);
111 const auto z_line = CubatureDirectLineGauss<DT,PT,WT>(degree[1]);
112 r_val = Teuchos::rcp(
new CubatureTensor<DT,PT,WT>( xy_tri, z_line ));
117 case shards::Pyramid<>::key: {
118 INTREPID2_TEST_FOR_EXCEPTION( degree.size() < 1, std::invalid_argument,
119 ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
123 const auto xy_line = CubatureDirectLineGauss<DT,PT,WT>(degree[0]);
124 const auto z_line = CubatureDirectLineGaussJacobi20<DT,PT,WT>(degree[0]);
125 r_val = Teuchos::rcp(
new CubatureTensorPyr<DT,PT,WT>( xy_line, xy_line, z_line ));
130 INTREPID2_TEST_FOR_EXCEPTION( ( (topologyKey != shards::Line<>::key) &&
131 (topologyKey != shards::Beam<>::key) &&
132 (topologyKey != shards::ShellLine<>::key) &&
133 (topologyKey != shards::Triangle<>::key) &&
134 (topologyKey != shards::ShellTriangle<>::key) &&
135 (topologyKey != shards::Quadrilateral<>::key) &&
136 (topologyKey != shards::ShellQuadrilateral<>::key) &&
137 (topologyKey != shards::Tetrahedron<>::key) &&
138 (topologyKey != shards::Hexahedron<>::key) &&
139 (topologyKey != shards::Pyramid<>::key) &&
140 (topologyKey != shards::Wedge<>::key) ),
141 std::invalid_argument,
142 ">>> ERROR (DefaultCubatureFactory): Invalid cell topology prevents cubature creation.");
148 template<
typename DT,
typename PT,
typename WT>
149 Teuchos::RCP<Cubature<DT,PT,WT> >
151 create(
const shards::CellTopology cellTopology,
152 const std::vector<ordinal_type> °ree,
153 const EPolyType polytype,
154 const bool symmetric ) {
155 return create<DT,PT,WT>(cellTopology.getBaseKey(), degree, polytype, symmetric);
159 template<
typename DT,
typename PT,
typename WT>
160 Teuchos::RCP<Cubature<DT,PT,WT> >
162 create(
unsigned topologyKey,
163 const ordinal_type degree,
164 const EPolyType polytype,
165 const bool symmetric ) {
167 const std::vector<ordinal_type> degreeArray(3, degree);
168 return create<DT,PT,WT>(topologyKey, degreeArray, polytype, symmetric);
171 template<
typename DT,
typename PT,
typename WT>
172 Teuchos::RCP<Cubature<DT,PT,WT> >
174 create(
const shards::CellTopology cellTopology,
175 const ordinal_type degree,
176 const EPolyType polytype,
177 const bool symmetric ) {
179 const std::vector<ordinal_type> degreeArray(3, degree);
180 return create<DT,PT,WT>(cellTopology.getBaseKey(), degreeArray, polytype, symmetric);
KOKKOS_FORCEINLINE_FUNCTION bool isValidPolyType(const EPolyType polytype)
Verifies validity of a PolyType enum.
static Teuchos::RCP< Cubature< DeviceType, pointValueType, weightValueType > > create(unsigned topologyKey, const std::vector< ordinal_type > °ree, const EPolyType polytype=POLYTYPE_MAX, const bool symmetric=false)
Factory method.