Flow123d  release_2.2.0-914-gf1a3a4f
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 <limits> // for numeric_limits
25 #include <vector> // for vector
26 #include "la/linsys.hh" // for LinSys
27 #include "petscsys.h" // for PetscErrorCode
28 #include "petscvec.h" // for Vec, VecScatter, _p_Vec, _p_VecScatter
29 
30 class Distribution;
31 namespace Input {
32  class Record;
33  namespace Type {
34  class Record;
35  }
36 }
37 namespace la {
38  class BddcmlWrapper;
39 };
40 
41 class LinSys_BDDC : public LinSys
42 {
43 
44 public:
46 
47  static const Input::Type::Record & get_input_type();
48 
49  LinSys_BDDC( const unsigned numDofsSub,
50  const Distribution * rows_ds,
51  const int matrixTypeInt = 0,
52  const int numSubLoc = 1,
53  const bool swap_sign = false );
54 
55  void set_tolerances(double r_tol, double a_tol, unsigned int max_it) override;
56 
57  void load_mesh( const int nDim, const int numNodes, const int numDofs,
58  const std::vector<int> & inet,
59  const std::vector<int> & nnet,
60  const std::vector<int> & nndf,
61  const std::vector<int> & isegn,
62  const std::vector<int> & isngn,
63  const std::vector<int> & isvgvn,
64  const std::vector<double> & xyz,
65  const std::vector<double> & element_permeability,
66  const int meshDim );
67 
68  void mat_set_values( int nrow, int *rows, int ncol, int *cols, double *vals ) override;
69 
70  void rhs_set_values( int nrow, int *rows, double *vals ) override;
71 
72  void diagonal_weights_set_value( int global_index, double value );
73 
74  PetscErrorCode mat_zero_entries() override;
75 
76  PetscErrorCode rhs_zero_entries() override;
77 
78  void finish_assembly( ) override;
79 
80  void apply_constrains( double scalar = 1. ) override;
81 
82  LinSys::SolveInfo solve() override;
83 
84  void set_from_input(const Input::Record in_rec) override;
85 
86  double get_solution_precision() override;
87 
88  double compute_residual() override
89  {
90  // until we have correct function for residual we
91  // return a practical infinity
92  return numeric_limits<double>::max();
93  }
94 
95  /** Prints matrix in coordinate format, can be load by matlab as a sparse matrix.
96  * Works only on 1 proc.
97  */
98  void print_matrix(std::ostream& out);
99 
100  ~LinSys_BDDC( );
101 
102 //private:
103 
104  //void gatherSolution_( );
105 
106 private:
107  /// Registrar of class to factory
108  static const int registrar;
109 
110  //! parameters expected from input file:
111  int max_nondecr_it_; //!< maximum number of iterations of linear solver with non-decreasing residual
112  int number_of_levels_; //!< number of levels in the multilevel method
113  bool use_adaptive_bddc_; //!< should adaptive BDDC be used?
114  int bddcml_verbosity_level_; //!< level of verbosity of BDDCML library
115  //!< ( 0 - only fatal errors reported,
116  //!< 1 - mild output,
117  //!< 2 - detailed output )//!< should adaptive BDDC be used?
118 
119  const bool swap_sign_; //!< swap sign of matrix and rhs entries, e.g. to make the matrix SPD
120 
121  std::vector<int> isngn_; //!< indices of subdomain nodes in global numbering
122  std::vector<double> locSolution_; //!< subdomain solution
123  Vec locSolVec_; //!< local solution PETSc vector - sequential
124  VecScatter VSpetscToSubScatter_; //!< scatter from solution_ to locSolVec_
125 
127  Bddcml_ * bddcml_; //!< BDDCML wrapper
128 };
129 
130 #endif /* LA_LINSYS_BDDC_HH_ */
int bddcml_verbosity_level_
Definition: linsys_BDDC.hh:114
VecScatter VSpetscToSubScatter_
scatter from solution_ to locSolVec_
Definition: linsys_BDDC.hh:124
std::vector< int > isngn_
indices of subdomain nodes in global numbering
Definition: linsys_BDDC.hh:121
Abstract linear system class.
Definition: equation.hh:37
Wrappers for linear systems based on MPIAIJ and MATIS format.
bool use_adaptive_bddc_
should adaptive BDDC be used?
Definition: linsys_BDDC.hh:113
static constexpr bool value
Definition: json.hpp:87
double compute_residual() override
Definition: linsys_BDDC.hh:88
LinSys FactoryBaseType
Definition: linsys_BDDC.hh:45
Vec locSolVec_
local solution PETSc vector - sequential
Definition: linsys_BDDC.hh:123
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:111
static const int registrar
Registrar of class to factory.
Definition: linsys_BDDC.hh:108
const bool swap_sign_
swap sign of matrix and rhs entries, e.g. to make the matrix SPD
Definition: linsys_BDDC.hh:119
int number_of_levels_
number of levels in the multilevel method
Definition: linsys_BDDC.hh:112
la::BddcmlWrapper Bddcml_
Definition: linsys_BDDC.hh:126
Bddcml_ * bddcml_
BDDCML wrapper.
Definition: linsys_BDDC.hh:127
Record type proxy class.
Definition: type_record.hh:182
std::vector< double > locSolution_
subdomain solution
Definition: linsys_BDDC.hh:122
Multilevel BDDC based linear system solver.