Panzer  Version of the Day
Panzer_IntegrationValues2.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 
44 #ifndef PANZER_INTEGRATION_VALUES2_HPP
45 #define PANZER_INTEGRATION_VALUES2_HPP
46 
47 #include "Teuchos_RCP.hpp"
48 
49 #include "PanzerDiscFE_config.hpp"
51 #include "Panzer_ArrayTraits.hpp"
52 #include "Panzer_Dimension.hpp"
53 #include "Phalanx_MDField.hpp"
54 #include "Intrepid2_Cubature.hpp"
55 
56 namespace panzer {
57 
58  class SubcellConnectivity;
59 
60  template <typename Scalar>
62  public:
64 
65  typedef PHX::MDField<Scalar> ArrayDynamic;
66  typedef PHX::MDField<double> DblArrayDynamic;
67 
68  typedef PHX::MDField<Scalar,IP> Array_IP;
69  typedef PHX::MDField<Scalar,IP,Dim> Array_IPDim;
70  typedef PHX::MDField<Scalar,Point> Array_Point;
71  typedef PHX::MDField<Scalar,Cell,IP> Array_CellIP;
72  typedef PHX::MDField<Scalar,Cell,IP,Dim> Array_CellIPDim;
73  typedef PHX::MDField<Scalar,Cell,IP,Dim,Dim> Array_CellIPDimDim;
74  typedef PHX::MDField<Scalar,Cell,BASIS,Dim> Array_CellBASISDim;
75 
76  typedef PHX::MDField<const Scalar,IP> ConstArray_IP;
77  typedef PHX::MDField<const Scalar,IP,Dim> ConstArray_IPDim;
78  typedef PHX::MDField<const Scalar,Point> ConstArray_Point;
79  typedef PHX::MDField<const Scalar,Cell,IP> ConstArray_CellIP;
80  typedef PHX::MDField<const Scalar,Cell,IP,Dim> ConstArray_CellIPDim;
81  typedef PHX::MDField<const Scalar,Cell,IP,Dim,Dim> ConstArray_CellIPDimDim;
82  typedef PHX::MDField<const Scalar,Cell,BASIS,Dim> ConstArray_CellBASISDim;
83 
90  IntegrationValues2(const std::string & pre="",
91  const bool allocArrays=false);
92 
93 
94  // =====================================================================================================
95  // Classic Interface (DEPRECATED)
96 
98  void setupArrays(const Teuchos::RCP<const panzer::IntegrationRule>& ir);
99 
111  void evaluateValues(const PHX::MDField<Scalar,Cell,NODE,Dim> & vertex_coordinates,
112  const int num_cells = -1,
113  const Teuchos::RCP<const SubcellConnectivity> & face_connectivity = Teuchos::null,
114  const int num_virtual_cells = -1);
115 
130  void evaluateValues(const PHX::MDField<Scalar,Cell,NODE,Dim> & vertex_coordinates,
131  const PHX::MDField<Scalar,Cell,IP,Dim> & other_ip_coordinates,
132  const int num_cells = -1);
133 
134  // Reference space quantities
135  mutable Array_IPDim cub_points; // <IP,Dim>
136  mutable Array_IPDim side_cub_points; // <IP,Dim> points on face topology (dim-1)
137  mutable Array_IP cub_weights; // <IP>
138 
139  // Physical space quantities
140  mutable Array_CellBASISDim node_coordinates; // <Cell,BASIS,Dim>
141  mutable Array_CellIPDimDim jac; // <Cell,IP,Dim,Dim>
142  mutable Array_CellIPDimDim jac_inv; // <Cell,IP,Dim,Dim>
143  mutable Array_CellIP jac_det; // <Cell,IP>
144  mutable Array_CellIP weighted_measure; // <Cell,IP>
145  mutable Array_CellIPDim weighted_normals; // <Cell,IP,Dim>
146  mutable Array_CellIPDim surface_normals; // <Cell,IP,Dim>
147  mutable Array_CellIPDimDim surface_rotation_matrices; // <Cell,IP,Dim,Dim>
148  // this (appears) is a matrix where the first row is the "normal" direction
149  // and the remaining two rows lie in the hyperplane
150 
151  // for Shakib stabilization <Cell,IP,Dim,Dim>
155 
156  // integration points
157  mutable Array_CellIPDim ip_coordinates; // <Cell,IP,Dim>
158  mutable Array_CellIPDim ref_ip_coordinates; // <Cell,IP,Dim> for Control Volumes or Surface integrals
159 
160 
161  Teuchos::RCP<const panzer::IntegrationRule> int_rule;
162 
163  Teuchos::RCP<Intrepid2::Cubature<PHX::Device::execution_space,double,double>> intrepid_cubature;
164 
165  // =====================================================================================================
166  // Lazy evaluation interface
167 
190  void
191  setup(const Teuchos::RCP<const panzer::IntegrationRule>& ir,
192  const PHX::MDField<Scalar,Cell,NODE,Dim> & node_coordinates,
193  const int num_cells = -1);
194 
205  void
206  setupPermutations(const Teuchos::RCP<const SubcellConnectivity> & face_connectivity,
207  const int num_virtual_cells);
208 
217  void
218  setupPermutations(const PHX::MDField<Scalar,Cell,IP,Dim> & other_ip_coordinates);
219 
233  getUniformCubaturePointsRef(const bool cache = true,
234  const bool force = false,
235  const bool apply_permutation = true) const;
236 
250  getUniformSideCubaturePointsRef(const bool cache = true,
251  const bool force = false,
252  const bool apply_permutation = true) const;
253 
267  getUniformCubatureWeightsRef(const bool cache = true,
268  const bool force = false,
269  const bool apply_permutation = true) const;
270 
271 
278  getNodeCoordinates() const;
279 
291  getJacobian(const bool cache = true,
292  const bool force = false) const;
293 
294 
306  getJacobianInverse(const bool cache = true,
307  const bool force = false) const;
308 
320  getJacobianDeterminant(const bool cache = true,
321  const bool force = false) const;
322 
334  getWeightedMeasure(const bool cache = true,
335  const bool force = false) const;
336 
348  getWeightedNormals(const bool cache = true,
349  const bool force = false) const;
350 
362  getSurfaceNormals(const bool cache = true,
363  const bool force = false) const;
364 
376  getSurfaceRotationMatrices(const bool cache = true,
377  const bool force = false) const;
378 
392  getCovarientMatrix(const bool cache = true,
393  const bool force = false) const;
394 
408  getContravarientMatrix(const bool cache = true,
409  const bool force = false) const;
410 
424  getNormContravarientMatrix(const bool cache = true,
425  const bool force = false) const;
426 
438  getCubaturePoints(const bool cache = true,
439  const bool force = false) const;
440 
452  getCubaturePointsRef(const bool cache = true,
453  const bool force = false) const;
454 
455  // =====================================================================================================
456 
457  protected:
458 
459  // Reset all the lazy evaluation arrays
460  void
461  resetArrays();
462 
463  // Number of cells in mesh
465 
466  // Number of cells in mesh to evaluate
468 
469  // Number of virtual cells in the mesh - used for surface evaluations
471 
472  // Permutations (used to re-orient arrays similar to orientations in BasisValues2)
474 
475  // Array contains the mapping from uniform reference space to permuted space
476  PHX::MDField<const int,Cell,IP> permutations_;
477 
478  // TODO: There is a way around this, but it will require some work
479  // Subcell connectivity is required for surface evaluations (normals and rotation matrices)
480  Teuchos::RCP<const SubcellConnectivity> side_connectivity_;
481 
482  // Lazy evaluation checks
483  mutable bool cub_points_evaluated_;
487  mutable bool jac_evaluated_;
488  mutable bool jac_inv_evaluated_;
489  mutable bool jac_det_evaluated_;
494  mutable bool covarient_evaluated_;
499 
500  // Backward compatibility call that evaluates all internal values for CV, surface, side, or volume integration schemes
501  void
503 
504  private:
505 
507  std::string prefix_;
508  std::vector<PHX::index_size_type> ddims_;
509 
510  };
511 
512 } // namespace panzer
513 
514 #endif
void setupPermutations(const Teuchos::RCP< const SubcellConnectivity > &face_connectivity, const int num_virtual_cells)
Initialize the permutation arrays given a face connectivity.
ConstArray_CellIPDim getSurfaceNormals(const bool cache=true, const bool force=false) const
Get the surface normals.
ConstArray_CellIP getNormContravarientMatrix(const bool cache=true, const bool force=false) const
Get the contravarient matrix.
ConstArray_CellIP getJacobianDeterminant(const bool cache=true, const bool force=false) const
Get the determinant of the Jacobian matrix evaluated at the cubature points.
PHX::MDField< Scalar, Cell, IP > Array_CellIP
PHX::MDField< Scalar, Point > Array_Point
ConstArray_CellIP getWeightedMeasure(const bool cache=true, const bool force=false) const
Get the weighted measure (integration weights)
ConstArray_CellIPDimDim getJacobian(const bool cache=true, const bool force=false) const
Get the Jacobian matrix evaluated at the cubature points.
PHX::MDField< const int, Cell, IP > permutations_
PHX::MDField< const Scalar, Point > ConstArray_Point
PHX::MDField< Scalar, IP > Array_IP
ConstArray_CellBASISDim getNodeCoordinates() const
Get the node coordinates describing the geometry of the mesh.
PHX::MDField< const Scalar, IP > ConstArray_IP
PHX::MDField< const Scalar, Cell, IP > ConstArray_CellIP
ConstArray_CellIPDimDim getCovarientMatrix(const bool cache=true, const bool force=false) const
Get the covarient matrix.
PHX::MDField< Scalar, Cell, IP, Dim, Dim > Array_CellIPDimDim
ConstArray_IPDim getUniformCubaturePointsRef(const bool cache=true, const bool force=false, const bool apply_permutation=true) const
Get the uniform cubature points.
ConstArray_IP getUniformCubatureWeightsRef(const bool cache=true, const bool force=false, const bool apply_permutation=true) const
Get the uniform cubature weights.
Teuchos::RCP< Intrepid2::Cubature< PHX::Device::execution_space, double, double > > intrepid_cubature
PHX::MDField< const Scalar, IP, Dim > ConstArray_IPDim
Teuchos::RCP< const panzer::IntegrationRule > int_rule
ConstArray_CellIPDimDim getContravarientMatrix(const bool cache=true, const bool force=false) const
Get the contravarient matrix.
ConstArray_IPDim getUniformSideCubaturePointsRef(const bool cache=true, const bool force=false, const bool apply_permutation=true) const
Get the uniform cubature points for a side.
void setup(const Teuchos::RCP< const panzer::IntegrationRule > &ir, const PHX::MDField< Scalar, Cell, NODE, Dim > &node_coordinates, const int num_cells=-1)
Main setup call for the lazy evaluation interface.
PHX::MDField< Scalar, Cell, BASIS, Dim > Array_CellBASISDim
ArrayTraits< Scalar, PHX::MDField< Scalar > >::size_type size_type
void evaluateValues(const PHX::MDField< Scalar, Cell, NODE, Dim > &vertex_coordinates, const int num_cells=-1, const Teuchos::RCP< const SubcellConnectivity > &face_connectivity=Teuchos::null, const int num_virtual_cells=-1)
Evaluate basis values.
void setupArrays(const Teuchos::RCP< const panzer::IntegrationRule > &ir)
Sizes/allocates memory for arrays.
ConstArray_CellIPDimDim getSurfaceRotationMatrices(const bool cache=true, const bool force=false) const
Get the surface rotation matrices.
PHX::MDField< Scalar, Cell, IP, Dim > Array_CellIPDim
PHX::MDField< double > DblArrayDynamic
ConstArray_CellIPDim getCubaturePoints(const bool cache=true, const bool force=false) const
Get the cubature points in physical space.
PHX::MDField< Scalar, IP, Dim > Array_IPDim
IntegrationValues2(const std::string &pre="", const bool allocArrays=false)
Base constructor.
PHX::MDField< const Scalar, Cell, IP, Dim > ConstArray_CellIPDim
std::vector< PHX::index_size_type > ddims_
PHX::MDField< const Scalar, Cell, IP, Dim, Dim > ConstArray_CellIPDimDim
ConstArray_CellIPDim getCubaturePointsRef(const bool cache=true, const bool force=false) const
Get the cubature points in the reference space.
ConstArray_CellIPDim getWeightedNormals(const bool cache=true, const bool force=false) const
Get the weighted normals.
Teuchos::RCP< const SubcellConnectivity > side_connectivity_
ConstArray_CellIPDimDim getJacobianInverse(const bool cache=true, const bool force=false) const
Get the inverse of the Jacobian matrix evaluated at the cubature points.
PHX::MDField< const Scalar, Cell, BASIS, Dim > ConstArray_CellBASISDim