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 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef PANZER_DOF_MANAGER_FACTORY_IMPL_HPP
44 #define PANZER_DOF_MANAGER_FACTORY_IMPL_HPP
45 
46 #include "Panzer_DOFManager.hpp"
50 
52 
53 namespace panzer {
54 
57  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
58  const Teuchos::RCP<ConnManager> & connMngr,
59  const std::string & fieldOrder) const
60 {
61  PANZER_FUNC_TIME_MONITOR_DIFF("panzer::DOFManagerFactory::buildUnqueGlobalIndexer",BUGI);
62 
63  Teuchos::RCP<Teuchos::FancyOStream> pout = Teuchos::getFancyOStream(Teuchos::rcpFromRef(std::cout));
64  pout->setShowProcRank(true);
65  pout->setOutputToRootOnly(0);
66 
67  // build the DOF manager for the problem
69  = Teuchos::rcp(new panzer::DOFManager(connMngr,*mpiComm));
70 
71  dofManager->enableTieBreak(useTieBreak_);
72  dofManager->useNeighbors(useNeighbors_);
73 
74  // by default assume orientations are not required
75  bool orientationsRequired = false;
76 
77  std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator physIter;
78  for(physIter=physicsBlocks.begin();physIter!=physicsBlocks.end();++physIter) {
80 
81  const std::vector<StrPureBasisPair> & blockFields = pb->getProvidedDOFs();
82 
83  // insert all fields into a set
84  std::set<StrPureBasisPair,StrPureBasisComp> fieldNames;
85  fieldNames.insert(blockFields.begin(),blockFields.end());
86 
87  // add basis to DOF manager: block specific
88  std::set<StrPureBasisPair,StrPureBasisComp>::const_iterator fieldItr;
89  for (fieldItr=fieldNames.begin();fieldItr!=fieldNames.end();++fieldItr) {
90  // determine if orientations are required
91  // PureBasis::EElementSpace space = fieldItr->second->getElementSpace();
92  // orientationsRequired |= ((space==PureBasis::HDIV) || (space==PureBasis::HCURL));
93  orientationsRequired |= fieldItr->second->requiresOrientations();
94 
96  = fieldItr->second->getIntrepid2Basis();
98  dofManager->addField(pb->elementBlockID(),fieldItr->first,fp);
99 
100  // *pout << "\"" << fieldItr->first << "\" Field Pattern = \n";
101  // fp->print(*pout);
102  }
103  }
104 
105  // set orientations required flag
106  dofManager->setOrientationsRequired(orientationsRequired);
107 
108  if(fieldOrder!="") {
109  std::vector<std::string> fieldOrderV;
110  buildFieldOrder(fieldOrder,fieldOrderV);
111  dofManager->setFieldOrder(fieldOrderV);
112  }
113 
114  {
115  PANZER_FUNC_TIME_MONITOR_DIFF("panzer::DOFManagerFactory::buildUnqueGlobalIndexer:buildGlobalUnknowns",BGU);
116  dofManager->buildGlobalUnknowns();
117  }
118 
119  // dofManager->printFieldInformation(*pout);
120 
121  // print out mesh topology information. Uncomment at your own risk, there will
122  // be A LOT of information printed to the screen (scaling with the number of elements)
123  // {
124  // Teuchos::FancyOStream out(Teuchos::rcpFromRef(std::cout));
125  // out.setShowProcRank(true);
126  // out.setOutputToRootOnly(-1);
127  // printMeshTopology(out,*dofManager);
128  // }
129 
130  return dofManager;
131 }
132 
133 void
135 buildFieldOrder(const std::string & fieldOrderStr,std::vector<std::string> & fieldOrder)
136 {
137  // this tokenizes "fieldOrderStr" string
138  // and dumps it into "fieldOrder"
139  std::stringstream ss;
140  ss << fieldOrderStr;
141 
142  // until all tokens are eaten
143  while(!ss.eof()) {
144  std::string token;
145  ss >> token;
146 
147  // reorder tokens
148  if(token!="")
149  fieldOrder.push_back(token);
150  }
151 }
152 
153 }
154 
155 #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)
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