Flow123d  release_2.2.0-34-g18a8075
linsys_BDDC.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file linsys_BDDC.hh
15  * @brief Solver based on Multilevel BDDC - using corresponding class of OpenFTL package
16  * @author Jakub Sistek
17  */
18 
19 #ifndef LA_LINSYS_BDDC_HH_
20 #define LA_LINSYS_BDDC_HH_
21 
22 // derived from base linsys
23 
24 #include "la/linsys.hh"
27 
28 #include <vector>
29 
30 namespace la {
31  class BddcmlWrapper;
32 };
33 
34 class LinSys_BDDC : public LinSys
35 {
36 
37 public:
39 
40  static const Input::Type::Record & get_input_type();
41 
42  LinSys_BDDC( const unsigned numDofsSub,
43  const Distribution * rows_ds,
44  const int matrixTypeInt = 0,
45  const int numSubLoc = 1,
46  const bool swap_sign = false );
47 
48  void set_tolerances(double r_tol, double a_tol, unsigned int max_it) override;
49 
50  void load_mesh( const int nDim, const int numNodes, const int numDofs,
51  const std::vector<int> & inet,
52  const std::vector<int> & nnet,
53  const std::vector<int> & nndf,
54  const std::vector<int> & isegn,
55  const std::vector<int> & isngn,
56  const std::vector<int> & isvgvn,
57  const std::vector<double> & xyz,
58  const std::vector<double> & element_permeability,
59  const int meshDim );
60 
61  void mat_set_values( int nrow, int *rows, int ncol, int *cols, double *vals ) override;
62 
63  void rhs_set_values( int nrow, int *rows, double *vals ) override;
64 
65  void diagonal_weights_set_value( int global_index, double value );
66 
67  PetscErrorCode mat_zero_entries() override;
68 
69  PetscErrorCode rhs_zero_entries() override;
70 
71  void finish_assembly( ) override;
72 
73  void apply_constrains( double scalar = 1. ) override;
74 
75  int solve() override;
76 
77  void set_from_input(const Input::Record in_rec) override;
78 
79  double get_solution_precision() override;
80 
81  double compute_residual() override
82  {
83  // until we have correct function for residual we
84  // return a practical infinity
85  return numeric_limits<double>::max();
86  }
87 
88  ~LinSys_BDDC( );
89 
90 //private:
91 
92  //void gatherSolution_( );
93 
94 private:
95  /// Registrar of class to factory
96  static const int registrar;
97 
98  //! parameters expected from input file:
99  int max_nondecr_it_; //!< maximum number of iterations of linear solver with non-decreasing residual
100  int number_of_levels_; //!< number of levels in the multilevel method
101  bool use_adaptive_bddc_; //!< should adaptive BDDC be used?
102  int bddcml_verbosity_level_; //!< level of verbosity of BDDCML library
103  //!< ( 0 - only fatal errors reported,
104  //!< 1 - mild output,
105  //!< 2 - detailed output )//!< should adaptive BDDC be used?
106 
107  const bool swap_sign_; //!< swap sign of matrix and rhs entries, e.g. to make the matrix SPD
108 
109  std::vector<int> isngn_; //!< indices of subdomain nodes in global numbering
110  std::vector<double> locSolution_; //!< subdomain solution
111  Vec locSolVec_; //!< local solution PETSc vector - sequential
112  VecScatter VSpetscToSubScatter_; //!< scatter from solution_ to locSolVec_
113 
115  Bddcml_ * bddcml_; //!< BDDCML wrapper
116 };
117 
118 #endif /* LA_LINSYS_BDDC_HH_ */
int bddcml_verbosity_level_
Definition: linsys_BDDC.hh:102
VecScatter VSpetscToSubScatter_
scatter from solution_ to locSolVec_
Definition: linsys_BDDC.hh:112
std::vector< int > isngn_
indices of subdomain nodes in global numbering
Definition: linsys_BDDC.hh:109
Wrappers for linear systems based on MPIAIJ and MATIS format.
bool use_adaptive_bddc_
should adaptive BDDC be used?
Definition: linsys_BDDC.hh:101
static constexpr bool value
Definition: json.hpp:87
double compute_residual() override
Definition: linsys_BDDC.hh:81
LinSys FactoryBaseType
Definition: linsys_BDDC.hh:38
Vec locSolVec_
local solution PETSc vector - sequential
Definition: linsys_BDDC.hh:111
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
int max_nondecr_it_
parameters expected from input file:
Definition: linsys_BDDC.hh:99
static const int registrar
Registrar of class to factory.
Definition: linsys_BDDC.hh:96
const bool swap_sign_
swap sign of matrix and rhs entries, e.g. to make the matrix SPD
Definition: linsys_BDDC.hh:107
int number_of_levels_
number of levels in the multilevel method
Definition: linsys_BDDC.hh:100
la::BddcmlWrapper Bddcml_
Definition: linsys_BDDC.hh:114
Bddcml_ * bddcml_
BDDCML wrapper.
Definition: linsys_BDDC.hh:115
Abstract linear system class.
Record type proxy class.
Definition: type_record.hh:182
std::vector< double > locSolution_
subdomain solution
Definition: linsys_BDDC.hh:110
Multilevel BDDC based linear system solver.