33 #ifndef __H__UG__LIB_DISC__ORDERING_STRATEGIES_ALGORITHMS__RIVERORDER__
34 #define __H__UG__LIB_DISC__ORDERING_STRATEGIES_ALGORITHMS__RIVERORDER__
36 #include <boost/graph/adjacency_list.hpp>
37 #include <boost/graph/graph_traits.hpp>
38 #include <boost/graph/properties.hpp>
56 template <
typename TAlgebra,
typename TDomain,
typename O_t>
60 typedef typename TAlgebra::matrix_type
M_t;
61 typedef typename TAlgebra::vector_type
V_t;
62 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS>
G_t;
68 typedef typename boost::graph_traits<G_t>::vertex_descriptor
vd;
69 typedef typename boost::graph_traits<G_t>::adjacency_iterator
adj_iter;
91 boost::clear_vertex(i,
g);
107 std::vector<BOOL> visited(n,
false);
108 for(
unsigned i = 0; i < n; ++i){
136 size_t numSources = 0;
142 if((pGridF =
dynamic_cast<const GridFunc_t*
>(&V)) == 0){
143 UG_THROW(
name() <<
"::init: No DoFDistribution specified.");
148 n = dd->num_indices();
150 if(n != A->num_rows ()){
157 UG_THROW(
name() <<
"::init: Invalid subset for sources selected! Call 'select_sources(const char*)'.");
159 std::vector<std::vector<size_t> > vvConnection(n);
161 dd->get_connections<
ug::Edge>(vvConnection);
167 for(
unsigned i = 0; i < n; ++i){
168 for(
unsigned j = 0; j < vvConnection[i].size(); ++j){
169 if(i != vvConnection[i][j]){
170 boost::add_edge(i, vvConnection[i][j],
g);
183 typedef typename GridFunc_t::template traits<ug::Vertex>::const_iterator ugVertIt_t;
185 ugVertIt_t ugVertIt = pGridF->template begin<ug::Vertex>();
186 ugVertIt_t ugVertEnd = pGridF->template end<ug::Vertex>();
188 for(; ugVertIt != ugVertEnd; ++ugVertIt, ++k){
191 int si = pGridF->
domain()->subset_handler()->get_subset_index(v);
199 #ifdef UG_ENABLE_DEBUG_LOGS
202 <<
", s=" << numSources <<
")\n");
207 UG_THROW(
name() <<
"::init: Cannot initialize smoother without a geometry. Specify the 2nd argument for init!");
211 UG_THROW(
name() <<
"::init: Algorithm does not support induced subgraph version!");
215 UG_THROW(
name() <<
"::init: Algorithm does not support induced subgraph version!");
218 virtual const char*
name()
const {
return "RiverOrdering";}
Definition: smart_pointer.h:108
Base-class for edges.
Definition: grid_base_objects.h:397
represents numerical solutions on a grid using an algebraic vector
Definition: grid_function.h:121
SmartPtr< TDomain > domain()
returns domain
Definition: grid_function.h:342
Definition: IOrderingAlgorithm.h:52
Definition: lexorder.h:68
Definition: riverorder.h:58
virtual const char * name() const
Definition: riverorder.h:218
std::vector< BOOL > m_sources
Definition: riverorder.h:231
const char * m_ssName
Definition: riverorder.h:230
IOrderingAlgorithm< TAlgebra, O_t > baseclass
Definition: riverorder.h:63
void init(M_t *A, const V_t &V)
Definition: riverorder.h:134
void init(M_t *, const O_t &)
Definition: riverorder.h:214
void init(M_t *)
Definition: riverorder.h:206
GridFunction< TDomain, TAlgebra > GridFunc_t
Grid function type for the solution.
Definition: riverorder.h:66
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS > G_t
Definition: riverorder.h:62
RiverOrdering(const LexOrdering< TAlgebra, TDomain, O_t > &parent)
clone constructor
Definition: riverorder.h:74
O_t & ordering()
Definition: riverorder.h:130
O_t o
Definition: riverorder.h:227
void compute()
Definition: riverorder.h:114
RiverOrdering()
Definition: riverorder.h:71
vd get_source_vertex(std::vector< BOOL > &visited, G_t &g)
Definition: riverorder.h:83
G_t g
Definition: riverorder.h:226
void check()
Definition: riverorder.h:124
boost::graph_traits< G_t >::adjacency_iterator adj_iter
Definition: riverorder.h:69
void init(M_t *, const V_t &, const O_t &)
Definition: riverorder.h:210
SmartPtr< IOrderingAlgorithm< TAlgebra, O_t > > clone()
Definition: riverorder.h:77
TAlgebra::vector_type V_t
Definition: riverorder.h:61
void select_sources(const char *ssName)
Definition: riverorder.h:220
void topological_ordering(O_t &o, G_t &g)
Definition: riverorder.h:105
int m_ssIdx
Definition: riverorder.h:229
TAlgebra::matrix_type M_t
Definition: riverorder.h:60
boost::graph_traits< G_t >::vertex_descriptor vd
Definition: riverorder.h:68
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
std::pair< typename graph_traits< T >::adjacency_iterator, typename graph_traits< T >::adjacency_iterator > adjacent_vertices(size_t v, ug::BidirectionalMatrix< T > const &M)
Definition: bidirectional_boost.h:108
int in_degree(int v, ug::BidirectionalMatrix< T > const &M)
Definition: bidirectional_boost.h:82
int num_vertices(ug::BidirectionalMatrix< T > const &M)
Definition: bidirectional_boost.h:70
bool is_permutation(O_t &o)
Definition: permutation_util.h:135
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition: smart_pointer.h:836