243 TrilinosMatrix &matrix,
244 TrilinosVector &solution,
245 TrilinosVector &right_hand_side,
246 const bool eliminate_columns)
249 Assert(matrix.n() == right_hand_side.size(),
251 Assert(matrix.n() == solution.size(),
257 if (boundary_values.size() > 0)
259 const std::pair<types::global_dof_index, types::global_dof_index>
273 if (matrix.diag_element(i) != 0)
275 average_nonzero_diagonal_entry =
276 std::fabs(matrix.diag_element(i));
282 std::vector<types::global_dof_index> constrained_rows;
283 for (
const auto &boundary_value : boundary_values)
286 constrained_rows.push_back(boundary_value.first);
295 matrix.clear_rows(constrained_rows, average_nonzero_diagonal_entry);
297 std::vector<types::global_dof_index> indices;
298 std::vector<TrilinosScalar> solution_values;
299 for (
const auto &boundary_value : boundary_values)
303 indices.push_back(boundary_value.first);
304 solution_values.push_back(boundary_value.second);
306 solution.set(indices, solution_values);
310 for (
unsigned int i = 0; i < solution_values.size(); ++i)
311 solution_values[i] *= matrix.diag_element(indices[i]);
313 right_hand_side.set(indices, solution_values);
319 std::vector<types::global_dof_index> constrained_rows;
320 matrix.clear_rows(constrained_rows, 1.);
334 const std::map<types::global_dof_index, TrilinosScalar>
336 TrilinosMatrix &matrix,
337 TrilinosBlockVector &solution,
338 TrilinosBlockVector &right_hand_side,
339 const bool eliminate_columns)
343 Assert(matrix.n() == right_hand_side.size(),
345 Assert(matrix.n() == solution.size(),
347 Assert(matrix.n_block_rows() == matrix.n_block_cols(),
350 const unsigned int n_blocks = matrix.n_block_rows();
356 std::vector<std::map<types::global_dof_index, TrilinosScalar>>
357 block_boundary_values(n_blocks);
361 for (
const auto &boundary_value : boundary_values)
363 if (boundary_value.first >= matrix.block(block, 0).m() + offset)
365 offset += matrix.block(block, 0).m();
369 boundary_value.first - offset;
370 block_boundary_values[block].insert(
371 std::pair<types::global_dof_index, TrilinosScalar>(
372 index, boundary_value.second));
379 for (
unsigned int block = 0; block < n_blocks; ++block)
381 matrix.block(block, block),
382 solution.block(block),
383 right_hand_side.block(block),
390 for (
unsigned int block_m = 0; block_m < n_blocks; ++block_m)
392 const std::pair<types::global_dof_index, types::global_dof_index>
393 local_range = matrix.block(block_m, 0).local_range();
395 std::vector<types::global_dof_index> constrained_rows;
398 block_boundary_values[block_m].
begin();
399 dof != block_boundary_values[block_m].end();
403 constrained_rows.push_back(dof->first);
405 for (
unsigned int block_n = 0; block_n < n_blocks; ++block_n)
406 if (block_m != block_n)
407 matrix.block(block_m, block_n).clear_rows(constrained_rows);