ug4
active_set.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3  * Author: Raphael Prohl
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 ACTIVE_SET_H_
34 #define ACTIVE_SET_H_
35 
38 
39 using namespace std;
40 
41 namespace ug {
42 
44 
98 template <typename TDomain, typename TAlgebra>
99 class ActiveSet
100 {
101  public:
103  typedef TAlgebra algebra_type;
104 
106  typedef typename algebra_type::matrix_type matrix_type;
107 
109  typedef typename algebra_type::vector_type vector_type;
110 
113 
116 
119 
121  static const int dim = TDomain::dim;
122 
123  public:
125  ActiveSet() : m_bObs(false), m_spLagMultDisc(NULL) {
126  // specifies the number of fcts
127  //value_type u_val;
128  //m_nrFcts = GetSize(u_val); //ToDo: This field is only used in check_dist_to_obs which is commented out. Remove it completely?
129  };
130 
133  m_spObs = obs; m_bObs = true;
134  // if 'obs'-gridfunction is defined on a subset,
135  // which is not a boundary-subset -> UG_LOG
136  }
137 
141  {m_spLagMultDisc = lagMultDisc;};
142 
143  void prepare(function_type& u);
144 
146  //bool check_dist_to_obs(vector_type& u);
147 
148  template <typename TElem, typename TIterator>
149  void active_index_elem(TIterator iterBegin,
150  TIterator iterEnd, function_type& u,
151  function_type& rhs, function_type& lagrangeMult);
152 
154  bool active_index(function_type& u, function_type& rhs, function_type& lagrangeMult,
155  function_type& gap);
156 
157  void set_dirichlet_rows(matrix_type& mat);
158 
160  void lagrange_multiplier(function_type& lagrangeMult, const function_type& u);
161 
164  void residual_lagrange_mult(vector_type& lagMult, const matrix_type& mat,
165  const vector_type& u, vector_type& rhs);
166 
167  template <typename TElem, typename TIterator>
168  bool check_conv_elem(TIterator iterBegin,
169  TIterator iterEnd, function_type& u, const function_type& lambda);
170 
172  bool check_conv(function_type& u, const function_type& lambda, const size_t step);
173 
175  bool check_inequ(const matrix_type& mat, const vector_type& u,
176  const vector_type& lagrangeMult, const vector_type& rhs);
177 
178  template <typename TElem, typename TIterator>
179  void lagrange_mat_inv_elem(TIterator iterBegin,
180  TIterator iterEnd, matrix_type& lagrangeMatInv);
181 
182  void lagrange_mat_inv(matrix_type& lagrangeMatInv);
183 
184  private:
188 
190  //size_t m_nrFcts; //ToDo: This field is only used in check_dist_to_obs which is commented out. Remove it completely?
191 
194  bool m_bObs;
195 
198 
200  vector<int> m_vActiveSubsets;
201 
202  /*template <typename TElem>
203  struct activeElemAndLocInd{
204  TElem* pElem; // pointer to active elem
205  vector<vector<size_t> > vlocInd; // vector of local active indices
206  };*/
207 
209  vector<DoFIndex> m_vActiveSetGlob;
211  vector<DoFIndex> m_vActiveSetGlobOld;
212 };
213 
214 } // namespace ug
215 
216 #include "active_set_impl.h"
217 
218 #endif /* ACTIVE_SET_H_ */
Definition: smart_pointer.h:296
Definition: smart_pointer.h:108
Active Set method.
Definition: active_set.h:100
vector_type::value_type value_type
Type of algebra value.
Definition: active_set.h:112
ActiveSet()
constructor
Definition: active_set.h:125
void set_obstacle(ConstSmartPtr< function_type > obs)
sets obstacle gridfunction, which limits the solution u
Definition: active_set.h:132
GridFunction< TDomain, TAlgebra > function_type
Type of grid function.
Definition: active_set.h:115
vector< DoFIndex > m_vActiveSetGlobOld
vector remembering the active set of global DoFIndices
Definition: active_set.h:211
SmartPtr< DoFDistribution > m_spDD
pointer to the DofDistribution on the whole domain
Definition: active_set.h:186
algebra_type::matrix_type matrix_type
Type of algebra matrix.
Definition: active_set.h:106
void set_lagrange_multiplier_disc(SmartPtr< ILagrangeMultiplierDisc< TDomain, function_type > > lagMultDisc)
sets a discretization in order to compute the lagrange multiplier
Definition: active_set.h:139
TAlgebra algebra_type
Type of algebra.
Definition: active_set.h:103
SmartPtr< TDomain > m_spDom
Definition: active_set.h:187
domain_traits< TDomain::dim >::grid_base_object TBaseElem
base element type of associated domain
Definition: active_set.h:118
vector< DoFIndex > m_vActiveSetGlob
vector of the current active set of global DoFIndices
Definition: active_set.h:209
algebra_type::vector_type vector_type
Type of algebra vector.
Definition: active_set.h:109
bool m_bObs
Definition: active_set.h:194
SmartPtr< ILagrangeMultiplierDisc< TDomain, function_type > > m_spLagMultDisc
pointer to a lagrangeMultiplier-Disc
Definition: active_set.h:197
ConstSmartPtr< function_type > m_spObs
number of functions
Definition: active_set.h:193
vector< int > m_vActiveSubsets
vector of possible active subsets
Definition: active_set.h:200
represents numerical solutions on a grid using an algebraic vector
Definition: grid_function.h:121
Definition: lagrange_multiplier_disc_interface.h:46
static const int dim
Definition: smart_pointer.h:814
CPUAlgebra::matrix_type matrix_type
CPUAlgebra::vector_type vector_type
the ug namespace
T value_type
Definition: sparsematrix_interface.h:2
Definition: domain_traits.h:53