Panzer Version of the Day
Loading...
Searching...
No Matches
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"
49
50namespace panzer {
51
52//**********************************************************************
53template<typename EvalT, typename Traits>
56 const Teuchos::ParameterList& p)
57 : derivativesRequired_(true)
58{
59 Teuchos::RCP<const panzer::PointRule> pointRule
60 = p.get< Teuchos::RCP<const panzer::PointRule> >("Point Rule");
61 Teuchos::RCP<const panzer::PureBasis> inBasis
62 = p.get<Teuchos::RCP<const panzer::PureBasis> >("Basis");
63
64 bool derivativesRequired = true;
65 if(p.isType<bool>("Derivatives Required"))
66 derivativesRequired = p.get<bool>("Derivatives Required");
67
68 initialize(pointRule,inBasis,derivativesRequired);
69}
70
71//**********************************************************************
72template <typename EvalT, typename TRAITST>
73BasisValues_Evaluator<EvalT,TRAITST>::BasisValues_Evaluator(const Teuchos::RCP<const panzer::PointRule> & pointRule,
74 const Teuchos::RCP<const panzer::PureBasis> & inBasis)
75 : derivativesRequired_(true)
76{
77 bool derivativesRequired = true;
78 initialize(pointRule,inBasis,derivativesRequired);
79}
80
81//**********************************************************************
82template <typename EvalT, typename TRAITST>
83BasisValues_Evaluator<EvalT,TRAITST>::BasisValues_Evaluator(const Teuchos::RCP<const panzer::PointRule> & pointRule,
84 const Teuchos::RCP<const panzer::PureBasis> & inBasis,
85 bool derivativesRequired)
86 : derivativesRequired_(true)
87{
88 initialize(pointRule,inBasis,derivativesRequired);
89}
90
91//**********************************************************************
92template <typename EvalT, typename TRAITST>
93void BasisValues_Evaluator<EvalT,TRAITST>::initialize(const Teuchos::RCP<const panzer::PointRule> & pointRule,
94 const Teuchos::RCP<const panzer::PureBasis> & inBasis,
95 bool derivativesRequired)
96{
97 basis = inBasis;
98 derivativesRequired_ = derivativesRequired;
99
100 int space_dim = basis->dimension();
101
102 // setup all fields to be evaluated and constructed
103 pointValues = PointValues2<double>(pointRule->getName()+"_",false);
104 pointValues.setupArrays(pointRule);
105
106 // the field manager will allocate all of these field
107 {
108 constPointValues = pointValues;
109 this->addDependentField(constPointValues.coords_ref);
110 this->addDependentField(constPointValues.jac);
111 this->addDependentField(constPointValues.jac_inv);
112 this->addDependentField(constPointValues.jac_det);
113 }
114
115 // setup all fields to be evaluated and constructed
116 Teuchos::RCP<panzer::BasisIRLayout> layout = Teuchos::rcp(new panzer::BasisIRLayout(basis,*pointRule));
117 basisValues = Teuchos::rcp(new BasisValues2<double>(basis->name()+"_"+pointRule->getName()+"_",false));
118 basisValues->setupArrays(layout,derivativesRequired_);
119
120 // the field manager will allocate all of these field
121
122 if(basis->getElementSpace()==panzer::PureBasis::HGRAD) {
123 this->addEvaluatedField(basisValues->basis_ref_scalar);
124 this->addEvaluatedField(basisValues->basis_scalar);
125
126 if(derivativesRequired) {
127 this->addEvaluatedField(basisValues->grad_basis_ref);
128 this->addEvaluatedField(basisValues->grad_basis);
129 }
130 }
131
132 if(basis->getElementSpace()==panzer::PureBasis::HCURL) {
133 this->addEvaluatedField(basisValues->basis_ref_vector);
134 this->addEvaluatedField(basisValues->basis_vector);
135
136 if(derivativesRequired && space_dim==2) {
137 this->addEvaluatedField(basisValues->curl_basis_ref_scalar);
138 this->addEvaluatedField(basisValues->curl_basis_scalar);
139 }
140 else if(derivativesRequired && space_dim==3) {
141 this->addEvaluatedField(basisValues->curl_basis_ref_vector);
142 this->addEvaluatedField(basisValues->curl_basis_vector);
143 }
144 }
145
146 if(basis->getElementSpace()==panzer::PureBasis::HDIV) {
147 this->addEvaluatedField(basisValues->basis_ref_vector);
148 this->addEvaluatedField(basisValues->basis_vector);
149
150 if(derivativesRequired) {
151 this->addEvaluatedField(basisValues->div_basis_ref);
152 this->addEvaluatedField(basisValues->div_basis);
153 }
154 }
155
156 std::string n = "BasisValues_Evaluator: " +basis->name() + "_" + pointRule->getName();
157 this->setName(n);
158}
159
160//**********************************************************************
161template<typename EvalT, typename Traits>
162void
165 typename Traits::SetupData sd,
167{
168 int space_dim = basis->dimension();
169
170 orientations = sd.orientations_;
171
172 basisValues->setExtendedDimensions(fm.template getKokkosExtendedDataTypeDimensions<EvalT>());
173
174 // setup the pointers for the point values data structure
175 this->utils.setFieldData(pointValues.coords_ref,fm);
176 this->utils.setFieldData(pointValues.jac,fm);
177 this->utils.setFieldData(pointValues.jac_inv,fm);
178 this->utils.setFieldData(pointValues.jac_det,fm);
179
180 // setup the pointers for the basis values data structure
181
182 if(basis->getElementSpace()==panzer::PureBasis::HGRAD) {
183 this->utils.setFieldData(basisValues->basis_ref_scalar,fm);
184 this->utils.setFieldData(basisValues->basis_scalar,fm);
185
186 if(derivativesRequired_) {
187 this->utils.setFieldData(basisValues->grad_basis_ref,fm);
188 this->utils.setFieldData(basisValues->grad_basis,fm);
189 }
190 }
191
192 if(basis->getElementSpace()==panzer::PureBasis::HCURL) {
193 this->utils.setFieldData(basisValues->basis_ref_vector,fm);
194 this->utils.setFieldData(basisValues->basis_vector,fm);
195
196 if(derivativesRequired_ && space_dim==2) {
197 this->utils.setFieldData(basisValues->curl_basis_ref_scalar,fm);
198 this->utils.setFieldData(basisValues->curl_basis_scalar,fm);
199 }
200 else if(derivativesRequired_ && space_dim==3) {
201 this->utils.setFieldData(basisValues->curl_basis_ref_vector,fm);
202 this->utils.setFieldData(basisValues->curl_basis_vector,fm);
203 }
204 }
205
206 if(basis->getElementSpace()==panzer::PureBasis::HDIV) {
207 this->utils.setFieldData(basisValues->basis_ref_vector,fm);
208 this->utils.setFieldData(basisValues->basis_vector,fm);
209
210 if(derivativesRequired_) {
211 this->utils.setFieldData(basisValues->div_basis_ref,fm);
212 this->utils.setFieldData(basisValues->div_basis,fm);
213 }
214 }
215
216}
217
218//**********************************************************************
219template<typename EvalT, typename Traits>
220void
223 typename Traits::EvalData workset)
224{
225 // evaluate the point values (construct jacobians etc...)
226 basisValues->evaluateValues(pointValues.coords_ref,
227 pointValues.jac,
228 pointValues.jac_det,
229 pointValues.jac_inv,
230 (int) workset.num_cells);
231
232 // this can be over-ridden in basisValues e.g., DG element setting
233 if(basis->requiresOrientations()) {
234 const WorksetDetails & details = workset;
235
236 std::vector<Intrepid2::Orientation> ortPerWorkset;
237 for (index_t c=0;c<workset.num_cells;++c)
238 ortPerWorkset.push_back((*orientations)[details.cell_local_ids[c]]);
239
240 basisValues->applyOrientations(ortPerWorkset, (int) workset.num_cells);
241 }
242}
243
244//**********************************************************************
245
246}
247
248#endif
void evaluateFields(typename Traits::EvalData d)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
void initialize(const Teuchos::RCP< const panzer::PointRule > &pointRule, const Teuchos::RCP< const panzer::PureBasis > &basis, bool derivativesRequired)
Initialization method to unify the constructors.
BasisValues_Evaluator(const Teuchos::ParameterList &p)
int num_cells
DEPRECATED - use: numCells()
Teuchos::RCP< const std::vector< Intrepid2::Orientation > > orientations_