Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_ResponseScatterEvaluator_IPCoordinates_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_RESPONSE_SCATTER_EVALUATOR_IPCoordinates_IMPL_HPP
44 #define PANZER_RESPONSE_SCATTER_EVALUATOR_IPCoordinates_IMPL_HPP
45 
46 #include <iostream>
47 #include <string>
48 
49 #include "PanzerDiscFE_config.hpp"
50 
51 #include "Phalanx_Evaluator_Macros.hpp"
52 #include "Phalanx_MDField.hpp"
53 #include "Phalanx_DataLayout_MDALayout.hpp"
54 
55 #include "Panzer_ResponseBase.hpp"
56 #include "Panzer_Dimension.hpp"
59 
60 namespace panzer {
61 
65 template<typename EvalT, typename Traits>
67 ResponseScatterEvaluator_IPCoordinates(const std::string & name,
68  int ir_order)
69  : responseName_(name), ir_order_(ir_order)
70 {
71  using Teuchos::RCP;
72  using Teuchos::rcp;
73 
74  std::string dummyName = ResponseBase::buildLookupName(name) + " dummy target";
75 
76  // build dummy target tag
77  RCP<PHX::DataLayout> dl_dummy = rcp(new PHX::MDALayout<panzer::Dummy>(0));
78  scatterHolder_ = rcp(new PHX::Tag<ScalarT>(dummyName,dl_dummy));
79  this->addEvaluatedField(*scatterHolder_);
80 
81  std::string n = "IPCoordinates Response Scatter: " + name;
82  this->setName(n);
83 }
84 
85 template<typename EvalT, typename Traits>
88 {
89  // extract response object
90  responseObj_ = Teuchos::rcp_dynamic_cast<Response_IPCoordinates<EvalT> >(
91  d.gedc->getDataObject(ResponseBase::buildLookupName(responseName_)),true);
92 }
93 
94 
95 template<typename EvalT, typename Traits>
98  PHX::FieldManager<Traits>& /* fm */)
99 {
100  ir_index_ = panzer::getIntegrationRuleIndex(ir_order_,(*sd.worksets_)[0], this->wda);
101 }
102 
103 template<typename EvalT, typename Traits>
106 {
107  // Kokkos::DynRankView<double,PHX::Device>& workset_coords = (this->wda(workset).int_rules[ir_index_])->ip_coordinates;
108  IntegrationValues2<double> & iv = *this->wda(workset).int_rules[ir_index_];
109 
110  if (tmpCoords_.size() != Teuchos::as<std::size_t>(iv.ip_coordinates.extent(2))) {
111  tmpCoords_.resize(iv.ip_coordinates.extent(2));
112  for(std::size_t dim=0;dim<tmpCoords_.size();dim++)
113  tmpCoords_[dim].clear();
114  }
115 
116  // This ordering is for the DataTransferKit. It blocks all x
117  // coordinates for a set of points, then all y coordinates and if
118  // required all z coordinates.
119  for (int dim = 0; dim < iv.ip_coordinates.extent_int(2); ++dim)
120  for (index_t cell = 0; cell < workset.num_cells; ++cell)
121  for (int ip = 0; ip < iv.ip_coordinates.extent_int(1); ++ip)
122  tmpCoords_[dim].push_back(iv.ip_coordinates(static_cast<int>(cell),ip,dim));
123 }
124 
125 //**********************************************************************
126 template<typename EvalT, typename Traits>
128 postEvaluate(typename Traits::PostEvalData /* data */)
129 {
130  std::vector<panzer::Traits::Residual::ScalarT> & coords = *responseObj_->getNonconstCoords();
131  coords.clear();
132 
133  for (std::size_t dim = 0; dim < tmpCoords_.size(); ++dim) {
134  for (typename std::vector<ScalarT>::const_iterator x=tmpCoords_[dim].begin(); x != tmpCoords_[dim].end(); ++ x)
135  coords.push_back(Sacado::ScalarValue<ScalarT>::eval(*x));
136  }
137 
138  tmpCoords_.clear();
139 }
140 
141 }
142 
143 #endif
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
Teuchos::RCP< GlobalEvaluationDataContainer > gedc
static std::string buildLookupName(const std::string &responseName)
ResponseScatterEvaluator_IPCoordinates(const std::string &name, int ir_order)
A constructor with concrete arguments instead of a parameter list.
std::vector< std::string >::size_type getIntegrationRuleIndex(int ir_degree, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_