Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_IntegrationValues_impl.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_INTEGRATION_VALUES_IMPL_HPP
44 #define PANZER_INTEGRATION_VALUES_IMPL_HPP
45 
46 #include "Shards_CellTopology.hpp"
47 #include "Intrepid_FieldContainer.hpp"
48 #include "Intrepid_FunctionSpaceTools.hpp"
49 #include "Intrepid_RealSpaceTools.hpp"
50 #include "Intrepid_CellTools.hpp"
51 #include "Panzer_ArrayTraits.hpp"
52 
53 // ***********************************************************
54 // * Specializations of setupArrays() for different array types
55 // ***********************************************************
56 
57 namespace panzer {
58 
59  // * Specialization for Intrepid::FieldContainer<double>
60  template<>
61  inline
63  setupArraysForNodeRule(const Teuchos::RCP<const panzer::IntegrationRule>& ir)
64  {
65  int num_nodes = ir->topology->getNodeCount();
66  int num_cells = ir->workset_size;
67  int num_space_dim = ir->topology->getDimension();
68 
69  int num_ip = 1;
70  cub_points = Intrepid::FieldContainer<double>(num_ip, num_space_dim);
71 
72  if (ir->isSide())
73  side_cub_points =
74  Intrepid::FieldContainer<double>(num_ip,
75  ir->side_topology->getDimension());
76 
77  cub_weights = Intrepid::FieldContainer<double>(num_ip);
78 
79  node_coordinates =
80  Intrepid::FieldContainer<double>(num_cells, num_nodes, num_space_dim);
81 
82  jac = Intrepid::FieldContainer<double>(num_cells, num_ip, num_space_dim,
83  num_space_dim);
84 
85  jac_inv = Intrepid::FieldContainer<double>(num_cells, num_ip,
86  num_space_dim,
87  num_space_dim);
88 
89  jac_det = Intrepid::FieldContainer<double>(num_cells, num_ip);
90 
91  weighted_measure =
92  Intrepid::FieldContainer<double>(num_cells, num_ip);
93 
94  covarient =
95  Intrepid::FieldContainer<double>(num_cells, num_ip,
96  num_space_dim,
97  num_space_dim);
98 
99  contravarient =
100  Intrepid::FieldContainer<double>(num_cells, num_ip,
101  num_space_dim,
102  num_space_dim);
103 
104  norm_contravarient =
105  Intrepid::FieldContainer<double>(num_cells, num_ip);
106 
107  ip_coordinates =
108  Intrepid::FieldContainer<double>(num_cells, num_ip, num_space_dim);
109  }
110 
111  template<>
112  inline
115  {
116  int_rule = ir;
117 
118  int num_nodes = ir->topology->getNodeCount();
119  int num_cells = ir->workset_size;
120  int num_space_dim = ir->topology->getDimension();
121 
122  // specialize content if this is quadrature at anode
123  if(num_space_dim==1 && ir->isSide()) {
124  setupArraysForNodeRule(ir);
125  return;
126  }
127 
128  Intrepid::DefaultCubatureFactory<double,Intrepid::FieldContainer<double> >
129  cubature_factory;
130 
131  if (ir->isSide())
132  intrepid_cubature = cubature_factory.create(*(ir->side_topology),
133  ir->cubature_degree);
134  else
135  intrepid_cubature = cubature_factory.create(*(ir->topology),
136  ir->cubature_degree);
137 
138  int num_ip = intrepid_cubature->getNumPoints();
139 
140  cub_points = Intrepid::FieldContainer<double>(num_ip, num_space_dim);
141 
142  if (ir->isSide())
143  side_cub_points =
144  Intrepid::FieldContainer<double>(num_ip,
145  ir->side_topology->getDimension());
146 
147  cub_weights = Intrepid::FieldContainer<double>(num_ip);
148 
149  node_coordinates =
150  Intrepid::FieldContainer<double>(num_cells, num_nodes, num_space_dim);
151 
152  jac = Intrepid::FieldContainer<double>(num_cells, num_ip, num_space_dim,
153  num_space_dim);
154 
155  jac_inv = Intrepid::FieldContainer<double>(num_cells, num_ip,
156  num_space_dim,
157  num_space_dim);
158 
159  jac_det = Intrepid::FieldContainer<double>(num_cells, num_ip);
160 
161  weighted_measure =
162  Intrepid::FieldContainer<double>(num_cells, num_ip);
163 
164  covarient =
165  Intrepid::FieldContainer<double>(num_cells, num_ip,
166  num_space_dim,
167  num_space_dim);
168 
169  contravarient =
170  Intrepid::FieldContainer<double>(num_cells, num_ip,
171  num_space_dim,
172  num_space_dim);
173 
174  norm_contravarient =
175  Intrepid::FieldContainer<double>(num_cells, num_ip);
176 
177  ip_coordinates =
178  Intrepid::FieldContainer<double>(num_cells, num_ip, num_space_dim);
179 
180  }
181 
182 // ***********************************************************
183 // * Evaluation of values - NOT specialized
184 // ***********************************************************
185 
186  template<typename Scalar, typename Array>
187  template<typename NodeCoordinateArray>
188  inline
190  evaluateValues(const NodeCoordinateArray& in_node_coordinates)
191  {
192  int num_space_dim = int_rule->topology->getDimension();
193  if (int_rule->isSide() && num_space_dim==1) {
194  std::cout << "WARNING: 0-D quadrature rule ifrastructure does not exist!!! Will not be able to do "
195  << "non-natural integration rules.";
196  return;
197  }
198 
199  Intrepid::CellTools<Scalar> cell_tools;
200 
201  if (!int_rule->isSide())
202  intrepid_cubature->getCubature(cub_points, cub_weights);
203  else {
204  intrepid_cubature->getCubature(side_cub_points, cub_weights);
205 
206  cell_tools.mapToReferenceSubcell(cub_points,
207  side_cub_points,
208  int_rule->spatial_dimension-1,
209  int_rule->side,
210  *(int_rule->topology));
211  }
212 
213 
214  {
215  typedef typename
217 
218  size_type num_cells = in_node_coordinates.dimension(0);
219  size_type num_nodes = in_node_coordinates.dimension(1);
220  size_type num_dims = in_node_coordinates.dimension(2);
221 
222  for (size_type cell = 0; cell < num_cells; ++cell) {
223  for (size_type node = 0; node < num_nodes; ++node) {
224  for (size_type dim = 0; dim < num_dims; ++dim) {
225  node_coordinates(cell,node,dim) =
226  in_node_coordinates(cell,node,dim);
227  }
228  }
229  }
230  }
231 
232  cell_tools.setJacobian(jac, cub_points, node_coordinates,
233  *(int_rule->topology));
234 
235  cell_tools.setJacobianInv(jac_inv, jac);
236 
237  cell_tools.setJacobianDet(jac_det, jac);
238 
239  if (!int_rule->isSide()) {
240  Intrepid::FunctionSpaceTools::
241  computeCellMeasure<Scalar>(weighted_measure, jac_det, cub_weights);
242  }
243  else if(int_rule->spatial_dimension==3) {
244  Intrepid::FunctionSpaceTools::
245  computeFaceMeasure<Scalar>(weighted_measure, jac, cub_weights,int_rule->side,*int_rule->topology);
246  }
247  else if(int_rule->spatial_dimension==2) {
248  Intrepid::FunctionSpaceTools::
249  computeEdgeMeasure<Scalar>(weighted_measure, jac, cub_weights,int_rule->side,*int_rule->topology);
250  }
251  else TEUCHOS_ASSERT(false);
252 
253  // Shakib contravarient metric tensor
254  typedef typename
256 
257  for (size_type cell = 0; cell < contravarient.dimension(0); ++cell) {
258  for (size_type ip = 0; ip < contravarient.dimension(1); ++ip) {
259 
260  // zero out matrix
261  for (size_type i = 0; i < contravarient.dimension(2); ++i)
262  for (size_type j = 0; j < contravarient.dimension(3); ++j)
263  covarient(cell,ip,i,j) = 0.0;
264 
265  // g^{ij} = \frac{\parital x_i}{\partial \chi_\alpha}\frac{\parital x_j}{\partial \chi_\alpha}
266  for (size_type i = 0; i < contravarient.dimension(2); ++i) {
267  for (size_type j = 0; j < contravarient.dimension(3); ++j) {
268  for (size_type alpha = 0; alpha < contravarient.dimension(2); ++alpha) {
269  covarient(cell,ip,i,j) += jac(cell,ip,i,alpha) * jac(cell,ip,j,alpha);
270  }
271  }
272  }
273 
274 
275 
276  }
277  }
278 
279  Intrepid::RealSpaceTools<Scalar>::inverse(contravarient, covarient);
280 
281  /*
282  for (std::size_t cell = 0; cell < contravarient.dimension(0); ++cell) {
283  std::cout << "cell = " << cell << std::endl;
284  for (std::size_t ip = 0; ip < contravarient.dimension(1); ++ip) {
285  std::cout << " ip = " << ip << std::endl;
286  for (std::size_t i = 0; i < contravarient.dimension(2); ++i) {
287  for (std::size_t j = 0; j < contravarient.dimension(2); ++j) {
288  std::cout << "contravarient(" << i << "," << j << ") = " << contravarient(cell,ip,i,j) << std::endl;
289  }
290  }
291  }
292  }
293  */
294 
295  // norm of g_ij
296  for (size_type cell = 0; cell < contravarient.dimension(0); ++cell) {
297  for (size_type ip = 0; ip < contravarient.dimension(1); ++ip) {
298  norm_contravarient(cell,ip) = 0.0;
299  for (size_type i = 0; i < contravarient.dimension(2); ++i) {
300  for (size_type j = 0; j < contravarient.dimension(3); ++j) {
301  norm_contravarient(cell,ip) += contravarient(cell,ip,i,j) * contravarient(cell,ip,i,j);
302  }
303  }
304  norm_contravarient(cell,ip) = std::sqrt(norm_contravarient(cell,ip));
305  }
306  }
307 
308  // IP coordinates
309  {
310  cell_tools.mapToPhysicalFrame(ip_coordinates, cub_points, node_coordinates, *(int_rule->topology));
311  }
312 
313  }
314 }
315 
316 #endif
Array::size_type size_type
Teuchos::RCP< const shards::CellTopology > topology
Teuchos::RCP< shards::CellTopology > side_topology
void evaluateValues(const NodeCoordinateArray &node_coordinates)
node_coordinates are cell vertex coordinates, not basis coordinates
#define TEUCHOS_ASSERT(assertion_test)