ug4
boost_util.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022: G-CSC, Goethe University Frankfurt
3  * Author: Felix Salfelder, 2022
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef UG_GRAPH_INTERFACE_BOOST_UTIL_H
34 #define UG_GRAPH_INTERFACE_BOOST_UTIL_H
35 
36 #include <utility>
37 #include <boost/iterator/filter_iterator.hpp>
38 
39 namespace ug{
40 namespace util{
41 
42 namespace{
43 template<class G>
44 class noloop{
45 public:
46  explicit noloop(const G& g) : _g(g) {}
47  template<class E>
48  bool operator()(E const&e) const{
49  return boost::source(e, _g) != boost::target(e, _g);
50  }
51 private:
52  G const& _g;
53 };
54 }
55 
56 template<class T, class G>
57 std::pair<boost::filter_iterator<noloop<G>, T>,
58  boost::filter_iterator<noloop<G>, T>> omit_loops(std::pair<T, T> const& p, G const& g)
59 {
60  noloop<G> P(g);
61  typedef boost::filter_iterator<noloop<G>, T> f;
62  return std::make_pair(f(P, p.first, p.second), f(P, p.second, p.second));
63 }
64 
65 } // util
66 } // ug
67 
68 #endif // guard
parameterString p
G const & _g
Definition: boost_util.h:52
size_t target(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &m)
Definition: bidirectional_boost.h:100
size_t source(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &)
Definition: bidirectional_boost.h:94
std::pair< boost::filter_iterator< noloop< G >, T >, boost::filter_iterator< noloop< G >, T > > omit_loops(std::pair< T, T > const &p, G const &g)
Definition: boost_util.h:58
the ug namespace
value_type & operator()(size_t r, size_t c)