FrontISTR  5.2.0
Large-scale structural analysis program with finit element method
hecmw_solver.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 contains
8 
9  subroutine hecmw_solve (hecMESH, hecMAT)
10 
11  use hecmw_util
20  use m_hecmw_comm_f
21  implicit none
22 
23  type (hecmwST_matrix), target :: hecMAT
24  type (hecmwST_local_mesh) :: hecMESH
25 
26  real(kind=kreal) :: resid
27  integer(kind=kint) :: i, myrank, NDOF
28  integer(kind=kint) :: imsg = 51
29  ndof=hecmat%NDOF
30 
31  !C ERROR CHECK
32  if(hecmw_solve_check_zerorhs(hecmesh, hecmat))then
33  hecmat%X = 0.0d0
34  return
35  endif
36 
37  select case(hecmat%Iarray(99))
38  !* Call Iterative Solver
39  case (1)
40  call hecmw_solve_iterative(hecmesh,hecmat)
41  !* Call Direct Solver
42  case(2:)
43  !C
44  !* Please note the following:
45  !* Flag to activate symbolic factorization: 1(yes) 0(no) hecMESH%Iarray(98)
46  !* Flag to activate numeric factorization: 1(yes) 0(no) hecMESH%Iarray(97)
47 
48  if (hecmat%Iarray(97) .gt. 1) hecmat%Iarray(97)=1
49 
50  call hecmw_mat_set_flag_converged(hecmat, 0)
51  call hecmw_mat_set_flag_diverged(hecmat, 0)
52 
53  if (hecmat%Iarray(2) .eq. 102) then
54  if(hecmesh%PETOT.GT.1) then
55  call hecmw_solve_direct_clustermkl(hecmesh, hecmat)
56  else
57  call hecmw_solve_direct_mkl(hecmesh,hecmat)
58  endif
59  elseif (hecmat%Iarray(2) .eq. 104) then
60  call hecmw_solve_direct_mumps(hecmesh, hecmat)
61  else
62  if(hecmesh%PETOT.GT.1) then
63  call hecmw_solve_direct_parallel(hecmesh,hecmat,imsg)
64  else
65  call hecmw_solve_direct(hecmesh,hecmat,imsg)
66  endif
67  endif
68 
69  resid=hecmw_rel_resid_l2_nn(hecmesh,hecmat)
70  myrank=hecmw_comm_get_rank()
71  if (myrank==0) then
72  if (hecmat%Iarray(21) > 0 .or. hecmat%Iarray(22) > 0) then
73  write(*,"(a,1pe12.5)")'### Relative residual =', resid
74  endif
75  if( resid >= 1.0d-8) then
76  write(*,"(a)")'### Relative residual exceeded 1.0d-8---Direct Solver### '
77  ! stop
78  endif
79  endif
80  if (resid < hecmw_mat_get_resid(hecmat)) then
81  call hecmw_mat_set_flag_converged(hecmat, 1)
82  endif
83  !C
84  end select
85 
86  end subroutine hecmw_solve
87 
88  subroutine hecmw_substitute_solver(hecMESH, hecMATorig, NDOF)
89 
90  use hecmw_util
97  type (hecmwST_local_mesh) :: hecMESH
98  type (hecmwST_matrix) :: hecMATorig
99  type (hecmwST_matrix),pointer :: hecMAT => null()
100  integer(kind=kint) NDOF
101  if (ndof == hecmatorig%NDOF) then
102  call hecmw_clone_matrix(hecmatorig,hecmat)
103  else if (ndof < hecmatorig%NDOF) then
105  else
106  call hecmw_blockmatrix_expand(hecmatorig,hecmat,ndof)
107  call hecmw_cmat_init(hecmat%cmat)
108  end if
109  ! select case(NDOF)
110  ! case(1)
111  ! call hecmw_solve_11(hecMESH,hecMAT)
112  ! case(2)
113  ! call hecmw_solve_22(hecMESH,hecMAT)
114  ! case(3)
115  ! call hecmw_solve_33(hecMESH,hecMAT)
116  ! case(4)
117  ! call hecmw_solve_iterative(hecMESH,hecMAT)
118  ! case(5)
119  ! call hecmw_solve_iterative(hecMESH,hecMAT)
120  ! case(6)
121  ! call hecmw_solve_66(hecMESH,hecMAT)
122  ! case(7:)
123  ! call hecmw_solve_iterative(hecMESH,hecMAT)
124  ! end select
125  !call hecmw_solve_direct_MUMPS(hecMESH, hecMAT)
126  call hecmw_solve_iterative(hecmesh,hecmat)
127  if (ndof /= hecmatorig%NDOF) then
128  call hecmw_vector_contract(hecmatorig,hecmat,ndof)
129  end if
130  end subroutine hecmw_substitute_solver
131 
132 end module hecmw_solver
subroutine, public hecmw_cmat_init(cmat)
subroutine, public hecmw_mat_set_flag_diverged(hecMAT, flag_diverged)
real(kind=kreal) function, public hecmw_mat_get_resid(hecMAT)
subroutine, public hecmw_mat_set_flag_converged(hecMAT, flag_converged)
This module provides linear equation solver interface for Cluster Pardiso.
subroutine, public hecmw_solve_direct_clustermkl(hecMESH, hecMAT)
This module provides linear equation solver interface for Pardiso.
subroutine, public hecmw_solve_direct_mkl(hecMESH, hecMAT)
This module provides linear equation solver interface for MUMPS.
subroutine, public hecmw_solve_direct_mumps(hecMESH, hecMAT)
subroutine, public hecmw_solve_direct_parallel(hecMESH, hecMAT, ii)
HECMW_SOLVE_DIRECT is a program for the matrix direct solver.
subroutine, public hecmw_solve_direct(hecMESH, hecMAT, Ifmsg)
HECMW_SOLVE_DIRECT is a program for the matrix solver.
logical function hecmw_solve_check_zerorhs(hecMESH, hecMAT)
subroutine hecmw_solve_iterative(hecMESH, hecMAT)
real(kind=kreal) function, public hecmw_rel_resid_l2_nn(hecMESH, hecMAT, COMMtime)
subroutine hecmw_substitute_solver(hecMESH, hecMATorig, NDOF)
subroutine hecmw_solve(hecMESH, hecMAT)
I/O and Utility.
Definition: hecmw_util_f.F90:7
integer(kind=kint) function hecmw_comm_get_comm()
integer(kind=4), parameter kreal
integer(kind=kint) function hecmw_comm_get_rank()
subroutine hecmw_blockmatrix_expand(hecMATorig, hecMAT, NDOF)
subroutine hecmw_clone_matrix(hecMATorig, hecMAT)
subroutine hecmw_abort(comm)
subroutine hecmw_vector_contract(hecMATorig, hecMAT, NDOF)