245 TrilinosMatrix &matrix,
246 TrilinosVector &solution,
247 TrilinosVector &right_hand_side,
248 const bool eliminate_columns)
251 (void)eliminate_columns;
253 Assert(matrix.n() == right_hand_side.size(),
255 Assert(matrix.n() == solution.size(),
261 if (boundary_values.size() > 0)
263 const std::pair<types::global_dof_index, types::global_dof_index>
277 if (matrix.diag_element(i) != 0)
279 average_nonzero_diagonal_entry =
280 std::fabs(matrix.diag_element(i));
286 std::vector<types::global_dof_index> constrained_rows;
287 for (
const auto &boundary_value : boundary_values)
290 constrained_rows.push_back(boundary_value.first);
299 matrix.clear_rows(constrained_rows, average_nonzero_diagonal_entry);
301 std::vector<types::global_dof_index> indices;
302 std::vector<TrilinosScalar> solution_values;
303 for (
const auto &boundary_value : boundary_values)
307 indices.push_back(boundary_value.first);
308 solution_values.push_back(boundary_value.second);
310 solution.set(indices, solution_values);
314 for (
unsigned int i = 0; i < solution_values.size(); ++i)
315 solution_values[i] *= matrix.diag_element(indices[i]);
317 right_hand_side.set(indices, solution_values);
323 std::vector<types::global_dof_index> constrained_rows;
324 matrix.clear_rows(constrained_rows, 1.);
338 const std::map<types::global_dof_index, TrilinosScalar>
340 TrilinosMatrix &matrix,
341 TrilinosBlockVector &solution,
342 TrilinosBlockVector &right_hand_side,
343 const bool eliminate_columns)
347 Assert(matrix.n() == right_hand_side.size(),
349 Assert(matrix.n() == solution.size(),
351 Assert(matrix.n_block_rows() == matrix.n_block_cols(),
354 const unsigned int n_blocks = matrix.n_block_rows();
360 std::vector<std::map<types::global_dof_index, TrilinosScalar>>
361 block_boundary_values(n_blocks);
365 for (
const auto &boundary_value : boundary_values)
367 if (boundary_value.first >= matrix.block(block, 0).m() + offset)
369 offset += matrix.block(block, 0).m();
373 boundary_value.first - offset;
374 block_boundary_values[block].insert(
375 std::pair<types::global_dof_index, TrilinosScalar>(
376 index, boundary_value.second));
383 for (
unsigned int block = 0; block < n_blocks; ++block)
385 matrix.block(block, block),
386 solution.block(block),
387 right_hand_side.block(block),
394 for (
unsigned int block_m = 0; block_m < n_blocks; ++block_m)
396 const std::pair<types::global_dof_index, types::global_dof_index>
397 local_range = matrix.block(block_m, 0).local_range();
399 std::vector<types::global_dof_index> constrained_rows;
402 block_boundary_values[block_m].begin();
403 dof != block_boundary_values[block_m].end();
407 constrained_rows.push_back(dof->first);
409 for (
unsigned int block_n = 0; block_n < n_blocks; ++block_n)
410 if (block_m != block_n)
411 matrix.block(block_m, block_n).clear_rows(constrained_rows);