schwz  Generated automatically from develop
restricted_schwarz.hpp (cd61077)
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 restricted_schwarz_hpp
36 #define restricted_schwarz_hpp
37 
38 #include <cmath>
39 #include <fstream>
40 #include <memory>
41 
42 #include <schwarz/config.hpp>
43 
44 #include <schwarz_base.hpp>
45 
51 namespace schwz {
52 
61 template <typename ValueType = gko::default_precision,
62  typename IndexType = gko::int32,
63  typename MixedValueType = gko::default_precision>
64 class SolverRAS : public SchwarzBase<ValueType, IndexType, MixedValueType> {
65 public:
75 
77  Settings &settings, Metadata<ValueType, IndexType> &metadata,
78  std::vector<unsigned int> &partition_indices,
79  std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> &global_matrix,
80  std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> &local_matrix,
81  std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>>
82  &interface_matrix) override;
83 
84  void setup_comm_buffers() override;
85 
86  void setup_windows(
87  const Settings &settings,
88  const Metadata<ValueType, IndexType> &metadata,
89  std::shared_ptr<gko::matrix::Dense<ValueType>> &main_buffer) override;
90 
91  void exchange_boundary(const Settings &settings,
92  const Metadata<ValueType, IndexType> &metadata,
93  std::shared_ptr<gko::matrix::Dense<ValueType>>
94  &global_solution) override;
95 
96  void update_boundary(
97  const Settings &settings,
98  const Metadata<ValueType, IndexType> &metadata,
99  std::shared_ptr<gko::matrix::Dense<ValueType>> &local_solution,
100  const std::shared_ptr<gko::matrix::Dense<ValueType>> &local_rhs,
101  const std::shared_ptr<gko::matrix::Dense<ValueType>> &global_solution,
102  const std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>>
103  &interface_matrix) override;
104 };
105 
106 
107 } // namespace schwz
108 
109 
110 #endif // restricted_schwarz.hpp
void setup_windows(const Settings &settings, const Metadata< ValueType, IndexType > &metadata, std::shared_ptr< gko::matrix::Dense< ValueType >> &main_buffer) override
Sets up the windows needed for the asynchronous communication.
Definition: restricted_schwarz.cpp:608
std::shared_ptr< gko::matrix::Csr< ValueType, IndexType > > interface_matrix
The local interface matrix.
Definition: schwarz_base.hpp:162
The solver metadata struct.
Definition: settings.hpp:319
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
void setup_comm_buffers() override
Sets up the communication buffers needed for the boundary exchange.
Definition: restricted_schwarz.cpp:308
void exchange_boundary(const Settings &settings, const Metadata< ValueType, IndexType > &metadata, std::shared_ptr< gko::matrix::Dense< ValueType >> &global_solution) override
Exchanges the elements of the solution vector.
Definition: restricted_schwarz.cpp:977
std::shared_ptr< gko::matrix::Dense< ValueType > > local_rhs
The local right hand side.
Definition: schwarz_base.hpp:172
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 setup_local_matrices(Settings &settings, Metadata< ValueType, IndexType > &metadata, std::vector< unsigned int > &partition_indices, std::shared_ptr< gko::matrix::Csr< ValueType, IndexType >> &global_matrix, std::shared_ptr< gko::matrix::Csr< ValueType, IndexType >> &local_matrix, std::shared_ptr< gko::matrix::Csr< ValueType, IndexType >> &interface_matrix) override
Sets up the local and the interface matrices from the global matrix and the partition indices...
Definition: restricted_schwarz.cpp:56
The Schwarz wrappers namespace.
Definition: comm_helpers.hpp:49
An implementation of the solver interface using the RAS solver.
Definition: restricted_schwarz.hpp:64
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< unsigned int > partition_indices
The partition indices containing the subdomains to which each row(vertex) of the matrix(graph) belong...
Definition: initialization.hpp:80
SolverRAS(Settings &settings, Metadata< ValueType, IndexType > &metadata)
The constructor that takes in the user settings and a metadata struct containing the solver metadata...
Definition: restricted_schwarz.cpp:49
void update_boundary(const Settings &settings, const Metadata< ValueType, IndexType > &metadata, std::shared_ptr< gko::matrix::Dense< ValueType >> &local_solution, const std::shared_ptr< gko::matrix::Dense< ValueType >> &local_rhs, const std::shared_ptr< gko::matrix::Dense< ValueType >> &global_solution, const std::shared_ptr< gko::matrix::Csr< ValueType, IndexType >> &interface_matrix) override
Update the values into local vector from obtained from the neighboring sub-domains using the interfac...
Definition: restricted_schwarz.cpp:992