deal.II version GIT relicensing-6842-g793a97d2aa 2026-10-02 14:00:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
matrix_scaling.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2001 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_matrix_scaling_h
14#define dealii_matrix_scaling_h
15
16#include <deal.II/base/config.h>
17
22
25#include <deal.II/lac/vector.h>
26
27#ifdef DEAL_II_WITH_TRILINOS
30#endif
31
32#ifdef DEAL_II_WITH_PETSC
35#endif
36
38
64{
65public:
70 {
72 l1,
73
76 };
77
83 {
88 {
90
97
99
108 };
109
114 {
120 enum class NormType
121 {
123 l1,
124
126 l_infty
127 };
128
133 const unsigned int max_iterations = 20);
134
138 unsigned int max_iterations;
139
144 };
145
152 {
156 explicit l1linfParameters(const unsigned int start_inf_norm_steps = 1,
157 const unsigned int l1_norm_steps = 3,
158 const unsigned int end_inf_norm_steps = 1);
159
164
168 unsigned int l1_norm_steps;
169
173 unsigned int end_inf_norm_steps;
174 };
175
179 explicit AdditionalData(
180 const double scaling_tolerance = 1e-5,
181 const ScalingAlgorithm alg =
183 const SKParameters sk_params = SKParameters(),
184 const l1linfParameters l1linf_params = l1linfParameters());
185
186
197
202
207
212 };
213
220
224 ~MatrixScaling() = default;
225
234 template <class Matrix>
235 bool
236 find_scaling_and_scale_matrix(Matrix &matrix);
237
249 template <class Matrix, class VectorType>
250 bool
251 find_scaling_and_scale_linear_system(Matrix &matrix, VectorType &rhs);
252
258 template <class VectorType>
259 void
260 scale_system_solution(VectorType &sol) const;
261
266 const Vector<double> &
267 get_row_scaling() const;
268
273 const Vector<double> &
274 get_column_scaling() const;
275
276private:
281
287
293
298
303
310
314 std::vector<unsigned int> ghost_column_owners;
315
320
326 template <class Matrix>
327 bool
328 do_l1_scaling(Matrix &matrix, const unsigned int nsteps);
329
335 template <class Matrix>
336 bool
337 do_linfty_scaling(Matrix &matrix, const unsigned int nsteps);
338
343 template <class Matrix>
344 bool
345 do_sk_scaling(Matrix &matrix, const unsigned int nsteps);
346
347 /*
348 * Check convergence of the sequential scaling algorithms. Only on either row
349 * or columns for SK scaling.
350 */
351 template <typename Number>
352 bool
353 check_convergence(const Vector<Number> &row_col_norm,
354 const ConvergenceNormType &norm_type) const;
355
356 /*
357 * Check convergence of the sequential scaling algorithms. On both row
358 * and columns for symmetry preserving scaling.
359 */
360 template <typename Number>
361 bool
362 check_convergence(const Vector<Number> &row_norm,
363 const Vector<Number> &col_norm,
364 const ConvergenceNormType &norm_type) const;
365
366 /*
367 * Check convergence of the parallel scaling algorithm. Only on either row
368 * or columns for SK scaling.
369 */
370 bool
371 check_convergence(const Vector<double> &local_row_col_norm,
372 const ConvergenceNormType &norm_type,
373 const MPI_Comm mpi_communicator) const;
374
375 /*
376 * Check convergence of the parallel scaling algorithm. Only on both row
377 * and columns for symmetry preserving scaling.
378 */
379 bool
380 check_convergence(const Vector<double> &local_row_norm,
381 const Vector<double> &local_col_norm,
382 const ConvergenceNormType &norm_type,
383 const MPI_Comm mpi_communicator) const;
384
385 /*
386 * Fill the send_data map with the partial column norms that need to be sent
387 * to other MPI processes. Prepare the local_col_norms vector. This is a
388 * helper function for the distributed implementation of the scaling
389 * algorithms.
390 */
391 void
393 const std::map<types::global_dof_index, double> &partial_column_norms,
394 std::map<unsigned int,
395 std::vector<std::pair<types::global_dof_index, double>>>
396 &send_data,
397 Vector<double> &local_col_norms);
398
399 /*
400 * Fill the send_column_norms map with the updated column norms that need to
401 * be sent to other MPI processes. This is a helper function for the
402 * distributed implementation of the scaling algorithms.
403 */
404 void
406 const std::map<unsigned int,
407 std::vector<std::pair<types::global_dof_index, double>>>
408 &received_data,
409 const Vector<double> &local_col_norms,
410 std::map<unsigned int,
411 std::vector<std::pair<types::global_dof_index, double>>>
412 &send_column_norms);
413};
414
416
417#endif // dealii_matrix_scaling_h
Utilities::MPI::Partitioner partitioner
const Vector< double > & get_row_scaling() const
Vector< double > column_scaling
bool do_linfty_scaling(Matrix &matrix, const unsigned int nsteps)
bool do_sk_scaling(Matrix &matrix, const unsigned int nsteps)
IndexSet locally_owned_cols
AdditionalData control
Vector< double > row_scaling
bool find_scaling_and_scale_linear_system(Matrix &matrix, VectorType &rhs)
bool check_convergence(const Vector< Number > &row_col_norm, const ConvergenceNormType &norm_type) const
const Vector< double > & get_column_scaling() const
void send_prepare_updated_col_norms(const std::map< unsigned int, std::vector< std::pair< types::global_dof_index, double > > > &received_data, const Vector< double > &local_col_norms, std::map< unsigned int, std::vector< std::pair< types::global_dof_index, double > > > &send_column_norms)
@ l_infty
l_infinity vector norm
void send_prepare_col_norms(const std::map< types::global_dof_index, double > &partial_column_norms, std::map< unsigned int, std::vector< std::pair< types::global_dof_index, double > > > &send_data, Vector< double > &local_col_norms)
IndexSet ghost_columns
IndexSet locally_owned_rows
~MatrixScaling()=default
std::vector< unsigned int > ghost_column_owners
bool do_l1_scaling(Matrix &matrix, const unsigned int nsteps)
void scale_system_solution(VectorType &sol) const
bool find_scaling_and_scale_matrix(Matrix &matrix)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
@ l1_linf_symmetry_preserving
Symmetry preserving scaling algorithm.
@ sinkhorn_knopp
Sinkhorn-Knopp scaling algorithm.