11#include "PanzerAdaptersSTK_config.hpp"
12#ifdef PANZER_HAVE_TEKO
21ParameterListCallback::ParameterListCallback(
const std::string & coordFieldName,
22 const std::map<std::string,Teuchos::RCP<const panzer::Intrepid2FieldPattern> > & fps,
23 const Teuchos::RCP<const panzer_stk::STKConnManager> & connManager,
24 const Teuchos::RCP<const panzer::GlobalIndexer> & ugi)
25 : coordFieldName_(coordFieldName), fieldPatterns_(fps), connManager_(connManager), ugi_(ugi), coordinatesBuilt_(false)
28Teuchos::RCP<Teuchos::ParameterList> ParameterListCallback::request(
const Teko::RequestMesg & rm)
30 TEUCHOS_ASSERT(handlesRequest(rm));
33 Teuchos::RCP<Teuchos::ParameterList> outputPL = rcp(
new Teuchos::ParameterList);
34 Teuchos::RCP<const Teuchos::ParameterList> inputPL = rm.getParameterList();
35 Teuchos::ParameterList::ConstIterator itr;
36 for(itr=inputPL->begin();itr!=inputPL->end();++itr)
37 setFieldByKey(itr->first,*outputPL);
42bool ParameterListCallback::handlesRequest(
const Teko::RequestMesg & rm)
46 if(rm.getName()==
"Parameter List")
return true;
50void ParameterListCallback::preRequest(
const Teko::RequestMesg & rm)
52 TEUCHOS_ASSERT(handlesRequest(rm));
59void ParameterListCallback::setFieldByKey(
const std::string & key,Teuchos::ParameterList & pl)
const
61 TEUCHOS_TEST_FOR_EXCEPTION(!coordinatesBuilt_,std::runtime_error,
62 "ParameterListCallback::setFieldByKey: Coordinates have not been built!");
64 double * x =
const_cast<double *
>(&xcoords_[0]);
65 double * y =
const_cast<double *
>(&ycoords_[0]);
66 double * z =
const_cast<double *
>(&zcoords_[0]);
68 if(key==
"x-coordinates")
69 pl.set<
double*>(key,x);
70 else if(key==
"y-coordinates")
71 pl.set<
double*>(key,y);
72 else if(key==
"z-coordinates")
73 pl.set<
double*>(key,z);
75 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::runtime_error,
76 "ParameterListCallback cannot handle key=\"" << key <<
"\"");
79void ParameterListCallback::buildArrayToVector()
81 if(arrayToVector_==Teuchos::null)
85void ParameterListCallback::buildCoordinates()
87 TEUCHOS_ASSERT(fieldPatterns_.size()>0);
89 std::map<std::string,Kokkos::DynRankView<double,PHX::Device> > data;
91 std::map<std::string,Teuchos::RCP<const panzer::Intrepid2FieldPattern> >::const_iterator itr;
92 for(itr=fieldPatterns_.begin();itr!=fieldPatterns_.end();++itr) {
93 std::string blockId = itr->first;
94 Teuchos::RCP<const panzer::Intrepid2FieldPattern> fieldPattern = itr->second;
95 std::vector<std::size_t> localCellIds;
98 Kokkos::DynRankView<double,PHX::Device> & fieldData = data[blockId];
99 fieldData = Kokkos::DynRankView<double,PHX::Device>(
"fieldData",connManager_->getElementBlock(blockId).size(),fieldPattern->numberIds());
101 if(fieldPattern->supportsInterpolatoryCoordinates()) {
103 connManager_->getDofCoords(blockId,*fieldPattern,localCellIds,fieldData);
106 Teuchos::FancyOStream out(Teuchos::rcpFromRef(std::cout));
107 out.setOutputToRootOnly(-1);
108 out <<
"WARNING: In ParameterListCallback::buildCoordinates(), the Intrepid2::FieldPattern in "
109 <<
"block \"" << blockId <<
"\" does not support interpolatory coordinates. "
110 <<
"This may be fine if coordinates are not actually needed. However if they are then bad things "
111 <<
"will happen. Enjoy!" << std::endl;
113 coordinatesBuilt_ =
true;
118 Teuchos::RCP<Tpetra::MultiVector<double,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> > resultVec
119 = arrayToVector_->template getDataVector<double>(coordFieldName_,data);
121 switch(resultVec->getNumVectors()) {
123 zcoords_.resize(resultVec->getLocalLength());
124 resultVec->getVector(2)->get1dCopy(Teuchos::arrayViewFromVector(zcoords_));
127 ycoords_.resize(resultVec->getLocalLength());
128 resultVec->getVector(1)->get1dCopy(Teuchos::arrayViewFromVector(ycoords_));
131 xcoords_.resize(resultVec->getLocalLength());
132 resultVec->getVector(0)->get1dCopy(Teuchos::arrayViewFromVector(xcoords_));
135 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
136 "ParameterListCallback::buildCoordinates: Constructed multivector has nonphysical dimensions.");
140 coordinatesBuilt_ =
true;