1! 2! CalculiX - A 3-dimensional finite element program 3! Copyright (C) 1998-2021 Guido Dhondt 4! 5! This program is free software; you can redistribute it and/or 6! modify it under the terms of the GNU General Public License as 7! published by the Free Software Foundation(version 2); 8! 9! 10! This program is distributed in the hope that it will be useful, 11! but WITHOUT ANY WARRANTY; without even the implied warranty of 12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13! GNU General Public License for more details. 14! 15! You should have received a copy of the GNU General Public License 16! along with this program; if not, write to the Free Software 17! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18! 19 subroutine localaxes(ibody,nbody,xbody,e1,e2,xn) 20! 21! determines a local axis system based on the rotation axis 22! defined on a CENTRIF card 23! 24 implicit none 25! 26 integer ibody(3,*),nbody,i,imax 27! 28 real*8 xbody(7,*),xn(3),e1(3),e2(3),xmax,dd 29! 30! xn: axis direction 31! 32 do i=1,nbody 33 if(ibody(1,i).eq.4) then 34 xn(1)=xbody(5,i) 35 xn(2)=xbody(6,i) 36 xn(3)=xbody(7,i) 37 exit 38 endif 39 enddo 40! 41! e1: unit vector orthogonal to xn 42! 43 if(xn(1).eq.0.d0) then 44 e1(1)=1.d0 45 e1(2)=0.d0 46 e1(3)=0.d0 47 elseif(xn(2).eq.0.d0) then 48 e1(1)=0.d0 49 e1(2)=1.d0 50 e1(3)=0.d0 51 elseif(xn(3).eq.0.d0) then 52 e1(1)=0.d0 53 e1(2)=0.d0 54 e1(3)=1.d0 55 else 56! 57! determining the maximum entry in xn in absolute value 58! 59 xmax=0.d0 60 if(dabs(xn(1)).gt.xmax) then 61 xmax=dabs(xn(1)) 62 imax=1 63 endif 64 if(dabs(xn(2)).gt.xmax) then 65 xmax=dabs(xn(2)) 66 imax=2 67 endif 68 if(dabs(xn(3)).gt.xmax) then 69 xmax=dabs(xn(3)) 70 imax=3 71 endif 72! 73! creating a vector orthogonal to xn using the maximum 74! component value of xn 75! 76 e1(1)=1.d0 77 e1(2)=1.d0 78 e1(3)=1.d0 79! 80 e1(imax)=-(xn(1)+xn(2)+xn(3)-xn(imax))/xn(imax) 81! 82! normalizing e1 83! 84 dd=dsqrt(e1(1)*e1(1)+e1(2)*e1(2)+e1(3)*e1(3)) 85 do i=1,3 86 e1(i)=e1(i)/dd 87 enddo 88 endif 89! 90! e2 = n x e1 91! 92 e2(1)=xn(2)*e1(3)-xn(3)*e1(2) 93 e2(2)=xn(3)*e1(1)-xn(1)*e1(3) 94 e2(3)=xn(1)*e1(2)-xn(2)*e1(1) 95! 96c write(*,*) 'localaxes',e1(1),e1(2),e1(3) 97c write(*,*) 'localaxes',e2(1),e2(2),e2(3) 98c write(*,*) 'localaxes',xn(1),xn(2),xn(3) 99! 100 return 101 end 102 103