FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
fstr_AddBC.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 !-------------------------------------------------------------------------------
6 
8  implicit none
9 contains
10 
12  !------------------------------------------------------------------------------------------*
13  subroutine fstr_addbc(cstep,hecMESH,hecMAT,fstrSOLID,fstrPARAM,hecLagMAT,iter,conMAT,RHSvector)
14  !------------------------------------------------------------------------------------------*
15  use m_fstr
16  use mcontact
17  use m_static_lib_1d
18  use m_utilities
19  use m_fstr_timeinc
20  integer, intent(in) :: cstep
21  type(hecmwst_local_mesh) :: hecMESH
22  type(hecmwst_matrix) :: hecMAT
23  type(fstr_solid) :: fstrSOLID
24  type(fstr_param) :: fstrPARAM
25  type(hecmwst_matrix_lagrange) :: hecLagMAT
26  integer(kind=kint) :: iter
27  type(hecmwst_matrix), optional :: conMAT
28  real(kind=kreal), optional :: rhsvector(:)
29 
30  integer(kind=kint) :: ig0, ig, ityp, idofS, idofE, idof, iS0, iE0, ik, in
31  real(kind=kreal) :: rhs0, rhs, factor, factor0
32  integer(kind=kint) :: ndof, grpid, istot
33 
34  !for rotation
35  integer(kind=kint) :: n_rot, rid, jj_n_amp
36  type(trotinfo) :: rinfo
37  real(kind=kreal) :: ccoord(3), cdiff(3), cdiff0(3)
38  real(kind=kreal) :: cdisp(3), cddisp(3)
39 
40  !
41  ndof = hecmat%NDOF
42 
43  n_rot = fstrsolid%BOUNDARY_ngrp_rot
44  if( n_rot > 0 ) call fstr_rotinfo_init(n_rot, rinfo)
45 
46  ! ----- Prescibed displacement Boundary Conditions
47  do ig0 = 1, fstrsolid%BOUNDARY_ngrp_tot
48  grpid = fstrsolid%BOUNDARY_ngrp_GRPID(ig0)
49  if( iter>1 ) then
50  factor=0.d0
51  else
52  jj_n_amp = fstrsolid%BOUNDARY_ngrp_amp(ig0)
53  if( jj_n_amp <= 0 ) then ! Amplitude not defined
54  factor0 = fstrsolid%FACTOR(1)
55  factor = fstrsolid%FACTOR(2)
56  else
57  factor0 = 1.d0
58  call fstr_get_amplitude(hecmesh,fstrsolid,cstep,jj_n_amp,fstr_get_time(),factor0)
59  factor = 1.d0
60  call fstr_get_amplitude(hecmesh,fstrsolid,cstep,jj_n_amp,fstr_get_time()+fstr_get_timeinc(),factor)
61  endif
62  factor = factor - factor0
63  if(fstrsolid%step_ctrl(cstep)%amp_default_type==stepampstep)then
64  factor = 0.d0
65  if(factor0 < 1.d-10) factor = 1.d0
66  endif
67  endif
68 
69  if( .not. fstr_isboundaryactive( fstrsolid, grpid, cstep ) ) cycle
70  ig = fstrsolid%BOUNDARY_ngrp_ID(ig0)
71  rhs0 = fstrsolid%BOUNDARY_ngrp_val(ig0)
72  !
73  ityp = fstrsolid%BOUNDARY_ngrp_type(ig0)
74  idofs = ityp/10
75  idofe = ityp - idofs*10
76  !
77  istot = fstrsolid%BOUNDARY_ngrp_istot(ig0)
78  !
79  is0 = hecmesh%node_group%grp_index(ig-1) + 1
80  ie0 = hecmesh%node_group%grp_index(ig )
81 
82  if( fstrsolid%BOUNDARY_ngrp_rotID(ig0) > 0 ) then ! setup rotation information
83  rid = fstrsolid%BOUNDARY_ngrp_rotID(ig0)
84  if( .not. rinfo%conds(rid)%active ) then
85  rinfo%conds(rid)%active = .true.
86  rinfo%conds(rid)%center_ngrp_id = fstrsolid%BOUNDARY_ngrp_centerID(ig0)
87  rinfo%conds(rid)%torque_ngrp_id = ig
88  endif
89  if( istot == 0 ) then
90  rhs= rhs0*factor
91  else
92  ! not implemented yet
93  write(*,*) 'Error: rotational boundary cannot be specified with total value'
94  call hecmw_abort( hecmw_comm_get_comm() )
95  endif
96  do idof=idofs,idofe
97  if( idof>ndof ) then
98  rinfo%conds(rid)%vec(idof-ndof) = rhs
99  else
100  rinfo%conds(rid)%vec(idof) = rhs
101  endif
102  enddo
103  cycle
104  endif
105 
106  !
107  do ik = is0, ie0
108  in = hecmesh%node_group%grp_item(ik)
109  !
110  do idof = idofs, idofe
111  if( istot == 0 ) then
112  rhs = rhs0*factor
113  else
114  rhs = (rhs0 - fstrsolid%unode_bak(ndof*(in-1)+idof))*factor
115  endif
116  if(present(rhsvector)) then
117  rhsvector(ndof*(in-1)+idof) = rhs
118  ! write(6,*) 'BC: ', ndof*(in-1)+idof, RHS
119  cycle
120  endif
121  if(present(conmat)) then
122  call hecmw_mat_ass_bc(hecmat, in, idof, rhs, conmat)
123  else
124  call hecmw_mat_ass_bc(hecmat, in, idof, rhs)
125  endif
126  if( fstr_is_contact_active() .and. fstrparam%solution_type == kststatic &
127  .and. fstrparam%contact_algo == kcaslagrange ) then
128  if(present(conmat)) then
129  call hecmw_mat_ass_bc_contactlag(conmat,heclagmat,in,idof,rhs)
130  else
131  call hecmw_mat_ass_bc_contactlag(hecmat,heclagmat,in,idof,rhs)
132  endif
133  endif
134 
135  enddo
136  enddo
137  enddo
138 
139  !Apply rotational boundary condition
140  !need to fix!!
141  do rid = 1, n_rot
142  if( .not. rinfo%conds(rid)%active ) cycle
143  cdiff = 0.d0
144  cdiff0 = 0.d0
145  cddisp = 0.d0
146 
147  if( factor > 0.d0 ) then
148  ig = rinfo%conds(rid)%center_ngrp_id
149  do idof = 1, ndof
150  ccoord(idof) = hecmw_ngrp_get_totalvalue(hecmesh, ig, ndof, idof, hecmesh%node)
151  cdisp(idof) = hecmw_ngrp_get_totalvalue(hecmesh, ig, ndof, idof, fstrsolid%unode)
152  cddisp(idof) = hecmw_ngrp_get_totalvalue(hecmesh, ig, ndof, idof, hecmat%B)
153  enddo
154  ccoord(1:ndof) = ccoord(1:ndof) + cdisp(1:ndof)
155  endif
156 
157  ig = rinfo%conds(rid)%torque_ngrp_id
158  is0 = hecmesh%node_group%grp_index(ig-1) + 1
159  ie0 = hecmesh%node_group%grp_index(ig )
160  do ik = is0, ie0
161  in = hecmesh%node_group%grp_item(ik)
162  if( factor > 0.d0 ) then
163  cdiff0(1:ndof) = hecmesh%node(ndof*(in-1)+1:ndof*in)+fstrsolid%unode(ndof*(in-1)+1:ndof*in)-ccoord(1:ndof)
164  cdiff(1:ndof) = cdiff0(1:ndof)
165  call rotate_3dvector_by_rodrigues_formula(rinfo%conds(rid)%vec(1:ndof),cdiff(1:ndof))
166  endif
167  do idof = 1, ndof
168  rhs = cdiff(idof)-cdiff0(idof)+cddisp(idof)
169  if(present(rhsvector)) then
170  rhsvector(ndof*(in-1)+idof) = rhs
171  ! write(6,*) 'BC(rot): ', ndof*(in-1)+idof, RHS
172  cycle
173  endif
174  if(present(conmat)) then
175  call hecmw_mat_ass_bc(hecmat, in, idof, rhs, conmat)
176  else
177  call hecmw_mat_ass_bc(hecmat, in, idof, rhs)
178  endif
179  if( fstr_is_contact_active() .and. fstrparam%solution_type == kststatic &
180  .and. fstrparam%contact_algo == kcaslagrange ) then
181  if(present(conmat)) then
182  call hecmw_mat_ass_bc_contactlag(conmat,heclagmat,in,idof,rhs)
183  else
184  call hecmw_mat_ass_bc_contactlag(hecmat,heclagmat,in,idof,rhs)
185  endif
186  endif
187  enddo
188  enddo
189  enddo
190  if( n_rot > 0 ) call fstr_rotinfo_finalize(rinfo)
191 
192  !
193  ! ------ Truss element Diagonal Modification
194  call truss_diag_modify(hecmat,hecmesh)
195 
196  !
197  ! ------ Equation boundary conditions
198  do ig0=1,fstrsolid%n_fix_mpc
199  if( fstrsolid%mpc_const(ig0) == 0.d0 ) cycle
200  ! we need to confirm if it is active in curr step here
201  rhs = fstrsolid%mpc_const(ig0)*factor
202  hecmesh%mpc%mpc_const(ig0) = rhs
203  enddo
204 
205  end subroutine fstr_addbc
206 
207 end module m_fstr_addbc
This module provides a function to deal with prescribed displacement.
Definition: fstr_AddBC.f90:7
subroutine fstr_addbc(cstep, hecMESH, hecMAT, fstrSOLID, fstrPARAM, hecLagMAT, iter, conMAT, RHSvector)
Add Essential Boundary Conditions.
Definition: fstr_AddBC.f90:14
This module provides functions to deal with time and increment of stress analysis.
real(kind=kreal) function fstr_get_timeinc()
real(kind=kreal) function fstr_get_time()
This module defines common data and basic structures for analysis.
Definition: m_fstr.F90:15
subroutine fstr_get_amplitude(hecMESH, fstrSOLID, cstep, jj_n_amp, time, value)
Evaluate the amplitude-scaled target value a(t) for static analysis.
Definition: m_fstr.F90:1223
integer(kind=kint), parameter kcaslagrange
contact analysis algorithm
Definition: m_fstr.F90:61
integer(kind=kint), parameter kststatic
Definition: m_fstr.F90:39
logical function fstr_isboundaryactive(fstrSOLID, nbc, cstep)
Definition: m_fstr.F90:1061
This module provide common functions of 3D truss elements.
subroutine truss_diag_modify(hecMAT, hecMESH)
This module provides aux functions.
Definition: utilities.f90:6
subroutine rotate_3dvector_by_rodrigues_formula(r, v)
Definition: utilities.f90:591
Top-level contact analysis module (System level)
logical function fstr_is_contact_active()
FSTR INNER CONTROL PARAMETERS (fstrPARAM)
Definition: m_fstr.F90:157