Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_BasisValues_Evaluator_impl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef PANZER_BasisValues_Evaluator_IMPL_HPP
12 #define PANZER_BasisValues_Evaluator_IMPL_HPP
13 
14 #include <algorithm>
15 #include "Panzer_PointRule.hpp"
17 
18 namespace panzer {
19 
20 //**********************************************************************
21 template<typename EvalT, typename Traits>
24  const Teuchos::ParameterList& p)
25  : derivativesRequired_(true)
26 {
28  = p.get< Teuchos::RCP<const panzer::PointRule> >("Point Rule");
31 
32  bool derivativesRequired = true;
33  if(p.isType<bool>("Derivatives Required"))
34  derivativesRequired = p.get<bool>("Derivatives Required");
35 
36  initialize(pointRule,inBasis,derivativesRequired);
37 }
38 
39 //**********************************************************************
40 template <typename EvalT, typename TRAITST>
43  : derivativesRequired_(true)
44 {
45  bool derivativesRequired = true;
46  initialize(pointRule,inBasis,derivativesRequired);
47 }
48 
49 //**********************************************************************
50 template <typename EvalT, typename TRAITST>
53  bool derivativesRequired)
54  : derivativesRequired_(true)
55 {
56  initialize(pointRule,inBasis,derivativesRequired);
57 }
58 
59 //**********************************************************************
60 template <typename EvalT, typename TRAITST>
63  bool derivativesRequired)
64 {
65  basis = inBasis;
66  derivativesRequired_ = derivativesRequired;
67 
68  int space_dim = basis->dimension();
69 
70  // setup all fields to be evaluated and constructed
71  pointValues = PointValues2<double>(pointRule->getName()+"_",false);
72  pointValues.setupArrays(pointRule);
73 
74  // the field manager will allocate all of these field
75  {
76  constPointValues = pointValues;
77  this->addDependentField(constPointValues.coords_ref);
78  this->addDependentField(constPointValues.jac);
79  this->addDependentField(constPointValues.jac_inv);
80  this->addDependentField(constPointValues.jac_det);
81  }
82 
83  // setup all fields to be evaluated and constructed
85  basisValues = Teuchos::rcp(new BasisValues2<double>(basis->name()+"_"+pointRule->getName()+"_",false));
86  basisValues->setupArrays(layout,derivativesRequired_);
87 
88  // the field manager will allocate all of these field
89 
90  if(basis->getElementSpace()==panzer::PureBasis::HGRAD) {
91  this->addEvaluatedField(basisValues->basis_ref_scalar);
92  this->addEvaluatedField(basisValues->basis_scalar);
93 
94  if(derivativesRequired) {
95  this->addEvaluatedField(basisValues->grad_basis_ref);
96  this->addEvaluatedField(basisValues->grad_basis);
97  }
98  }
99 
100  if(basis->getElementSpace()==panzer::PureBasis::HCURL) {
101  this->addEvaluatedField(basisValues->basis_ref_vector);
102  this->addEvaluatedField(basisValues->basis_vector);
103 
104  if(derivativesRequired && space_dim==2) {
105  this->addEvaluatedField(basisValues->curl_basis_ref_scalar);
106  this->addEvaluatedField(basisValues->curl_basis_scalar);
107  }
108  else if(derivativesRequired && space_dim==3) {
109  this->addEvaluatedField(basisValues->curl_basis_ref_vector);
110  this->addEvaluatedField(basisValues->curl_basis_vector);
111  }
112  }
113 
114  if(basis->getElementSpace()==panzer::PureBasis::HDIV) {
115  this->addEvaluatedField(basisValues->basis_ref_vector);
116  this->addEvaluatedField(basisValues->basis_vector);
117 
118  if(derivativesRequired) {
119  this->addEvaluatedField(basisValues->div_basis_ref);
120  this->addEvaluatedField(basisValues->div_basis);
121  }
122  }
123 
124  std::string n = "BasisValues_Evaluator: " +basis->name() + "_" + pointRule->getName();
125  this->setName(n);
126 }
127 
128 //**********************************************************************
129 template<typename EvalT, typename Traits>
130 void
133  typename Traits::SetupData sd,
135 {
136  int space_dim = basis->dimension();
137 
138  orientations = sd.orientations_;
139 
140  basisValues->setExtendedDimensions(fm.template getKokkosExtendedDataTypeDimensions<EvalT>());
141 
142  // setup the pointers for the point values data structure
143  this->utils.setFieldData(pointValues.coords_ref,fm);
144  this->utils.setFieldData(pointValues.jac,fm);
145  this->utils.setFieldData(pointValues.jac_inv,fm);
146  this->utils.setFieldData(pointValues.jac_det,fm);
147 
148  // setup the pointers for the basis values data structure
149 
150  if(basis->getElementSpace()==panzer::PureBasis::HGRAD) {
151  this->utils.setFieldData(basisValues->basis_ref_scalar,fm);
152  this->utils.setFieldData(basisValues->basis_scalar,fm);
153 
154  if(derivativesRequired_) {
155  this->utils.setFieldData(basisValues->grad_basis_ref,fm);
156  this->utils.setFieldData(basisValues->grad_basis,fm);
157  }
158  }
159 
160  if(basis->getElementSpace()==panzer::PureBasis::HCURL) {
161  this->utils.setFieldData(basisValues->basis_ref_vector,fm);
162  this->utils.setFieldData(basisValues->basis_vector,fm);
163 
164  if(derivativesRequired_ && space_dim==2) {
165  this->utils.setFieldData(basisValues->curl_basis_ref_scalar,fm);
166  this->utils.setFieldData(basisValues->curl_basis_scalar,fm);
167  }
168  else if(derivativesRequired_ && space_dim==3) {
169  this->utils.setFieldData(basisValues->curl_basis_ref_vector,fm);
170  this->utils.setFieldData(basisValues->curl_basis_vector,fm);
171  }
172  }
173 
174  if(basis->getElementSpace()==panzer::PureBasis::HDIV) {
175  this->utils.setFieldData(basisValues->basis_ref_vector,fm);
176  this->utils.setFieldData(basisValues->basis_vector,fm);
177 
178  if(derivativesRequired_) {
179  this->utils.setFieldData(basisValues->div_basis_ref,fm);
180  this->utils.setFieldData(basisValues->div_basis,fm);
181  }
182  }
183 
184 }
185 
186 //**********************************************************************
187 template<typename EvalT, typename Traits>
188 void
191  typename Traits::EvalData workset)
192 {
193  // evaluate the point values (construct jacobians etc...)
194  basisValues->evaluateValues(pointValues.coords_ref,
195  pointValues.jac,
196  pointValues.jac_det,
197  pointValues.jac_inv,
198  (int) workset.num_cells);
199 
200  // this can be over-ridden in basisValues e.g., DG element setting
201  if(basis->requiresOrientations()) {
202  const WorksetDetails & details = workset;
203 
204  std::vector<Intrepid2::Orientation> ortPerWorkset;
205  for (index_t c=0;c<workset.num_cells;++c)
206  ortPerWorkset.push_back((*orientations)[details.cell_local_ids[c]]);
207 
208  basisValues->applyOrientations(ortPerWorkset, (int) workset.num_cells);
209  }
210 }
211 
212 //**********************************************************************
213 
214 }
215 
216 #endif
Teuchos::RCP< const std::vector< Intrepid2::Orientation > > orientations_
int num_cells
DEPRECATED - use: numCells()
BasisValues_Evaluator(const Teuchos::ParameterList &p)
T & get(const std::string &name, T def_value)
std::vector< size_t > cell_local_ids
const std::string & getName() const
int dimension() const
Returns the dimension of the basis from the topology.
void setupArrays(const Teuchos::RCP< const panzer::PointRule > &pr)
Sizes/allocates memory for arrays.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void initialize(const Teuchos::RCP< const panzer::PointRule > &pointRule, const Teuchos::RCP< const panzer::PureBasis > &basis, bool derivativesRequired)
Initialization method to unify the constructors.
void evaluateFields(typename Traits::EvalData d)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
bool isType(const std::string &name) const