99 using domain_type_to =
typename CudaPreconditionerType::domain_type;
106 using block_type =
typename domain_type::block_type;
108 using XTo = Dune::BlockVector<Dune::FieldVector<field_type_to, block_type::dimension>>;
109 using YTo = Dune::BlockVector<Dune::FieldVector<field_type_to, block_type::dimension>>;
110 using matrix_type_to =
111 typename Dune::BCRSMatrix<Dune::FieldMatrix<field_type_to, block_type::dimension, block_type::dimension>>;
122 , m_convertedMatrix(createConvertedMatrix())
129 static_assert(!detail::shouldCallPreconditionerPre<CudaPreconditionerType>(),
130 "We currently do not support Preconditioner::pre().");
137 "You need to set the underlying preconditioner with setUnderlyingPreconditioner.");
139 for (
size_t i = 0;
i <
v.N(); ++
i) {
140 for (
size_t j = 0;
j < block_type::dimension; ++
j) {
146 for (
size_t i = 0;
i <
d.N(); ++
i) {
147 for (
size_t j = 0;
j < block_type::dimension; ++
j) {
154 for (
size_t i = 0;
i <
v.N(); ++
i) {
155 for (
size_t j = 0;
j < block_type::dimension; ++
j) {
164 static_assert(!detail::shouldCallPreconditionerPost<CudaPreconditionerType>(),
165 "We currently do not support Preconditioner::post().");
169 virtual Dune::SolverCategory::Category
category()
const override
171 return m_underlyingPreconditioner->category();
174 virtual void update()
override
177 "You need to set the underlying preconditioner with setUnderlyingPreconditioner.");
179 m_underlyingPreconditioner->update();
182 const matrix_type_to& getConvertedMatrix()
const
184 return m_convertedMatrix;
187 void setUnderlyingPreconditioner(
const std::shared_ptr<CudaPreconditionerType>& conditioner)
189 m_underlyingPreconditioner = conditioner;
196 const auto nnz = m_matrix.nonzeroes() * m_matrix[0][0].N() * m_matrix[0][0].N();
197 const auto dataPointerIn =
static_cast<const field_type*
>(&((m_matrix[0][0][0][0])));
198 auto dataPointerOut =
static_cast<field_type_to*
>(&((m_convertedMatrix[0][0][0][0])));
200 std::vector<field_type_to> buffer(nnz, 0);
201 for (
size_t i = 0; i < nnz; ++i) {
205 matrix_type_to createConvertedMatrix()
208 const auto N = m_matrix.N();
209 matrix_type_to matrixBuilder(N, N, m_matrix.nonzeroes(), matrix_type_to::row_wise);
211 auto rowIn = m_matrix.begin();
212 for (
auto rowOut = matrixBuilder.createbegin(); rowOut != matrixBuilder.createend(); ++rowOut) {
213 for (
auto column = rowIn->begin(); column != rowIn->end(); ++column) {
214 rowOut.insert(column.index());
220 for (
auto row = m_matrix.begin(); row != m_matrix.end(); ++row) {
221 for (
auto column = row->begin(); column != row->end(); ++column) {
222 for (
size_t i = 0; i < block_type::dimension; ++i) {
223 for (
size_t j = 0; j < block_type::dimension; ++j) {
224 matrixBuilder[row.index()][column.index()][i][j]
225 =
field_type_to(m_matrix[row.index()][column.index()][i][j]);
231 return matrixBuilder;
234 matrix_type_to m_convertedMatrix;
236 std::shared_ptr<CudaPreconditionerType> m_underlyingPreconditioner;