35 integer(kind=kint) :: contact_elim, solver_type, loglevel, myrank
42 writelog = (myrank==0 .and. loglevel>0)
44 if( contact_elim==0 )
then
45 if( solver_type==1 )
then
59 if( .not. any_lagrange(hecmesh, hecmat) ) contact_elim = 1
62 if( contact_elim==1 )
then
63 if( writelog )
write(*,*)
'solve contact with elimination'
66 if( writelog )
write(*,*)
'solve contact without elimination'
67 if( solver_type==1 )
then
68 write(*,*)
'ERROR: iterative solver without elimination not available in contact analysis'
70 elseif( solver_type==2 )
then
72 else if( solver_type==3 )
then
74 elseif( solver_type==5 )
then
76 elseif( solver_type==7 )
then
78 write(*,*)
'ERROR: !SOLVER,METHOD=DIRECTmf not available in parallel contact analysis',&
79 ' without elimination; specify CONTACT_ELIM=1 or use MUMPS or DIRECTmkl instead'
84 write(*,*)
'ERROR: specified solver not available in contact analysis without elimination;',&
85 ' please use MUMPS or DIRECTmkl instead'
97 type (hecmwst_ebc) :: hecebc
98 integer(kind=kint),
intent(out) :: istat
99 real(kind=
kreal),
optional :: rf
100 logical :: is_contact_active
102 real(kind=
kreal) :: factor
103 real(kind=
kreal) :: t1, t2, resid
104 integer(kind=kint) :: ndof
105 integer(kind=kint) :: contact_elim, solver_type
106 logical :: conmat_added
113 if( .not. any_lagrange(hecmesh, hecmat) ) contact_elim = 1
117 if(
present(rf) )factor = rf
122 conmat_added = .false.
128 if( contact_elim==1 )
then
131 if( solver_type==1 )
then
132 write(*,*)
'ERROR: iterative solver without elimination not available in contact analysis'
134 elseif( solver_type==2 )
then
136 write(*,*)
'ERROR: !SOLVER,METHOD=DIRECT not available in parallel contact analysis;',&
137 ' please use MUMPS or DIRECTmkl instead'
140 call add_conmat_to_hecmat(hecmat)
141 conmat_added = .true.
144 elseif( solver_type==3 )
then
146 call add_conmat_to_hecmat(hecmat)
147 conmat_added = .true.
150 elseif( solver_type==5 )
then
152 elseif( solver_type==7 )
then
154 write(*,*)
'ERROR: !SOLVER,METHOD=DIRECTmf not available in parallel contact analysis',&
155 ' without elimination; specify CONTACT_ELIM=1 or use MUMPS or DIRECTmkl instead'
158 call add_conmat_to_hecmat(hecmat)
159 conmat_added = .true.
163 write(*,*)
'ERROR: specified solver not available in contact analysis without elimination;',&
164 ' please use MUMPS or DIRECTmkl instead'
176 resid = rel_resid_lagrange(hecmesh,hecmat,.not. conmat_added)
185 hecmat%X=factor*hecmat%X
191 logical function any_lagrange(hecMESH, hecMAT)
194 integer(kind=kint) :: n
196 n = hecmat%lagmat%num_lagrange
199 end function any_lagrange
202 subroutine add_conmat_to_hecmat(hecMAT)
206 integer(kind=kint) :: ndof,ndof2,i
211 do i=1,hecmat%NP*ndof + hecmat%lagmat%num_lagrange
212 hecmat%B(i) = hecmat%B(i) + hecmat%conmat%B(i)
215 do i=1,hecmat%NP*ndof2
216 hecmat%D(i) = hecmat%D(i) + hecmat%conmat%D(i)
219 do i=1,hecmat%NPL*ndof2
220 hecmat%AL(i) = hecmat%AL(i) + hecmat%conmat%AL(i)
223 do i=1,hecmat%NPU*ndof2
224 hecmat%AU(i) = hecmat%AU(i) + hecmat%conmat%AU(i)
226 end subroutine add_conmat_to_hecmat
231 function rel_resid_lagrange(hecMESH, hecMAT, with_conmat)
result(resid)
234 logical,
intent(in) :: with_conmat
235 real(kind=
kreal) :: resid
237 integer(kind=kint) :: ndof, ndof2, nndof, npndof, i, idof, jdof, j, k, l, irow
238 real(kind=
kreal),
allocatable :: y(:), yc(:), bc(:)
239 real(kind=
kreal),
pointer :: blag(:)
240 real(kind=
kreal) :: bi, rl, sums(2)
244 nndof = hecmat%N*ndof
245 npndof = hecmat%NP*ndof
247 allocate(y(npndof), yc(npndof), bc(npndof))
254 if( with_conmat )
then
257 irow = ndof*(i-1)+idof
258 bc(irow) = hecmat%conmat%B(irow)
260 yc(irow) = yc(irow) + hecmat%conmat%D(ndof2*(i-1)+ndof*(idof-1)+jdof)*hecmat%X(ndof*(i-1)+jdof)
262 do k = hecmat%conmat%indexL(i-1)+1, hecmat%conmat%indexL(i)
263 j = hecmat%conmat%itemL(k)
265 yc(irow) = yc(irow) + hecmat%conmat%AL(ndof2*(k-1)+ndof*(idof-1)+jdof)*hecmat%X(ndof*(j-1)+jdof)
268 do k = hecmat%conmat%indexU(i-1)+1, hecmat%conmat%indexU(i)
269 j = hecmat%conmat%itemU(k)
271 yc(irow) = yc(irow) + hecmat%conmat%AU(ndof2*(k-1)+ndof*(idof-1)+jdof)*hecmat%X(ndof*(j-1)+jdof)
278 if( hecmat%lagmat%num_lagrange > 0 )
then
280 do l = hecmat%lagmat%indexU_lagrange(i-1)+1, hecmat%lagmat%indexU_lagrange(i)
281 j = hecmat%lagmat%itemU_lagrange(l)
283 irow = ndof*(i-1)+idof
284 yc(irow) = yc(irow) + hecmat%lagmat%AU_lagrange(ndof*(l-1)+idof)*hecmat%X(npndof+j)
295 bi = hecmat%B(i) + bc(i)
296 sums(1) = sums(1) + (bi - (y(i) + yc(i)))**2
297 sums(2) = sums(2) + bi**2
301 if( with_conmat )
then
302 blag => hecmat%conmat%B
306 do i = 1, hecmat%lagmat%num_lagrange
308 do l = hecmat%lagmat%indexL_lagrange(i-1)+1, hecmat%lagmat%indexL_lagrange(i)
309 j = hecmat%lagmat%itemL_lagrange(l)
311 rl = rl - hecmat%lagmat%AL_lagrange(ndof*(l-1)+jdof)*hecmat%X(ndof*(j-1)+jdof)
314 sums(1) = sums(1) + rl**2
315 sums(2) = sums(2) + blag(npndof+i)**2
319 if( .not. (sums(2) > 0.0d0) ) sums(2) = 1.0d0
320 resid = sqrt(sums(1)/sums(2))
322 deallocate(y, yc, bc)
323 end function rel_resid_lagrange
Essential boundary conditions kept as per-DOF marks and values so that they can be imposed on the mat...
integer(kind=kint) function, public hecmw_mat_get_solver_type(hecMAT)
subroutine, public hecmw_mat_set_contact_elim(hecMAT, contact_elim)
subroutine, public hecmw_mat_set_flag_diverged(hecMAT, flag_diverged)
subroutine, public hecmw_mat_set_flag_converged(hecMAT, flag_converged)
integer(kind=kint) function, public hecmw_mat_get_iterlog(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_timelog(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_loglevel(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_contact_elim(hecMAT)
subroutine, public hecmw_matvec(hecMESH, hecMAT, X, Y, COMMtime)
integer(kind=kint), parameter hecmw_sum
subroutine hecmw_abort(comm, code)
integer(kind=kint) function hecmw_comm_get_size()
integer(kind=kint) function hecmw_comm_get_comm()
integer(kind=kint), parameter hecmw_max
integer(kind=4), parameter kreal
integer(kind=kint) function hecmw_comm_get_rank()
real(kind=kreal) function hecmw_wtime()
subroutine hecmw_assemble_r(hecMESH, val, n, m)
subroutine hecmw_update_r(hecMESH, val, n, m)
subroutine hecmw_allreduce_i1(hecMESH, s, ntag)
subroutine hecmw_allreduce_r(hecMESH, val, n, ntag)
subroutine solve_lineq_serial_lag_hecmw(hecMESH, hecMAT, hecEBC)
subroutine solve_lineq_serial_lag_hecmw_init(hecMAT, is_sym)