Line data Source code
1 : // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 : // SPDX-License-Identifier: Apache-2.0
3 :
4 : #ifndef PALACE_LINALG_JACOBI_SMOOTHER_HPP
5 : #define PALACE_LINALG_JACOBI_SMOOTHER_HPP
6 :
7 : #include "linalg/operator.hpp"
8 : #include "linalg/solver.hpp"
9 : #include "linalg/vector.hpp"
10 :
11 : namespace palace
12 : {
13 :
14 : //
15 : // Simple Jacobi smoother using the diagonal vector from OperType::AssembleDiagonal(),
16 : // which allows for (approximate) diagonal construction for matrix-free operators.
17 : //
18 : template <typename OperType>
19 : class JacobiSmoother : public Solver<OperType>
20 : {
21 : using VecType = typename Solver<OperType>::VecType;
22 :
23 : private:
24 : // MPI communicator associated with the solver operator and vectors.
25 : MPI_Comm comm;
26 :
27 : // Inverse diagonal scaling of the operator (real-valued for now).
28 : VecType dinv;
29 :
30 : // Damping factor and scaling factor for maximum eigenvalue.
31 : double omega, sf_max;
32 :
33 : public:
34 0 : JacobiSmoother(MPI_Comm comm, double omega = 1.0, double sf_max = 1.0)
35 0 : : Solver<OperType>(), comm(comm), omega(omega), sf_max(sf_max)
36 : {
37 0 : }
38 :
39 : void SetOperator(const OperType &op) override;
40 :
41 : void Mult(const VecType &x, VecType &y) const override;
42 :
43 0 : void MultTranspose(const VecType &x, VecType &y) const override { Mult(x, y); }
44 : };
45 :
46 : } // namespace palace
47 :
48 : #endif // PALACE_LINALG_JACOBI_SMOOTHER_HPP
|