Flow123d  jenkins-Flow123d-windows32-release-multijob-28
linsys_BDDC.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2007 Technical University of Liberec. All rights reserved.
4  *
5  * Please make a following refer to Flow123d on your project site if you use the program for any purpose,
6  * especially for academic research:
7  * Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic
8  *
9  * This program is free software; you can redistribute it and/or modify it under the terms
10  * of the GNU General Public License version 3 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with this program; if not,
17  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
18  *
19  *
20  * $Id: la_linsys.hh 1299 2011-08-23 21:42:50Z jakub.sistek $
21  * $Revision: 1299 $
22  * $LastChangedBy: jakub.sistek $
23  * $LastChangedDate: 2011-08-23 23:42:50 +0200 (Tue, 23 Aug 2011) $
24  *
25  * @file
26  * @brief Solver based on Multilevel BDDC - using corresponding class of OpenFTL package
27  * @author Jakub Sistek
28  *
29  *
30  */
31 
32 #ifndef LA_LINSYS_BDDC_HH_
33 #define LA_LINSYS_BDDC_HH_
34 
35 // derived from base linsys
36 #include "mesh/mesh.h"
37 #include "la/linsys.hh"
38 #include "input/input_type.hh"
39 #include "input/accessors.hh"
40 
41 #include <vector>
42 
43 //#include <boost/numeric/ublas/matrix.hpp>
44 //#include <boost/numeric/ublas/vector.hpp>
45 
46 namespace la {
47  class BddcmlWrapper;
48 };
49 
50 class LinSys_BDDC : public LinSys
51 {
52 
53 public:
55 
56  LinSys_BDDC( const unsigned numDofsSub,
57  const Distribution * rows_ds,
58  const int matrixTypeInt = 0,
59  const int numSubLoc = 1,
60  const bool swap_sign = false );
61 
62  void load_mesh( const int nDim, const int numNodes, const int numDofs,
63  const std::vector<int> & inet,
64  const std::vector<int> & nnet,
65  const std::vector<int> & nndf,
66  const std::vector<int> & isegn,
67  const std::vector<int> & isngn,
68  const std::vector<int> & isvgvn,
69  const std::vector<double> & xyz,
70  const std::vector<double> & element_permeability,
71  const int meshDim );
72 
73  void mat_set_values( int nrow, int *rows, int ncol, int *cols, double *vals );
74 
75  void rhs_set_values( int nrow, int *rows, double *vals );
76 
77  void diagonal_weights_set_value( int global_index, double value );
78 
79  PetscErrorCode mat_zero_entries() override;
80 
81  PetscErrorCode rhs_zero_entries() override;
82 
83  void finish_assembly( );
84 
85  void apply_constrains( double scalar = 1. );
86 
87  int solve();
88 
89  void get_whole_solution( std::vector<double> & globalSolution );
90 
91  void set_whole_solution( std::vector<double> & globalSolution );
92 
93  void set_from_input(const Input::Record in_rec);
94 
95  double get_solution_precision();
96 
97  ~LinSys_BDDC( );
98 
99 private:
100 
101  void gatherSolution_( );
102 
103 private:
104 
105  //! parameters expected from input file:
106  int max_nondecr_it_; //!< maximum number of iterations of linear solver with non-decreasing residual
107  int number_of_levels_; //!< number of levels in the multilevel method
108  bool use_adaptive_bddc_; //!< should adaptive BDDC be used?
109  int bddcml_verbosity_level_; //!< level of verbosity of BDDCML library
110  //!< ( 0 - only fatal errors reported,
111  //!< 1 - mild output,
112  //!< 2 - detailed output )//!< should adaptive BDDC be used?
113 
114  const bool swap_sign_; //!< swap sign of matrix and rhs entries, e.g. to make the matrix SPD
115 
116  std::vector<int> isngn_; //!< indices of subdomain nodes in global numbering
117  std::vector<double> locSolution_; //!< subdomain solution
118  Vec locSolVec_; //!< local solution PETSc vector - sequential
119  VecScatter VSpetscToSubScatter_; //!< scatter from solution_ to locSolVec_
120 
122  Bddcml_ * bddcml_; //!< BDDCML wrapper
123 };
124 
125 #endif /* LA_LINSYS_BDDC_HH_ */
int bddcml_verbosity_level_
Definition: linsys_BDDC.hh:109
void gatherSolution_()
Definition: linsys_BDDC.cc:337
void mat_set_values(int nrow, int *rows, int ncol, int *cols, double *vals)
Definition: linsys_BDDC.cc:173
VecScatter VSpetscToSubScatter_
scatter from solution_ to locSolVec_
Definition: linsys_BDDC.hh:119
std::vector< int > isngn_
indices of subdomain nodes in global numbering
Definition: linsys_BDDC.hh:116
PetscErrorCode rhs_zero_entries() override
Definition: linsys_BDDC.cc:234
void get_whole_solution(std::vector< double > &globalSolution)
Definition: linsys_BDDC.cc:291
Wrappers for linear systems based on MPIAIJ and MATIS format.
???
void load_mesh(const int nDim, const int numNodes, const int numDofs, const std::vector< int > &inet, const std::vector< int > &nnet, const std::vector< int > &nndf, const std::vector< int > &isegn, const std::vector< int > &isngn, const std::vector< int > &isvgvn, const std::vector< double > &xyz, const std::vector< double > &element_permeability, const int meshDim)
Definition: linsys_BDDC.cc:114
void rhs_set_values(int nrow, int *rows, double *vals)
Definition: linsys_BDDC.cc:198
bool use_adaptive_bddc_
should adaptive BDDC be used?
Definition: linsys_BDDC.hh:108
Vec locSolVec_
local solution PETSc vector - sequential
Definition: linsys_BDDC.hh:118
Accessor to the data with type Type::Record.
Definition: accessors.hh:308
int max_nondecr_it_
parameters expected from input file:
Definition: linsys_BDDC.hh:106
void diagonal_weights_set_value(int global_index, double value)
Definition: linsys_BDDC.cc:219
const bool swap_sign_
swap sign of matrix and rhs entries, e.g. to make the matrix SPD
Definition: linsys_BDDC.hh:114
double get_solution_precision()
Definition: linsys_BDDC.cc:389
int number_of_levels_
number of levels in the multilevel method
Definition: linsys_BDDC.hh:107
la::BddcmlWrapper Bddcml_
Definition: linsys_BDDC.hh:121
static Input::Type::Record input_type
Definition: linsys_BDDC.hh:54
Bddcml_ * bddcml_
BDDCML wrapper.
Definition: linsys_BDDC.hh:122
PetscErrorCode mat_zero_entries() override
Definition: linsys_BDDC.cc:226
Abstract linear system class.
void apply_constrains(double scalar=1.)
Definition: linsys_BDDC.cc:249
Record type proxy class.
Definition: type_record.hh:161
void finish_assembly()
Definition: linsys_BDDC.cc:242
std::vector< double > locSolution_
subdomain solution
Definition: linsys_BDDC.hh:117
LinSys_BDDC(const unsigned numDofsSub, const Distribution *rows_ds, const int matrixTypeInt=0, const int numSubLoc=1, const bool swap_sign=false)
Definition: linsys_BDDC.cc:61
void set_whole_solution(std::vector< double > &globalSolution)
Definition: linsys_BDDC.cc:300
Multilevel BDDC based linear system solver.
void set_from_input(const Input::Record in_rec)
Definition: linsys_BDDC.cc:308