MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
darcy_solver.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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#include <memory>
17#include <vector>
18
19namespace mfem
20{
21namespace blocksolvers
22{
24{
25 int print_level = 0;
26 int max_iter = 500;
27#if defined(MFEM_USE_DOUBLE)
28 real_t abs_tol = 1e-12;
30#elif defined(MFEM_USE_SINGLE)
31 real_t abs_tol = 1e-8;
32 real_t rel_tol = 1e-5;
33#else
34#error "Only single and double precision are supported!"
35 real_t abs_tol = 1e-12;
36 real_t rel_tol = 1e-9;
37#endif
38};
39
40void SetOptions(IterativeSolver& solver, const IterSolveParameters& param);
41
42/// Abstract solver class for Darcy's flow
43class DarcySolver : public Solver
44{
45protected:
47public:
48 DarcySolver(int size0, int size1) : Solver(size0 + size1),
49 offsets_({0, size0, height}) { }
50 virtual int GetNumIterations() const = 0;
51};
52
53/// Wrapper for the block-diagonal-preconditioned MINRES employed in ex5p.cpp
55{
56 BlockOperator op_;
58 OperatorPtr BT_;
59 OperatorPtr S_; // S_ = B diag(M)^{-1} B^T
60 MINRESSolver solver_;
61 Array<int> ess_zero_dofs_;
62public:
64 const HypreParMatrix& B,
66 virtual void Mult(const Vector & x, Vector & y) const;
67 virtual void SetOperator(const Operator &op) { }
68 void SetEssZeroDofs(const Array<int>& dofs) { dofs.Copy(ess_zero_dofs_); }
69 virtual int GetNumIterations() const { return solver_.GetNumIterations(); }
70};
71} // namespace blocksolvers
72} // namespace mfem
73
74#endif // MFEM_DARCY_SOLVER_HPP
void Copy(Array &copy) const
Create a copy of the internal array to the provided copy.
Definition array.hpp:874
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:388
Abstract base class for iterative solver.
Definition solvers.hpp:67
int GetNumIterations() const
Returns the number of iterations taken during the last call to Mult()
Definition solvers.hpp:260
MINRES method.
Definition solvers.hpp:628
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:683
Vector data type.
Definition vector.hpp:80
Wrapper for the block-diagonal-preconditioned MINRES employed in ex5p.cpp.
void SetEssZeroDofs(const Array< int > &dofs)
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
virtual void Mult(const Vector &x, Vector &y) const
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:43