MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
darcy_solver.hpp
Go to the documentation of this file.
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_DARCY_SOLVER_HPP
13#define MFEM_DARCY_SOLVER_HPP
14
15#include "mfem.hpp"
16
17namespace mfem::blocksolvers
18{
19
21{
22 int print_level = 0;
23 int max_iter = 500;
24#if defined(MFEM_USE_DOUBLE)
25 real_t abs_tol = 1e-12;
27#elif defined(MFEM_USE_SINGLE)
28 real_t abs_tol = 1e-8;
29 real_t rel_tol = 1e-5;
30#else
31#error "Only single and double precision are supported!"
32#endif
33};
34
35void SetOptions(IterativeSolver& solver, const IterSolveParameters& param);
36
37/// Abstract solver class for Darcy's flow
38class DarcySolver : public Solver
39{
40protected:
42public:
43 DarcySolver(int size0, int size1) : Solver(size0 + size1),
44 offsets_({0, size0, height}) { }
45 virtual int GetNumIterations() const = 0;
46};
47
48/// Wrapper for the block-diagonal-preconditioned MINRES employed in ex5p.cpp
50{
51 BlockOperator op_;
53 OperatorPtr BT_;
54 OperatorPtr S_; // S_ = B diag(M)^{-1} B^T
55 MINRESSolver solver_;
56 Array<int> ess_zero_dofs_;
57public:
59 const HypreParMatrix& B,
61 void Mult(const Vector & x, Vector & y) const override;
62 void SetOperator(const Operator &op) override { }
63 void SetEssZeroDofs(const Array<int>& dofs) { dofs.Copy(ess_zero_dofs_); }
64 int GetNumIterations() const override { return solver_.GetNumIterations(); }
65};
66
67} // namespace mfem::blocksolvers
68
69#endif // MFEM_DARCY_SOLVER_HPP
void Copy(Array &copy) const
Create a copy of the internal array to the provided copy.
Definition array.hpp:1042
A class to handle Block diagonal preconditioners in a matrix-free implementation.
A class to handle Block systems in a matrix-free implementation.
Wrapper for hypre's ParCSR matrix class.
Definition hypre.hpp:419
Abstract base class for iterative solver.
Definition solvers.hpp:91
int GetNumIterations() const
Returns the number of iterations taken during the last call to Mult()
Definition solvers.hpp:289
MINRES method.
Definition solvers.hpp:742
Pointer to an Operator of a specified type.
Definition handle.hpp:34
Abstract operator.
Definition operator.hpp:25
int height
Dimension of the output / number of rows in the matrix.
Definition operator.hpp:27
Base class for solvers.
Definition operator.hpp:792
Vector data type.
Definition vector.hpp:82
Wrapper for the block-diagonal-preconditioned MINRES employed in ex5p.cpp.
int GetNumIterations() const override
void SetEssZeroDofs(const Array< int > &dofs)
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
void Mult(const Vector &x, Vector &y) const override
Operator application: y=A(x).
BDPMinresSolver(const HypreParMatrix &M, const HypreParMatrix &B, IterSolveParameters param)
Wrapper Block Diagonal Preconditioned MINRES (ex5p)
Abstract solver class for Darcy's flow.
virtual int GetNumIterations() const =0
DarcySolver(int size0, int size1)
void SetOptions(IterativeSolver &solver, const IterSolveParameters &param)
float real_t
Definition config.hpp:46