CalculiX  2.13
A Free Software Three-Dimensional Structural Finite Element Program
bodyadd.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine bodyadd (cbody, ibody, xbody, nbody, nbody_, set, label, iamplitude, xmagnitude, p1, p2, bodyf, xbodyold, lc, idefbody)
 

Function/Subroutine Documentation

◆ bodyadd()

subroutine bodyadd ( character*81, dimension(*)  cbody,
integer, dimension(3,*)  ibody,
real*8, dimension(7,*)  xbody,
integer  nbody,
integer  nbody_,
character*81  set,
character*20  label,
integer  iamplitude,
real*8  xmagnitude,
real*8, dimension(3)  p1,
real*8, dimension(3)  p2,
real*8, dimension(3)  bodyf,
real*8, dimension(7,*)  xbodyold,
integer  lc,
integer, dimension(*)  idefbody 
)
21 !
22 ! adds a volumetric dload condition to the data base
23 !
24  implicit none
25 !
26  character*20 label
27  character*81 set,cbody(*)
28 !
29  integer ibody(3,*),nbody,nbody_,id,iamplitude,ilabel,i,j,id1,lc,
30  & idefbody(*)
31 !
32  real*8 xbody(7,*),p1(3),p2(3),bodyf(3),xmagnitude,xbodyold(7,*),
33  & dd,p(3)
34 !
35 ! assigning a number to the load type (stored in ibody(1,*))
36 !
37  if(label(1:7).eq.'CENTRIF') then
38  ilabel=1
39  elseif(label(1:4).eq.'GRAV') then
40  ilabel=2
41  elseif(label(1:6).eq.'NEWTON') then
42  ilabel=3
43  endif
44 !
45 ! normalizing the direction for gravity forces
46 !
47  if(ilabel.eq.2) then
48  dd=dsqrt(bodyf(1)*bodyf(1)+bodyf(2)*bodyf(2)+bodyf(3)*bodyf(3))
49  do i=1,3
50  bodyf(i)=bodyf(i)/dd
51  enddo
52  endif
53 !
54 ! checking whether a similar load type was already assigned to the
55 ! same set
56 !
57  call cident(cbody,set,nbody,id)
58 !
59  if(id.ne.0) then
60  do
61  if(id.eq.0) exit
62  if(cbody(id).eq.set) then
63  if(ibody(1,id).eq.ilabel) then
64 !
65 ! for gravity forces the gravity direction is
66 ! checked; if the direction is different,it is
67 ! a new loading
68 !
69  if(ilabel.eq.2) then
70  if(dabs(bodyf(1)*xbody(2,id)+bodyf(2)*xbody(3,id)+
71  & bodyf(3)*xbody(4,id)-1.d0).gt.1.d-10) then
72  id=id-1
73  cycle
74  endif
75  endif
76 !
77 ! for centrifugal loads the centrifugal axis is
78 ! checked
79 !
80  if(ilabel.eq.1) then
81  if(dabs(p2(1)*xbody(5,id)+p2(2)*xbody(6,id)+
82  & p2(3)*xbody(7,id)-1.d0).gt.1.d-10) then
83  id=id-1
84  cycle
85  endif
86  do i=1,3
87  p(i)=xbody(1+i,id)-p1(i)
88  enddo
89  dd=dsqrt(p(1)*p(1)+p(2)*p(2)+p(3)*p(3))
90  if(dd.gt.1.d-10) then
91  do i=1,3
92  p(i)=p(i)/dd
93  enddo
94  if(dabs(p(1)*xbody(5,id)+p(2)*xbody(6,id)+
95  & p(3)*xbody(7,id)-1.d0).gt.1.d-10) then
96  id=id-1
97  cycle
98  endif
99  endif
100  endif
101 !
102 ! check for the same loadcase
103 !
104  if(ibody(3,id).ne.lc) then
105  id=id-1
106  cycle
107  endif
108 !
109  ibody(2,id)=iamplitude
110  ibody(3,id)=lc
111  if(ilabel.eq.1) then
112  if(idefbody(id).eq.0) then
113  xbody(1,id)=xmagnitude
114  idefbody(id)=1
115  else
116  if(ibody(2,id).ne.iamplitude) then
117  write(*,*) '*ERROR in bodyadd:'
118  write(*,*) ' it is not allowed to add'
119  write(*,*)' two centrifugal loads with'
120  write(*,*) ' different amplitudes'
121  call exit(201)
122  endif
123  xbody(1,id)=xbody(1,id)+xmagnitude
124  endif
125  xbody(2,id)=p1(1)
126  xbody(3,id)=p1(2)
127  xbody(4,id)=p1(3)
128  xbody(5,id)=p2(1)
129  xbody(6,id)=p2(2)
130  xbody(7,id)=p2(3)
131  elseif(ilabel.eq.2) then
132  if(idefbody(id).eq.0) then
133  xbody(1,id)=xmagnitude
134  idefbody(id)=1
135  else
136  if(ibody(2,id).ne.iamplitude) then
137  write(*,*) '*ERROR in bodyadd:'
138  write(*,*) ' it is not allowed to add'
139  write(*,*) ' two gravity loads with'
140  write(*,*) ' different amplitudes'
141  call exit(201)
142  endif
143  xbody(1,id)=xbody(1,id)+xmagnitude
144  endif
145  xbody(2,id)=bodyf(1)
146  xbody(3,id)=bodyf(2)
147  xbody(4,id)=bodyf(3)
148  endif
149  return
150  endif
151  id=id-1
152  else
153  exit
154  endif
155  enddo
156  endif
157 !
158 ! new set/loadtype combination
159 !
160  nbody=nbody+1
161  if(nbody.gt.nbody_) then
162  write(*,*) '*ERROR in bodyadd: increase nbody_'
163  call exit(201)
164  endif
165 !
166 ! reordering the arrays
167 !
168  do i=nbody,id+2,-1
169  cbody(i)=cbody(i-1)
170  idefbody(i)=idefbody(i-1)
171  do j=1,3
172  ibody(j,i)=ibody(j,i-1)
173  enddo
174  do j=1,7
175  xbody(j,i)=xbody(j,i-1)
176  xbodyold(j,i)=xbodyold(j,i-1)
177  enddo
178  enddo
179 !
180 ! inserting the new values
181 !
182  id1=id+1
183 !
184  cbody(id1)=set
185  idefbody(id1)=1
186  ibody(1,id1)=ilabel
187  ibody(2,id1)=iamplitude
188  ibody(3,id1)=lc
189  if(ilabel.eq.1) then
190  xbody(1,id1)=xmagnitude
191  xbody(2,id1)=p1(1)
192  xbody(3,id1)=p1(2)
193  xbody(4,id1)=p1(3)
194  xbody(5,id1)=p2(1)
195  xbody(6,id1)=p2(2)
196  xbody(7,id1)=p2(3)
197  elseif(ilabel.eq.2) then
198  xbody(1,id1)=xmagnitude
199  xbody(2,id1)=bodyf(1)
200  xbody(3,id1)=bodyf(2)
201  xbody(4,id1)=bodyf(3)
202  endif
203 !
204  return
subroutine cident(x, px, n, id)
Definition: cident.f:26
Hosted by OpenAircraft.com, (Michigan UAV, LLC)