Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_GatherOrientation_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_GATHER_ORIENTATION_IMPL_HPP
12 #define PANZER_GATHER_ORIENTATION_IMPL_HPP
13 
14 #include "Teuchos_Assert.hpp"
15 #include "Phalanx_DataLayout.hpp"
16 
17 #include "Panzer_GlobalIndexer.hpp"
19 #include "Panzer_PureBasis.hpp"
20 
21 #include "Teuchos_FancyOStream.hpp"
22 
23 template<typename EvalT,typename TRAITS,typename LO,typename GO>
27  const Teuchos::ParameterList& p)
28 {
29  indexers_.push_back(indexer);
30 
31  const std::vector<std::string>& names =
32  *(p.get< Teuchos::RCP< std::vector<std::string> > >("DOF Names"));
33 
34  indexerNames_ = p.get< Teuchos::RCP< std::vector<std::string> > >("Indexer Names");
35 
36  // this is beging to fix the issues with incorrect use of const
38  if(p.isType< Teuchos::RCP<panzer::PureBasis> >("Basis"))
39  basis = p.get< Teuchos::RCP<panzer::PureBasis> >("Basis");
40  else
41  basis = p.get< Teuchos::RCP<const panzer::PureBasis> >("Basis");
42 
43  gatherFieldOrientations_.resize(names.size());
44  for (std::size_t fd = 0; fd < names.size(); ++fd) {
45  gatherFieldOrientations_[fd] =
46  // PHX::MDField<ScalarT,Cell,NODE>(names[fd]+" Orientation",basis->functional);
47  PHX::MDField<ScalarT,Cell,NODE>(basis->name()+" Orientation",basis->functional);
48  this->addEvaluatedField(gatherFieldOrientations_[fd]);
49  }
50 
51  this->setName("Gather Orientation");
52 }
53 
54 template<typename EvalT,typename TRAITS,typename LO,typename GO>
56 GatherOrientation(const std::vector<Teuchos::RCP<const GlobalIndexer> > & indexers,
57  const Teuchos::ParameterList& p)
58  : indexers_(indexers)
59 {
60  const std::vector<std::string>& names =
61  *(p.get< Teuchos::RCP< std::vector<std::string> > >("DOF Names"));
62 
64 
65  // this is beging to fix the issues with incorrect use of const
67  if(p.isType< Teuchos::RCP<panzer::PureBasis> >("Basis"))
68  basis = p.get< Teuchos::RCP<panzer::PureBasis> >("Basis");
69  else
70  basis = p.get< Teuchos::RCP<const panzer::PureBasis> >("Basis");
71 
72  gatherFieldOrientations_.resize(names.size());
73  for (std::size_t fd = 0; fd < names.size(); ++fd) {
75  PHX::MDField<ScalarT,Cell,NODE>(basis->name()+" Orientation",basis->functional);
76  this->addEvaluatedField(gatherFieldOrientations_[fd]);
77  }
78 
79  this->setName("Gather Orientation");
80 }
81 
82 // **********************************************************************
83 template<typename EvalT,typename TRAITS,typename LO,typename GO>
85 postRegistrationSetup(typename TRAITS::SetupData /* d */,
86  PHX::FieldManager<TRAITS>& /* fm */)
87 {
88  TEUCHOS_ASSERT(gatherFieldOrientations_.size() == indexerNames_->size());
89 
90  indexerIds_.resize(gatherFieldOrientations_.size());
91  subFieldIds_.resize(gatherFieldOrientations_.size());
92 
93  for (std::size_t fd = 0; fd < gatherFieldOrientations_.size(); ++fd) {
94  // get field ID from DOF manager
95  const std::string& fieldName = (*indexerNames_)[fd];
96 
97  indexerIds_[fd] = getFieldBlock(fieldName,indexers_);
98  subFieldIds_[fd] = indexers_[indexerIds_[fd]]->getFieldNum(fieldName);
99  }
100 
101  indexerNames_ = Teuchos::null; // Don't need this anymore
102 }
103 
104 // **********************************************************************
105 template<typename EvalT,typename TRAITS,typename LO,typename GO>
107 evaluateFields(typename TRAITS::EvalData workset)
108 {
109  std::vector<double> orientation;
110 
111  // for convenience pull out some objects from workset
112  std::string blockId = this->wda(workset).block_id;
113  const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
114 
115  // loop over the fields to be gathered
116  for (std::size_t fieldIndex=0; fieldIndex<gatherFieldOrientations_.size();fieldIndex++) {
117 
118  int indexerId = indexerIds_[fieldIndex];
119  int subFieldNum = subFieldIds_[fieldIndex];
120 
121  auto subRowIndexer = indexers_[indexerId];
122  const std::vector<int> & elmtOffset = subRowIndexer->getGIDFieldOffsets(blockId,subFieldNum);
123 
124  // gather operation for each cell in workset
125  for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
126  std::size_t cellLocalId = localCellIds[worksetCellIndex];
127 
128  subRowIndexer->getElementOrientation(cellLocalId,orientation);
129 
130  // loop over basis functions and fill the fields
131  for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
132  int offset = elmtOffset[basis];
133  (gatherFieldOrientations_[fieldIndex])(worksetCellIndex,basis) = orientation[offset];
134  (gatherFieldOrientations_[fieldIndex])(worksetCellIndex,basis) = std::sqrt(-1.0);
135  }
136  }
137  }
138 }
139 
140 #endif
Teuchos::RCP< std::vector< std::string > > indexerNames_
T & get(const std::string &name, T def_value)
int getFieldBlock(const std::string &fieldName, const std::vector< Teuchos::RCP< const GlobalIndexer >> &ugis)
std::vector< PHX::MDField< ScalarT, Cell, NODE > > gatherFieldOrientations_
void evaluateFields(typename TRAITS::EvalData d)
bool isType(const std::string &name) const
#define TEUCHOS_ASSERT(assertion_test)
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)