245 TrilinosMatrix &matrix,
246 TrilinosVector &solution,
247 TrilinosVector &right_hand_side,
248 const bool eliminate_columns)
251 Assert(matrix.n() == right_hand_side.size(),
253 Assert(matrix.n() == solution.size(),
259 if (boundary_values.size() > 0)
261 const std::pair<types::global_dof_index, types::global_dof_index>
275 if (matrix.diag_element(i) != 0)
277 average_nonzero_diagonal_entry =
278 std::fabs(matrix.diag_element(i));
284 std::vector<types::global_dof_index> constrained_rows;
285 for (
const auto &boundary_value : boundary_values)
288 constrained_rows.push_back(boundary_value.first);
297 matrix.clear_rows(constrained_rows, average_nonzero_diagonal_entry);
299 std::vector<types::global_dof_index> indices;
300 std::vector<TrilinosScalar> solution_values;
301 for (
const auto &boundary_value : boundary_values)
305 indices.push_back(boundary_value.first);
306 solution_values.push_back(boundary_value.second);
308 solution.set(indices, solution_values);
312 for (
unsigned int i = 0; i < solution_values.size(); ++i)
313 solution_values[i] *= matrix.diag_element(indices[i]);
315 right_hand_side.set(indices, solution_values);
321 std::vector<types::global_dof_index> constrained_rows;
322 matrix.clear_rows(constrained_rows, 1.);
336 const std::map<types::global_dof_index, TrilinosScalar>
338 TrilinosMatrix &matrix,
339 TrilinosBlockVector &solution,
340 TrilinosBlockVector &right_hand_side,
341 const bool eliminate_columns)
345 Assert(matrix.n() == right_hand_side.size(),
347 Assert(matrix.n() == solution.size(),
349 Assert(matrix.n_block_rows() == matrix.n_block_cols(),
352 const unsigned int n_blocks = matrix.n_block_rows();
358 std::vector<std::map<types::global_dof_index, TrilinosScalar>>
359 block_boundary_values(n_blocks);
363 for (
const auto &boundary_value : boundary_values)
365 if (boundary_value.first >= matrix.block(block, 0).m() + offset)
367 offset += matrix.block(block, 0).m();
371 boundary_value.first - offset;
372 block_boundary_values[block].insert(
373 std::pair<types::global_dof_index, TrilinosScalar>(
374 index, boundary_value.second));
381 for (
unsigned int block = 0; block < n_blocks; ++block)
383 matrix.block(block, block),
384 solution.block(block),
385 right_hand_side.block(block),
392 for (
unsigned int block_m = 0; block_m < n_blocks; ++block_m)
394 const std::pair<types::global_dof_index, types::global_dof_index>
395 local_range = matrix.block(block_m, 0).local_range();
397 std::vector<types::global_dof_index> constrained_rows;
400 block_boundary_values[block_m].begin();
401 dof != block_boundary_values[block_m].end();
405 constrained_rows.push_back(dof->first);
407 for (
unsigned int block_n = 0; block_n < n_blocks; ++block_n)
408 if (block_m != block_n)
409 matrix.block(block_m, block_n).clear_rows(constrained_rows);