43#ifndef PANZER_STK_SCATTER_FIELDS_IMPL_HPP
44#define PANZER_STK_SCATTER_FIELDS_IMPL_HPP
46#include "Teuchos_Assert.hpp"
48#include "Phalanx_config.hpp"
49#include "Phalanx_Evaluator_Macros.hpp"
50#include "Phalanx_MDField.hpp"
51#include "Phalanx_DataLayout.hpp"
52#include "Phalanx_DataLayout_MDALayout.hpp"
57#include "Teuchos_FancyOStream.hpp"
61template <
typename EvalT,
typename TraitsT>
64 const Teuchos::RCP<STK_Interface> mesh,
65 const Teuchos::RCP<const panzer::PureBasis> & basis,
66 const std::vector<std::string> & names)
68 std::vector<double> scaling;
70 initialize(scatterName,mesh,basis,names,scaling);
73template <
typename EvalT,
typename TraitsT>
76 const Teuchos::RCP<STK_Interface> mesh,
77 const Teuchos::RCP<const panzer::PureBasis> & basis,
78 const std::vector<std::string> & names,
79 const std::vector<double> & scaling)
81 initialize(scatterName,mesh,basis,names,scaling);
84template <
typename EvalT,
typename TraitsT>
87 const Teuchos::RCP<STK_Interface> mesh,
88 const Teuchos::RCP<const panzer::PureBasis> & basis,
89 const std::vector<std::string> & names,
90 const std::vector<double> & scaling)
98 bool correctScaling = (names.size()==scaling.size()) || (scaling.size()==0);
99 TEUCHOS_TEST_FOR_EXCEPTION(!correctScaling,std::invalid_argument,
100 "panzer_stk::ScatterFields evaluator requites a consistent number of scaling parameters (equal to the number of field names) "
101 "or an empty \"Field Scaling\" vector");
104 scatterFields_.resize(names.size());
105 for (std::size_t fd = 0; fd < names.size(); ++fd) {
107 PHX::MDField<const ScalarT,Cell,NODE>(names[fd],basis->functional);
108 this->addDependentField(scatterFields_[fd]);
115 PHX::Tag<ScalarT> scatterHolder(scatterName,Teuchos::rcp(
new PHX::MDALayout<panzer::Dummy>(0)));
116 this->addEvaluatedField(scatterHolder);
118 this->setName(scatterName+
": STK-Scatter Fields");
121template <
typename EvalT,
typename TraitsT>
126 for (std::size_t fd = 0; fd < scatterFields_.size(); ++fd)
127 std::string fieldName = scatterFields_[fd].fieldTag().name();
130template <
typename EvalT,
typename TraitsT>
134 TEUCHOS_ASSERT(
false);
142 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
143 std::string blockId = this->wda(workset).block_id;
145 for(std::size_t fieldIndex=0; fieldIndex<scatterFields_.size();fieldIndex++) {
147 double scaling = (scaling_.size()>0) ? scaling_[fieldIndex] : 1.0;
151 mesh_->setSolutionFieldData(scatterFields_[fieldIndex].fieldTag().name(),blockId,
152 localCellIds,scatterFields_[fieldIndex].get_view(),scaling);
154 mesh_->setCellFieldData(scatterFields_[fieldIndex].fieldTag().name(),blockId,
155 localCellIds,scatterFields_[fieldIndex].get_view(),scaling);
void initialize(const std::string &scatterName, const Teuchos::RCP< STK_Interface > mesh, const Teuchos::RCP< const panzer::PureBasis > &basis, const std::vector< std::string > &names, const std::vector< double > &scaling)
void evaluateFields(typename TraitsT::EvalData d)
ScatterFields(const std::string &scatterName, const Teuchos::RCP< STK_Interface > mesh, const Teuchos::RCP< const panzer::PureBasis > &basis, const std::vector< std::string > &names)
void postRegistrationSetup(typename TraitsT::SetupData d, PHX::FieldManager< TraitsT > &fm)