FrontISTR  5.7.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  call table_amp(hecmesh,fstrsolid,cstep,jj_n_amp,fstr_get_time(),factor0)
58  call table_amp(hecmesh,fstrsolid,cstep,jj_n_amp,fstr_get_time()+fstr_get_timeinc(),factor)
59  endif
60  factor = factor - factor0
61  if(fstrsolid%step_ctrl(cstep)%solution==stepvisco)then
62  factor = 0.d0
63  if(factor0 < 1.d-10) factor = 1.d0
64  endif
65  endif
66 
67  if( .not. fstr_isboundaryactive( fstrsolid, grpid, cstep ) ) cycle
68  ig = fstrsolid%BOUNDARY_ngrp_ID(ig0)
69  rhs0 = fstrsolid%BOUNDARY_ngrp_val(ig0)
70  !
71  ityp = fstrsolid%BOUNDARY_ngrp_type(ig0)
72  idofs = ityp/10
73  idofe = ityp - idofs*10
74  !
75  istot = fstrsolid%BOUNDARY_ngrp_istot(ig0)
76  !
77  is0 = hecmesh%node_group%grp_index(ig-1) + 1
78  ie0 = hecmesh%node_group%grp_index(ig )
79 
80  if( fstrsolid%BOUNDARY_ngrp_rotID(ig0) > 0 ) then ! setup rotation information
81  rid = fstrsolid%BOUNDARY_ngrp_rotID(ig0)
82  if( .not. rinfo%conds(rid)%active ) then
83  rinfo%conds(rid)%active = .true.
84  rinfo%conds(rid)%center_ngrp_id = fstrsolid%BOUNDARY_ngrp_centerID(ig0)
85  rinfo%conds(rid)%torque_ngrp_id = ig
86  endif
87  if( istot == 0 ) then
88  rhs= rhs0*factor
89  else
90  ! not implemented yet
91  write(*,*) 'Error: rotational boundary cannot be specified with total value'
92  call hecmw_abort( hecmw_comm_get_comm() )
93  endif
94  do idof=idofs,idofe
95  if( idof>ndof ) then
96  rinfo%conds(rid)%vec(idof-ndof) = rhs
97  else
98  rinfo%conds(rid)%vec(idof) = rhs
99  endif
100  enddo
101  cycle
102  endif
103 
104  !
105  do ik = is0, ie0
106  in = hecmesh%node_group%grp_item(ik)
107  !
108  do idof = idofs, idofe
109  if( istot == 0 ) then
110  rhs = rhs0*factor
111  else
112  rhs = (rhs0 - fstrsolid%unode_bak(ndof*(in-1)+idof))*factor
113  endif
114  if(present(rhsvector)) then
115  rhsvector(ndof*(in-1)+idof) = rhs
116  ! write(6,*) 'BC: ', ndof*(in-1)+idof, RHS
117  cycle
118  endif
119  if(present(conmat)) then
120  call hecmw_mat_ass_bc(hecmat, in, idof, rhs, conmat)
121  else
122  call hecmw_mat_ass_bc(hecmat, in, idof, rhs)
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, hecmat%B)
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  if(present(rhsvector)) then
168  rhsvector(ndof*(in-1)+idof) = rhs
169  ! write(6,*) 'BC(rot): ', ndof*(in-1)+idof, RHS
170  cycle
171  endif
172  if(present(conmat)) then
173  call hecmw_mat_ass_bc(hecmat, in, idof, rhs, conmat)
174  else
175  call hecmw_mat_ass_bc(hecmat, in, idof, rhs)
176  endif
177  if( fstr_is_contact_active() .and. fstrparam%solution_type == kststatic &
178  .and. fstrparam%contact_algo == kcaslagrange ) then
179  if(present(conmat)) then
180  call hecmw_mat_ass_bc_contactlag(conmat,heclagmat,in,idof,rhs)
181  else
182  call hecmw_mat_ass_bc_contactlag(hecmat,heclagmat,in,idof,rhs)
183  endif
184  endif
185  enddo
186  enddo
187  enddo
188  if( n_rot > 0 ) call fstr_rotinfo_finalize(rinfo)
189 
190  !
191  ! ------ Truss element Diagonal Modification
192  call truss_diag_modify(hecmat,hecmesh)
193 
194  !
195  ! ------ Equation boundary conditions
196  do ig0=1,fstrsolid%n_fix_mpc
197  if( fstrsolid%mpc_const(ig0) == 0.d0 ) cycle
198  ! we need to confirm if it is active in curr step here
199  rhs = fstrsolid%mpc_const(ig0)*factor
200  hecmesh%mpc%mpc_const(ig0) = rhs
201  enddo
202 
203  end subroutine fstr_addbc
204 
205 end module m_fstr_addbc
m_utilities::rotate_3dvector_by_rodrigues_formula
subroutine rotate_3dvector_by_rodrigues_formula(r, v)
Definition: utilities.f90:515
m_fstr_timeinc
This module provides functions to deal with time and increment of stress analysis.
Definition: fstr_Ctrl_TimeInc.f90:7
m_utilities
This module provides aux functions.
Definition: utilities.f90:6
m_fstr_timeinc::fstr_get_time
real(kind=kreal) function fstr_get_time()
Definition: fstr_Ctrl_TimeInc.f90:22
m_fstr::fstr_solid
Definition: m_fstr.f90:238
m_fstr::fstr_param
FSTR INNER CONTROL PARAMETERS (fstrPARAM)
Definition: m_fstr.f90:154
m_static_lib_1d::truss_diag_modify
subroutine truss_diag_modify(hecMAT, hecMESH)
Definition: static_LIB_1d.f90:250
m_fstr::fstr_isboundaryactive
logical function fstr_isboundaryactive(fstrSOLID, nbc, cstep)
Definition: m_fstr.f90:1028
m_fstr::kcaslagrange
integer(kind=kint), parameter kcaslagrange
contact analysis algorithm
Definition: m_fstr.f90:59
m_fstr::kststatic
integer(kind=kint), parameter kststatic
Definition: m_fstr.f90:37
m_fstr
This module defines common data and basic structures for analysis.
Definition: m_fstr.f90:15
mcontact::fstr_is_contact_active
logical function fstr_is_contact_active()
Definition: fstr_contact.f90:52
m_fstr::table_amp
subroutine table_amp(hecMESH, fstrSOLID, cstep, jj_n_amp, time, f_t)
Definition: m_fstr.f90:1155
m_fstr_addbc::fstr_addbc
subroutine fstr_addbc(cstep, hecMESH, hecMAT, fstrSOLID, fstrPARAM, hecLagMAT, iter, conMAT, RHSvector)
Add Essential Boundary Conditions.
Definition: fstr_AddBC.f90:14
m_fstr_addbc
This module provides a function to deal with prescribed displacement.
Definition: fstr_AddBC.f90:7
m_static_lib_1d
This module provide common functions of 3D truss elements.
Definition: static_LIB_1d.f90:6
m_fstr_timeinc::fstr_get_timeinc
real(kind=kreal) function fstr_get_timeinc()
Definition: fstr_Ctrl_TimeInc.f90:26
mcontact
This module provides functions to calculate contact stiff matrix.
Definition: fstr_contact.f90:6