33 #ifndef __H__UG__LIB_ALGEBRA__OPERATOR__PRECONDITIONER__PROJECTED_GAUSS_SEIDEL__PROJ_GAUSS_SEIDEL_INTERFACE_IMPL__
34 #define __H__UG__LIB_ALGEBRA__OPERATOR__PRECONDITIONER__PROJECTED_GAUSS_SEIDEL__PROJ_GAUSS_SEIDEL_INTERFACE_IMPL__
38 #define PROFILE_PROJ_GAUSS_SEIDEL
39 #ifdef PROFILE_PROJ_GAUSS_SEIDEL
40 #define PROJ_GAUSS_SEIDEL_PROFILE_FUNC() PROFILE_FUNC()
41 #define PROJ_GAUSS_SEIDEL_PROFILE_BEGIN(name) PROFILE_BEGIN_GROUP(name, "IProjGaussSeidel")
42 #define PROJ_GAUSS_SEIDEL_PROFILE_END() PROFILE_END()
44 #define PROJ_GAUSS_SEIDEL_PROFILE_FUNC()
45 #define PROJ_GAUSS_SEIDEL_PROFILE_BEGIN(name)
46 #define PROJ_GAUSS_SEIDEL_PROFILE_END()
51 template <
typename TDomain,
typename TAlgebra>
56 typedef typename vector<DoFIndex>::iterator iter_type;
57 iter_type dofIter = vInd.begin();
58 iter_type dofIterEnd = vInd.end();
59 for( ; dofIter != dofIterEnd; dofIter++)
61 if (vec.size() <= (*dofIter)[0])
62 UG_THROW(
"vec size is to small in IProjGaussSeidel::truncateVec \n");
64 UG_LOG(
"truncateVec: " <<*dofIter<<
"\n");
66 DoFRef(vec, *dofIter) = 0.0;
70 template <
typename TDomain,
typename TAlgebra>
75 typedef typename vector<DoFIndex>::iterator iter_type;
76 iter_type dofIter = vInd.begin();
77 iter_type dofIterEnd = vInd.end();
78 for( ; dofIter != dofIterEnd; dofIter++)
80 UG_LOG(
"activeDof : " <<*dofIter<<
"\n");
83 SetRow(mat, (*dofIter)[0], 0.0);
86 UG_LOG(
"truncateMat: mat(" <<(*dofIter)[1]<<
","<<(*dofIter)[0]<<
") \n");
87 mat((*dofIter)[1], (*dofIter)[0]) = 0.0;
91 template <
typename TDomain,
typename TAlgebra>
107 UG_LOG(
"In IProjGaussSeidel::init u hat "<<(*m_spSol).size()<<
"Eintraege \n");
110 typedef typename vector<SmartPtr<IObstacleConstraint<TDomain,TAlgebra> > >::iterator iter_type;
111 iter_type iter = m_spvObsConstraint.begin();
112 iter_type iterEnd = m_spvObsConstraint.end();
113 for( ; iter != iterEnd; iter++)
114 (*iter)->preprocess();
127 template <
typename TDomain,
typename TAlgebra>
135 typedef typename vector<SmartPtr<IObstacleConstraint<TDomain,TAlgebra> > >::iterator iter_type;
136 iter_type iterEnd = m_spvObsConstraint.end();
138 for(
size_t comp = 0; comp <
GetSize(c_i); comp++)
145 bool dofIsActive =
false;
146 bool dofIsObsDoF =
false;
149 iter_type iter = m_spvObsConstraint.begin();
150 for( ; iter != iterEnd; iter++)
153 if (!((*iter)->is_obs_dof(dof)))
159 (*iter)->adjust_sol_and_cor((*m_spSol)[i], c_i, dofIsActive, dof);
162 if (dofIsObsDoF && (!dofIsActive))
171 template <
typename TDomain,
typename TAlgebra>
180 UG_LOG(
"ERROR in 'IProjGaussSeidel::apply': Iterator not initialized.\n");
187 typedef typename vector<SmartPtr<IObstacleConstraint<TDomain,TAlgebra> > >::iterator iter_type;
188 iter_type iter = m_spvObsConstraint.begin();
189 iter_type iterEnd = m_spvObsConstraint.end();
191 for( ; iter != iterEnd; iter++)
192 (*iter)->reset_active_dofs();
195 base_type::apply(c, d);
198 const GF& def =
dynamic_cast<const GF&
>(d);
204 int surfaceLev = spD->dof_distribution()->grid_level().level();
206 UG_LOG(
"NumIndices :" <<spD->dof_distribution()->num_indices() <<
"\n");
207 UG_LOG(
"numLevels: " << spD->approx_space()->num_levels() <<
"\n");
209 if (spD->dof_distribution()->multi_grid().
valid())
211 size_t topLev = spD->dof_distribution()->multi_grid()->top_level();
212 UG_LOG(
"surfaceLev: " << surfaceLev <<
"!\n");
213 UG_LOG(
"topLev: " << topLev <<
"!\n");
215 if((
size_t)surfaceLev == topLev)
217 UG_LOG(
"topLev gleich surfaceLev!\n");
221 typedef typename vector<SmartPtr<IObstacleConstraint<TDomain,TAlgebra> > >::iterator iter_type;
222 iter_type iter = m_spvObsConstraint.begin();
223 iter_type iterEnd = m_spvObsConstraint.end();
225 for( ; iter != iterEnd; iter++)
228 vector<DoFIndex> vActiveDoFs;
229 (*iter)->active_dofs(vActiveDoFs);
230 UG_LOG(
"vActiveDoFs.size() : " <<vActiveDoFs.size()<<
"\n");
232 typedef typename vector<DoFIndex>::iterator dof_iter_type;
233 dof_iter_type dofIter = vActiveDoFs.begin();
234 dof_iter_type dofIterEnd = vActiveDoFs.end();
235 for( ; dofIter != dofIterEnd; dofIter++)
236 UG_LOG(
"activeDof : " <<*dofIter<<
"\n");
295 template <
typename TDomain,
typename TAlgebra>
306 base_type::apply_update_defect(c, d);
311 typedef typename vector<SmartPtr<IObstacleConstraint<TDomain,TAlgebra> > >::iterator iter_type;
312 iter_type iter = m_spvObsConstraint.begin();
313 iter_type iterEnd = m_spvObsConstraint.end();
315 for( ; iter != iterEnd; iter++)
316 (*iter)->adjust_defect_to_constraint(d);
Definition: smart_pointer.h:296
bool valid() const
returns true if the pointer is valid, false if not.
Definition: smart_pointer.h:414
Definition: smart_pointer.h:108
TAlgebra::matrix_type matrix_type
type of matrix
Definition: debug_writer.h:363
represents numerical solutions on a grid using an algebraic vector
Definition: grid_function.h:121
SmartPtr< this_type > clone_without_values() const
clone excluding values
Definition: grid_function.h:219
describes a linear mapping X->Y
Definition: linear_operator.h:80
vector_type::value_type value_type
Value type.
Definition: proj_gauss_seidel_interface.h:89
virtual bool init(SmartPtr< ILinearOperator< vector_type > > J, const vector_type &u)
Prepare for Operator J(u) and linearization point u (current solution)
Definition: proj_gauss_seidel_interface_impl.h:94
void truncateMat(matrix_type &mat, vector< DoFIndex > &vInd)
Definition: proj_gauss_seidel_interface_impl.h:73
void project_correction(value_type &c_i, const size_t i)
projects the correction on the underlying constraints set by the obstacleConstraints
Definition: proj_gauss_seidel_interface_impl.h:130
algebra_type::vector_type vector_type
Vector type.
Definition: proj_gauss_seidel_interface.h:86
virtual bool apply_update_defect(vector_type &c, vector_type &d)
Compute new correction c = B*d and return new defect d := d - A*c.
Definition: proj_gauss_seidel_interface_impl.h:298
void truncateVec(vector_type &vec, vector< DoFIndex > &vInd)
Definition: proj_gauss_seidel_interface_impl.h:54
virtual bool apply(vector_type &c, const vector_type &d)
Compute new correction c = B*d.
Definition: proj_gauss_seidel_interface_impl.h:174
Definition: multi_index.h:50
void SetRow(TSparseMatrix &A, size_t i, size_t alpha, number val=0.0)
Definition: sparsematrix_util.h:710
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
number & DoFRef(TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
Definition: multi_index.h:276
double & BlockRef(T &vec, size_t i)
Definition: blocks.h:66
MultiIndex< 2 > DoFIndex
type of DoF-Index used to identify an DoF in the Algebra
Definition: multi_index.h:272
size_t GetSize(const T &t)
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258