FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
m_common_struct.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 !-------------------------------------------------------------------------------
7  implicit none
8  integer, parameter, private :: kreal = kind(0.0d0)
9 
11  character(len=128) :: sys_name
12  integer :: sys_type
15  integer :: node_id(3)
16  real(kind=kreal) :: coordsys(3, 3)
17  end type tlocalcoordsys
18 
19  type(tlocalcoordsys), pointer, save :: g_localcoordsys(:) => null()
20 
21  type trotinfo
22  integer :: n_rot
23  type(trotcond), pointer :: conds(:)
24  end type
25 
26  type trotcond
27  logical :: active
28  integer :: center_ngrp_id
29  integer :: torque_ngrp_id
30  real(kind=kreal) :: vec(3)
31  end type
32 
33 contains
34 
36  logical function iscoordneeds( coordsys )
37  type(tlocalcoordsys), intent(in) :: coordsys
38 
39  integer stype
40  iscoordneeds = .false.
41  stype = mod( coordsys%sys_type, 10 )
42  if( stype==0 ) iscoordneeds = .true.
43  end function
44 
46  subroutine set_localcoordsys(coords, coordsys, outsys, ierr)
47  use m_utilities, only: cross_product
48  real(kind=kreal), intent(inout) :: coords(:, :) ! coord needs to define local coord sys
49  type(tlocalcoordsys), intent(in) :: coordsys
50  real(kind=kreal), intent(out) :: outsys(3, 3)
51  integer, intent(out) :: ierr
52 
53  real(kind=kreal) :: f, xyza(3), xyzb(3), xyzc(3)
54  integer :: stype
55 
56  ierr = 0
57  stype = mod( coordsys%sys_type, 10 )
58 
59  if( stype==0 ) then ! given coordinates
60  outsys = coordsys%CoordSys
61  elseif( stype>=1 ) then ! given nodes id
62  xyza = coords(1,:)-coords(3,:)
63  xyzb = coords(2,:)-coords(3,:)
64  call cross_product(xyza,xyzb,xyzc)
65  f = dsqrt( dot_product( xyza, xyza ) )
66  outsys(1,:) = xyza/f
67  f = dsqrt( dot_product( xyzc, xyzc ) )
68  outsys(3,:) = xyzc/f
69  call cross_product(outsys(3,:), outsys(1,:), outsys(2,:) )
70  endif
71  end subroutine
72 
73  subroutine fstr_rotinfo_init(n, rinfo)
74  integer, intent(in) :: n
75  type(trotinfo), intent(inout) :: rinfo
76 
77  integer :: i
78 
79  if( n < 1 ) return
80 
81  rinfo%n_rot = n
82  allocate(rinfo%conds(n))
83  do i=1,n
84  rinfo%conds(i)%active = .false.
85  rinfo%conds(i)%center_ngrp_id = -1
86  rinfo%conds(i)%torque_ngrp_id = -1
87  rinfo%conds(i)%vec(1:3) = 0.d0
88  enddo
89  end subroutine
90 
91  subroutine fstr_rotinfo_finalize(rinfo)
92  type(trotinfo), intent(inout) :: rinfo
93 
94  rinfo%n_rot = 0
95  if( associated(rinfo%conds)) deallocate(rinfo%conds)
96  end subroutine
97 
98 end module
This modules defines common structures for fem analysis.
logical function iscoordneeds(coordsys)
if need to fetch global nodes' coordinate
subroutine fstr_rotinfo_init(n, rinfo)
type(tlocalcoordsys), dimension(:), pointer, save g_localcoordsys
subroutine set_localcoordsys(coords, coordsys, outsys, ierr)
setup of coordinate system
subroutine fstr_rotinfo_finalize(rinfo)
This module provides aux functions.
Definition: utilities.f90:6
subroutine cross_product(v1, v2, vn)
Definition: utilities.f90:406