13 #include "sll_working_precision.h"
14 #include "sll_errors.h"
37 sll_int32,
dimension(:),
allocatable :: arr_n_rows
39 sll_int32,
dimension(:),
allocatable :: arr_n_cols
42 sll_real64,
dimension(:,:),
allocatable :: arr_coeffs
45 sll_int32 :: n_block_rows = 1
46 sll_int32 :: n_block_cols = 1
72 sll_int32 ,
intent(in) :: n_block_rows
73 sll_int32 ,
intent(in) :: n_block_cols
75 sll_int32 :: i_block_row
76 sll_int32 :: i_block_col
79 self % n_block_rows = n_block_rows
80 self % n_block_cols = n_block_cols
88 allocate(self % arr_n_rows(n_block_rows))
89 allocate(self % arr_n_cols(n_block_cols))
90 allocate(self % linear_solvers(n_block_rows, n_block_cols))
91 allocate(self % arr_coeffs(n_block_rows, n_block_cols))
97 self % arr_coeffs = 1.0_f64
101 do i_block_col = 1, n_block_cols
102 do i_block_row = 1, n_block_rows
103 self % linear_solvers(i_block_row, i_block_col) % ptr_linear_solver => null()
124 sll_int32 ,
intent(in) :: i_block_row
125 sll_int32 ,
intent(in) :: i_block_col
127 sll_real64,
optional,
intent(in) :: r_coeff
129 logical,
parameter :: verbose = .false.
133 if (
present(r_coeff))
then
134 self % arr_coeffs(i_block_row, i_block_col) = r_coeff
139 self % linear_solvers(i_block_row, i_block_col) % ptr_linear_solver => linop
143 self % arr_n_rows(i_block_row) = max(self % arr_n_rows(i_block_row), linop % n_global_rows)
144 self % arr_n_cols(i_block_col) = max(self % arr_n_cols(i_block_col), linop % n_global_cols)
148 self % n_rows = sum(self % arr_n_rows)
149 self % n_cols = sum(self % arr_n_cols)
150 self % n_global_rows = sum(self % arr_n_rows)
151 self % n_global_cols = sum(self % arr_n_cols)
159 character(len=*),
intent( in ) :: filename
165 logical,
intent( in ) :: verbose
167 self%verbose = verbose
180 sll_real64,
dimension(:),
intent(in ) :: rhs
181 sll_real64,
dimension(:),
intent( out) :: unknown
183 sll_int32 :: n_block_rows
184 sll_int32 :: n_block_cols
185 sll_int32 :: i_block_row
186 sll_int32 :: i_block_col
187 sll_int32 :: i_begin_row
188 sll_int32 :: i_begin_col
189 sll_int32 :: i_end_row
190 sll_int32 :: i_end_col
192 sll_real64,
dimension(:),
allocatable :: z
195 allocate(z(self % n_global_rows))
200 n_block_rows = self % n_block_rows
201 n_block_cols = self % n_block_cols
207 do i_block_row = 1, n_block_rows
208 i_end_row = i_begin_row - 1 + self % arr_n_rows(i_block_row)
212 do i_block_col = 1, n_block_cols
213 i_end_col = i_begin_col - 1 + self % arr_n_cols(i_block_col)
216 ptr_linop => self % linear_solvers(i_block_row, i_block_col) % ptr_linear_solver
218 if (
associated(ptr_linop))
then
219 call ptr_linop % solve(rhs(i_begin_col:i_end_col), z(i_begin_row:i_end_row))
220 unknown(i_begin_row:i_end_row) = unknown(i_begin_row:i_end_row) &
221 & + z(i_begin_row:i_end_row) * self % arr_coeffs(i_block_row, i_block_col)
224 i_begin_col = i_begin_col + self % arr_n_cols(i_block_col)
227 i_begin_row = i_begin_row + self % arr_n_rows(i_block_row)
256 deallocate(self % arr_n_rows)
257 deallocate(self % arr_n_cols)
258 deallocate(self % linear_solvers)
259 deallocate(self % arr_coeffs)
module for abstract linear solver
module for a block linear solver
subroutine create_linear_solver_block(self, n_block_rows, n_block_cols)
creates a linear solver_block you must sets the linop using set
subroutine solve_real_linear_solver_block(self, rhs, unknown)
apply the dot operation
subroutine set_linear_solver_block(self, i_block_row, i_block_col, linop, r_coeff)
sets a linear solver
subroutine free_linear_solver_block(self)
destroys the current object
subroutine set_verbose_linear_solver_block(self, verbose)
subroutine read_from_file_linear_solver_block(self, filename)
subroutine print_info_linear_solver_block(self)
prints the current object
class for abstract linear solver
class that contains a pointer to a linear solver
class for a linear solver_block