Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_STK_Utilities.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 #ifdef PANZER_HAVE_EPETRA_STACK
12 
13 #ifndef __Panzer_STK_Utilities_hpp__
14 #define __Panzer_STK_Utilities_hpp__
15 
16 #include "Panzer_STK_Interface.hpp"
17 
18 #include "Epetra_Vector.h"
19 #include "Epetra_MultiVector.h"
20 
21 namespace panzer {
22  class GlobalIndexer;
23 }
24 
25 namespace panzer_stk {
26 
35 void write_cell_data(panzer_stk::STK_Interface & mesh,const std::vector<double> & data,const std::string & fieldName);
36 
37 void write_solution_data(const panzer::GlobalIndexer& dofMngr,panzer_stk::STK_Interface & mesh,const Epetra_MultiVector & x,const std::string & prefx="",const std::string & postfix="");
38 void write_solution_data(const panzer::GlobalIndexer& dofMngr,panzer_stk::STK_Interface & mesh,const Epetra_Vector & x,const std::string & prefix="",const std::string & postfix="");
39 
46 template <typename RAContainer,class Compare>
47 void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & permutation,const Compare & comp);
48 
55 template <typename RAContainer>
56 void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & permutation);
57 
58 }
59 
60 namespace panzer_stk {
61 // utility class used by the sorted permutation objects
62 template <typename RAContainer,typename Compare>
63 struct PermFunctor {
64  PermFunctor(const RAContainer & cont,const Compare & comp)
65  : compare(comp), values(cont) {}
66  PermFunctor(const PermFunctor & p)
67  : compare(p.compare), values(p.values) {}
68 
69  bool operator()(std::size_t a,std::size_t b) const
70  { return compare(values[a],values[b]); }
71 
72 private:
73  const Compare & compare;
74  const RAContainer & values;
75 
76  PermFunctor();
77 };
78 
79 template <typename RAContainer>
80 void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & permutation)
81 {
82  std::less<typename RAContainer::value_type> comp;
83  sorted_permutation(cont,permutation,comp);
84 }
85 
86 template <typename RAContainer,class Compare>
87 void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & permutation,const Compare & comp)
88 {
89  PermFunctor<RAContainer,Compare> pf(cont,comp);
90 
91  permutation.resize(cont.size());
92  for(std::size_t i=0;i<cont.size();i++)
93  permutation[i] = i;
94 
95  std::sort(permutation.begin(),permutation.end(),pf);
96 }
97 
98 }
99 
100 #endif
101 
102 #endif // PANZER_HAVE_EPETRA_STACK