OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
HypreAmgPreconditioner.hpp
Go to the documentation of this file.
1
26
27#ifndef OPENSWMM_ENGINE_2D_HYPRE_AMG_PRECONDITIONER_HPP
28#define OPENSWMM_ENGINE_2D_HYPRE_AMG_PRECONDITIONER_HPP
29
30#include "SurfaceJacobian.hpp"
31
32#include <vector>
33
34namespace openswmm::twoD {
35
36class MeshData;
38
43public:
46
49
52 void initialize(const MeshData& mesh);
53
63 void setup(const MeshData& mesh, const SurfaceStateData& state, double gamma,
64 bool recompute = true);
65
67 void solve(const double* r, double* z, int n);
68
70 void finalize();
71
72 bool ready() const noexcept { return amg_ != nullptr; }
73
75 bool hierarchyBuilt() const noexcept { return hierarchy_built_; }
76
80 void invalidate() noexcept { hierarchy_built_ = false; }
81
82private:
83 SurfaceJacobian jac_;
84 int n_ = 0;
85 bool hierarchy_built_ = false;
86 std::vector<int> rows_;
87 std::vector<int> ncols_;
88
89 // Opaque hypre handles (HYPRE_IJMatrix / HYPRE_IJVector / HYPRE_Solver are
90 // pointer typedefs; kept as void* so this header needs no HYPRE.h).
91 void* A_ = nullptr;
92 void* b_ = nullptr;
93 void* x_ = nullptr;
94 void* amg_ = nullptr;
95};
96
97} // namespace openswmm::twoD
98
99#endif // OPENSWMM_ENGINE_2D_HYPRE_AMG_PRECONDITIONER_HPP
CSR assembly of the approximate Newton matrix M = I − γ·J for the 2D diffusive-wave surface operator,...
void invalidate() noexcept
Definition HypreAmgPreconditioner.hpp:80
void initialize(const MeshData &mesh)
Definition HypreAmgPreconditioner.cpp:32
HypreAmgPreconditioner & operator=(const HypreAmgPreconditioner &)=delete
~HypreAmgPreconditioner()
Definition HypreAmgPreconditioner.cpp:168
HypreAmgPreconditioner(const HypreAmgPreconditioner &)=delete
void solve(const double *r, double *z, int n)
Apply one BoomerAMG V-cycle: z ≈ M⁻¹ r (n entries each).
Definition HypreAmgPreconditioner.cpp:127
void setup(const MeshData &mesh, const SurfaceStateData &state, double gamma, bool recompute=true)
Definition HypreAmgPreconditioner.cpp:88
bool hierarchyBuilt() const noexcept
True once the multigrid hierarchy has been built at least once.
Definition HypreAmgPreconditioner.hpp:75
bool ready() const noexcept
Definition HypreAmgPreconditioner.hpp:72
void finalize()
Release all hypre objects.
Definition HypreAmgPreconditioner.cpp:159
Assembles M = I − γ·J (diffusion stencil) in CSR for AMG.
Definition SurfaceJacobian.hpp:43
Definition NodeCoupling.cpp:15
SoA storage for 2D triangular mesh geometry and topology.
Definition MeshData.hpp:34
Definition SurfaceStateData.hpp:41