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,hecEBC,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  use hecmw_ebc_defer
21  integer, intent(in) :: cstep
22  type(hecmwst_local_mesh) :: hecMESH
23  type(hecmwst_matrix) :: hecMAT
24  type(fstr_solid) :: fstrSOLID
25  type(fstr_param) :: fstrPARAM
26  type(hecmwst_matrix_lagrange) :: hecLagMAT
27  integer(kind=kint) :: iter
28  type(hecmwst_ebc) :: hecEBC
29  type(hecmwst_matrix), optional :: conMAT
30  real(kind=kreal), optional :: rhsvector(:)
31 
32  integer(kind=kint) :: ig0, ig, ityp, idofS, idofE, idof, iS0, iE0, ik, in
33  real(kind=kreal) :: rhs0, rhs, factor, factor0
34  integer(kind=kint) :: ndof, grpid, istot
35 
36  !for rotation
37  integer(kind=kint) :: n_rot, rid, jj_n_amp
38  type(trotinfo) :: rinfo
39  real(kind=kreal) :: ccoord(3), cdiff(3), cdiff0(3)
40  real(kind=kreal) :: cdisp(3), cddisp(3)
41 
42  !
43  ndof = hecmat%NDOF
44 
45  n_rot = fstrsolid%BOUNDARY_ngrp_rot
46  if( n_rot > 0 ) call fstr_rotinfo_init(n_rot, rinfo)
47 
48  ! ----- Prescibed displacement Boundary Conditions
49  do ig0 = 1, fstrsolid%BOUNDARY_ngrp_tot
50  grpid = fstrsolid%BOUNDARY_ngrp_GRPID(ig0)
51  if( iter>1 ) then
52  factor=0.d0
53  else
54  jj_n_amp = fstrsolid%BOUNDARY_ngrp_amp(ig0)
55  if( jj_n_amp <= 0 ) then ! Amplitude not defined
56  factor0 = fstrsolid%FACTOR(1)
57  factor = fstrsolid%FACTOR(2)
58  else
59  factor0 = 1.d0
60  call fstr_get_amplitude(hecmesh,fstrsolid,cstep,jj_n_amp,fstr_get_time(),factor0)
61  factor = 1.d0
62  call fstr_get_amplitude(hecmesh,fstrsolid,cstep,jj_n_amp,fstr_get_time()+fstr_get_timeinc(),factor)
63  endif
64  factor = factor - factor0
65  if(fstrsolid%step_ctrl(cstep)%amp_default_type==stepampstep)then
66  factor = 0.d0
67  if(factor0 < 1.d-10) factor = 1.d0
68  endif
69  endif
70 
71  if( .not. fstr_isboundaryactive( fstrsolid, grpid, cstep ) ) cycle
72  ig = fstrsolid%BOUNDARY_ngrp_ID(ig0)
73  rhs0 = fstrsolid%BOUNDARY_ngrp_val(ig0)
74  !
75  ityp = fstrsolid%BOUNDARY_ngrp_type(ig0)
76  idofs = ityp/10
77  idofe = ityp - idofs*10
78  !
79  istot = fstrsolid%BOUNDARY_ngrp_istot(ig0)
80  !
81  is0 = hecmesh%node_group%grp_index(ig-1) + 1
82  ie0 = hecmesh%node_group%grp_index(ig )
83 
84  if( fstrsolid%BOUNDARY_ngrp_rotID(ig0) > 0 ) then ! setup rotation information
85  rid = fstrsolid%BOUNDARY_ngrp_rotID(ig0)
86  if( .not. rinfo%conds(rid)%active ) then
87  rinfo%conds(rid)%active = .true.
88  rinfo%conds(rid)%center_ngrp_id = fstrsolid%BOUNDARY_ngrp_centerID(ig0)
89  rinfo%conds(rid)%torque_ngrp_id = ig
90  endif
91  if( istot == 0 ) then
92  rhs= rhs0*factor
93  else
94  ! not implemented yet
95  write(*,*) 'Error: rotational boundary cannot be specified with total value'
96  call hecmw_abort( hecmw_comm_get_comm() )
97  endif
98  do idof=idofs,idofe
99  if( idof>ndof ) then
100  rinfo%conds(rid)%vec(idof-ndof) = rhs
101  else
102  rinfo%conds(rid)%vec(idof) = rhs
103  endif
104  enddo
105  cycle
106  endif
107 
108  !
109  do ik = is0, ie0
110  in = hecmesh%node_group%grp_item(ik)
111  !
112  do idof = idofs, idofe
113  if( istot == 0 ) then
114  rhs = rhs0*factor
115  else
116  rhs = (rhs0 - fstrsolid%unode_bak(ndof*(in-1)+idof))*factor
117  endif
118  call hecmw_ebc_set(hecebc, in, idof, rhs)
119  if(present(rhsvector)) then
120  rhsvector(ndof*(in-1)+idof) = rhs
121  ! write(6,*) 'BC: ', ndof*(in-1)+idof, RHS
122  cycle
123  endif
124  if( fstr_is_contact_active() .and. fstrparam%solution_type == kststatic &
125  .and. fstrparam%contact_algo == kcaslagrange ) then
126  if(present(conmat)) then
127  call hecmw_mat_ass_bc_contactlag(conmat,heclagmat,in,idof,rhs)
128  else
129  call hecmw_mat_ass_bc_contactlag(hecmat,heclagmat,in,idof,rhs)
130  endif
131  endif
132 
133  enddo
134  enddo
135  enddo
136 
137  !Apply rotational boundary condition
138  !need to fix!!
139  do rid = 1, n_rot
140  if( .not. rinfo%conds(rid)%active ) cycle
141  cdiff = 0.d0
142  cdiff0 = 0.d0
143  cddisp = 0.d0
144 
145  if( factor > 0.d0 ) then
146  ig = rinfo%conds(rid)%center_ngrp_id
147  do idof = 1, ndof
148  ccoord(idof) = hecmw_ngrp_get_totalvalue(hecmesh, ig, ndof, idof, hecmesh%node)
149  cdisp(idof) = hecmw_ngrp_get_totalvalue(hecmesh, ig, ndof, idof, fstrsolid%unode)
150  cddisp(idof) = hecmw_ngrp_get_totalvalue(hecmesh, ig, ndof, idof, hecebc%val)
151  enddo
152  ccoord(1:ndof) = ccoord(1:ndof) + cdisp(1:ndof)
153  endif
154 
155  ig = rinfo%conds(rid)%torque_ngrp_id
156  is0 = hecmesh%node_group%grp_index(ig-1) + 1
157  ie0 = hecmesh%node_group%grp_index(ig )
158  do ik = is0, ie0
159  in = hecmesh%node_group%grp_item(ik)
160  if( factor > 0.d0 ) then
161  cdiff0(1:ndof) = hecmesh%node(ndof*(in-1)+1:ndof*in)+fstrsolid%unode(ndof*(in-1)+1:ndof*in)-ccoord(1:ndof)
162  cdiff(1:ndof) = cdiff0(1:ndof)
163  call rotate_3dvector_by_rodrigues_formula(rinfo%conds(rid)%vec(1:ndof),cdiff(1:ndof))
164  endif
165  do idof = 1, ndof
166  rhs = cdiff(idof)-cdiff0(idof)+cddisp(idof)
167  call hecmw_ebc_set(hecebc, in, idof, rhs)
168  if(present(rhsvector)) then
169  rhsvector(ndof*(in-1)+idof) = rhs
170  ! write(6,*) 'BC(rot): ', ndof*(in-1)+idof, RHS
171  cycle
172  endif
173  if( fstr_is_contact_active() .and. fstrparam%solution_type == kststatic &
174  .and. fstrparam%contact_algo == kcaslagrange ) then
175  if(present(conmat)) then
176  call hecmw_mat_ass_bc_contactlag(conmat,heclagmat,in,idof,rhs)
177  else
178  call hecmw_mat_ass_bc_contactlag(hecmat,heclagmat,in,idof,rhs)
179  endif
180  endif
181  enddo
182  enddo
183  enddo
184  if( n_rot > 0 ) call fstr_rotinfo_finalize(rinfo)
185 
186  !
187  ! ------ Truss element Diagonal Modification
188  call truss_diag_modify(hecmat,hecmesh)
189 
190  !
191  ! ------ Equation boundary conditions
192  do ig0=1,fstrsolid%n_fix_mpc
193  if( fstrsolid%mpc_const(ig0) == 0.d0 ) cycle
194  ! we need to confirm if it is active in curr step here
195  rhs = fstrsolid%mpc_const(ig0)*factor
196  hecmesh%mpc%mpc_const(ig0) = rhs
197  enddo
198 
199  end subroutine fstr_addbc
200 
201 end module m_fstr_addbc
Essential boundary conditions kept as per-DOF marks and values so that they can be imposed on the mat...
subroutine, public hecmw_ebc_set(hecEBC, inode, idof, val)
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, hecEBC, 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:1251
integer(kind=kint), parameter kcaslagrange
contact analysis algorithm
Definition: m_fstr.F90:62
integer(kind=kint), parameter kststatic
Definition: m_fstr.F90:38
logical function fstr_isboundaryactive(fstrSOLID, nbc, cstep)
Definition: m_fstr.F90:1089
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:161