43 #ifdef PANZER_HAVE_TEKO 50 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
51 ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::ParameterListCallbackBlocked(
55 : connManager_(connManager), blocked_ugi_(blocked_ugi), aux_blocked_ugi_(aux_blocked_ugi)
59 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
61 ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::request(
const Teko::RequestMesg & rm)
69 for(itr=inputPL->
begin();itr!=inputPL->
end();++itr) {
70 std::string * str_ptr = 0;
72 setFieldByKey(itr->first,
field,*outputPL);
78 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
79 bool ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::handlesRequest(
const Teko::RequestMesg & rm)
83 if(rm.getName()==
"Parameter List") {
84 bool isHandled =
true;
87 if(pl->
isType<std::string>(
"x-coordinates")) {
88 field = pl->
get<std::string>(
"x-coordinates");
93 if(pl->
isType<std::string>(
"y-coordinates")) {
95 if(
field != pl->
get<std::string>(
"y-coordinates")) {
99 if(pl->
isType<std::string>(
"z-coordinates")) {
101 if(
field != pl->
get<std::string>(
"z-coordinates")) {
105 if(pl->
isType<std::string>(
"Coordinates")){
106 field = pl->
get<std::string>(
"Coordinates");
108 if(pl->
isType<std::string>(
"Coordinates-Epetra")){
109 field = pl->
get<std::string>(
"Coordinates-Epetra");
117 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
118 void ParameterListCallbackBlocked<LocalOrdinalT, GlobalOrdinalT, Node>::
119 preRequest(
const Teko::RequestMesg & rm)
123 const std::string&
field(getHandledField(*rm.getParameterList()));
128 std::vector<Teuchos::RCP<panzer::UniqueGlobalIndexer<int, GlobalOrdinalT>>>
129 fieldDOFMngrs = blocked_ugi_->getFieldDOFManagers();
130 for (
int b(0); b < static_cast<int>(fieldDOFMngrs.size()); ++b)
132 for (
int f(0); f < fieldDOFMngrs[b]->getNumFields(); ++f)
134 if (fieldDOFMngrs[b]->getFieldString(f) ==
field)
142 aux_blocked_ugi_->getFieldBlock(aux_blocked_ugi_->getFieldNum(
field));
144 block = blocked_ugi_->getFieldBlock(blocked_ugi_->getFieldNum(
field));
147 if (rm.getParameterList()->isType<std::string>(
"Coordinates-Epetra")) {
148 buildArrayToVectorEpetra(block,
field, useAux);
149 buildCoordinatesEpetra(
field, useAux);
151 buildArrayToVectorTpetra(block,
field, useAux);
152 buildCoordinatesTpetra(
field, useAux);
156 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
157 void ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::setFieldByKey(
const std::string & key,
const std::string &
field,
Teuchos::ParameterList & pl)
const 160 if(key==
"x-coordinates") {
161 double * x =
const_cast<double *
>(&getCoordinateByField(0,
field)[0]);
162 pl.
set<
double*>(key,x);
164 else if(key==
"y-coordinates") {
165 double * y =
const_cast<double *
>(&getCoordinateByField(1,
field)[0]);
166 pl.
set<
double*>(key,y);
168 else if(key==
"z-coordinates") {
169 double * z =
const_cast<double *
>(&getCoordinateByField(2,
field)[0]);
170 pl.
set<
double*>(key,z);
171 }
else if(key ==
"Coordinates") {
173 }
else if(key ==
"Coordinates-Epetra") {
179 "ParameterListCallback cannot handle key=\"" << key <<
"\"");
182 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
183 void ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::buildArrayToVectorTpetra(
int block,
const std::string &
field,
const bool useAux)
185 if(arrayToVectorTpetra_[
field]==Teuchos::null) {
188 ugi = aux_blocked_ugi_->getFieldDOFManagers()[block];
190 ugi = blocked_ugi_->getFieldDOFManagers()[block];
195 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
196 void ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::buildArrayToVectorEpetra(
int block,
const std::string &
field,
const bool useAux)
198 if(arrayToVectorEpetra_[
field]==Teuchos::null) {
201 ugi = aux_blocked_ugi_->getFieldDOFManagers()[block];
203 ugi = blocked_ugi_->getFieldDOFManagers()[block];
208 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
209 void ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::buildCoordinatesTpetra(
const std::string &
field,
const bool useAux)
211 std::map<std::string,Kokkos::DynRankView<double,PHX::Device> > data;
215 std::vector<std::string> elementBlocks;
217 aux_blocked_ugi_->getElementBlockIds(elementBlocks);
219 blocked_ugi_->getElementBlockIds(elementBlocks);
220 for(std::size_t i=0;i<elementBlocks.size();++i) {
221 std::string blockId = elementBlocks[i];
222 std::vector<std::size_t> localCellIds;
225 Kokkos::DynRankView<double,PHX::Device> & fieldData = data[blockId];
226 fieldData = Kokkos::DynRankView<double,PHX::Device>(
"fieldData",connManager_->getElementBlock(blockId).size(),fieldPattern->
numberIds());
230 connManager_->getDofCoords(blockId,*fieldPattern,localCellIds,fieldData);
234 out.setOutputToRootOnly(-1);
235 out <<
"WARNING: In ParameterListCallback::buildCoordinates(), the Intrepid2::FieldPattern in " 236 <<
"block \"" << blockId <<
"\" does not support interpolatory coordinates. " 237 <<
"This may be fine if coordinates are not actually needed. However if they are then bad things " 238 <<
"will happen. Enjoy!" << std::endl;
244 coordsVecTp_ = arrayToVectorTpetra_[
field]->template getDataVector<double>(
field,data);
246 switch(coordsVecTp_->getNumVectors()) {
248 zcoords_[
field].resize(coordsVecTp_->getLocalLength());
249 coordsVecTp_->getVector(2)->get1dCopy(Teuchos::arrayViewFromVector(zcoords_[
field]));
252 ycoords_[
field].resize(coordsVecTp_->getLocalLength());
253 coordsVecTp_->getVector(1)->get1dCopy(Teuchos::arrayViewFromVector(ycoords_[
field]));
256 xcoords_[
field].resize(coordsVecTp_->getLocalLength());
257 coordsVecTp_->getVector(0)->get1dCopy(Teuchos::arrayViewFromVector(xcoords_[
field]));
261 "ParameterListCallback::buildCoordinates: Constructed multivector has nonphysical dimensions.");
266 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
267 void ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::buildCoordinatesEpetra(
const std::string &
field,
const bool useAux)
269 std::map<std::string,Kokkos::DynRankView<double,PHX::Device> > data;
273 std::vector<std::string> elementBlocks;
275 aux_blocked_ugi_->getElementBlockIds(elementBlocks);
277 blocked_ugi_->getElementBlockIds(elementBlocks);
278 for(std::size_t i=0;i<elementBlocks.size();++i) {
279 std::string blockId = elementBlocks[i];
280 std::vector<std::size_t> localCellIds;
283 Kokkos::DynRankView<double,PHX::Device> & fieldData = data[blockId];
284 fieldData = Kokkos::DynRankView<double,PHX::Device>(
"fieldData",connManager_->getElementBlock(blockId).size(),fieldPattern->
numberIds());
288 connManager_->getDofCoords(blockId,*fieldPattern,localCellIds,fieldData);
292 out.setOutputToRootOnly(-1);
293 out <<
"WARNING: In ParameterListCallback::buildCoordinates(), the Intrepid2::FieldPattern in " 294 <<
"block \"" << blockId <<
"\" does not support interpolatory coordinates. " 295 <<
"This may be fine if coordinates are not actually needed. However if they are then bad things " 296 <<
"will happen. Enjoy!" << std::endl;
302 coordsVecEp_ = arrayToVectorEpetra_[
field]->template getDataVector<double>(
field,data);
306 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
307 std::string ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::
311 if(pl.
isType<std::string>(
"x-coordinates"))
312 return pl.
get<std::string>(
"x-coordinates");
313 else if(pl.
isType<std::string>(
"Coordinates"))
314 return pl.
get<std::string>(
"Coordinates");
315 else if(pl.
isType<std::string>(
"Coordinates-Epetra"))
316 return pl.
get<std::string>(
"Coordinates-Epetra");
318 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"Neither x-coordinates nor Coordinates or Coordinates-Epetra field provided.");
322 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
323 const std::vector<double> & ParameterListCallbackBlocked<LocalOrdinalT,GlobalOrdinalT,Node>::
324 getCoordinateByField(
int dim,
const std::string &
field)
const 330 const std::map<std::string,std::vector<double> > * coord;
331 if(dim==0) coord = &xcoords_;
332 else if(dim==1) coord = &ycoords_;
333 else if(dim==2) coord = &zcoords_;
335 std::map<std::string,std::vector<double> >::const_iterator itr;
336 itr = coord->find(
field);
339 "ParameterListCallbackBlocked::getCoordinateByField: Coordinates for field \"" +
field +
340 "\" dimension " << dim <<
" have not been built!");
345 template <
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename Node>
347 ::getFieldPattern(
const std::string & fieldName,
const bool useAux)
const 349 std::vector<std::string> elementBlocks;
351 aux_blocked_ugi_->getElementBlockIds(elementBlocks);
353 blocked_ugi_->getElementBlockIds(elementBlocks);
355 for(std::size_t e=0;e<elementBlocks.size();e++) {
356 std::string blockId = elementBlocks[e];
358 if(blocked_ugi_->fieldInBlock(fieldName,blockId))
359 return Teuchos::rcp_dynamic_cast<const panzer::Intrepid2FieldPattern>(blocked_ugi_->getFieldPattern(blockId,fieldName),
true);
361 if(aux_blocked_ugi_->fieldInBlock(fieldName,blockId))
362 return Teuchos::rcp_dynamic_cast<const panzer::Intrepid2FieldPattern>(aux_blocked_ugi_->getFieldPattern(blockId,fieldName),
true);
365 return Teuchos::null;
bool supportsInterpolatoryCoordinates() const
Does this field pattern support interpolatory coordinates?
ConstIterator begin() const
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
const ParameterEntry & entry(ConstIterator i) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
ConstIterator end() const
virtual int numberIds() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
params_t::ConstIterator ConstIterator
bool isType(const std::string &name) const
T & getValue(T *ptr) const
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral...
#define TEUCHOS_ASSERT(assertion_test)