ug4
Loading...
Searching...
No Matches
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
39using namespace std;
40
41namespace ug {
42
44
98template <typename TDomain, typename TAlgebra>
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
112 typedef typename vector_type::value_type value_type;
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
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
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
static const int dim
domain dimension
Definition active_set.h:121
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 lagrange_mat_inv(matrix_type &lagrangeMatInv)
Definition active_set_impl.h:432
bool active_index(function_type &u, function_type &rhs, function_type &lagrangeMult, function_type &gap)
determines the active indices, stores them in a vector and sets dirichlet values in rhs for active in...
Definition active_set_impl.h:253
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
bool check_conv(function_type &u, const function_type &lambda, const size_t step)
checks if all constraints are fulfilled & the activeSet remained unchanged
Definition active_set_impl.h:607
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
bool check_conv_elem(TIterator iterBegin, TIterator iterEnd, function_type &u, const function_type &lambda)
Definition active_set_impl.h:518
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 check_inequ(const matrix_type &mat, const vector_type &u, const vector_type &lagrangeMult, const vector_type &rhs)
checks if all inequalities are fulfilled
Definition active_set_impl.h:673
bool m_bObs
Definition active_set.h:194
void residual_lagrange_mult(vector_type &lagMult, const matrix_type &mat, const vector_type &u, vector_type &rhs)
Definition active_set_impl.h:463
void lagrange_multiplier(function_type &lagrangeMult, const function_type &u)
computes the lagrange multiplier for a given disc
Definition active_set_impl.h:341
SmartPtr< ILagrangeMultiplierDisc< TDomain, function_type > > m_spLagMultDisc
pointer to a lagrangeMultiplier-Disc
Definition active_set.h:197
void lagrange_mat_inv_elem(TIterator iterBegin, TIterator iterEnd, matrix_type &lagrangeMatInv)
Definition active_set_impl.h:359
void active_index_elem(TIterator iterBegin, TIterator iterEnd, function_type &u, function_type &rhs, function_type &lagrangeMult)
checks the distance to the prescribed obstacle/constraint
Definition active_set_impl.h:115
ConstSmartPtr< function_type > m_spObs
number of functions
Definition active_set.h:193
void set_dirichlet_rows(matrix_type &mat)
Definition active_set_impl.h:331
void prepare(function_type &u)
Definition active_set_impl.h:73
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
Definition smart_pointer.h:814
the ug namespace
Definition domain_traits.h:53