Panzer Version of the Day
Loading...
Searching...
No Matches
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
21PointRule(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
30PointRule(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
43PointRule(const panzer::PointDescriptor& description,
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
52setup(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
111setup(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
141const std::string & panzer::PointRule::getName() const
142{
143 return point_name;
144}
145
147{
148 return (!Teuchos::is_null(side_topology));
149}
150
151Teuchos::RCP<shards::CellTopology> panzer::PointRule::getSideTopology(const CellData & cell_data)
152{
153 Teuchos::RCP<shards::CellTopology> sideTopo;
154 int spatial_dimension = cell_data.baseCellDimension();
155 Teuchos::RCP<const shards::CellTopology> topology = cell_data.getCellTopology();
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
174Teuchos::RCP<PHX::DataLayout>
176{return Teuchos::rcp(new PHX::MDALayout<Cell>(workset_size));}
177
178Teuchos::RCP<PHX::DataLayout>
180{return Teuchos::rcp(new PHX::MDALayout<Cell,Dim>(workset_size, dim0));}
181
182Teuchos::RCP<PHX::DataLayout>
183panzer::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
187Teuchos::RCP<PHX::DataLayout>
189{return Teuchos::rcp(new PHX::MDALayout<Cell,IP>(workset_size, num_points));}
190
191Teuchos::RCP<PHX::DataLayout>
193{return Teuchos::rcp(new PHX::MDALayout<Cell,IP,Dim>(workset_size, num_points, dim0));}
194
195Teuchos::RCP<PHX::DataLayout>
196panzer::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
200Teuchos::RCP<PHX::DataLayout>
202{return Teuchos::rcp(new PHX::MDALayout<Face>(_num_faces));}
203
204Teuchos::RCP<PHX::DataLayout>
206{return Teuchos::rcp(new PHX::MDALayout<Face,Dim>(_num_faces, dim0));}
207
208Teuchos::RCP<PHX::DataLayout>
209panzer::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
213Teuchos::RCP<PHX::DataLayout>
215{return Teuchos::rcp(new PHX::MDALayout<Face,IP>(_num_faces, _num_points_per_face));}
216
217Teuchos::RCP<PHX::DataLayout>
219{return Teuchos::rcp(new PHX::MDALayout<Face,IP,Dim>(_num_faces, _num_points_per_face, dim0));}
220
221Teuchos::RCP<PHX::DataLayout>
222panzer::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
227void 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}
Data for determining cell topology and dimensionality.
int baseCellDimension() const
Dimension of the base cell. NOT the dimension of the local side, even if the side() method returns tr...
Teuchos::RCP< const shards::CellTopology > getCellTopology() const
Get CellTopology for the base cell.
std::size_t numCells() 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 ...
virtual int numPoints(const shards::CellTopology &topo) const =0
Get the points for a particular topology.
Teuchos::RCP< PHX::DataLayout > getFaceDataLayout() const
Teuchos::RCP< PHX::DataLayout > getFacePointDataLayout() const
static Teuchos::RCP< shards::CellTopology > getSideTopology(const CellData &cell_data)
virtual void print(std::ostream &os)
print information about the integration rule
void setup(const std::string &ptName, int np, const panzer::CellData &cell_data)
Teuchos::RCP< PHX::DataLayout > getCellDataLayout() const
Teuchos::RCP< PHX::DataLayout > getCellPointDataLayout() const
const std::string & getName() const