Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_PointValues_Evaluator_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_PointValues_Evaluator_IMPL_HPP
44 #define PANZER_PointValues_Evaluator_IMPL_HPP
45 
46 #include <algorithm>
47 #include "Panzer_PointRule.hpp"
50 
51 namespace panzer {
52 
53 //**********************************************************************
54 template<typename EvalT, typename Traits>
57  const Teuchos::ParameterList& p)
58 {
59  basis_index = 0;
60 
62  = p.get< Teuchos::RCP<const panzer::PointRule> >("Point Rule");
65 
66  initialize(pointRule,userArray.ptr(),Teuchos::null);
67 }
68 
69 //**********************************************************************
70 template <typename EvalT, typename TRAITST>
72  const Kokkos::DynRankView<double,PHX::Device> & userArray)
73 {
74  basis_index = 0;
75 
76  initialize(pointRule,Teuchos::ptrFromRef(userArray),Teuchos::null);
77 }
78 
79 //**********************************************************************
80 template <typename EvalT, typename TRAITST>
82  const PHX::MDField<double, panzer::IP, panzer::Dim> & userArray)
83 {
84  basis_index = 0;
85 
86  initialize(pointRule,Teuchos::ptrFromRef(userArray),Teuchos::null);
87 }
88 
89 //**********************************************************************
90 template <typename EvalT, typename TRAITST>
92  const Teuchos::RCP<const panzer::PureBasis> & pureBasis)
93 {
94  basis_index = 0;
95 
97  initialize(pointRule,userArray,pureBasis);
98 }
99 
100 //**********************************************************************
101 template <typename EvalT, typename TRAITST>
102 template <typename ArrayT>
104  const Teuchos::Ptr<const ArrayT> & userArray,
105  const Teuchos::RCP<const panzer::PureBasis> & pureBasis)
106 {
107  basis = pureBasis;
108 
109  if(userArray!=Teuchos::null && basis==Teuchos::null)
110  useBasisValuesRefArray = false;
111  else if(userArray==Teuchos::null && basis!=Teuchos::null)
112  useBasisValuesRefArray = true;
113  else {
114  // this is a conflicting request, throw an exception
115  TEUCHOS_ASSERT(false);
116  }
117 
118  // copy user array data
119  if(userArray!=Teuchos::null) {
120  TEUCHOS_ASSERT(userArray->rank()==2);
121  MDFieldArrayFactory md_af("refPointArray",true);
122 
123  refPointArray = md_af.buildStaticArray<double,NODE,Dim>("refPointArray",userArray->extent(0),userArray->extent(1));
124  // TEUCHOS_ASSERT(refPointArray.size()==userArray->size());
125  for(int i=0;i<userArray->extent_int(0);i++)
126  for(int j=0;j<userArray->extent_int(1);j++)
127  refPointArray(i,j) = (*userArray)(i,j);
128  }
129 
130  // setup all fields to be evaluated and constructed
131  pointValues = PointValues2<double>(pointRule->getName()+"_",false);
132  pointValues.setupArrays(pointRule);
133 
134  // the field manager will allocate all of these field
135  this->addEvaluatedField(pointValues.coords_ref);
136  this->addEvaluatedField(pointValues.node_coordinates);
137  this->addEvaluatedField(pointValues.jac);
138  this->addEvaluatedField(pointValues.jac_inv);
139  this->addEvaluatedField(pointValues.jac_det);
140  this->addEvaluatedField(pointValues.point_coords);
141 
142  std::string n = "PointValues_Evaluator: " + pointRule->getName();
143  this->setName(n);
144 }
145 
146 //**********************************************************************
147 template<typename EvalT, typename Traits>
148 void
151  typename Traits::SetupData sd,
153 {
154  // setup the pointers for evaluation
155  this->utils.setFieldData(pointValues.coords_ref,fm);
156  this->utils.setFieldData(pointValues.node_coordinates,fm);
157  this->utils.setFieldData(pointValues.jac,fm);
158  this->utils.setFieldData(pointValues.jac_inv,fm);
159  this->utils.setFieldData(pointValues.jac_det,fm);
160  this->utils.setFieldData(pointValues.point_coords,fm);
161 
162  if(useBasisValuesRefArray) {
163  basis_index = panzer::getPureBasisIndex(basis->name(), (*sd.worksets_)[0], this->wda);
164 
165  // basis better have coordinates if you want to use them! Assertion to protect
166  // a silent failure.
167  TEUCHOS_ASSERT(basis->supportsBasisCoordinates());
168  }
169 }
170 
171 //**********************************************************************
172 template<typename EvalT, typename Traits>
173 void
176  typename Traits::EvalData workset)
177 {
178  if(useBasisValuesRefArray) {
179  panzer::BasisValues2<double> & basisValues = *this->wda(workset).bases[basis_index];
180 
181  // evaluate the point values (construct jacobians etc...)
182  pointValues.evaluateValues(this->wda(workset).cell_vertex_coordinates,
183  basisValues.basis_coordinates_ref,
184  workset.num_cells);
185  }
186  else {
187  // evaluate the point values (construct jacobians etc...)
188  pointValues.evaluateValues(this->wda(workset).cell_vertex_coordinates,refPointArray,
189  workset.num_cells);
190  }
191 }
192 
193 //**********************************************************************
194 
195 }
196 
197 #endif
PointValues_Evaluator(const Teuchos::ParameterList &p)
T & get(const std::string &name, T def_value)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
const std::string & getName() const
void setupArrays(const Teuchos::RCP< const panzer::PointRule > &pr)
Sizes/allocates memory for arrays.
void evaluateValues(const PHX::MDField< Scalar, IP, Dim, void, void, void, void, void, void > &cub_points, const PHX::MDField< Scalar, Cell, IP, Dim, Dim, void, void, void, void > &jac, const PHX::MDField< Scalar, Cell, IP, void, void, void, void, void, void > &jac_det, const PHX::MDField< Scalar, Cell, IP, Dim, Dim, void, void, void, void > &jac_inv, const int in_num_cells=-1)
void initialize(const Teuchos::RCP< const panzer::PointRule > &pointRule, const Teuchos::Ptr< const ArrayT > &userArray, const Teuchos::RCP< const panzer::PureBasis > &pureBasis)
Initialization method to unify the constructors.
Ptr< T > ptr() const
void evaluateFields(typename Traits::EvalData d)
std::vector< std::string >::size_type getPureBasisIndex(std::string basis_name, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
Returns the index in the workset bases for a particular PureBasis name.
Array_BasisDim basis_coordinates_ref
BASIS NODE
Spatial Dimension Tag.
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_