schwz  Generated automatically from develop
schwarz_base.hpp (ca00a18)
1 
2 /*******************************<SCHWARZ LIB LICENSE>***********************
3 Copyright (c) 2019, the SCHWARZ LIB authors
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its
18 contributors may be used to endorse or promote products derived from
19 this software without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 ******************************<SCHWARZ LIB LICENSE>*************************/
33 
34 
35 #ifndef schwarz_base_hpp
36 #define schwarz_base_hpp
37 
38 #include <cmath>
39 #include <fstream>
40 #include <memory>
41 
42 #include <omp.h>
43 
44 #include <schwarz/config.hpp>
45 
46 #include <communicate.hpp>
47 #include <initialization.hpp>
48 #include <solve.hpp>
49 
50 
51 #if SCHW_HAVE_DEALII
52 #include <deal.II/lac/sparse_matrix.h>
53 #endif
54 
60 namespace schwz {
61 
73 template <typename ValueType = gko::default_precision,
74  typename IndexType = gko::int32,
75  typename MixedValueType = gko::default_precision>
76 class SchwarzBase : public Initialize<ValueType, IndexType>,
77  public Communicate<ValueType, IndexType, MixedValueType>,
78  public Solve<ValueType, IndexType, MixedValueType> {
79 public:
88 
89 #if SCHW_HAVE_DEALII
90 
96  void initialize(const dealii::SparseMatrix<ValueType> &matrix,
97  const dealii::Vector<ValueType> &system_rhs);
98 #endif
99 
103  void initialize();
104 
110  void run(std::shared_ptr<gko::matrix::Dense<ValueType>> &solution);
111 
119  void print_vector(
120  const std::shared_ptr<gko::matrix::Dense<ValueType>> &vector, int subd,
121  std::string name);
122 
130  void print_matrix(
131  const std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> &matrix,
132  int rank, std::string name);
133 
137  std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> local_matrix;
138 
142  std::shared_ptr<gko::matrix::Permutation<IndexType>> local_perm;
143 
147  std::shared_ptr<gko::matrix::Permutation<IndexType>> local_inv_perm;
148 
152  std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> triangular_factor_l;
153 
157  std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> triangular_factor_u;
158 
162  std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> interface_matrix;
163 
167  std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> global_matrix;
168 
172  std::shared_ptr<gko::matrix::Dense<ValueType>> local_rhs;
173 
177  std::shared_ptr<gko::matrix::Dense<ValueType>> global_rhs;
178 
182  std::shared_ptr<gko::matrix::Dense<ValueType>> local_solution;
183 
187  std::shared_ptr<gko::matrix::Dense<ValueType>> global_solution;
188 
192  std::vector<ValueType> local_residual_vector_out;
193 
197  std::vector<std::vector<ValueType>> global_residual_vector_out;
198 
199 protected:
204  Settings &settings;
205 
210 
215  struct Communicate<ValueType, IndexType, MixedValueType>::comm_struct
216  comm_struct;
217 };
218 
219 
220 } // namespace schwz
221 
222 
223 #endif // schwarz_base.hpp
void run(std::shared_ptr< gko::matrix::Dense< ValueType >> &solution)
The function that runs the actual solver and obtains the final solution.
Definition: schwarz_base.cpp:323
std::shared_ptr< gko::matrix::Csr< ValueType, IndexType > > interface_matrix
The local interface matrix.
Definition: schwarz_base.hpp:162
std::shared_ptr< gko::matrix::Permutation< IndexType > > local_perm
The local subdomain permutation matrix/array.
Definition: schwarz_base.hpp:142
The solver metadata struct.
Definition: settings.hpp:319
std::shared_ptr< gko::matrix::Dense< ValueType > > global_rhs
The global right hand side.
Definition: schwarz_base.hpp:177
The Solver class the provides the solver and the convergence checking methods.
Definition: solve.hpp:64
std::shared_ptr< gko::matrix::Dense< ValueType > > local_solution
The local solution vector.
Definition: schwarz_base.hpp:182
std::shared_ptr< gko::matrix::Csr< ValueType, IndexType > > local_matrix
The local subdomain matrix.
Definition: schwarz_base.hpp:137
std::shared_ptr< gko::matrix::Dense< ValueType > > global_solution
The global solution vector.
Definition: schwarz_base.hpp:187
std::shared_ptr< gko::matrix::Csr< ValueType, IndexType > > triangular_factor_u
The local upper triangular factor used for the triangular solves.
Definition: schwarz_base.hpp:157
SchwarzBase(Settings &settings, Metadata< ValueType, IndexType > &metadata)
The constructor that takes in the user settings and a metadata struct containing the solver metadata...
Definition: schwarz_base.cpp:74
void print_matrix(const std::shared_ptr< gko::matrix::Csr< ValueType, IndexType >> &matrix, int rank, std::string name)
The auxiliary function that prints a passed in CSR matrix.
The communication class that provides the methods for the communication between the subdomains...
Definition: communicate.hpp:60
std::shared_ptr< gko::matrix::Dense< ValueType > > local_rhs
The local right hand side.
Definition: schwarz_base.hpp:172
std::shared_ptr< gko::matrix::Permutation< IndexType > > local_inv_perm
The local subdomain inverse permutation matrix/array.
Definition: schwarz_base.hpp:147
The struct that contains the solver settings and the parameters to be set by the user.
Definition: settings.hpp:77
std::shared_ptr< gko::matrix::Csr< ValueType, IndexType > > global_matrix
The global matrix.
Definition: schwarz_base.hpp:167
void print_vector(const std::shared_ptr< gko::matrix::Dense< ValueType >> &vector, int subd, std::string name)
The auxiliary function that prints a passed in vector.
std::shared_ptr< gko::matrix::Csr< ValueType, IndexType > > triangular_factor_l
The local lower triangular factor used for the triangular solves.
Definition: schwarz_base.hpp:152
The Schwarz wrappers namespace.
Definition: comm_helpers.hpp:49
The initialization class that provides methods for initialization of the solver.
Definition: initialization.hpp:72
std::vector< std::vector< ValueType > > global_residual_vector_out
The local residual vector.
Definition: schwarz_base.hpp:197
The Base solver class is meant to be the class implementing the common implementations for all the sc...
Definition: schwarz_base.hpp:76
std::vector< ValueType > local_residual_vector_out
The global residual vector.
Definition: schwarz_base.hpp:192
void initialize()
Initialize the matrix and vectors.
Definition: schwarz_base.cpp:128