Plugins
Loading...
Searching...
No Matches
df_transforming.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Gesellschaft fuer Anlagen- und Reaktorsicherheit gGmbH
3 * SPDX-License-Identifier: EUPL-1.2
4 * SPDX-FileContributor: Arne Naegel
5 * SPDX-FileContributor: Goethe Universität Frankfurt
6 * SPDX-FileType: SOURCE
7 *
8 * This file is part of d3f++.
9 * d3f++ is an extension for UG4. Licensing information and citation requirements of UG4 are provided in LICENSES/UG4-LGPL_2.1
10 */
11
12#ifndef __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__TRANSFORMING__
13#define __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__TRANSFORMING__
14
19
20#include "df_transform.h"
21#ifdef UG_PARALLEL
24#endif
25
26namespace ug{
27
29
33template <typename TAlgebra, typename TTransform>
35//public virtual ILinearIterator<typename TAlgebra::vector_type>,
36//public DebugWritingObject <TAlgebra>
37public ITransformingIteration<TAlgebra, LeftTransformIterator<TAlgebra, TTransform> >
38{
39 public:
41 typedef TAlgebra algebra_type;
42
44 typedef typename TAlgebra::vector_type vector_type;
45
47 typedef typename TAlgebra::matrix_type matrix_type;
48
51
53 typedef TTransform transform_type;
54
55 public:
56 // Constructor
63
64 // Clone
71
72private:
75 {
76 // transform
77 get_transform().transform_operator(pOp->get_matrix(), transformed_matrix()->get_matrix());
78
79 // write debug
80 this->write_debug(pOp->get_matrix(), "DebugOriginalMatrix");
81 this->write_debug(transformed_matrix()->get_matrix(), "DebugTransformedMatrix");
82
83 // forward init
84 return get_preconditioner()->init(transformed_matrix());
85 }
86
87public:
88
89
92 {
94
95 // cast to matrix based operator
97 J.template cast_dynamic<MatrixOperator<matrix_type, vector_type> >();
98
99 // Check that matrix if of correct type
100 if(pOp.invalid())
101 UG_THROW(name() << "::init': Passed Operator is "
102 "not based on matrix. This Preconditioner can only "
103 "handle matrix-based operators.");
104
105 // forward request to matrix based implementation
106 get_transform().init(pOp->get_matrix(), &u);
107 return init(pOp);
108 }
109
110
113 {
114 m_spOriginalOp = L;
115 // cast to matrix based operator
117 L.template cast_dynamic<MatrixOperator<matrix_type, vector_type> >();
118
119 // Check that matrix if of correct type
120 if(pOp.invalid())
121 UG_THROW(name() << "::init': Passed Operator is "
122 "not based on matrix. This Preconditioner can only "
123 "handle matrix-based operators.");
124
125 // forward request to matrix based implementation
126 get_transform().init(pOp->get_matrix(), NULL);
127 return init(pOp);
128 };
129
130
133 { return get_transform().transform_rhs(d, m_dTransformed); }
134
137 { return get_preconditioner()->apply(c, m_dTransformed); }
138
141 { return true; }
142
146
147
149
150
151
152 protected:
153 // reference to 'real' preconditioner
154
157
158 SmartPtr <MatrixOperator<matrix_type, vector_type> > transformed_matrix()
159 {return m_spOpTransformed;}
160
163
164 virtual bool supports_parallel() const
165 {
166 UG_LOG("WARNING: Not sure if LeftTransformIterator supports parallel execution!\n");
167 return true;
168 }
169
170 // Name of preconditioner
171 virtual const char* name() const {return "LeftTransform";}
172
173
174
175
176 protected:
179
182
185
186};
187
188
189
190} // end namespace ug
191
192#endif // __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__TRANSFORMING__
bool invalid() const
void write_debug(const matrix_type &mat, const char *filename)
SmartPtr< IDamping< X, Y > > damping()
Transforming preconditioner.
Definition df_transforming.h:38
TAlgebra::matrix_type matrix_type
Matrix type.
Definition df_transforming.h:47
void set_preconditioner(SmartPtr< base_type > pprecond)
Definition df_transforming.h:148
bool untransform_correction(vector_type &c, const vector_type &d)
map: ctilde -> c (CRTP)
Definition df_transforming.h:140
vector_type & transformed_rhs()
Definition df_transforming.h:161
SmartPtr< base_type > get_preconditioner()
Definition df_transforming.h:155
SmartPtr< base_type > m_pprecond
Definition df_transforming.h:178
SmartPtr< ILinearOperator< vector_type > > m_spOriginalOp
operator of original system
Definition df_transforming.h:184
TAlgebra::vector_type vector_type
Vector type.
Definition df_transforming.h:44
SmartPtr< MatrixOperator< matrix_type, vector_type > > transformed_matrix()
Definition df_transforming.h:158
virtual SmartPtr< ILinearIterator< vector_type > > clone()
Definition df_transforming.h:65
bool transform_defect(vector_type &c, const vector_type &d)
map: d -> dtilde (CRTP)
Definition df_transforming.h:132
virtual bool supports_parallel() const
Definition df_transforming.h:164
vector_type m_dTransformed
Definition df_transforming.h:180
transform_type & get_transform()
Definition df_transforming.h:156
bool init(SmartPtr< MatrixOperator< matrix_type, vector_type > > pOp)
transform operator and forward call to original
Definition df_transforming.h:74
LeftTransformIterator()
Definition df_transforming.h:57
SmartPtr< ILinearOperator< vector_type > > original_operator()
original operator (CRTP)
Definition df_transforming.h:144
ILinearIterator< typename TAlgebra::vector_type > base_type
Base type.
Definition df_transforming.h:50
bool apply_transformed(vector_type &c, const vector_type &d)
map: dtilde -> ctilde (CRTP)
Definition df_transforming.h:136
TAlgebra algebra_type
Algebra type.
Definition df_transforming.h:41
SmartPtr< MatrixOperator< matrix_type, vector_type > > m_spOpTransformed
Definition df_transforming.h:181
TTransform transform_type
Transform type.
Definition df_transforming.h:53
transform_type m_transform
Definition df_transforming.h:177
virtual const char * name() const
Definition df_transforming.h:171
bool init(SmartPtr< ILinearOperator< vector_type > > L)
implementation of init for linear (CRTP)
Definition df_transforming.h:112
bool init(SmartPtr< ILinearOperator< vector_type > > J, const vector_type &u)
implementation of init for non-linear (CRTP)
Definition df_transforming.h:91
#define UG_THROW(msg)
#define UG_LOG(msg)