Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_DOFManagerFactory_impl.hpp
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"
49 
51 
52 namespace panzer {
53 
54 template <typename LO,typename GO>
57  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
58  const Teuchos::RCP<ConnManager<LO,GO> > & connMngr,
59  const std::string & fieldOrder) const
60 {
61  return buildUniqueGlobalIndexer<panzer::DOFManager<LO,GO> >(mpiComm,physicsBlocks,connMngr,fieldOrder);
62 }
63 
64 template <typename LO,typename GO>
65 template <typename DOFManagerT>
68  const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
69  const Teuchos::RCP<ConnManager<LO,GO> > & connMngr,
70  const std::string & fieldOrder) const
71 {
72  PANZER_FUNC_TIME_MONITOR_DIFF("panzer::DOFManagerFactory::buildUnqueGlobalIndexer",BUGI);
73 
74  Teuchos::RCP<Teuchos::FancyOStream> pout = Teuchos::getFancyOStream(Teuchos::rcpFromRef(std::cout));
75  pout->setShowProcRank(true);
76  pout->setOutputToRootOnly(0);
77 
78  // build the DOF manager for the problem
79  Teuchos::RCP<DOFManagerT> dofManager
80  = Teuchos::rcp(new DOFManagerT(connMngr,*mpiComm));
81 
82  // this is bad, but it works for now; DOFManagerFEI does not have a
83  // tie break capability but the native one does, so cast to it
84  // and set the tie break if needed.
85  {
87  Teuchos::rcp_dynamic_cast<panzer::DOFManager<LO,GO> >(dofManager);
88  if (nativeDofMngr!=Teuchos::null) {
89  nativeDofMngr->enableTieBreak(useTieBreak_);
90  nativeDofMngr->useNeighbors(useNeighbors_);
91  }
92  TEUCHOS_TEST_FOR_EXCEPTION(useNeighbors_ && nativeDofMngr.is_null(), std::logic_error,
93  "The non-native DOF manager does not support the necessary ghosting.");
94  }
95 
96  // by default assume orientations are not required
97  bool orientationsRequired = false;
98 
99  std::vector<Teuchos::RCP<panzer::PhysicsBlock> >::const_iterator physIter;
100  for(physIter=physicsBlocks.begin();physIter!=physicsBlocks.end();++physIter) {
102 
103  const std::vector<StrPureBasisPair> & blockFields = pb->getProvidedDOFs();
104 
105  // insert all fields into a set
106  std::set<StrPureBasisPair,StrPureBasisComp> fieldNames;
107  fieldNames.insert(blockFields.begin(),blockFields.end());
108 
109  // add basis to DOF manager: block specific
110  std::set<StrPureBasisPair,StrPureBasisComp>::const_iterator fieldItr;
111  for (fieldItr=fieldNames.begin();fieldItr!=fieldNames.end();++fieldItr) {
112  // determine if orientations are required
113  // PureBasis::EElementSpace space = fieldItr->second->getElementSpace();
114  // orientationsRequired |= ((space==PureBasis::HDIV) || (space==PureBasis::HCURL));
115  orientationsRequired |= fieldItr->second->requiresOrientations();
116 
118  = fieldItr->second->getIntrepid2Basis();
119  Teuchos::RCP<Intrepid2FieldPattern> fp = Teuchos::rcp(new Intrepid2FieldPattern(intrepidBasis));
120  dofManager->addField(pb->elementBlockID(),fieldItr->first,fp);
121 
122  // *pout << "\"" << fieldItr->first << "\" Field Pattern = \n";
123  // fp->print(*pout);
124  }
125  }
126 
127  // set orientations required flag
128  dofManager->setOrientationsRequired(orientationsRequired);
129 
130  if(fieldOrder!="") {
131  std::vector<std::string> fieldOrderV;
132 
133  buildFieldOrder(fieldOrder,fieldOrderV);
134 
135  dofManager->setFieldOrder(fieldOrderV);
136  }
137 
138  {
139  PANZER_FUNC_TIME_MONITOR_DIFF("panzer::DOFManagerFactory::buildUnqueGlobalIndexer:buildGlobalUnknowns",BGU);
140  dofManager->buildGlobalUnknowns();
141  }
142 
143  // dofManager->printFieldInformation(*pout);
144 
145  // print out mesh topology information. Uncomment at your own risk, there will
146  // be A LOT of information printed to the screen (scaling with the number of elements)
147  // {
148  // Teuchos::FancyOStream out(Teuchos::rcpFromRef(std::cout));
149  // out.setShowProcRank(true);
150  // out.setOutputToRootOnly(-1);
151  // printMeshTopology(out,*dofManager);
152  // }
153 
154  return dofManager;
155 }
156 
157 template <typename LO,typename GO>
158 void
160 buildFieldOrder(const std::string & fieldOrderStr,std::vector<std::string> & fieldOrder)
161 {
162  // this tokenizes "fieldOrderStr" string
163  // and dumps it into "fieldOrder"
164  std::stringstream ss;
165  ss << fieldOrderStr;
166 
167  // until all tokens are eaten
168  while(!ss.eof()) {
169  std::string token;
170  ss >> token;
171 
172  // reorder tokens
173  if(token!="")
174  fieldOrder.push_back(token);
175  }
176 }
177 
178 }
179 
180 #endif
basic_FancyOStream & setShowProcRank(const bool showProcRank)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual Teuchos::RCP< panzer::UniqueGlobalIndexer< LO, GO > > buildUniqueGlobalIndexer(const Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > &mpiComm, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const Teuchos::RCP< ConnManager< LO, GO > > &connMngr, const std::string &fieldOrder="") const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
std::string elementBlockID() const
static void buildFieldOrder(const std::string &fieldOrderStr, std::vector< std::string > &fieldOrder)
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
const std::vector< StrPureBasisPair > & getProvidedDOFs() const
bool is_null() const