PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
Poisson.hh
Go to the documentation of this file.
1 /* Copyright (C) 2019, 2020, 2022 PISM Authors
2  *
3  * This file is part of PISM.
4  *
5  * PISM is free software; you can redistribute it and/or modify it under the
6  * terms of the GNU General Public License as published by the Free Software
7  * Foundation; either version 3 of the License, or (at your option) any later
8  * version.
9  *
10  * PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with PISM; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #include "pism/util/Logger.hh"
21 #include "pism/util/array/Scalar.hh"
22 #include "pism/util/petscwrappers/KSP.hh"
23 #include "pism/util/petscwrappers/Mat.hh"
24 
25 namespace pism {
26 
27 class Grid;
28 
29 class Poisson {
30 public:
31  Poisson(std::shared_ptr<const Grid> grid);
32 
33  int solve(const array::Scalar& mask, const array::Scalar& bc, double rhs,
34  bool reuse_matrix = false);
35 
36  const array::Scalar &solution() const;
37 private:
38  void assemble_matrix(const array::Scalar1 &mask, Mat A);
39  void assemble_rhs(double rhs,
40  const array::Scalar &mask,
41  const array::Scalar &bc,
42  array::Scalar &b);
43 
44  std::shared_ptr<const Grid> m_grid;
46  std::shared_ptr<petsc::DM> m_da; // dof=1 DA used by the KSP solver
52 };
53 
54 } // end of namespace pism
std::shared_ptr< const Logger > ConstPtr
Definition: Logger.hh:46
int solve(const array::Scalar &mask, const array::Scalar &bc, double rhs, bool reuse_matrix=false)
Definition: Poisson.cc:67
void assemble_matrix(const array::Scalar1 &mask, Mat A)
Definition: Poisson.cc:159
petsc::Mat m_A
Definition: Poisson.hh:48
std::shared_ptr< const Grid > m_grid
Definition: Poisson.hh:44
const array::Scalar & solution() const
Definition: Poisson.cc:121
std::shared_ptr< petsc::DM > m_da
Definition: Poisson.hh:46
void assemble_rhs(double rhs, const array::Scalar &mask, const array::Scalar &bc, array::Scalar &b)
Definition: Poisson.cc:267
array::Scalar1 m_mask
Definition: Poisson.hh:51
array::Scalar m_b
Definition: Poisson.hh:49
petsc::KSP m_KSP
Definition: Poisson.hh:47
Poisson(std::shared_ptr< const Grid > grid)
Definition: Poisson.cc:29
array::Scalar m_x
Definition: Poisson.hh:50
Logger::ConstPtr m_log
Definition: Poisson.hh:45