Panzer  Version of the Day
Panzer_PointRule.cpp
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 
44 #include "Panzer_PointRule.hpp"
45 
46 #include "Teuchos_Assert.hpp"
47 #include "Phalanx_DataLayout_MDALayout.hpp"
48 #include "Intrepid2_DefaultCubatureFactory.hpp"
49 #include "Panzer_Dimension.hpp"
50 #include "Panzer_CellData.hpp"
51 
53 PointRule(const std::string & ptName,
54  int np,
55  const panzer::CellData& cell_data) :
56  side(-1)
57 {
58  setup(ptName,np,cell_data);
59 }
60 
62 setup(const std::string & ptName,
63  int np,
64  const panzer::CellData& cell_data)
65 {
66  point_name = ptName;
67  num_points = np;
68  spatial_dimension = cell_data.baseCellDimension();
69  workset_size = cell_data.numCells();
70 
71  topology = cell_data.getCellTopology();
72  TEUCHOS_TEST_FOR_EXCEPTION(topology==Teuchos::null,std::runtime_error,
73  "PointRule::setup - Base topology from cell_data cannot be null!");
74  TEUCHOS_TEST_FOR_EXCEPTION(spatial_dimension!=(int) topology->getDimension(), std::runtime_error,
75  "PointRule::setup - Spatial dimension from cell_data does not match the cell topology.");
76 
77  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(topology), std::runtime_error,
78  "PointRule::setup - Failed to allocate cell topology!");
79 
80  // handle side issues : first veryify the 0D side follows the rules
81  if(cell_data.isSide() && spatial_dimension==1) {
82  TEUCHOS_ASSERT(num_points==1); // only one point on a node
83  }
84 
85  // now extract side topology
86  side_topology = getSideTopology(cell_data);
87  if (side_topology!=Teuchos::null)
88  side = cell_data.side();
89 
90  TEUCHOS_TEST_FOR_EXCEPTION(side >= 0 && Teuchos::is_null(side_topology),
91  std::runtime_error,
92  "Failed to allocate side topology!");
93 
94  // allocate data layout objects
95  using Teuchos::rcp;
96  using PHX::MDALayout;
97 
98  dl_scalar =
99  rcp(new MDALayout<Cell,IP>(workset_size,num_points));
100 
101  dl_vector =
102  rcp(new MDALayout<Cell,IP,Dim>(workset_size, num_points,
103  spatial_dimension));
104 
105  dl_tensor =
106  rcp(new MDALayout<Cell,IP,Dim,Dim>(workset_size, num_points,
107  spatial_dimension,
108  spatial_dimension));
109 
110  dl_vector3 =
111  rcp(new MDALayout<Cell,IP,Dim>(workset_size, num_points,3));
112  dl_tensor3x3 =
113  rcp(new MDALayout<Cell,IP,Dim,Dim>(workset_size, num_points,3,3));
114 
115 }
116 
117 const std::string & panzer::PointRule::getName() const
118 {
119  return point_name;
120 }
121 
123 {
124  return (!Teuchos::is_null(side_topology));
125 }
126 
127 Teuchos::RCP<shards::CellTopology> panzer::PointRule::getSideTopology(const CellData & cell_data)
128 {
129  Teuchos::RCP<shards::CellTopology> sideTopo;
130  int spatial_dimension = cell_data.baseCellDimension();
131  Teuchos::RCP<const shards::CellTopology> topology = cell_data.getCellTopology();
132 
133  if (cell_data.isSide() && spatial_dimension>1) {
134  int side = cell_data.side();
135 
136  TEUCHOS_TEST_FOR_EXCEPTION( (side >= static_cast<int>(topology->getSideCount())),
137  std::runtime_error, "Error - local side "
138  << side << " is not in range (0->" << topology->getSideCount()-1
139  << ") of topologic entity!");
140 
141  sideTopo = Teuchos::rcp(new shards::CellTopology(topology->getCellTopologyData(topology->getDimension()-1,side)));
142  }
143  else if(cell_data.isSide() && spatial_dimension==1) {
144  sideTopo = Teuchos::rcp(new shards::CellTopology(shards::getCellTopologyData<shards::Node>()));
145  }
146 
147  return sideTopo;
148 }
149 
150 void panzer::PointRule::print(std::ostream & os)
151 {
152  os << "panzer::PointRule ( "
153  << "Name = " << getName()
154  << ", Dimension = " << spatial_dimension
155  << ", Workset Size = " << workset_size
156  << ", Num Points = " << num_points
157  << ", Side = " << side
158  << " )";
159 }
void setup(const std::string &ptName, int np, const panzer::CellData &cell_data)
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.
virtual void print(std::ostream &os)
print information about the integration rule
Data for determining cell topology and dimensionality.
bool isSide() const
static Teuchos::RCP< shards::CellTopology > getSideTopology(const CellData &cell_data)
const std::string & getName() const
std::size_t numCells() const