ug4
pprocess.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2017: G-CSC, Goethe University Frankfurt
3  * Author: Andreas Vogel
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 __H__LIB_ALGEBRA__OPERATOR__INTERFACE__PPREPROCESS__
34 #define __H__LIB_ALGEBRA__OPERATOR__INTERFACE__PPREPROCESS__
35 
36 #include <vector>
37 
39 
40 namespace ug{
42 // Pre/Post Process for solvers
44 
46 
57 template <typename TVector>
59 {
60 public:
61  typedef TVector vector_type;
62 
64  virtual void apply (vector_type& v) = 0;
65 
67  virtual ~IPProcessVector () {}
68 };
69 
71 
76 template <typename TVector>
78 {
79 public:
81  typedef TVector vector_type;
82 
83 public:
84 
86  void apply (vector_type& v)
87  {
88  for (size_t i = 0; i < m_pp_chain.size (); i++)
89  {
91  if (op.valid ()) op->apply (v);
92  }
93  }
94 
97  {
98  m_pp_chain.push_back (p);
99  }
100 
102  size_t size () {return m_pp_chain.size ();}
103 
106 
109  {
110  size_t i = 0;
111  while (i < m_pp_chain.size ())
112  {
113  if (m_pp_chain[i].get () == p.get ())
114  m_pp_chain.erase (m_pp_chain.begin () + i);
115  else
116  i++;
117  }
118  }
119 
120 private:
121 
122  std::vector<SmartPtr<p_process_type> > m_pp_chain;
123 };
124 
125 } // end namespace ug
126 #endif /* __H__LIB_ALGEBRA__OPERATOR__INTERFACE__PPREPROCESS__ */
127 
128 /* End of File */
parameterString p
Definition: smart_pointer.h:108
bool valid() const
returns true if the pointer is valid, false if not.
Definition: smart_pointer.h:206
interface for pre- and postprocess functions
Definition: pprocess.h:59
virtual ~IPProcessVector()
virtual destructor
Definition: pprocess.h:67
virtual void apply(vector_type &v)=0
user-defined pre- or post-process function
TVector vector_type
the vector type
Definition: pprocess.h:61
a chain of pre- or postprocess operations
Definition: pprocess.h:78
TVector vector_type
the vector type
Definition: pprocess.h:81
SmartPtr< p_process_type > operator[](size_t i)
returns the operation #i
Definition: pprocess.h:105
void add(SmartPtr< p_process_type > p)
adds an operation at the end of the chain
Definition: pprocess.h:96
size_t size()
returns the number of the operations
Definition: pprocess.h:102
void apply(vector_type &v)
performs all the operations
Definition: pprocess.h:86
IPProcessVector< TVector > p_process_type
Definition: pprocess.h:80
std::vector< SmartPtr< p_process_type > > m_pp_chain
Definition: pprocess.h:122
void remove(SmartPtr< p_process_type > p)
removes an operation from the chain
Definition: pprocess.h:108
SM_edge_weight_map< typename T::value_type, ug::BidirectionalMatrix< T > > get(edge_weight_t, ug::BidirectionalMatrix< T > const &g)
Definition: bidirectional_boost.h:157
the ug namespace