Panzer Version of the Day
Loading...
Searching...
No Matches
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
51namespace panzer {
52
53//**********************************************************************
54template<typename EvalT, typename Traits>
57 const Teuchos::ParameterList& p)
58{
59 basis_index = 0;
60
61 Teuchos::RCP<const panzer::PointRule> pointRule
62 = p.get< Teuchos::RCP<const panzer::PointRule> >("Point Rule");
63 Teuchos::RCP<const Kokkos::DynRankView<double,PHX::Device> > userArray
64 = p.get<Teuchos::RCP<const Kokkos::DynRankView<double,PHX::Device> > >("Point Array");
65
66 initialize(pointRule,userArray.ptr(),Teuchos::null);
67}
68
69//**********************************************************************
70template <typename EvalT, typename TRAITST>
71PointValues_Evaluator<EvalT,TRAITST>::PointValues_Evaluator(const Teuchos::RCP<const panzer::PointRule> & pointRule,
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//**********************************************************************
80template <typename EvalT, typename TRAITST>
81PointValues_Evaluator<EvalT,TRAITST>::PointValues_Evaluator(const Teuchos::RCP<const panzer::PointRule> & pointRule,
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//**********************************************************************
90template <typename EvalT, typename TRAITST>
91PointValues_Evaluator<EvalT,TRAITST>::PointValues_Evaluator(const Teuchos::RCP<const panzer::PointRule> & pointRule,
92 const Teuchos::RCP<const panzer::PureBasis> & pureBasis)
93{
94 basis_index = 0;
95
96 Teuchos::Ptr<const PHX::MDField<double, panzer::IP, panzer::Dim> > userArray;
97 initialize(pointRule,userArray,pureBasis);
98}
99
100//**********************************************************************
101template <typename EvalT, typename TRAITST>
102template <typename ArrayT>
103void PointValues_Evaluator<EvalT,TRAITST>::initialize(const Teuchos::RCP<const panzer::PointRule> & pointRule,
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 Kokkos::deep_copy(PHX::as_view(refPointArray), PHX::as_view(*userArray));
125
126 }
127
128 // setup all fields to be evaluated and constructed
129 pointValues = PointValues2<double>(pointRule->getName()+"_",false);
130 pointValues.setupArrays(pointRule);
131
132 // the field manager will allocate all of these field
133 this->addEvaluatedField(pointValues.coords_ref);
134 this->addEvaluatedField(pointValues.node_coordinates);
135 this->addEvaluatedField(pointValues.jac);
136 this->addEvaluatedField(pointValues.jac_inv);
137 this->addEvaluatedField(pointValues.jac_det);
138 this->addEvaluatedField(pointValues.point_coords);
139
140 std::string n = "PointValues_Evaluator: " + pointRule->getName();
141 this->setName(n);
142}
143
144//**********************************************************************
145template<typename EvalT, typename Traits>
146void
149 typename Traits::SetupData sd,
151{
152 // setup the pointers for evaluation
153 this->utils.setFieldData(pointValues.coords_ref,fm);
154 this->utils.setFieldData(pointValues.node_coordinates,fm);
155 this->utils.setFieldData(pointValues.jac,fm);
156 this->utils.setFieldData(pointValues.jac_inv,fm);
157 this->utils.setFieldData(pointValues.jac_det,fm);
158 this->utils.setFieldData(pointValues.point_coords,fm);
159
160 if(useBasisValuesRefArray) {
161 basis_index = panzer::getPureBasisIndex(basis->name(), (*sd.worksets_)[0], this->wda);
162
163 // basis better have coordinates if you want to use them! Assertion to protect
164 // a silent failure.
165 TEUCHOS_ASSERT(basis->supportsBasisCoordinates());
166 }
167}
168
169//**********************************************************************
170template<typename EvalT, typename Traits>
171void
174 typename Traits::EvalData workset)
175{
176 if(useBasisValuesRefArray) {
177 panzer::BasisValues2<double> & basisValues = *this->wda(workset).bases[basis_index];
178
179 // evaluate the point values (construct jacobians etc...)
180 pointValues.evaluateValues(this->wda(workset).cell_vertex_coordinates,
181 basisValues.basis_coordinates_ref,
182 workset.num_cells);
183 }
184 else {
185 // evaluate the point values (construct jacobians etc...)
186 pointValues.evaluateValues(this->wda(workset).cell_vertex_coordinates,refPointArray,
187 workset.num_cells);
188 }
189}
190
191//**********************************************************************
192
193}
194
195#endif
Array_BasisDim basis_coordinates_ref
void evaluateValues(const PHX::MDField< Scalar, IP, Dim > &cub_points, const PHX::MDField< Scalar, Cell, IP, Dim, Dim > &jac, const PHX::MDField< Scalar, Cell, IP > &jac_det, const PHX::MDField< Scalar, Cell, IP, Dim, Dim > &jac_inv, const int in_num_cells=-1)
PHX::MDField< Scalar, T0 > buildStaticArray(const std::string &str, int d0) const
PointValues_Evaluator(const Teuchos::ParameterList &p)
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.
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
void evaluateFields(typename Traits::EvalData d)
int num_cells
DEPRECATED - use: numCells()
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.
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_