FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
hecmw_matrix_misc.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
2 ! Copyright (c) 2019 FrontISTR Commons
3 ! This software is released under the MIT License, see LICENSE.txt
4 !-------------------------------------------------------------------------------
5 
7  use hecmw_util
9  implicit none
10 
11  private
12  public :: hecmw_mat_clear
13  public :: hecmw_mat_clear_b
14  public :: hecmw_mat_init
15  public :: hecmw_mat_finalize
16  public :: hecmw_mat_copy_profile
17  public :: hecmw_mat_copy_val
18 
19  public :: hecmw_mat_set_iter
20  public :: hecmw_mat_get_iter
21  public :: hecmw_mat_set_method
22  public :: hecmw_mat_get_method
23  public :: hecmw_mat_set_precond
24  public :: hecmw_mat_get_precond
25  public :: hecmw_mat_set_nset
26  public :: hecmw_mat_get_nset
27  public :: hecmw_mat_set_iterpremax
28  public :: hecmw_mat_get_iterpremax
29  public :: hecmw_mat_set_nrest
30  public :: hecmw_mat_get_nrest
31  public :: hecmw_mat_set_nbfgs
32  public :: hecmw_mat_get_nbfgs
33  public :: hecmw_mat_set_scaling
34  public :: hecmw_mat_get_scaling
35  public :: hecmw_mat_set_penalized
36  public :: hecmw_mat_get_penalized
39  public :: hecmw_mat_set_mpc_method
40  public :: hecmw_mat_get_mpc_method
41  public :: hecmw_mat_set_estcond
42  public :: hecmw_mat_get_estcond
45  public :: hecmw_mat_set_iterlog
46  public :: hecmw_mat_get_iterlog
47  public :: hecmw_mat_set_timelog
48  public :: hecmw_mat_get_timelog
49  public :: hecmw_mat_set_dump
50  public :: hecmw_mat_get_dump
51  public :: hecmw_mat_set_dump_exit
52  public :: hecmw_mat_get_dump_exit
53  public :: hecmw_mat_set_usejad
54  public :: hecmw_mat_get_usejad
55  public :: hecmw_mat_set_ncolor_in
56  public :: hecmw_mat_get_ncolor_in
69 
70  public :: hecmw_mat_set_method2
71  public :: hecmw_mat_get_method2
78 
79  public :: hecmw_mat_set_solver_opt
80  public :: hecmw_mat_get_solver_opt
81 
82  public :: hecmw_mat_set_resid
83  public :: hecmw_mat_get_resid
84  public :: hecmw_mat_set_sigma_diag
85  public :: hecmw_mat_get_sigma_diag
86  public :: hecmw_mat_set_sigma
87  public :: hecmw_mat_get_sigma
88  public :: hecmw_mat_set_thresh
89  public :: hecmw_mat_get_thresh
90  public :: hecmw_mat_set_filter
91  public :: hecmw_mat_get_filter
92  public :: hecmw_mat_set_penalty
93  public :: hecmw_mat_get_penalty
96 
97  public :: hecmw_mat_diag_max
98  public :: hecmw_mat_diag
100  public :: hecmw_mat_substitute
101  public :: hecmw_mat_integrate
102 
103  integer, parameter :: IDX_I_ITER = 1
104  integer, parameter :: IDX_I_METHOD = 2
105  integer, parameter :: IDX_I_PRECOND = 3
106  integer, parameter :: IDX_I_NSET = 4
107  integer, parameter :: IDX_I_ITERPREMAX = 5
108  integer, parameter :: IDX_I_NREST = 6
109  integer, parameter :: IDX_I_NBFGS = 60
110  integer, parameter :: IDX_I_SCALING = 7
111  integer, parameter :: IDX_I_PENALIZED = 11
112  integer, parameter :: IDX_I_PENALIZED_B = 12
113  integer, parameter :: IDX_I_MPC_METHOD = 13
114  integer, parameter :: IDX_I_ESTCOND = 14
115  integer, parameter :: IDX_I_CONTACT_ELIM = 15
116  integer, parameter :: IDX_I_ITERLOG = 21
117  integer, parameter :: IDX_I_TIMELOG = 22
118  integer, parameter :: IDX_I_DUMP = 31
119  integer, parameter :: IDX_I_DUMP_EXIT = 32
120  integer, parameter :: IDX_I_USEJAD = 33
121  integer, parameter :: IDX_I_NCOLOR_IN = 34
122  integer, parameter :: IDX_I_MAXRECYCLE_PRECOND = 35
123  integer, parameter :: IDX_I_NRECYCLE_PRECOND = 96
124  integer, parameter :: IDX_I_FLAG_NUMFACT = 97
125  integer, parameter :: IDX_I_FLAG_SYMBFACT = 98
126  integer, parameter :: IDX_I_SOLVER_TYPE = 99
127 
128  integer, parameter :: IDX_I_METHOD2 = 8
129  integer, parameter :: IDX_I_FLAG_CONVERGED = 81
130  integer, parameter :: IDX_I_FLAG_DIVERGED = 82
131  integer, parameter :: IDX_I_FLAG_MPCMATVEC = 83
132 
133  integer, parameter :: IDX_I_SOLVER_OPT_S = 41
134  integer, parameter :: IDX_I_SOLVER_OPT_E = 50
135 
136  integer, parameter :: IDX_R_RESID = 1
137  integer, parameter :: IDX_R_SIGMA_DIAG = 2
138  integer, parameter :: IDX_R_SIGMA = 3
139  integer, parameter :: IDX_R_THRESH = 4
140  integer, parameter :: IDX_R_FILTER = 5
141  integer, parameter :: IDX_R_PENALTY = 11
142  integer, parameter :: IDX_R_PENALTY_ALPHA = 12
143 
144 contains
145 
146  subroutine hecmw_mat_clear( hecMAT )
147  type(hecmwst_matrix) :: hecmat
148 
149  hecmat%D = 0.0d0
150  hecmat%AL = 0.0d0
151  hecmat%AU = 0.0d0
152  call hecmw_mat_set_penalized( hecmat, 0 )
153  call hecmw_mat_set_penalty_alpha( hecmat, 0.d0 )
154  end subroutine hecmw_mat_clear
155 
156  subroutine hecmw_mat_clear_b( hecMAT )
157  type(hecmwst_matrix) :: hecmat
158 
159  hecmat%B = 0.0d0
160  call hecmw_mat_set_penalized_b( hecmat, 0 )
161  end subroutine hecmw_mat_clear_b
162 
163  subroutine hecmw_mat_init( hecMAT )
164  type(hecmwst_matrix) :: hecmat
165 
166  call hecmw_nullify_matrix( hecmat )
167 
168  hecmat%Iarray = 0
169  hecmat%Rarray = 0.d0
170 
171  call hecmw_mat_set_iter( hecmat, 100 )
172  call hecmw_mat_set_method( hecmat, 1 )
173  call hecmw_mat_set_precond( hecmat, 1 )
174  call hecmw_mat_set_nset( hecmat, 0 )
175  call hecmw_mat_set_iterpremax( hecmat, 1 )
176  call hecmw_mat_set_nrest( hecmat, 10 )
177  call hecmw_mat_set_nbfgs( hecmat, 0 )
178  call hecmw_mat_set_scaling( hecmat, 0 )
179  call hecmw_mat_set_iterlog( hecmat, 0 )
180  call hecmw_mat_set_timelog( hecmat, 0 )
181  call hecmw_mat_set_dump( hecmat, 0 )
182  call hecmw_mat_set_dump_exit( hecmat, 0 )
183  call hecmw_mat_set_usejad( hecmat, 0 )
184  call hecmw_mat_set_ncolor_in( hecmat, 10 )
185  call hecmw_mat_set_estcond( hecmat, 0 )
186  call hecmw_mat_set_maxrecycle_precond( hecmat, 3 )
187 
188  call hecmw_mat_set_resid( hecmat, 1.d-8 )
189  call hecmw_mat_set_sigma_diag( hecmat, 1.d0 )
190  call hecmw_mat_set_sigma( hecmat, 0.d0 )
191  call hecmw_mat_set_thresh( hecmat, 0.10d0 )
192  call hecmw_mat_set_filter( hecmat, 0.10d0 )
193 
194  call hecmw_mat_set_penalized( hecmat, 0 )
195  call hecmw_mat_set_penalty( hecmat, 1.d+4 )
196  call hecmw_mat_set_penalty_alpha( hecmat, 0.d0 )
197  call hecmw_mat_set_mpc_method( hecmat, 0 )
198 
199  call hecmw_mat_reset_nrecycle_precond( hecmat )
200  call hecmw_mat_set_flag_numfact( hecmat, 1 )
201  call hecmw_mat_set_flag_symbfact( hecmat, 1 )
202  call hecmw_mat_set_solver_type( hecmat, 1 )
203  end subroutine hecmw_mat_init
204 
205  subroutine hecmw_mat_finalize( hecMAT )
206  type(hecmwst_matrix) :: hecmat
207  if (associated(hecmat%D)) deallocate(hecmat%D)
208  if (associated(hecmat%B)) deallocate(hecmat%B)
209  if (associated(hecmat%X)) deallocate(hecmat%X)
210  if (associated(hecmat%AL)) deallocate(hecmat%AL)
211  if (associated(hecmat%AU)) deallocate(hecmat%AU)
212  if (associated(hecmat%indexL)) deallocate(hecmat%indexL)
213  if (associated(hecmat%indexU)) deallocate(hecmat%indexU)
214  if (associated(hecmat%itemL)) deallocate(hecmat%itemL)
215  if (associated(hecmat%itemU)) deallocate(hecmat%itemU)
216  end subroutine hecmw_mat_finalize
217 
218  subroutine hecmw_mat_copy_profile( hecMATorg, hecMAT )
219  type(hecmwst_matrix), intent(in) :: hecmatorg
220  type(hecmwst_matrix), intent(inout) :: hecmat
221  hecmat%N = hecmatorg%N
222  hecmat%NP = hecmatorg%NP
223  hecmat%NDOF = hecmatorg%NDOF
224  hecmat%NPL = hecmatorg%NPL
225  hecmat%NPU = hecmatorg%NPU
226  allocate(hecmat%indexL(0:size(hecmatorg%indexL)-1))
227  allocate(hecmat%indexU(0:size(hecmatorg%indexU)-1))
228  allocate(hecmat%itemL (size(hecmatorg%itemL )))
229  allocate(hecmat%itemU (size(hecmatorg%itemU )))
230  allocate(hecmat%D (size(hecmatorg%D )))
231  allocate(hecmat%AL(size(hecmatorg%AL)))
232  allocate(hecmat%AU(size(hecmatorg%AU)))
233  allocate(hecmat%B (size(hecmatorg%B )))
234  allocate(hecmat%X (size(hecmatorg%X )))
235  hecmat%indexL = hecmatorg%indexL
236  hecmat%indexU = hecmatorg%indexU
237  hecmat%itemL = hecmatorg%itemL
238  hecmat%itemU = hecmatorg%itemU
239  hecmat%D = 0.d0
240  hecmat%AL = 0.d0
241  hecmat%AU = 0.d0
242  hecmat%B = 0.d0
243  hecmat%X = 0.d0
244  end subroutine hecmw_mat_copy_profile
245 
246  subroutine hecmw_mat_copy_val( hecMATorg, hecMAT )
247  type(hecmwst_matrix), intent(in) :: hecmatorg
248  type(hecmwst_matrix), intent(inout) :: hecmat
249  integer(kind=kint) :: ierr
250  integer(kind=kint) :: i
251  ierr = 0
252  if (hecmat%N /= hecmatorg%N) ierr = 1
253  if (hecmat%NP /= hecmatorg%NP) ierr = 1
254  if (hecmat%NDOF /= hecmatorg%NDOF) ierr = 1
255  if (hecmat%NPL /= hecmatorg%NPL) ierr = 1
256  if (hecmat%NPU /= hecmatorg%NPU) ierr = 1
257  if (ierr /= 0) then
258  write(0,*) 'ERROR: hecmw_mat_copy_val: different profile'
259  stop
260  endif
261  do i = 1, size(hecmat%D)
262  hecmat%D(i) = hecmatorg%D(i)
263  enddo
264  do i = 1, size(hecmat%AL)
265  hecmat%AL(i) = hecmatorg%AL(i)
266  enddo
267  do i = 1, size(hecmat%AU)
268  hecmat%AU(i) = hecmatorg%AU(i)
269  enddo
270  end subroutine hecmw_mat_copy_val
271 
272  subroutine hecmw_mat_set_iter( hecMAT, iter )
273  type(hecmwst_matrix) :: hecmat
274  integer(kind=kint) :: iter
275 
276  hecmat%Iarray(idx_i_iter) = iter
277  end subroutine hecmw_mat_set_iter
278 
279  function hecmw_mat_get_iter( hecMAT )
280  integer(kind=kint) :: hecmw_mat_get_iter
281  type(hecmwst_matrix) :: hecmat
282 
283  hecmw_mat_get_iter = hecmat%Iarray(idx_i_iter)
284  end function hecmw_mat_get_iter
285 
286  subroutine hecmw_mat_set_method( hecMAT, method )
287  type(hecmwst_matrix) :: hecmat
288  integer(kind=kint) :: method
289 
290  hecmat%Iarray(idx_i_method) = method
291  end subroutine hecmw_mat_set_method
292 
293  function hecmw_mat_get_method( hecMAT )
294  integer(kind=kint) :: hecmw_mat_get_method
295  type(hecmwst_matrix) :: hecmat
296 
297  hecmw_mat_get_method = hecmat%Iarray(idx_i_method)
298  end function hecmw_mat_get_method
299 
300  subroutine hecmw_mat_set_method2( hecMAT, method2 )
301  type(hecmwst_matrix) :: hecmat
302  integer(kind=kint) :: method2
303 
304  hecmat%Iarray(idx_i_method2) = method2
305  end subroutine hecmw_mat_set_method2
306 
307  function hecmw_mat_get_method2( hecMAT )
308  integer(kind=kint) :: hecmw_mat_get_method2
309  type(hecmwst_matrix) :: hecmat
310 
311  hecmw_mat_get_method2 = hecmat%Iarray(idx_i_method2)
312  end function hecmw_mat_get_method2
313 
314  subroutine hecmw_mat_set_precond( hecMAT, precond )
315  type(hecmwst_matrix) :: hecmat
316  integer(kind=kint) :: precond
317 
318  hecmat%Iarray(idx_i_precond) = precond
319  end subroutine hecmw_mat_set_precond
320 
321  function hecmw_mat_get_precond( hecMAT )
322  integer(kind=kint) :: hecmw_mat_get_precond
323  type(hecmwst_matrix) :: hecmat
324 
325  hecmw_mat_get_precond = hecmat%Iarray(idx_i_precond)
326  end function hecmw_mat_get_precond
327 
328  subroutine hecmw_mat_set_nset( hecMAT, nset )
329  type(hecmwst_matrix) :: hecmat
330  integer(kind=kint) :: nset
331 
332  hecmat%Iarray(idx_i_nset) = nset
333  end subroutine hecmw_mat_set_nset
334 
335  function hecmw_mat_get_nset( hecMAT )
336  integer(kind=kint) :: hecmw_mat_get_nset
337  type(hecmwst_matrix) :: hecmat
338 
339  hecmw_mat_get_nset = hecmat%Iarray(idx_i_nset)
340  end function hecmw_mat_get_nset
341 
342  subroutine hecmw_mat_set_iterpremax( hecMAT, iterpremax )
343  type(hecmwst_matrix) :: hecmat
344  integer(kind=kint) :: iterpremax
345 
346  if (iterpremax.lt.0) iterpremax= 0
347  if (iterpremax.gt.4) iterpremax= 4
348 
349  hecmat%Iarray(idx_i_iterpremax) = iterpremax
350  end subroutine hecmw_mat_set_iterpremax
351 
352  function hecmw_mat_get_iterpremax( hecMAT )
353  integer(kind=kint) :: hecmw_mat_get_iterpremax
354  type(hecmwst_matrix) :: hecmat
355 
356  hecmw_mat_get_iterpremax = hecmat%Iarray(idx_i_iterpremax)
357  end function hecmw_mat_get_iterpremax
358 
359  subroutine hecmw_mat_set_nrest( hecMAT, nrest )
360  type(hecmwst_matrix) :: hecmat
361  integer(kind=kint) :: nrest
362 
363  hecmat%Iarray(idx_i_nrest) = nrest
364  end subroutine hecmw_mat_set_nrest
365 
366  function hecmw_mat_get_nrest( hecMAT )
367  integer(kind=kint) :: hecmw_mat_get_nrest
368  type(hecmwst_matrix) :: hecmat
369 
370  hecmw_mat_get_nrest = hecmat%Iarray(idx_i_nrest)
371  end function hecmw_mat_get_nrest
372 
373  subroutine hecmw_mat_set_nbfgs( hecMAT, nbfgs )
374  type(hecmwst_matrix) :: hecmat
375  integer(kind=kint) :: nbfgs
376 
377  hecmat%Iarray(idx_i_nbfgs) = nbfgs
378  end subroutine hecmw_mat_set_nbfgs
379 
380  function hecmw_mat_get_nbfgs( hecMAT )
381  integer(kind=kint) :: hecmw_mat_get_nbfgs
382  type(hecmwst_matrix) :: hecmat
383 
384  hecmw_mat_get_nbfgs = hecmat%Iarray(idx_i_nbfgs)
385  end function hecmw_mat_get_nbfgs
386 
387  subroutine hecmw_mat_set_scaling( hecMAT, scaling )
388  type(hecmwst_matrix) :: hecmat
389  integer(kind=kint) :: scaling
390 
391  hecmat%Iarray(idx_i_scaling) = scaling
392  end subroutine hecmw_mat_set_scaling
393 
394  function hecmw_mat_get_scaling( hecMAT )
395  integer(kind=kint) :: hecmw_mat_get_scaling
396  type(hecmwst_matrix) :: hecmat
397 
398  hecmw_mat_get_scaling = hecmat%Iarray(idx_i_scaling)
399  end function hecmw_mat_get_scaling
400 
401  subroutine hecmw_mat_set_penalized( hecMAT, penalized )
402  type(hecmwst_matrix) :: hecmat
403  integer(kind=kint) :: penalized
404 
405  hecmat%Iarray(idx_i_penalized) = penalized
406  end subroutine hecmw_mat_set_penalized
407 
408  function hecmw_mat_get_penalized( hecMAT )
409  integer(kind=kint) :: hecmw_mat_get_penalized
410  type(hecmwst_matrix) :: hecmat
411 
412  hecmw_mat_get_penalized = hecmat%Iarray(idx_i_penalized)
413  end function hecmw_mat_get_penalized
414 
415  subroutine hecmw_mat_set_penalized_b( hecMAT, penalized_b )
416  type(hecmwst_matrix) :: hecmat
417  integer(kind=kint) :: penalized_b
418 
419  hecmat%Iarray(idx_i_penalized_b) = penalized_b
420  end subroutine hecmw_mat_set_penalized_b
421 
422  function hecmw_mat_get_penalized_b( hecMAT )
423  integer(kind=kint) :: hecmw_mat_get_penalized_b
424  type(hecmwst_matrix) :: hecmat
425 
426  hecmw_mat_get_penalized_b = hecmat%Iarray(idx_i_penalized_b)
427  end function hecmw_mat_get_penalized_b
428 
429  subroutine hecmw_mat_set_mpc_method( hecMAT, mpc_method )
430  type(hecmwst_matrix) :: hecmat
431  integer(kind=kint) :: mpc_method
432 
433  hecmat%Iarray(idx_i_mpc_method) = mpc_method
434  end subroutine hecmw_mat_set_mpc_method
435 
436  function hecmw_mat_get_mpc_method( hecMAT )
437  integer(kind=kint) :: hecmw_mat_get_mpc_method
438  type(hecmwst_matrix) :: hecmat
439 
440  hecmw_mat_get_mpc_method = hecmat%Iarray(idx_i_mpc_method)
441  end function hecmw_mat_get_mpc_method
442 
443  function hecmw_mat_get_estcond( hecMAT )
444  integer(kind=kint) :: hecmw_mat_get_estcond
445  type(hecmwst_matrix) :: hecmat
446  hecmw_mat_get_estcond = hecmat%Iarray(idx_i_estcond)
447  end function hecmw_mat_get_estcond
448 
449  subroutine hecmw_mat_set_estcond( hecMAT, estcond )
450  type(hecmwst_matrix) :: hecmat
451  integer(kind=kint) :: estcond
452  hecmat%Iarray(idx_i_estcond) = estcond
453  end subroutine hecmw_mat_set_estcond
454 
455  function hecmw_mat_get_contact_elim( hecMAT )
456  integer(kind=kint) :: hecmw_mat_get_contact_elim
457  type(hecmwst_matrix) :: hecmat
458  hecmw_mat_get_contact_elim = hecmat%Iarray(idx_i_contact_elim)
459  end function hecmw_mat_get_contact_elim
460 
461  subroutine hecmw_mat_set_contact_elim( hecMAT, contact_elim )
462  type(hecmwst_matrix) :: hecmat
463  integer(kind=kint) :: contact_elim
464  hecmat%Iarray(idx_i_contact_elim) = contact_elim
465  end subroutine hecmw_mat_set_contact_elim
466 
467  subroutine hecmw_mat_set_iterlog( hecMAT, iterlog )
468  type(hecmwst_matrix) :: hecmat
469  integer(kind=kint) :: iterlog
470 
471  hecmat%Iarray(idx_i_iterlog) = iterlog
472  end subroutine hecmw_mat_set_iterlog
473 
474  function hecmw_mat_get_iterlog( hecMAT )
475  integer(kind=kint) :: hecmw_mat_get_iterlog
476  type(hecmwst_matrix) :: hecmat
477 
478  hecmw_mat_get_iterlog = hecmat%Iarray(idx_i_iterlog)
479  end function hecmw_mat_get_iterlog
480 
481  subroutine hecmw_mat_set_timelog( hecMAT, timelog )
482  type(hecmwst_matrix) :: hecmat
483  integer(kind=kint) :: timelog
484 
485  hecmat%Iarray(idx_i_timelog) = timelog
486  end subroutine hecmw_mat_set_timelog
487 
488  function hecmw_mat_get_timelog( hecMAT )
489  integer(kind=kint) :: hecmw_mat_get_timelog
490  type(hecmwst_matrix) :: hecmat
491 
492  hecmw_mat_get_timelog = hecmat%Iarray(idx_i_timelog)
493  end function hecmw_mat_get_timelog
494 
495  function hecmw_mat_get_dump( hecMAT )
496  integer(kind=kint) :: hecmw_mat_get_dump
497  type(hecmwst_matrix) :: hecmat
498  hecmw_mat_get_dump = hecmat%Iarray(idx_i_dump)
499  end function hecmw_mat_get_dump
500 
501  subroutine hecmw_mat_set_dump( hecMAT, dump_type )
502  type(hecmwst_matrix) :: hecmat
503  integer(kind=kint) :: dump_type
504  hecmat%Iarray(idx_i_dump) = dump_type
505  end subroutine hecmw_mat_set_dump
506 
507  function hecmw_mat_get_dump_exit( hecMAT )
508  integer(kind=kint) :: hecmw_mat_get_dump_exit
509  type(hecmwst_matrix) :: hecmat
510  hecmw_mat_get_dump_exit = hecmat%Iarray(idx_i_dump_exit)
511  end function hecmw_mat_get_dump_exit
512 
513  subroutine hecmw_mat_set_dump_exit( hecMAT, dump_exit )
514  type(hecmwst_matrix) :: hecmat
515  integer(kind=kint) :: dump_exit
516  hecmat%Iarray(idx_i_dump_exit) = dump_exit
517  end subroutine hecmw_mat_set_dump_exit
518 
519  function hecmw_mat_get_usejad( hecMAT )
520  integer(kind=kint) :: hecmw_mat_get_usejad
521  type(hecmwst_matrix) :: hecmat
522  hecmw_mat_get_usejad = hecmat%Iarray(idx_i_usejad)
523  end function hecmw_mat_get_usejad
524 
525  subroutine hecmw_mat_set_usejad( hecMAT, usejad )
526  type(hecmwst_matrix) :: hecmat
527  integer(kind=kint) :: usejad
528  hecmat%Iarray(idx_i_usejad) = usejad
529  end subroutine hecmw_mat_set_usejad
530 
531  function hecmw_mat_get_ncolor_in( hecMAT )
532  integer(kind=kint) :: hecmw_mat_get_ncolor_in
533  type(hecmwst_matrix) :: hecmat
534  hecmw_mat_get_ncolor_in = hecmat%Iarray(idx_i_ncolor_in)
535  end function hecmw_mat_get_ncolor_in
536 
537  subroutine hecmw_mat_set_ncolor_in( hecMAT, ncolor_in )
538  type(hecmwst_matrix) :: hecmat
539  integer(kind=kint) :: ncolor_in
540  hecmat%Iarray(idx_i_ncolor_in) = ncolor_in
541  end subroutine hecmw_mat_set_ncolor_in
542 
544  integer(kind=kint) :: hecmw_mat_get_maxrecycle_precond
545  type(hecmwst_matrix) :: hecmat
546  hecmw_mat_get_maxrecycle_precond = hecmat%Iarray(idx_i_maxrecycle_precond)
548 
549  subroutine hecmw_mat_set_maxrecycle_precond( hecMAT, maxrecycle_precond )
550  type(hecmwst_matrix) :: hecmat
551  integer(kind=kint) :: maxrecycle_precond
552  if (maxrecycle_precond > 100) maxrecycle_precond = 100
553  hecmat%Iarray(idx_i_maxrecycle_precond) = maxrecycle_precond
554  end subroutine hecmw_mat_set_maxrecycle_precond
555 
557  integer(kind=kint) :: hecmw_mat_get_nrecycle_precond
558  type(hecmwst_matrix) :: hecmat
559  hecmw_mat_get_nrecycle_precond = hecmat%Iarray(idx_i_nrecycle_precond)
560  end function hecmw_mat_get_nrecycle_precond
561 
562  subroutine hecmw_mat_reset_nrecycle_precond( hecMAT )
563  type(hecmwst_matrix) :: hecmat
564  hecmat%Iarray(idx_i_nrecycle_precond) = 0
565  end subroutine hecmw_mat_reset_nrecycle_precond
566 
567  subroutine hecmw_mat_incr_nrecycle_precond( hecMAT )
568  type(hecmwst_matrix) :: hecmat
569  hecmat%Iarray(idx_i_nrecycle_precond) = hecmat%Iarray(idx_i_nrecycle_precond) + 1
570  end subroutine hecmw_mat_incr_nrecycle_precond
571 
572  function hecmw_mat_get_flag_numfact( hecMAT )
573  integer(kind=kint) :: hecmw_mat_get_flag_numfact
574  type(hecmwst_matrix) :: hecmat
575  hecmw_mat_get_flag_numfact = hecmat%Iarray(idx_i_flag_numfact)
576  end function hecmw_mat_get_flag_numfact
577 
578  subroutine hecmw_mat_set_flag_numfact( hecMAT, flag_numfact )
579  type(hecmwst_matrix) :: hecmat
580  integer(kind=kint) :: flag_numfact
581  hecmat%Iarray(idx_i_flag_numfact) = flag_numfact
582  end subroutine hecmw_mat_set_flag_numfact
583 
584  function hecmw_mat_get_flag_symbfact( hecMAT )
585  integer(kind=kint) :: hecmw_mat_get_flag_symbfact
586  type(hecmwst_matrix) :: hecmat
587  hecmw_mat_get_flag_symbfact = hecmat%Iarray(idx_i_flag_symbfact)
588  end function hecmw_mat_get_flag_symbfact
589 
590  subroutine hecmw_mat_set_flag_symbfact( hecMAT, flag_symbfact )
591  type(hecmwst_matrix) :: hecmat
592  integer(kind=kint) :: flag_symbfact
593  hecmat%Iarray(idx_i_flag_symbfact) = flag_symbfact
594  end subroutine hecmw_mat_set_flag_symbfact
595 
596  subroutine hecmw_mat_clear_flag_symbfact( hecMAT )
597  type(hecmwst_matrix) :: hecmat
598  hecmat%Iarray(idx_i_flag_symbfact) = 0
599  end subroutine hecmw_mat_clear_flag_symbfact
600 
601  function hecmw_mat_get_solver_type( hecMAT )
602  integer(kind=kint) :: hecmw_mat_get_solver_type
603  type(hecmwst_matrix) :: hecmat
604  hecmw_mat_get_solver_type = hecmat%Iarray(idx_i_solver_type)
605  end function hecmw_mat_get_solver_type
606 
607  subroutine hecmw_mat_set_solver_type( hecMAT, solver_type )
608  type(hecmwst_matrix) :: hecmat
609  integer(kind=kint) :: solver_type
610  hecmat%Iarray(idx_i_solver_type) = solver_type
611  end subroutine hecmw_mat_set_solver_type
612 
613  subroutine hecmw_mat_set_flag_converged( hecMAT, flag_converged )
614  type(hecmwst_matrix) :: hecmat
615  integer(kind=kint) :: flag_converged
616  hecmat%Iarray(idx_i_flag_converged) = flag_converged
617  end subroutine hecmw_mat_set_flag_converged
618 
619  function hecmw_mat_get_flag_converged( hecMAT )
620  integer(kind=kint) :: hecmw_mat_get_flag_converged
621  type(hecmwst_matrix) :: hecmat
622  hecmw_mat_get_flag_converged = hecmat%Iarray(idx_i_flag_converged)
623  end function hecmw_mat_get_flag_converged
624 
625  subroutine hecmw_mat_set_flag_diverged( hecMAT, flag_diverged )
626  type(hecmwst_matrix) :: hecmat
627  integer(kind=kint) :: flag_diverged
628  hecmat%Iarray(idx_i_flag_diverged) = flag_diverged
629  end subroutine hecmw_mat_set_flag_diverged
630 
631  function hecmw_mat_get_flag_diverged( hecMAT )
632  integer(kind=kint) :: hecmw_mat_get_flag_diverged
633  type(hecmwst_matrix) :: hecmat
634  hecmw_mat_get_flag_diverged = hecmat%Iarray(idx_i_flag_diverged)
635  end function hecmw_mat_get_flag_diverged
636 
637  subroutine hecmw_mat_set_flag_mpcmatvec( hecMAT, flag_mpcmatvec )
638  type(hecmwst_matrix) :: hecmat
639  integer(kind=kint) :: flag_mpcmatvec
640  hecmat%Iarray(idx_i_flag_mpcmatvec) = flag_mpcmatvec
641  end subroutine hecmw_mat_set_flag_mpcmatvec
642 
643  function hecmw_mat_get_flag_mpcmatvec( hecMAT )
644  integer(kind=kint) :: hecmw_mat_get_flag_mpcmatvec
645  type(hecmwst_matrix) :: hecmat
646  hecmw_mat_get_flag_mpcmatvec = hecmat%Iarray(idx_i_flag_mpcmatvec)
647  end function hecmw_mat_get_flag_mpcmatvec
648 
649  subroutine hecmw_mat_set_solver_opt( hecMAT, solver_opt )
650  type(hecmwst_matrix) :: hecmat
651  integer(kind=kint) :: solver_opt(:)
652  integer(kind=kint) :: nopt
653  nopt = idx_i_solver_opt_e - idx_i_solver_opt_s + 1
654  hecmat%Iarray(idx_i_solver_opt_s:idx_i_solver_opt_e) = solver_opt(1:nopt)
655  end subroutine hecmw_mat_set_solver_opt
656 
657  subroutine hecmw_mat_get_solver_opt( hecMAT, solver_opt )
658  type(hecmwst_matrix) :: hecmat
659  integer(kind=kint) :: solver_opt(:)
660  integer(kind=kint) :: nopt
661  nopt = idx_i_solver_opt_e - idx_i_solver_opt_s + 1
662  solver_opt(1:nopt) = hecmat%Iarray(idx_i_solver_opt_s:idx_i_solver_opt_e)
663  end subroutine hecmw_mat_get_solver_opt
664 
665  subroutine hecmw_mat_set_resid( hecMAT, resid )
666  type(hecmwst_matrix) :: hecmat
667  real(kind=kreal) :: resid
668 
669  hecmat%Rarray(idx_r_resid) = resid
670  end subroutine hecmw_mat_set_resid
671 
672  function hecmw_mat_get_resid( hecMAT )
673  real(kind=kreal) :: hecmw_mat_get_resid
674  type(hecmwst_matrix) :: hecmat
675 
676  hecmw_mat_get_resid = hecmat%Rarray(idx_r_resid)
677  end function hecmw_mat_get_resid
678 
679  subroutine hecmw_mat_set_sigma_diag( hecMAT, sigma_diag )
680  type(hecmwst_matrix) :: hecmat
681  real(kind=kreal) :: sigma_diag
682 
683  if( sigma_diag < 0.d0 ) then
684  hecmat%Rarray(idx_r_sigma_diag) = -1.d0
685  elseif( sigma_diag < 1.d0 ) then
686  hecmat%Rarray(idx_r_sigma_diag) = 1.d0
687  elseif( sigma_diag > 2.d0 ) then
688  hecmat%Rarray(idx_r_sigma_diag) = 2.d0
689  else
690  hecmat%Rarray(idx_r_sigma_diag) = sigma_diag
691  endif
692  end subroutine hecmw_mat_set_sigma_diag
693 
694  function hecmw_mat_get_sigma_diag( hecMAT )
695  real(kind=kreal) :: hecmw_mat_get_sigma_diag
696  type(hecmwst_matrix) :: hecmat
697 
698  hecmw_mat_get_sigma_diag = hecmat%Rarray(idx_r_sigma_diag)
699  end function hecmw_mat_get_sigma_diag
700 
701  subroutine hecmw_mat_set_sigma( hecMAT, sigma )
702  type(hecmwst_matrix) :: hecmat
703  real(kind=kreal) :: sigma
704 
705  if (sigma < 0.d0) then
706  hecmat%Rarray(idx_r_sigma) = 0.d0
707  elseif (sigma > 1.d0) then
708  hecmat%Rarray(idx_r_sigma) = 1.d0
709  else
710  hecmat%Rarray(idx_r_sigma) = sigma
711  endif
712  end subroutine hecmw_mat_set_sigma
713 
714  function hecmw_mat_get_sigma( hecMAT )
715  real(kind=kreal) :: hecmw_mat_get_sigma
716  type(hecmwst_matrix) :: hecmat
717 
718  hecmw_mat_get_sigma = hecmat%Rarray(idx_r_sigma)
719  end function hecmw_mat_get_sigma
720 
721  subroutine hecmw_mat_set_thresh( hecMAT, thresh )
722  type(hecmwst_matrix) :: hecmat
723  real(kind=kreal) :: thresh
724 
725  hecmat%Rarray(idx_r_thresh) = thresh
726  end subroutine hecmw_mat_set_thresh
727 
728  function hecmw_mat_get_thresh( hecMAT )
729  real(kind=kreal) :: hecmw_mat_get_thresh
730  type(hecmwst_matrix) :: hecmat
731 
732  hecmw_mat_get_thresh = hecmat%Rarray(idx_r_thresh)
733  end function hecmw_mat_get_thresh
734 
735  subroutine hecmw_mat_set_filter( hecMAT, filter )
736  type(hecmwst_matrix) :: hecmat
737  real(kind=kreal) :: filter
738 
739  hecmat%Rarray(idx_r_filter) = filter
740  end subroutine hecmw_mat_set_filter
741 
742  function hecmw_mat_get_filter( hecMAT )
743  real(kind=kreal) :: hecmw_mat_get_filter
744  type(hecmwst_matrix) :: hecmat
745 
746  hecmw_mat_get_filter = hecmat%Rarray(idx_r_filter)
747  end function hecmw_mat_get_filter
748 
749  subroutine hecmw_mat_set_penalty( hecMAT, penalty )
750  type(hecmwst_matrix) :: hecmat
751  real(kind=kreal) :: penalty
752 
753  hecmat%Rarray(idx_r_penalty) = penalty
754  end subroutine hecmw_mat_set_penalty
755 
756  function hecmw_mat_get_penalty( hecMAT )
757  real(kind=kreal) :: hecmw_mat_get_penalty
758  type(hecmwst_matrix) :: hecmat
759 
760  hecmw_mat_get_penalty = hecmat%Rarray(idx_r_penalty)
761  end function hecmw_mat_get_penalty
762 
763  subroutine hecmw_mat_set_penalty_alpha( hecMAT, alpha )
764  type(hecmwst_matrix) :: hecmat
765  real(kind=kreal) :: alpha
766 
767  hecmat%Rarray(idx_r_penalty_alpha) = alpha
768  end subroutine hecmw_mat_set_penalty_alpha
769 
770  function hecmw_mat_get_penalty_alpha( hecMAT )
771  real(kind=kreal) :: hecmw_mat_get_penalty_alpha
772  type(hecmwst_matrix) :: hecmat
773 
774  hecmw_mat_get_penalty_alpha = hecmat%Rarray(idx_r_penalty_alpha)
775  end function hecmw_mat_get_penalty_alpha
776 
777  function hecmw_mat_diag_max(hecMAT, hecMESH)
778  real(kind=kreal) :: hecmw_mat_diag_max
779  type (hecmwst_matrix) :: hecmat
780  type (hecmwst_local_mesh) :: hecmesh
781  integer(kind=kint) :: ndiag, i
782 
783  hecmw_mat_diag_max = -1.0e20
784  ndiag = hecmat%NDOF**2 * hecmat%NP
785  do i = 1, ndiag
786  if( hecmat%D(i) > hecmw_mat_diag_max ) hecmw_mat_diag_max = hecmat%D(i)
787  enddo
789  end function hecmw_mat_diag_max
790 
794  function hecmw_mat_diag(hecMAT) result(diag)
795  type(hecmwst_matrix), intent(in), target :: hecmat
796  real(kind=kreal), pointer :: diag(:)
797  integer(kind=kint) :: i, k, idx, ndof, np
798 
799  ndof = hecmat%NDOF
800  np = hecmat%NP
801  allocate(diag(ndof * np))
802 
803  do i = 1, np
804  do k = 1, ndof
805  idx = ndof * ndof * (i - 1) + (k-1) * ndof + k
806  diag(ndof * (i - 1) + k) = hecmat%D(idx)
807  enddo
808  enddo
809  end function hecmw_mat_diag
810 
812  type (hecmwst_matrix) :: hecmat
813  integer(kind=kint) :: nrecycle, maxrecycle
814  if (hecmat%Iarray(idx_i_flag_symbfact) >= 1) then
815  hecmat%Iarray(idx_i_flag_numfact)=1
817  elseif (hecmat%Iarray(idx_i_flag_numfact) > 1) then
819  hecmat%Iarray(idx_i_flag_numfact) = 1
820  elseif (hecmat%Iarray(idx_i_flag_numfact) == 1) then
821  nrecycle = hecmw_mat_get_nrecycle_precond(hecmat)
822  maxrecycle = hecmw_mat_get_maxrecycle_precond(hecmat)
823  if ( nrecycle < maxrecycle ) then
824  hecmat%Iarray(idx_i_flag_numfact) = 0
826  else
828  endif
829  endif
830  end subroutine hecmw_mat_recycle_precond_setting
831 
832  subroutine hecmw_mat_substitute( dest, src )
833  type (hecmwst_matrix), intent(inout) :: dest
834  type (hecmwst_matrix), intent(inout) :: src
835  dest%N = src%N
836  dest%NP = src%NP
837  dest%NPL = src%NPL
838  dest%NPU = src%NPU
839  dest%NDOF = src%NDOF
840  if (associated(src%D)) dest%D => src%D
841  if (associated(src%B)) dest%B => src%B
842  if (associated(src%X)) dest%X => src%X
843  if (associated(src%AL)) dest%AL => src%AL
844  if (associated(src%AU)) dest%AU => src%AU
845  if (associated(src%indexL)) dest%indexL => src%indexL
846  if (associated(src%indexU)) dest%indexU => src%indexU
847  if (associated(src%itemL)) dest%itemL => src%itemL
848  if (associated(src%itemU)) dest%itemU => src%itemU
849  dest%Iarray(:) = src%Iarray(:)
850  dest%Rarray(:) = src%Rarray(:)
851  end subroutine hecmw_mat_substitute
852 
865  subroutine hecmw_mat_integrate( hecMAT )
866  type (hecmwst_matrix), intent(inout) :: hecmat
867 #ifdef _OPENACC
868  integer(kind=kint) :: i, j, k, nn, pre, pp, js, je
869 
870  nn = hecmat%NDOF * hecmat%NDOF
871  allocate (hecmat%indexA(0:hecmat%NP))
872  allocate (hecmat%itemA(hecmat%NPA))
873  hecmat%indexA(0) = 0
874 
875  pre = 0
876  pp = 0
877  !$acc parallel loop private(i, j, k, pre, pp, jS, jE)
878  do i = 1, hecmat%NP
879  indexa(i) = i + hecmat%indexL(i) + hecmat%indexU(i)
880 
881  pre = i - 1 + hecmat%indexU(i - 1)
882  js= hecmat%indexL(i - 1) + 1
883  je= hecmat%indexL(i )
884  do j = js, je
885  pp = pre + j
886  hecmat%itemA(pp) = hecmat%itemL(j)
887  do k = -nn+1, 0
888  hecmat%A(nn * pp + k) = hecmat%AL(nn * j + k)
889  enddo
890  enddo
891 
892  pp = i + hecmat%indexU(i - 1) + hecmat%indexL(i)
893  hecmat%itemA(pp) = i
894  do k = -nn+1, 0
895  hecmat%A(nn * pp + k) = hecmat%D(nn * i + k)
896  enddo
897 
898  pre = i + hecmat%indexL(i)
899  js= hecmat%indexU(i - 1) + 1
900  je= hecmat%indexU(i )
901  do j = js, je
902  pp = pre + j
903  hecmat%itemA(pp) = hecmat%itemU(j)
904  do k = -nn+1, 0
905  hecmat%A(nn * pp + k) = hecmat%AU(nn * j + k)
906  enddo
907  enddo
908  enddo
909 #endif
910  end subroutine hecmw_mat_integrate
911 
912 end module hecmw_matrix_misc
integer(kind=kint) function, public hecmw_mat_get_solver_type(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_flag_mpcmatvec(hecMAT)
subroutine, public hecmw_mat_set_usejad(hecMAT, usejad)
real(kind=kreal) function, dimension(:), pointer, public hecmw_mat_diag(hecMAT)
Extract diagonal components from matrix D into a 1D vector Returns: diag(i) = D(ndof*ndof*(node-1) + ...
subroutine, public hecmw_mat_set_ncolor_in(hecMAT, ncolor_in)
integer(kind=kint) function, public hecmw_mat_get_flag_diverged(hecMAT)
subroutine, public hecmw_mat_integrate(hecMAT)
Integrate matrix components into a single array for efficient access.
subroutine, public hecmw_mat_clear_flag_symbfact(hecMAT)
real(kind=kreal) function, public hecmw_mat_get_sigma_diag(hecMAT)
real(kind=kreal) function, public hecmw_mat_diag_max(hecMAT, hecMESH)
integer(kind=kint) function, public hecmw_mat_get_iterpremax(hecMAT)
subroutine, public hecmw_mat_set_sigma(hecMAT, sigma)
subroutine, public hecmw_mat_set_contact_elim(hecMAT, contact_elim)
integer(kind=kint) function, public hecmw_mat_get_dump_exit(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_nrest(hecMAT)
subroutine, public hecmw_mat_init(hecMAT)
subroutine, public hecmw_mat_set_iter(hecMAT, iter)
subroutine, public hecmw_mat_set_iterlog(hecMAT, iterlog)
subroutine, public hecmw_mat_finalize(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_nrecycle_precond(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_penalized(hecMAT)
subroutine, public hecmw_mat_copy_val(hecMATorg, hecMAT)
subroutine, public hecmw_mat_set_flag_diverged(hecMAT, flag_diverged)
subroutine, public hecmw_mat_set_penalized_b(hecMAT, penalized_b)
real(kind=kreal) function, public hecmw_mat_get_resid(hecMAT)
subroutine, public hecmw_mat_set_estcond(hecMAT, estcond)
integer(kind=kint) function, public hecmw_mat_get_maxrecycle_precond(hecMAT)
subroutine, public hecmw_mat_set_thresh(hecMAT, thresh)
subroutine, public hecmw_mat_set_flag_converged(hecMAT, flag_converged)
integer(kind=kint) function, public hecmw_mat_get_flag_converged(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_penalized_b(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_dump(hecMAT)
real(kind=kreal) function, public hecmw_mat_get_penalty_alpha(hecMAT)
subroutine, public hecmw_mat_get_solver_opt(hecMAT, solver_opt)
integer(kind=kint) function, public hecmw_mat_get_nbfgs(hecMAT)
subroutine, public hecmw_mat_substitute(dest, src)
real(kind=kreal) function, public hecmw_mat_get_penalty(hecMAT)
subroutine, public hecmw_mat_recycle_precond_setting(hecMAT)
subroutine, public hecmw_mat_incr_nrecycle_precond(hecMAT)
subroutine, public hecmw_mat_set_sigma_diag(hecMAT, sigma_diag)
subroutine, public hecmw_mat_set_penalty_alpha(hecMAT, alpha)
subroutine, public hecmw_mat_clear_b(hecMAT)
subroutine, public hecmw_mat_set_dump_exit(hecMAT, dump_exit)
integer(kind=kint) function, public hecmw_mat_get_iterlog(hecMAT)
subroutine, public hecmw_mat_set_flag_symbfact(hecMAT, flag_symbfact)
integer(kind=kint) function, public hecmw_mat_get_timelog(hecMAT)
subroutine, public hecmw_mat_set_nset(hecMAT, nset)
subroutine, public hecmw_mat_set_flag_numfact(hecMAT, flag_numfact)
subroutine, public hecmw_mat_copy_profile(hecMATorg, hecMAT)
subroutine, public hecmw_mat_set_method(hecMAT, method)
subroutine, public hecmw_mat_set_filter(hecMAT, filter)
integer(kind=kint) function, public hecmw_mat_get_method2(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_flag_numfact(hecMAT)
subroutine, public hecmw_mat_set_penalized(hecMAT, penalized)
subroutine, public hecmw_mat_set_penalty(hecMAT, penalty)
subroutine, public hecmw_mat_set_maxrecycle_precond(hecMAT, maxrecycle_precond)
subroutine, public hecmw_mat_clear(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_contact_elim(hecMAT)
subroutine, public hecmw_mat_set_timelog(hecMAT, timelog)
subroutine, public hecmw_mat_set_resid(hecMAT, resid)
real(kind=kreal) function, public hecmw_mat_get_thresh(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_flag_symbfact(hecMAT)
subroutine, public hecmw_mat_set_flag_mpcmatvec(hecMAT, flag_mpcmatvec)
integer(kind=kint) function, public hecmw_mat_get_method(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_precond(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_nset(hecMAT)
subroutine, public hecmw_mat_set_iterpremax(hecMAT, iterpremax)
real(kind=kreal) function, public hecmw_mat_get_filter(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_estcond(hecMAT)
subroutine, public hecmw_mat_set_nrest(hecMAT, nrest)
integer(kind=kint) function, public hecmw_mat_get_usejad(hecMAT)
subroutine, public hecmw_mat_set_solver_type(hecMAT, solver_type)
subroutine, public hecmw_mat_set_method2(hecMAT, method2)
integer(kind=kint) function, public hecmw_mat_get_mpc_method(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_ncolor_in(hecMAT)
real(kind=kreal) function, public hecmw_mat_get_sigma(hecMAT)
subroutine, public hecmw_mat_set_nbfgs(hecMAT, nbfgs)
integer(kind=kint) function, public hecmw_mat_get_iter(hecMAT)
subroutine, public hecmw_mat_set_precond(hecMAT, precond)
subroutine, public hecmw_mat_set_solver_opt(hecMAT, solver_opt)
integer(kind=kint) function, public hecmw_mat_get_scaling(hecMAT)
subroutine, public hecmw_mat_reset_nrecycle_precond(hecMAT)
subroutine, public hecmw_mat_set_scaling(hecMAT, scaling)
subroutine, public hecmw_mat_set_mpc_method(hecMAT, mpc_method)
subroutine, public hecmw_mat_set_dump(hecMAT, dump_type)
I/O and Utility.
Definition: hecmw_util_f.F90:7
integer(kind=kint), parameter hecmw_max
integer(kind=4), parameter kreal
subroutine hecmw_nullify_matrix(P)
subroutine hecmw_allreduce_r1(hecMESH, s, ntag)