Line data Source code
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 __H__UG__LIB_ALGEBRA__OPERATOR__PRECONDITIONER__PROJECTED_GAUSS_SEIDEL__SCALAR_LOWER_OBSTACLE__
34 : #define __H__UG__LIB_ALGEBRA__OPERATOR__PRECONDITIONER__PROJECTED_GAUSS_SEIDEL__SCALAR_LOWER_OBSTACLE__
35 :
36 : #include "obstacle_constraint_interface.h"
37 : #include "lib_disc/function_spaces/grid_function.h"
38 :
39 : using namespace std;
40 :
41 : namespace ug{
42 :
43 : /// Scalar Lower Obstacles
44 : /**
45 : * Scalar obstacle are described by constraints of the form
46 : *
47 : * u <= upObs (cf. 'set_upper_obstacle' in 'IObstacleConstraint')
48 : *
49 : * and
50 : *
51 : * u >= lowObs (cf. 'set_lower_obstacle' in 'IObstacleConstraint')
52 : *
53 : * where u is the solution vector. Here, 'upObs' and 'lowObs' are user-defined functions,
54 : * which need to be of the same size as the function of unknowns u.
55 : *
56 : * Those obstacle functions can be used in combination with projected preconditioners. They
57 : * should be passed to the preconditioner by 'IProjPreconditioner::set_obstacle_constraint'.
58 : */
59 : template <typename TDomain, typename TAlgebra>
60 : class ScalarLowerObstacle:
61 : public IObstacleConstraint<TDomain,TAlgebra>
62 : {
63 : public:
64 : /// Base class type
65 : typedef IObstacleConstraint<TDomain,TAlgebra> base_type;
66 :
67 : /// Algebra type
68 : typedef TAlgebra algebra_type;
69 :
70 : /// Matrix type
71 : typedef typename algebra_type::matrix_type matrix_type;
72 :
73 : /// Vector type
74 : typedef typename algebra_type::vector_type vector_type;
75 :
76 : /// Value type
77 : typedef typename vector_type::value_type value_type;
78 :
79 : /// Type of grid function
80 : typedef GridFunction<TDomain, TAlgebra> function_type;
81 :
82 : public:
83 : /// constructor for a scalar obstacle
84 0 : ScalarLowerObstacle(const function_type& u):
85 0 : IObstacleConstraint<TDomain,TAlgebra>(u){};
86 :
87 : /// default constructor
88 0 : ScalarLowerObstacle():
89 0 : IObstacleConstraint<TDomain,TAlgebra>(){};
90 :
91 : /// projects the i-th index of the solution onto the admissible set and adjusts the correction
92 : void adjust_sol_and_cor(value_type& sol_i, value_type& c_i, bool& dofIsActive,
93 : const DoFIndex& dof);
94 :
95 : void adjust_defect_to_constraint(vector_type& d);
96 :
97 : void restrict_obs_values();
98 :
99 : /// Destructor
100 0 : ~ScalarLowerObstacle(){};
101 :
102 : private:
103 : /// store the dofs, which satisfy the constraints with equality
104 : using base_type::m_vActiveDofs;
105 :
106 : /// map storing the obstacle values for every obstacle dof (key)
107 : using base_type::m_mObstacleValues;
108 : };
109 :
110 : template <typename TDomain, typename TAlgebra>
111 : class ScalarUpperObstacle:
112 : public IObstacleConstraint<TDomain,TAlgebra>
113 : {
114 : public:
115 : /// Base class type
116 : typedef IObstacleConstraint<TDomain,TAlgebra> base_type;
117 :
118 : /// Algebra type
119 : typedef TAlgebra algebra_type;
120 :
121 : /// Matrix type
122 : typedef typename algebra_type::matrix_type matrix_type;
123 :
124 : /// Vector type
125 : typedef typename algebra_type::vector_type vector_type;
126 :
127 : /// Value type
128 : typedef typename vector_type::value_type value_type;
129 :
130 : /// Type of grid function
131 : typedef GridFunction<TDomain, TAlgebra> function_type;
132 :
133 : public:
134 : /// constructor for a scalar obstacle
135 0 : ScalarUpperObstacle(const function_type& u):
136 0 : IObstacleConstraint<TDomain,TAlgebra>(u){};
137 :
138 : /// default constructor
139 0 : ScalarUpperObstacle():
140 0 : IObstacleConstraint<TDomain,TAlgebra>(){};
141 :
142 : /// projects the i-th index of the solution onto the admissible set and adjusts the correction
143 : void adjust_sol_and_cor(value_type& sol_i, value_type& c_i, bool& dofIsActive,
144 : const DoFIndex& dof);
145 :
146 : void adjust_defect_to_constraint(vector_type& d);
147 :
148 : void restrict_obs_values();
149 :
150 : /// Destructor
151 0 : ~ScalarUpperObstacle(){};
152 :
153 : private:
154 : /// store the dofs, which satisfy the constraints with equality
155 : using base_type::m_vActiveDofs;
156 :
157 : /// map storing the obstacle values for every obstacle dof (key)
158 : using base_type::m_mObstacleValues;
159 : };
160 :
161 : } // end namespace ug
162 :
163 : // include implementation
164 : #include "scalar_obstacle_impl.h"
165 :
166 : #endif /* __H__UG__LIB_ALGEBRA__OPERATOR__PRECONDITIONER__PROJECTED_GAUSS_SEIDEL__SCALAR_LOWER_OBSTACLE__ */
|