43 #include "Teuchos_Tuple.hpp" 
   47 #include "PanzerAdaptersSTK_config.hpp" 
   51 #include "Teuchos_FancyOStream.hpp" 
   55 namespace panzer_stk {
 
   56 namespace periodic_helpers {
 
   58 template <
typename Matcher>
 
   62                      const Matcher & matcher,
 
   63                      const std::vector<std::pair<std::size_t,std::size_t> >  & ownedToMapped, 
const std::string type_)
 
   87   std::pair<RCP<std::vector<std::size_t> >,
 
   89   std::vector<std::size_t> & sideIds = *idsAndCoords.first;
 
   90   std::vector<Tuple<double,3> > & sideCoords = *idsAndCoords.second;
 
  100   } 
catch(std::logic_error & e) {
 
  101      locallyMatchedIds = 
Teuchos::rcp(
new std::vector<std::pair<std::size_t,std::size_t> >);
 
  108      out << 
"Not all sides matched expect failure: \n" << e.what() << std::endl;
 
  121   std::map<std::size_t,std::vector<std::size_t> > reverseMap;
 
  122   for(std::size_t i=0;i<ownedToMapped.size();i++)
 
  123      reverseMap[ownedToMapped[i].second].push_back(ownedToMapped[i].first);
 
  126   std::vector<std::size_t> saved_locallyRequiredIds = *locallyRequiredIds; 
 
  129   std::vector<std::pair<std::size_t,std::size_t> > unusedOwnedToMapped;
 
  132   for(std::size_t i=0;i<ownedToMapped.size();i++) {
 
  133      std::size_t owned = ownedToMapped[i].first;
 
  134      std::size_t mapped = ownedToMapped[i].second;
 
  136      std::vector<std::size_t>::iterator itr 
 
  137         = std::find(locallyRequiredIds->begin(),locallyRequiredIds->end(),owned);
 
  139      if(itr!=locallyRequiredIds->end())
 
  142        unusedOwnedToMapped.push_back(ownedToMapped[i]);
 
  146   std::vector<std::size_t> unique_locallyRequiredIds;
 
  148      std::set<std::size_t> s;
 
  149      s.insert(locallyRequiredIds->begin(),locallyRequiredIds->end()); 
 
  150      unique_locallyRequiredIds.insert(unique_locallyRequiredIds.begin(),s.begin(),s.end());
 
  155         = 
getGlobalPairing(unique_locallyRequiredIds,*locallyMatchedIds,mesh,failure);
 
  164      std::set<std::pair<std::size_t,std::size_t> > gmi_set;
 
  165      gmi_set.insert(globallyMatchedIds->begin(),globallyMatchedIds->end()); 
 
  169      for(std::size_t i=0;i<globallyMatchedIds->size();i++) {
 
  170         std::pair<std::size_t,std::size_t> pair = (*globallyMatchedIds)[i];
 
  171         const std::vector<std::size_t> & others = reverseMap[pair.first];
 
  175         for(std::size_t j=0;j<others.size();j++) 
 
  176            gmi_set.insert(std::make_pair(others[j],pair.second)); 
 
  179         if(std::find(saved_locallyRequiredIds.begin(),
 
  180                      saved_locallyRequiredIds.end(),
 
  181                      pair.first)==saved_locallyRequiredIds.end()) {
 
  187      globallyMatchedIds->clear();
 
  188      globallyMatchedIds->insert(globallyMatchedIds->begin(),gmi_set.begin(),gmi_set.end());
 
  193   globallyMatchedIds->insert(globallyMatchedIds->end(),unusedOwnedToMapped.begin(),unusedOwnedToMapped.end());
 
  195   return globallyMatchedIds;
 
  198 template <
typename Matcher>
 
  202                      const Matcher & matcher, 
const std::string type_)
 
  226   std::pair<RCP<std::vector<std::size_t> >,
 
  228   std::vector<std::size_t> & sideIds = *idsAndCoords.first;
 
  229   std::vector<Tuple<double,3> > & sideCoords = *idsAndCoords.second;
 
  236   bool failure = 
false;
 
  239   } 
catch(std::logic_error & e) {
 
  240      locallyMatchedIds = 
Teuchos::rcp(
new std::vector<std::pair<std::size_t,std::size_t> >);
 
  247      out << 
"Not all sides matched expect failure: \n" << e.what() << std::endl;
 
  263   return globallyMatchedIds;
 
  266 template <
typename Matcher>
 
  271                          const std::string & sideName,
const Matcher & matcher, std::string type_)
 
  277          = 
Teuchos::rcp(
new std::vector<std::pair<std::size_t,std::size_t> >); 
 
  282    std::pair<Teuchos::RCP<std::vector<std::size_t> >,
 
  286    std::vector<std::size_t> & local_side_ids = *sidePair.first;
 
  287    std::vector<Teuchos::Tuple<double,3> > & local_side_coords = *sidePair.second;
 
  289    bool checkProb = 
false;
 
  290    std::vector<bool> side_flags(side_ids.size(),
false);
 
  295    for(std::size_t localNode=0;localNode<local_side_ids.size();localNode++) { 
 
  296       std::size_t local_gid = local_side_ids[localNode];
 
  297       const Tuple<double,3> & local_coord = local_side_coords[localNode];
 
  300       for(std::size_t globalNode=0;globalNode<side_ids.size();globalNode++) { 
 
  301          std::size_t global_gid = side_ids[globalNode];
 
  302          const Tuple<double,3> & global_coord = side_coords[globalNode];
 
  304          if(matcher(global_coord,local_coord)) {
 
  305             if(side_flags[globalNode]) 
 
  308             result->push_back(std::make_pair(global_gid,local_gid));
 
  309             side_flags[globalNode] = 
true; 
 
  318                       "getLocallyMatchedSideIds: checkProb failed");
 
  321                       "getLocallyMatchedSideIds: not all local side ids are satisfied!");
 
Teuchos::RCP< std::vector< std::size_t > > getLocalSideIds(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
 
Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > > matchPeriodicSides(const std::string &left, const std::string &right, const STK_Interface &mesh, const Matcher &matcher, const std::string type_="coord")
 
basic_FancyOStream & setShowProcRank(const bool showProcRank)
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
std::pair< Teuchos::RCP< std::vector< std::size_t > >, Teuchos::RCP< std::vector< Teuchos::Tuple< double, 3 > > > > getLocalSideIdsAndCoords(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
 
PHX::MDField< ScalarT, panzer::Cell, panzer::IP > result
A field that will be used to build up the result of the integral we're performing. 
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
 
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
 
Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > > getGlobalPairing(const std::vector< std::size_t > &locallyRequiredIds, const std::vector< std::pair< std::size_t, std::size_t > > &locallyMatchedIds, const STK_Interface &mesh, bool failure)
 
std::pair< Teuchos::RCP< std::vector< std::size_t > >, Teuchos::RCP< std::vector< Teuchos::Tuple< double, 3 > > > > getSideIdsAndCoords(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
 
Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > > getLocallyMatchedSideIds(const std::vector< std::size_t > &side_ids, const std::vector< Teuchos::Tuple< double, 3 > > &side_coords, const STK_Interface &mesh, const std::string &sideName, const Matcher &matcher, const std::string type_="coord")