Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_TestScatter_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_TEST_SCATTER_IMPL_HPP
12 #define PANZER_TEST_SCATTER_IMPL_HPP
13 
14 namespace panzer {
15 
16 template <typename EvalT,typename TRAITS>
18 
19 template<typename EvalT, typename Traits>
22  const Teuchos::ParameterList& p)
23 {
24  std::string test_name = p.get<std::string>("Test Name");
25  std::string test_name_res = p.get<std::string>("Test Name Residual");
27  value = PHX::MDField<const ScalarT,Cell,NODE>(p.get<std::string>("Test Name"), dl);
28  scatter_value = PHX::MDField<ScalarT,Cell,NODE>(test_name_res, dl);
29 
30  this->addDependentField(value);
31  this->addEvaluatedField(scatter_value);
32 
33  localOffset = offset;
34 
35  if(offset==0) offset = 10000;
36  else offset *= 10;
37 
38  std::string n = scatter_value.fieldTag().name();
39  this->setName(n);
40 }
41 
42 template<typename EvalT, typename Traits>
43 void
46  typename Traits::SetupData /* setupData */,
47  PHX::FieldManager<Traits>& /* fm */)
48 {
49  num_nodes = scatter_value.extent(1);
50 }
51 
52 template<typename EvalT, typename Traits>
53 void
56  typename Traits::EvalData workset)
57 {
58  // for (int i=0; i < scatter_value.size(); ++i)
59  // scatter_value[i] = 0.0;
60  Kokkos::deep_copy(scatter_value.get_static_view(), ScalarT(0.0));
61 
62  for (index_t cell = 0; cell < workset.num_cells; ++cell) {
63  ScalarT sum = 0.0;
64  for (std::size_t node = 0; node < num_nodes; ++node)
65  sum += value(cell,node);
66  sum = sum / double(num_nodes);
67 
68  for (std::size_t node = 0; node < num_nodes; ++node) {
69  //unsigned node_GID = *** need to fix this ***;
70 
71  scatter_value(cell,node) = 3.0*sum;
72  }
73  }
74 }
75 
76 }
77 
78 #endif
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
int num_cells
DEPRECATED - use: numCells()
typename EvalT::ScalarT ScalarT
T & get(const std::string &name, T def_value)
TestScatter(const Teuchos::ParameterList &p)
void evaluateFields(typename Traits::EvalData d)