| 1 |
// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced |
| 2 |
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files |
| 3 |
// LICENSE and NOTICE for details. LLNL-CODE-806117. |
| 4 |
// |
| 5 |
// This file is part of the MFEM library. For more information and source code |
| 6 |
// availability visit https://mfem.org. |
| 7 |
// |
| 8 |
// MFEM is free software; you can redistribute it and/or modify it under the |
| 9 |
// terms of the BSD-3 license. We welcome feedback and contributions, see file |
| 10 |
// CONTRIBUTING.md for details. |
| 11 |
|
| 12 |
#ifndef MFEM_ELASTICITY_DIAGONAL_PC_HPP |
| 13 |
#define MFEM_ELASTICITY_DIAGONAL_PC_HPP |
| 14 |
|
| 15 |
#include "../operators/elasticity_gradient_operator.hpp" |
| 16 |
|
| 17 |
namespace mfem |
| 18 |
{ |
| 19 |
/** |
| 20 |
* @brief ElasticityDiagonalPreconditioner acts as a matrix-free preconditioner |
| 21 |
* for ElasticityOperator. |
| 22 |
* |
| 23 |
* @note There are two types to choose from |
| 24 |
* - Diagonal: A classic Jacobi type preconditioner |
| 25 |
* - BlockDiagonal: A Jacobi type preconditioner which calculates the diagonal |
| 26 |
* contribution of ElasticityOperator on each diagonal element and applies |
| 27 |
* its inverted submatrix. |
| 28 |
*/ |
| 29 |
class ElasticityDiagonalPreconditioner : public Solver |
| 30 |
{ |
| 31 |
static constexpr int dim = 3; |
| 32 |
|
| 33 |
public: |
| 34 |
enum Type { Diagonal = 0, BlockDiagonal }; |
| 35 |
|
| 36 |
ElasticityDiagonalPreconditioner(Type type = Type::Diagonal) |
| 37 |
: Solver(), type_(type) {} |
| 38 |
|
| 39 |
void SetOperator(const Operator &op) override; |
| 40 |
|
| 41 |
void Mult(const Vector &x, Vector &y) const override; |
| 42 |
|
| 43 |
private: |
| 44 |
const ElasticityGradientOperator *gradient_operator_; |
| 45 |
int num_submats_, submat_height_; |
| 46 |
Vector Ke_diag_, K_diag_local_, K_diag_; |
| 47 |
Type type_; |
| 48 |
}; |
| 49 |
|
| 50 |
} // namespace mfem |
| 51 |
|
| 52 |
#endif |