Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_DOFManagerFactory.cpp
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_DOF_MANAGER_FACTORY_IMPL_HPP
12 #define PANZER_DOF_MANAGER_FACTORY_IMPL_HPP
13 
14 #include "Panzer_DOFManager.hpp"
18 
20 
21 namespace panzer {
22 
25  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
26  const Teuchos::RCP<ConnManager> & connMngr,
27  const std::string & fieldOrder) const
28 {
29  PANZER_FUNC_TIME_MONITOR_DIFF("panzer::DOFManagerFactory::buildUnqueGlobalIndexer",BUGI);
30 
31  Teuchos::RCP<Teuchos::FancyOStream> pout = Teuchos::getFancyOStream(Teuchos::rcpFromRef(std::cout));
32  pout->setShowProcRank(true);
33  pout->setOutputToRootOnly(0);
34 
35  // build the DOF manager for the problem
37  = Teuchos::rcp(new panzer::DOFManager(connMngr,*mpiComm));
38 
39  dofManager->enableTieBreak(useTieBreak_);
40  dofManager->useNeighbors(useNeighbors_);
41 
42  // by default assume orientations are not required
43  bool orientationsRequired = false;
44 
45  std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator physIter;
46  for(physIter=physicsBlocks.begin();physIter!=physicsBlocks.end();++physIter) {
48 
49  const std::vector<StrPureBasisPair> & blockFields = pb->getProvidedDOFs();
50 
51  // insert all fields into a set
52  std::set<StrPureBasisPair,StrPureBasisComp> fieldNames;
53  fieldNames.insert(blockFields.begin(),blockFields.end());
54 
55  // add basis to DOF manager: block specific
56  std::set<StrPureBasisPair,StrPureBasisComp>::const_iterator fieldItr;
57  for (fieldItr=fieldNames.begin();fieldItr!=fieldNames.end();++fieldItr) {
58  // determine if orientations are required
59  // PureBasis::EElementSpace space = fieldItr->second->getElementSpace();
60  // orientationsRequired |= ((space==PureBasis::HDIV) || (space==PureBasis::HCURL));
61  orientationsRequired |= fieldItr->second->requiresOrientations();
62 
64  = fieldItr->second->getIntrepid2Basis();
66  dofManager->addField(pb->elementBlockID(),fieldItr->first,fp);
67 
68  // *pout << "\"" << fieldItr->first << "\" Field Pattern = \n";
69  // fp->print(*pout);
70  }
71  }
72 
73  // set orientations required flag
74  dofManager->setOrientationsRequired(orientationsRequired);
75 
76  if(fieldOrder!="") {
77  std::vector<std::string> fieldOrderV;
78  buildFieldOrder(fieldOrder,fieldOrderV);
79  dofManager->setFieldOrder(fieldOrderV);
80  }
81 
82  {
83  PANZER_FUNC_TIME_MONITOR_DIFF("panzer::DOFManagerFactory::buildUnqueGlobalIndexer:buildGlobalUnknowns",BGU);
84  dofManager->buildGlobalUnknowns();
85  }
86 
87  // dofManager->printFieldInformation(*pout);
88 
89  // print out mesh topology information. Uncomment at your own risk, there will
90  // be A LOT of information printed to the screen (scaling with the number of elements)
91  // {
92  // Teuchos::FancyOStream out(Teuchos::rcpFromRef(std::cout));
93  // out.setShowProcRank(true);
94  // out.setOutputToRootOnly(-1);
95  // printMeshTopology(out,*dofManager);
96  // }
97 
98  return dofManager;
99 }
100 
101 void
103 buildFieldOrder(const std::string & fieldOrderStr,std::vector<std::string> & fieldOrder)
104 {
105  // this tokenizes "fieldOrderStr" string
106  // and dumps it into "fieldOrder"
107  std::stringstream ss;
108  ss << fieldOrderStr;
109 
110  // until all tokens are eaten
111  while(!ss.eof()) {
112  std::string token;
113  ss >> token;
114 
115  // reorder tokens
116  if(token!="")
117  fieldOrder.push_back(token);
118  }
119 }
120 
121 }
122 
123 #endif
void setFieldOrder(const std::vector< std::string > &fieldOrder)
static void buildFieldOrder(const std::string &fieldOrderStr, std::vector< std::string > &fieldOrder)
basic_FancyOStream & setShowProcRank(const bool showProcRank)
void enableTieBreak(bool enable)
void useNeighbors(bool flag)
virtual void buildGlobalUnknowns()
builds the global unknowns array
void setOrientationsRequired(bool ro)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
std::string elementBlockID() const
virtual Teuchos::RCP< panzer::GlobalIndexer > buildGlobalIndexer(const Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > &mpiComm, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< ConnManager > &connMngr, const std::string &fieldOrder="") const
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
int addField(const std::string &str, const Teuchos::RCP< const FieldPattern > &pattern, const panzer::FieldType &type=panzer::FieldType::CG)
Add a field to the DOF manager.
const std::vector< StrPureBasisPair > & getProvidedDOFs() const