Panzer  Version of the Day
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 //**********************************************************************
55 {
56  basis_index = 0;
57 
58  Teuchos::RCP<const panzer::PointRule> pointRule
59  = p.get< Teuchos::RCP<const panzer::PointRule> >("Point Rule");
60  Teuchos::RCP<const Kokkos::DynRankView<double,PHX::Device> > userArray
61  = p.get<Teuchos::RCP<const Kokkos::DynRankView<double,PHX::Device> > >("Point Array");
62 
63  initialize(pointRule,userArray.ptr(),Teuchos::null);
64 }
65 
66 //**********************************************************************
67 template <typename EvalT, typename TRAITST>
68 PointValues_Evaluator<EvalT,TRAITST>::PointValues_Evaluator(const Teuchos::RCP<const panzer::PointRule> & pointRule,
69  const Kokkos::DynRankView<double,PHX::Device> & userArray)
70 {
71  basis_index = 0;
72 
73  initialize(pointRule,Teuchos::ptrFromRef(userArray),Teuchos::null);
74 }
75 
76 //**********************************************************************
77 template <typename EvalT, typename TRAITST>
78 PointValues_Evaluator<EvalT,TRAITST>::PointValues_Evaluator(const Teuchos::RCP<const panzer::PointRule> & pointRule,
79  const PHX::MDField<double, panzer::IP, panzer::Dim> & userArray)
80 {
81  basis_index = 0;
82 
83  initialize(pointRule,Teuchos::ptrFromRef(userArray),Teuchos::null);
84 }
85 
86 //**********************************************************************
87 template <typename EvalT, typename TRAITST>
88 PointValues_Evaluator<EvalT,TRAITST>::PointValues_Evaluator(const Teuchos::RCP<const panzer::PointRule> & pointRule,
89  const Teuchos::RCP<const panzer::PureBasis> & pureBasis)
90 {
91  basis_index = 0;
92 
93  Teuchos::Ptr<const PHX::MDField<double, panzer::IP, panzer::Dim> > userArray;
94  initialize(pointRule,userArray,pureBasis);
95 }
96 
97 //**********************************************************************
98 template <typename EvalT, typename TRAITST>
99 template <typename ArrayT>
100 void PointValues_Evaluator<EvalT,TRAITST>::initialize(const Teuchos::RCP<const panzer::PointRule> & pointRule,
101  const Teuchos::Ptr<const ArrayT> & userArray,
102  // const Teuchos::Ptr<const Kokkos::DynRankView<double,PHX::Device> > & userArray,
103  const Teuchos::RCP<const panzer::PureBasis> & pureBasis)
104 {
105  basis = pureBasis;
106 
107  if(userArray!=Teuchos::null && basis==Teuchos::null)
108  useBasisValuesRefArray = false;
109  else if(userArray==Teuchos::null && basis!=Teuchos::null)
110  useBasisValuesRefArray = true;
111  else {
112  // this is a conflicting request, throw an exception
113  TEUCHOS_ASSERT(false);
114  }
115 
116  panzer::MDFieldArrayFactory af(pointRule->getName()+"_");
117 
118  // copy user array data
119  if(userArray!=Teuchos::null) {
120  TEUCHOS_ASSERT(userArray->rank()==2);
121  refPointArray = Kokkos::DynRankView<double,PHX::Device>("refPointArray",userArray->dimension(0),userArray->dimension(1));
122  // TEUCHOS_ASSERT(refPointArray.size()==userArray->size());
123  for(int i=0;i<userArray->extent_int(0);i++)
124  for(int j=0;j<userArray->extent_int(1);j++)
125  refPointArray(i,j) = (*userArray)(i,j);
126  }
127 
128  // setup all fields to be evaluated and constructed
130 
131  // the field manager will allocate all of these field
132  this->addEvaluatedField(pointValues.coords_ref);
133  this->addEvaluatedField(pointValues.node_coordinates);
134  this->addEvaluatedField(pointValues.jac);
135  this->addEvaluatedField(pointValues.jac_inv);
136  this->addEvaluatedField(pointValues.jac_det);
137  this->addEvaluatedField(pointValues.point_coords);
138 
139  std::string n = "PointValues_Evaluator: " + pointRule->getName();
140  this->setName(n);
141 }
142 
143 //**********************************************************************
145 {
146  // setup the pointers for evaluation
147  this->utils.setFieldData(pointValues.coords_ref,fm);
148  this->utils.setFieldData(pointValues.node_coordinates,fm);
149  this->utils.setFieldData(pointValues.jac,fm);
150  this->utils.setFieldData(pointValues.jac_inv,fm);
151  this->utils.setFieldData(pointValues.jac_det,fm);
152  this->utils.setFieldData(pointValues.point_coords,fm);
153 
155  basis_index = panzer::getPureBasisIndex(basis->name(), (*sd.worksets_)[0], this->wda);
156 
157  // basis better have coordinates if you want to use them! Assertion to protect
158  // a silent failure.
159  TEUCHOS_ASSERT(basis->supportsBasisCoordinates());
160  }
161 }
162 
163 //**********************************************************************
165 {
167  panzer::BasisValues2<double> & basisValues = *this->wda(workset).bases[basis_index];
168 
169  // evaluate the point values (construct jacobians etc...)
170  pointValues.evaluateValues(this->wda(workset).cell_vertex_coordinates,basisValues.basis_coordinates_ref);
171  }
172  else {
173  // evaluate the point values (construct jacobians etc...)
174  pointValues.evaluateValues(this->wda(workset).cell_vertex_coordinates,refPointArray);
175  }
176 }
177 
178 //**********************************************************************
179 
180 }
181 
182 #endif
Array< Scalar, Cell, IP, Dim, void, void, void, void, void > point_coords
std::size_t basis_index
Array< Scalar, Cell, IP, Dim, Dim, void, void, void, void > jac_inv
PointValues2< ScalarT, PHX::MDField > pointValues
Interpolates basis DOF values to IP DOF values.
void initialize(const Teuchos::RCP< const panzer::PointRule > &pointRule, const Teuchos::RCP< const panzer::PureBasis > &basis, bool derivativesRequired)
Initialization method to unify the constructors.
PointValues_Evaluator(const Teuchos::RCP< const panzer::PointRule > &pointRule, const Kokkos::DynRankView< double, PHX::Device > &userArray)
std::vector< std::string >::size_type getPureBasisIndex(std::string basis_name, panzer::Workset &workset, WorksetDetailsAccessor &wda)
Returns the index in the workset bases for a particular PureBasis name.
Kokkos::DynRankView< double, PHX::Device > refPointArray
Teuchos::RCP< const panzer::PointRule > pointRule
Array< Scalar, Cell, NODE, Dim, void, void, void, void, void > node_coordinates
Array< Scalar, Cell, IP, void, void, void, void, void, void > jac_det
void evaluateValues(const NodeCoordinateArray &node_coordinates, const PointCoordinateArray &point_coordinates)
PHX_EVALUATOR_CTOR(BasisValues_Evaluator, p)
Teuchos::RCP< BasisValues2< ScalarT > > basisValues
PHX_EVALUATE_FIELDS(BasisValues_Evaluator, workset)
Teuchos::RCP< const panzer::PureBasis > basis
Interpolates basis DOF values to IP DOF values.
Array< Scalar, Cell, IP, Dim, Dim, void, void, void, void > jac
void setupArrays(const Teuchos::RCP< const panzer::PointRule > &pr, const ArrayFactory &af)
Sizes/allocates memory for arrays.
PHX_POST_REGISTRATION_SETUP(BasisValues_Evaluator, sd, fm)
Array< Scalar, IP, Dim, void, void, void, void, void, void > coords_ref