Panzer Version of the Day
Loading...
Searching...
No Matches
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
17
18#include "Epetra_Vector.h"
19#include "Epetra_MultiVector.h"
20
21namespace panzer {
22 class GlobalIndexer;
23}
24
25namespace panzer_stk {
26
35void write_cell_data(panzer_stk::STK_Interface & mesh,const std::vector<double> & data,const std::string & fieldName);
36
37void write_solution_data(const panzer::GlobalIndexer& dofMngr,panzer_stk::STK_Interface & mesh,const Epetra_MultiVector & x,const std::string & prefx="",const std::string & postfix="");
38void 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
46template <typename RAContainer,class Compare>
47void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & permutation,const Compare & comp);
48
55template <typename RAContainer>
56void sorted_permutation(const RAContainer & cont,std::vector<std::size_t> & permutation);
57
58}
59
60namespace panzer_stk {
61// utility class used by the sorted permutation objects
62template <typename RAContainer,typename Compare>
63struct 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
72private:
73 const Compare & compare;
74 const RAContainer & values;
75
76 PermFunctor();
77};
78
79template <typename RAContainer>
80void 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
86template <typename RAContainer,class Compare>
87void 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