Panzer  Version of the Day
Panzer_BasisValues_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_BasisValues_Evaluator_IMPL_HPP
44 #define PANZER_BasisValues_Evaluator_IMPL_HPP
45 
46 #include <algorithm>
47 #include "Panzer_PointRule.hpp"
50 
51 namespace panzer {
52 
53 //**********************************************************************
55  : derivativesRequired_(true)
56 {
58  = p.get< Teuchos::RCP<const panzer::PointRule> >("Point Rule");
61 
62  bool derivativesRequired = true;
63  if(p.isType<bool>("Derivatives Required"))
64  derivativesRequired = p.get<bool>("Derivatives Required");
65 
66  initialize(pointRule,inBasis,derivativesRequired);
67 }
68 
69 //**********************************************************************
70 template <typename EvalT, typename TRAITST>
73  : derivativesRequired_(true)
74 {
75  bool derivativesRequired = true;
76  initialize(pointRule,inBasis,derivativesRequired);
77 }
78 
79 //**********************************************************************
80 template <typename EvalT, typename TRAITST>
83  bool derivativesRequired)
84  : derivativesRequired_(true)
85 {
86  initialize(pointRule,inBasis,derivativesRequired);
87 }
88 
89 //**********************************************************************
90 template <typename EvalT, typename TRAITST>
93  bool derivativesRequired)
94 {
95  basis = inBasis;
96  derivativesRequired_ = derivativesRequired;
97 
98  int space_dim = basis->dimension();
99 
100  panzer::MDFieldArrayFactory af_pv(pointRule->getName()+"_",false);
101 
102  // setup all fields to be evaluated and constructed
104 
105  // the field manager will allocate all of these field
106  this->addDependentField(pointValues.coords_ref);
107  this->addDependentField(pointValues.jac);
108  this->addDependentField(pointValues.jac_inv);
109  this->addDependentField(pointValues.jac_det);
110 
111  // setup all fields to be evaluated and constructed
113  basisValues = Teuchos::rcp(new BasisValues2<ScalarT>(basis->name()+"_"+pointRule->getName()+"_",false));
114  basisValues->setupArrays(layout,derivativesRequired_);
115 
116  // the field manager will allocate all of these field
117 
119  this->addEvaluatedField(basisValues->basis_ref_scalar);
120  this->addEvaluatedField(basisValues->basis_scalar);
121 
122  if(derivativesRequired) {
123  this->addEvaluatedField(basisValues->grad_basis_ref);
124  this->addEvaluatedField(basisValues->grad_basis);
125  }
126  }
127 
129  this->addEvaluatedField(basisValues->basis_ref_vector);
130  this->addEvaluatedField(basisValues->basis_vector);
131 
132  if(derivativesRequired && space_dim==2) {
133  this->addEvaluatedField(basisValues->curl_basis_ref_scalar);
134  this->addEvaluatedField(basisValues->curl_basis_scalar);
135  }
136  else if(derivativesRequired && space_dim==3) {
137  this->addEvaluatedField(basisValues->curl_basis_ref_vector);
138  this->addEvaluatedField(basisValues->curl_basis_vector);
139  }
140  }
141 
143  this->addEvaluatedField(basisValues->basis_ref_vector);
144  this->addEvaluatedField(basisValues->basis_vector);
145 
146  if(derivativesRequired) {
147  this->addEvaluatedField(basisValues->div_basis_ref);
148  this->addEvaluatedField(basisValues->div_basis);
149  }
150  }
151 
152  // inject orientations as needed
155  std::string orientationFieldName = basis->name()+" Orientation";
156  orientation = PHX::MDField<ScalarT,panzer::Cell,panzer::BASIS>(orientationFieldName,
157  basis->functional);
158  this->addDependentField(orientation);
159  }
160 
161  std::string n = "BasisValues_Evaluator: " +basis->name() + "_" + pointRule->getName();
162  this->setName(n);
163 }
164 
165 //**********************************************************************
167 {
168  int space_dim = basis->dimension();
169 
170  basisValues->setExtendedDimensions(fm.template getKokkosExtendedDataTypeDimensions<EvalT>());
171 
172  // setup the pointers for the point values data structure
173  this->utils.setFieldData(pointValues.coords_ref,fm);
174  this->utils.setFieldData(pointValues.jac,fm);
175  this->utils.setFieldData(pointValues.jac_inv,fm);
176  this->utils.setFieldData(pointValues.jac_det,fm);
177 
178  // setup the pointers for the basis values data structure
179 
181  this->utils.setFieldData(basisValues->basis_ref_scalar,fm);
182  this->utils.setFieldData(basisValues->basis_scalar,fm);
183 
185  this->utils.setFieldData(basisValues->grad_basis_ref,fm);
186  this->utils.setFieldData(basisValues->grad_basis,fm);
187  }
188  }
189 
191  this->utils.setFieldData(basisValues->basis_ref_vector,fm);
192  this->utils.setFieldData(basisValues->basis_vector,fm);
193 
194  if(derivativesRequired_ && space_dim==2) {
195  this->utils.setFieldData(basisValues->curl_basis_ref_scalar,fm);
196  this->utils.setFieldData(basisValues->curl_basis_scalar,fm);
197  }
198  else if(derivativesRequired_ && space_dim==3) {
199  this->utils.setFieldData(basisValues->curl_basis_ref_vector,fm);
200  this->utils.setFieldData(basisValues->curl_basis_vector,fm);
201  }
202  }
203 
205  this->utils.setFieldData(basisValues->basis_ref_vector,fm);
206  this->utils.setFieldData(basisValues->basis_vector,fm);
207 
209  this->utils.setFieldData(basisValues->div_basis_ref,fm);
210  this->utils.setFieldData(basisValues->div_basis,fm);
211  }
212  }
213 
216  this->utils.setFieldData(orientation,fm);
217  }
218 }
219 
220 //**********************************************************************
222 {
223  // evaluate the point values (construct jacobians etc...)
224  basisValues->evaluateValues(pointValues.coords_ref,
228 
231  basisValues->applyOrientations(orientation);
232  }
233 }
234 
235 //**********************************************************************
236 
237 }
238 
239 #endif
std::string name() const
A unique key that is the combination of the basis type and basis order.
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > orientation
Array< Scalar, Cell, IP, Dim, Dim, void, void, void, void > jac_inv
BasisValues_Evaluator(const Teuchos::RCP< const panzer::PointRule > &pointRule, const Teuchos::RCP< const panzer::PureBasis > &basis)
PointValues2< ScalarT, PHX::MDField > pointValues
Interpolates basis DOF values to IP DOF values.
T * get() const
void initialize(const Teuchos::RCP< const panzer::PointRule > &pointRule, const Teuchos::RCP< const panzer::PureBasis > &basis, bool derivativesRequired)
Initialization method to unify the constructors.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const panzer::PointRule > pointRule
EElementSpace getElementSpace() const
Array< Scalar, Cell, IP, void, void, void, void, void, void > jac_det
int dimension() const
Returns the dimension of the basis from the topology.
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.
const std::string & getName() const
Teuchos::RCP< PHX::DataLayout > functional
<Cell,Basis> or <Cell,Basis>
PHX_POST_REGISTRATION_SETUP(BasisValues_Evaluator, sd, fm)
Array< Scalar, IP, Dim, void, void, void, void, void, void > coords_ref