Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_PointRule.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #include "Panzer_PointRule.hpp"
12 
13 #include "Teuchos_Assert.hpp"
14 #include "Phalanx_DataLayout_MDALayout.hpp"
15 #include "Intrepid2_DefaultCubatureFactory.hpp"
16 #include "Panzer_Dimension.hpp"
17 #include "Panzer_CellData.hpp"
19 
21 PointRule(const std::string & ptName,
22  int np,
23  const panzer::CellData& cell_data) :
24  side(-1)
25 {
26  setup(ptName,np,cell_data);
27 }
28 
30 PointRule(const std::string & point_rule_name,
31  const int num_cells,
32  const int num_points_per_cell,
33  const int num_faces,
34  const int num_points_per_face,
35  const Teuchos::RCP<const shards::CellTopology> & cell_topology)
36 {
37  setup(point_rule_name, num_cells, num_points_per_cell, num_faces, num_points_per_face, cell_topology);
38 }
39 
44  const Teuchos::RCP<const shards::CellTopology> & cell_topology,
45  const int num_cells)
46 {
47  int num_points_per_cell = description.getGenerator().numPoints(*cell_topology);
48  setup(description.getType(), num_cells, num_points_per_cell, 0, 0, cell_topology);
49 }
50 
52 setup(const std::string & ptName,
53  int np,
54  const panzer::CellData& cell_data)
55 {
56  point_name = ptName;
57  num_points = np;
58  spatial_dimension = cell_data.baseCellDimension();
59  workset_size = cell_data.numCells();
60  _num_faces = -1;
61  _num_points_per_face = -1;
62 
63  topology = cell_data.getCellTopology();
64  TEUCHOS_TEST_FOR_EXCEPTION(topology==Teuchos::null,std::runtime_error,
65  "PointRule::setup - Base topology from cell_data cannot be null!");
66  TEUCHOS_TEST_FOR_EXCEPTION(spatial_dimension!=(int) topology->getDimension(), std::runtime_error,
67  "PointRule::setup - Spatial dimension from cell_data does not match the cell topology.");
68 
69  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(topology), std::runtime_error,
70  "PointRule::setup - Failed to allocate cell topology!");
71 
72  // handle side issues : first veryify the 0D side follows the rules
73  if(cell_data.isSide() && spatial_dimension==1) {
74  TEUCHOS_ASSERT(num_points==1); // only one point on a node
75  }
76 
77  // now extract side topology
78  side_topology = getSideTopology(cell_data);
79  if (side_topology!=Teuchos::null)
80  side = cell_data.side();
81 
82  TEUCHOS_TEST_FOR_EXCEPTION(side >= 0 && Teuchos::is_null(side_topology),
83  std::runtime_error,
84  "Failed to allocate side topology!");
85 
86  // allocate data layout objects
87  using Teuchos::rcp;
88  using PHX::MDALayout;
89 
90  dl_scalar =
91  rcp(new MDALayout<Cell,IP>(workset_size,num_points));
92 
93  dl_vector =
94  rcp(new MDALayout<Cell,IP,Dim>(workset_size, num_points,
95  spatial_dimension));
96 
97  dl_tensor =
98  rcp(new MDALayout<Cell,IP,Dim,Dim>(workset_size, num_points,
99  spatial_dimension,
100  spatial_dimension));
101 
102  dl_vector3 =
103  rcp(new MDALayout<Cell,IP,Dim>(workset_size, num_points,3));
104  dl_tensor3x3 =
105  rcp(new MDALayout<Cell,IP,Dim,Dim>(workset_size, num_points,3,3));
106 
107 }
108 
109 
111 setup(const std::string & point_rule_name,
112  const int num_cells,
113  const int num_points_per_cell,
114  const int num_faces,
115  const int num_points_per_face,
116  const Teuchos::RCP<const shards::CellTopology> & cell_topology)
117 {
118 
119  topology = cell_topology;
120  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(topology),std::runtime_error,
121  "PointRule::setup - Cell topology cannot be null.");
122 
123  point_name = point_rule_name;
124  num_points = num_points_per_cell;
125  spatial_dimension = cell_topology->getDimension();
126  workset_size = num_cells;
127  _num_faces = num_faces;
128  _num_points_per_face = num_points_per_face;
129  side = -1;
130 
131  // allocate data layout objects
132  dl_scalar = Teuchos::rcp(new PHX::MDALayout<Cell,IP>(workset_size,num_points));
133  dl_vector = Teuchos::rcp(new PHX::MDALayout<Cell,IP,Dim>(workset_size, num_points,spatial_dimension));
134  dl_tensor = Teuchos::rcp(new PHX::MDALayout<Cell,IP,Dim,Dim>(workset_size, num_points,spatial_dimension,spatial_dimension));
135 
136  dl_vector3 = Teuchos::rcp(new PHX::MDALayout<Cell,IP,Dim>(workset_size, num_points,3));
137  dl_tensor3x3 = Teuchos::rcp(new PHX::MDALayout<Cell,IP,Dim,Dim>(workset_size, num_points,3,3));
138 
139 }
140 
141 const std::string & panzer::PointRule::getName() const
142 {
143  return point_name;
144 }
145 
147 {
148  return (!Teuchos::is_null(side_topology));
149 }
150 
152 {
154  int spatial_dimension = cell_data.baseCellDimension();
156 
157  if (cell_data.isSide() && spatial_dimension>1) {
158  int side = cell_data.side();
159 
160  TEUCHOS_TEST_FOR_EXCEPTION( (side >= static_cast<int>(topology->getSideCount())),
161  std::runtime_error, "Error - local side "
162  << side << " is not in range (0->" << topology->getSideCount()-1
163  << ") of topologic entity!");
164 
165  sideTopo = Teuchos::rcp(new shards::CellTopology(topology->getCellTopologyData(topology->getDimension()-1,side)));
166  }
167  else if(cell_data.isSide() && spatial_dimension==1) {
168  sideTopo = Teuchos::rcp(new shards::CellTopology(shards::getCellTopologyData<shards::Node>()));
169  }
170 
171  return sideTopo;
172 }
173 
176 {return Teuchos::rcp(new PHX::MDALayout<Cell>(workset_size));}
177 
180 {return Teuchos::rcp(new PHX::MDALayout<Cell,Dim>(workset_size, dim0));}
181 
183 panzer::PointRule::getCellDataLayout(const int dim0, const int dim1) const
184 {return Teuchos::rcp(new PHX::MDALayout<Cell,Dim,Dim>(workset_size, dim0, dim1));}
185 
186 
189 {return Teuchos::rcp(new PHX::MDALayout<Cell,IP>(workset_size, num_points));}
190 
193 {return Teuchos::rcp(new PHX::MDALayout<Cell,IP,Dim>(workset_size, num_points, dim0));}
194 
196 panzer::PointRule::getCellPointDataLayout(const int dim0, const int dim1) const
197 {return Teuchos::rcp(new PHX::MDALayout<Cell,IP,Dim,Dim>(workset_size, num_points, dim0, dim1));}
198 
199 
202 {return Teuchos::rcp(new PHX::MDALayout<Face>(_num_faces));}
203 
206 {return Teuchos::rcp(new PHX::MDALayout<Face,Dim>(_num_faces, dim0));}
207 
209 panzer::PointRule::getFaceDataLayout(const int dim0, const int dim1) const
210 {return Teuchos::rcp(new PHX::MDALayout<Face,Dim,Dim>(_num_faces, dim0, dim1));}
211 
212 
215 {return Teuchos::rcp(new PHX::MDALayout<Face,IP>(_num_faces, _num_points_per_face));}
216 
219 {return Teuchos::rcp(new PHX::MDALayout<Face,IP,Dim>(_num_faces, _num_points_per_face, dim0));}
220 
222 panzer::PointRule::getFacePointDataLayout(const int dim0, const int dim1) const
223 {return Teuchos::rcp(new PHX::MDALayout<Face,IP,Dim,Dim>(_num_faces, _num_points_per_face, dim0, dim1));}
224 
225 
226 
227 void panzer::PointRule::print(std::ostream & os)
228 {
229  os << "panzer::PointRule ( "
230  << "Name = " << getName()
231  << ", Dimension = " << spatial_dimension
232  << ", Workset Size = " << workset_size
233  << ", Num Points = " << num_points
234  << ", Side = " << side
235  << " )";
236 }
int baseCellDimension() const
Dimension of the base cell. NOT the dimension of the local side, even if the side() method returns tr...
void setup(const std::string &ptName, int np, const panzer::CellData &cell_data)
bool is_null(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< const shards::CellTopology > getCellTopology() const
Get CellTopology for the base cell.
Teuchos::RCP< PHX::DataLayout > getCellDataLayout() const
virtual int numPoints(const shards::CellTopology &topo) const =0
Get the points for a particular topology.
const std::string & getName() const
std::size_t numCells() const
virtual void print(std::ostream &os)
print information about the integration rule
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Data for determining cell topology and dimensionality.
Teuchos::RCP< PHX::DataLayout > getFacePointDataLayout() const
Teuchos::RCP< PHX::DataLayout > getFaceDataLayout() const
const PointGenerator & getGenerator() const
const std::string & getType() const
Get unique string associated with the type of point descriptor. This will be used generate a hash to ...
static Teuchos::RCP< shards::CellTopology > getSideTopology(const CellData &cell_data)
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::RCP< PHX::DataLayout > getCellPointDataLayout() const
bool isSide() const