Line data Source code
1 : /*
2 : * Copyright (c) 2011-2015: 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__UG__LIB_DISC__SPATIAL_DISC__CONSTRAINTS__CONTINUITY_CONSTRAINTS__P1_CONTINUITY_CONSTRAINTS__
34 : #define __H__UG__LIB_DISC__SPATIAL_DISC__CONSTRAINTS__CONTINUITY_CONSTRAINTS__P1_CONTINUITY_CONSTRAINTS__
35 :
36 : #include "lib_disc/assemble_interface.h"
37 : #include "lib_disc/spatial_disc/constraints/constraint_interface.h"
38 : #include "lib_grid/algorithms/geom_obj_util/vertex_util.h"
39 :
40 : namespace ug {
41 :
42 : /// returns the vertices of the object constraining a hanging vertex
43 : void CollectConstraining(std::vector<Vertex*>& vConstrainingVrt,
44 : const Grid& grid,
45 : ConstrainedVertex* hgVrt,
46 : bool bClearContainer = true);
47 :
48 :
49 : template <typename TDomain, typename TAlgebra>
50 : class SymP1Constraints
51 : : public IDomainConstraint<TDomain, TAlgebra>
52 : {
53 : public:
54 : // Algebra type
55 : typedef TAlgebra algebra_type;
56 :
57 : // Type of algebra matrix
58 : typedef typename algebra_type::matrix_type matrix_type;
59 :
60 : // Type of algebra vector
61 : typedef typename algebra_type::vector_type vector_type;
62 :
63 : public:
64 0 : SymP1Constraints() : IDomainConstraint<TDomain, TAlgebra>(), m_bAssembleLinearProblem(false) {}
65 0 : virtual ~SymP1Constraints() {}
66 :
67 0 : virtual int type() const {return CT_HANGING;}
68 :
69 : void adjust_jacobian(matrix_type& J, const vector_type& u,
70 : ConstSmartPtr<DoFDistribution> dd, int type, number time = 0.0,
71 : ConstSmartPtr<VectorTimeSeries<vector_type> > vSol = NULL,
72 : const number s_a0 = 1.0);
73 :
74 : void adjust_defect(vector_type& d, const vector_type& u,
75 : ConstSmartPtr<DoFDistribution> dd, int type, number time = 0.0,
76 : ConstSmartPtr<VectorTimeSeries<vector_type> > vSol = NULL,
77 : const std::vector<number>* vScaleMass = NULL,
78 : const std::vector<number>* vScaleStiff = NULL);
79 :
80 : void adjust_rhs(vector_type& rhs, const vector_type& u,
81 : ConstSmartPtr<DoFDistribution> dd, int type, number time = 0.0);
82 :
83 : void adjust_linear(matrix_type& mat, vector_type& rhs,
84 : ConstSmartPtr<DoFDistribution> dd, int type, number time = 0.0);
85 :
86 : void adjust_solution(vector_type& u, ConstSmartPtr<DoFDistribution> dd,
87 : int type, number time = 0.0);
88 :
89 : void adjust_prolongation(matrix_type& P,
90 : ConstSmartPtr<DoFDistribution> ddFine,
91 : ConstSmartPtr<DoFDistribution> ddCoarse,
92 : int type,
93 : number time = 0.0);
94 :
95 : void adjust_restriction(matrix_type& R,
96 : ConstSmartPtr<DoFDistribution> ddCoarse,
97 : ConstSmartPtr<DoFDistribution> ddFine,
98 : int type,
99 : number time = 0.0);
100 :
101 : virtual void adjust_correction
102 : ( vector_type& u,
103 : ConstSmartPtr<DoFDistribution> dd,
104 : int type,
105 : number time = 0.0
106 : );
107 :
108 : protected:
109 : bool m_bAssembleLinearProblem;
110 : };
111 :
112 :
113 :
114 : template <typename TDomain, typename TAlgebra>
115 : class OneSideP1Constraints
116 : : public IDomainConstraint<TDomain, TAlgebra>
117 : {
118 : public:
119 : // Algebra type
120 : typedef TAlgebra algebra_type;
121 :
122 : // Type of algebra matrix
123 : typedef typename algebra_type::matrix_type matrix_type;
124 :
125 : // Type of algebra vector
126 : typedef typename algebra_type::vector_type vector_type;
127 :
128 : protected:
129 : typedef IDomainConstraint<TDomain, TAlgebra> base_type;
130 :
131 : public:
132 0 : OneSideP1Constraints() : IDomainConstraint<TDomain, TAlgebra>(), m_bAssembleLinearProblem(false) {}
133 0 : virtual ~OneSideP1Constraints() {}
134 :
135 0 : virtual int type() const {return CT_HANGING;}
136 :
137 : void adjust_jacobian(matrix_type& J, const vector_type& u,
138 : ConstSmartPtr<DoFDistribution> dd, int type, number time = 0.0,
139 : ConstSmartPtr<VectorTimeSeries<vector_type> > vSol = NULL,
140 : const number s_a0 = 1.0);
141 :
142 : void adjust_defect(vector_type& d, const vector_type& u,
143 : ConstSmartPtr<DoFDistribution> dd, int type, number time = 0.0,
144 : ConstSmartPtr<VectorTimeSeries<vector_type> > vSol = NULL,
145 : const std::vector<number>* vScaleMass = NULL,
146 : const std::vector<number>* vScaleStiff = NULL);
147 :
148 : void adjust_rhs(vector_type& rhs, const vector_type& u,
149 : ConstSmartPtr<DoFDistribution> dd, int type, number time = 0.0);
150 :
151 : void adjust_linear(matrix_type& mat, vector_type& rhs,
152 : ConstSmartPtr<DoFDistribution> dd, int type, number time = 0.0);
153 :
154 : void adjust_solution(vector_type& u, ConstSmartPtr<DoFDistribution> dd,
155 : int type, number time = 0.0);
156 :
157 : void adjust_prolongation(matrix_type& P,
158 : ConstSmartPtr<DoFDistribution> ddFine,
159 : ConstSmartPtr<DoFDistribution> ddCoarse,
160 : int type,
161 : number time = 0.0);
162 :
163 : void adjust_restriction(matrix_type& R,
164 : ConstSmartPtr<DoFDistribution> ddCoarse,
165 : ConstSmartPtr<DoFDistribution> ddFine,
166 : int type,
167 : number time = 0.0);
168 :
169 : virtual void adjust_correction
170 : ( vector_type& u,
171 : ConstSmartPtr<DoFDistribution> dd,
172 : int type,
173 : number time = 0.0
174 : );
175 :
176 : protected:
177 : bool m_bAssembleLinearProblem;
178 : };
179 :
180 : }; // namespace ug
181 :
182 : #include "p1_continuity_constraints_impl.h"
183 :
184 : #endif /* __H__UG__LIB_DISC__SPATIAL_DISC__CONSTRAINTS__CONTINUITY_CONSTRAINTS__P1_CONTINUITY_CONSTRAINTS__ */
|