~gabriel1984sibiu/calculix/ccx

« back to all changes in this revision

Viewing changes to CalculiX/ccx_2.11/src/dflux.f

  • Committer: Grevutiu Gabriel
  • Date: 2016-12-30 12:06:41 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20161230120641-kzmhfy8mn00w3mhg
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
!
 
2
!     CalculiX - A 3-dimensional finite element program
 
3
!              Copyright (C) 1998-2015 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 dflux(flux,sol,kstep,kinc,time,noel,npt,coords,
 
20
     &     jltyp,temp,press,loadtype,area,vold,co,lakonl,konl,
 
21
     &     ipompc,nodempc,coefmpc,nmpc,ikmpc,ilmpc,iscale,mi)
 
22
!
 
23
!     user subroutine dflux
 
24
!
 
25
!
 
26
!     INPUT:
 
27
!
 
28
!     sol                current temperature value
 
29
!     kstep              step number
 
30
!     kinc               increment number
 
31
!     time(1)            current step time
 
32
!     time(2)            current total time
 
33
!     noel               element number
 
34
!     npt                integration point number
 
35
!     coords(1..3)       global coordinates of the integration point
 
36
!     jltyp              loading face kode:
 
37
!                        1  = body flux
 
38
!                        11 = face 1 
 
39
!                        12 = face 2 
 
40
!                        13 = face 3 
 
41
!                        14 = face 4 
 
42
!                        15 = face 5 
 
43
!                        16 = face 6
 
44
!     temp               currently not used
 
45
!     press              currently not used
 
46
!     loadtype           load type label
 
47
!     area               for surface flux: area covered by the
 
48
!                            integration point
 
49
!                        for body flux: volume covered by the
 
50
!                            integration point
 
51
!     vold(0..4,1..nk)   solution field in all nodes
 
52
!                        0: temperature
 
53
!                        1: displacement in global x-direction
 
54
!                        2: displacement in global y-direction
 
55
!                        3: displacement in global z-direction
 
56
!                        4: static pressure
 
57
!     co(3,1..nk)        coordinates of all nodes
 
58
!                        1: coordinate in global x-direction
 
59
!                        2: coordinate in global y-direction
 
60
!                        3: coordinate in global z-direction
 
61
!     lakonl             element label
 
62
!     konl(1..20)        nodes belonging to the element
 
63
!     ipompc(1..nmpc))   ipompc(i) points to the first term of
 
64
!                        MPC i in field nodempc
 
65
!     nodempc(1,*)       node number of a MPC term
 
66
!     nodempc(2,*)       coordinate direction of a MPC term
 
67
!     nodempc(3,*)       if not 0: points towards the next term
 
68
!                                  of the MPC in field nodempc
 
69
!                        if 0: MPC definition is finished
 
70
!     coefmpc(*)         coefficient of a MPC term
 
71
!     nmpc               number of MPC's
 
72
!     ikmpc(1..nmpc)     ordered global degrees of freedom of the MPC's
 
73
!                        the global degree of freedom is
 
74
!                        8*(node-1)+direction of the dependent term of
 
75
!                        the MPC (direction = 0: temperature;
 
76
!                        1-3: displacements; 4: static pressure;
 
77
!                        5-7: rotations)
 
78
!     ilmpc(1..nmpc)     ilmpc(i) is the MPC number corresponding
 
79
!                        to the reference number in ikmpc(i)   
 
80
!     mi(1)              max # of integration points per element (max
 
81
!                        over all elements)
 
82
!     mi(2)              max degree of freedomm per node (max over all
 
83
!                        nodes) in fields like v(0:mi(2))...
 
84
!
 
85
!     OUTPUT:
 
86
!
 
87
!     flux(1)            magnitude of the flux
 
88
!     flux(2)            not used; please do NOT assign any value
 
89
!     iscale             determines whether the flux has to be
 
90
!                        scaled for increments smaller than the 
 
91
!                        step time in static calculations
 
92
!                        0: no scaling
 
93
!                        1: scaling (default)
 
94
!           
 
95
      implicit none
 
96
!
 
97
      character*8 lakonl
 
98
      character*20 loadtype
 
99
!
 
100
      integer kstep,kinc,noel,npt,jltyp,konl(20),ipompc(*),
 
101
     &  nodempc(3,*),nmpc,ikmpc(*),ilmpc(*),node,idof,id,iscale,mi(*)
 
102
!
 
103
      real*8 flux(2),time(2),coords(3),sol,temp,press,vold(0:mi(2),*),
 
104
     &  area,co(3,*),coefmpc(*)
 
105
!
 
106
!     the code starting here up to the end of the file serves as
 
107
!     an example for combined mechanical-lubrication problems. 
 
108
!     Please replace it by your own code for your concrete application.
 
109
!
 
110
      integer ifaceq(8,6),ifacet(6,4),ifacew(8,5),ig,nelem,nopes,
 
111
     &  iflag,i,j,k,nope
 
112
!
 
113
      real*8 xl21(3,9),xi,et,al,rho,um,h,pnode1(3),pnode2(3),
 
114
     &  ratio(9),dist,xl22(3,9),dpnode1(3,3),dpnode2(3,3),v1(3),
 
115
     &  v2(3),dh(3),xsj2(3),xs2(3,7),shp2(7,8)
 
116
!
 
117
      intent(in) sol,kstep,kinc,time,noel,npt,coords,
 
118
     &     jltyp,temp,press,loadtype,area,vold,co,lakonl,konl,
 
119
     &     ipompc,nodempc,coefmpc,nmpc,ikmpc,ilmpc,mi
 
120
!
 
121
      intent(out) flux,iscale
 
122
!
 
123
      include "gauss.f"
 
124
!
 
125
      ifaceq=reshape((/4,3,2,1,11,10,9,12,
 
126
     &            5,6,7,8,13,14,15,16,
 
127
     &            1,2,6,5,9,18,13,17,
 
128
     &            2,3,7,6,10,19,14,18,
 
129
     &            3,4,8,7,11,20,15,19,
 
130
     &            4,1,5,8,12,17,16,20/),(/8,6/))
 
131
      ifacet=reshape((/1,3,2,7,6,5,
 
132
     &             1,2,4,5,9,8,
 
133
     &             2,3,4,6,10,9,
 
134
     &             1,4,3,8,10,7/),(/6,4/))
 
135
      ifacew=reshape((/1,3,2,9,8,7,0,0,
 
136
     &             4,5,6,10,11,12,0,0,
 
137
     &             1,2,5,4,7,14,10,13,
 
138
     &             2,3,6,5,8,15,11,14,
 
139
     &             4,6,3,1,12,15,9,13/),(/8,5/))
 
140
      iflag=3
 
141
!
 
142
      nelem=noel
 
143
!
 
144
      if(lakonl(4:4).eq.'2') then
 
145
         nope=20
 
146
         nopes=8
 
147
      elseif(lakonl(4:4).eq.'8') then
 
148
         nope=8
 
149
         nopes=4
 
150
      elseif(lakonl(4:5).eq.'10') then
 
151
         nope=10
 
152
         nopes=6
 
153
      elseif(lakonl(4:4).eq.'4') then
 
154
         nope=4
 
155
         nopes=3
 
156
      elseif(lakonl(4:5).eq.'15') then
 
157
         nope=15
 
158
      elseif(lakonl(4:4).eq.'6') then
 
159
         nope=6
 
160
      endif
 
161
!     
 
162
!     treatment of wedge faces
 
163
!     
 
164
      if(lakonl(4:4).eq.'6') then
 
165
         if(ig.le.2) then
 
166
            nopes=3
 
167
         else
 
168
            nopes=4
 
169
         endif
 
170
      endif
 
171
      if(lakonl(4:5).eq.'15') then
 
172
         if(ig.le.2) then
 
173
            nopes=6
 
174
         else
 
175
            nopes=8
 
176
         endif
 
177
      endif
 
178
!
 
179
!     first side of the oil film
 
180
!     
 
181
      ig=1
 
182
!
 
183
      if((nope.eq.20).or.(nope.eq.8)) then
 
184
         do i=1,nopes
 
185
            node=konl(ifaceq(i,ig))
 
186
            idof=8*(node-1)+4
 
187
            call nident(ikmpc,idof,nmpc,id)
 
188
            if((id.eq.0).or.(ikmpc(id).ne.idof)) then
 
189
               write(*,*) '*ERROR in dflux: node ',node
 
190
               write(*,*) '       is not connected to the structure'
 
191
               call exit(201)
 
192
            endif
 
193
            node=nodempc(1,nodempc(3,ipompc(ilmpc(id))))
 
194
            do j=1,3
 
195
               xl21(j,i)=co(j,node)+
 
196
     &              vold(j,node)
 
197
            enddo
 
198
         enddo
 
199
      elseif((nope.eq.10).or.(nope.eq.4)) then
 
200
         write(*,*) '*ERROR in dload: tetrahedral elements'
 
201
         write(*,*) '       are not allowed'
 
202
         call exit(201)
 
203
      else
 
204
         do i=1,nopes
 
205
            node=konl(ifacew(i,ig))
 
206
            idof=8*(node-1)+4
 
207
            call nident(ikmpc,idof,nmpc,id)
 
208
            if((id.eq.0).or.(ikmpc(id).ne.idof)) then
 
209
               write(*,*) '*ERROR in dflux: node ',node
 
210
               write(*,*) '       is not connected to the structure'
 
211
               call exit(201)
 
212
            endif
 
213
            node=nodempc(1,nodempc(3,ipompc(ilmpc(id))))
 
214
            do j=1,3
 
215
               xl21(j,i)=co(j,node)+
 
216
     &              vold(j,node)
 
217
            enddo
 
218
         enddo
 
219
      endif
 
220
!
 
221
!     projecting the integration point on the first side of the
 
222
!     oil film
 
223
!
 
224
      do j=1,3
 
225
         pnode1(j)=coords(j)
 
226
      enddo
 
227
!
 
228
      call attach(xl21,pnode1,nopes,ratio,dist,xi,et)
 
229
 
230
!     derivative of the shape functions in (xi,et)
 
231
!    
 
232
      if(nopes.eq.8) then
 
233
         call shape8q(xi,et,xl21,xsj2,xs2,shp2,iflag)
 
234
      elseif(nopes.eq.4) then
 
235
         call shape4q(xi,et,xl21,xsj2,xs2,shp2,iflag)
 
236
      elseif(nopes.eq.6) then
 
237
         call shape6tri(xi,et,xl21,xsj2,xs2,shp2,iflag)
 
238
      else
 
239
         call shape3tri(xi,et,xl21,xsj2,xs2,shp2,iflag)
 
240
      endif
 
241
!
 
242
!     the gradient of pnode1 
 
243
!     dpnode1(j,k)=dpnode1(j)/dx(k)
 
244
!
 
245
      do i=1,3
 
246
         do j=1,3
 
247
            dpnode1(i,j)=0.d0
 
248
            do k=1,nopes
 
249
               dpnode1(i,j)=dpnode1(i,j)+shp2(j,k)*xl21(i,k)
 
250
            enddo
 
251
         enddo
 
252
      enddo
 
253
!
 
254
!     second side of the oil film
 
255
!     
 
256
      ig=2
 
257
!
 
258
      if((nope.eq.20).or.(nope.eq.8)) then
 
259
         do i=1,nopes
 
260
            node=konl(ifaceq(i,ig))
 
261
            idof=8*(node-1)+4
 
262
            call nident(ikmpc,idof,nmpc,id)
 
263
            if((id.eq.0).or.(ikmpc(id).ne.idof)) then
 
264
               write(*,*) '*ERROR in dflux: node ',node
 
265
               write(*,*) '       is not connected to the structure'
 
266
               call exit(201)
 
267
            endif
 
268
            node=nodempc(1,nodempc(3,ipompc(ilmpc(id))))
 
269
            do j=1,3
 
270
               xl22(j,i)=co(j,node)+
 
271
     &              vold(j,node)
 
272
            enddo
 
273
         enddo
 
274
      elseif((nope.eq.10).or.(nope.eq.4)) then
 
275
         write(*,*) '*ERROR in dload: tetrahedral elements'
 
276
         write(*,*) '       are not allowed'
 
277
         call exit(201)
 
278
      else
 
279
         do i=1,nopes
 
280
            node=konl(ifacew(i,ig))
 
281
            idof=8*(node-1)+4
 
282
            call nident(ikmpc,idof,nmpc,id)
 
283
            if((id.eq.0).or.(ikmpc(id).ne.idof)) then
 
284
               write(*,*) '*ERROR in dflux: node ',node
 
285
               write(*,*) '       is not connected to the structure'
 
286
               call exit(201)
 
287
            endif
 
288
            node=nodempc(1,nodempc(3,ipompc(ilmpc(id))))
 
289
            do j=1,3
 
290
               xl22(j,i)=co(j,node)+
 
291
     &              vold(j,node)
 
292
            enddo
 
293
         enddo
 
294
      endif
 
295
!
 
296
!     projecting the integration point on the second side of the
 
297
!     oil film
 
298
!
 
299
      do j=1,3
 
300
         pnode2(j)=coords(j)
 
301
      enddo
 
302
!
 
303
      call attach(xl22,pnode2,nopes,ratio,dist,xi,et)
 
304
 
305
!     derivative of the shape functions in (xi,et)
 
306
!    
 
307
      if(nopes.eq.8) then
 
308
         call shape8q(xi,et,xl22,xsj2,xs2,shp2,iflag)
 
309
      elseif(nopes.eq.4) then
 
310
         call shape4q(xi,et,xl22,xsj2,xs2,shp2,iflag)
 
311
      elseif(nopes.eq.6) then
 
312
         call shape6tri(xi,et,xl22,xsj2,xs2,shp2,iflag)
 
313
      else
 
314
         call shape3tri(xi,et,xl22,xsj2,xs2,shp2,iflag)
 
315
      endif
 
316
!
 
317
!     the gradient of pnode1 
 
318
!     dpnode2(j,k)=dpnode2(j)/dx(k)
 
319
!
 
320
      do i=1,3
 
321
         do j=1,3
 
322
            dpnode2(i,j)=0.d0
 
323
            do k=1,nopes
 
324
               dpnode2(i,j)=dpnode2(i,j)+shp2(j,k)*xl22(i,k)
 
325
            enddo
 
326
         enddo
 
327
      enddo
 
328
!
 
329
!     calculating the thickness of the oil film
 
330
!
 
331
      h=dsqrt((pnode1(1)-pnode2(1))**2+
 
332
     &        (pnode1(2)-pnode2(2))**2+
 
333
     &        (pnode1(3)-pnode2(3))**2)
 
334
!
 
335
!     calculating the gradient of the oil film thickness
 
336
!
 
337
      do i=1,3
 
338
         dh(i)=((pnode1(1)-pnode2(1))*(dpnode1(1,i)-dpnode2(1,i))
 
339
     &         +(pnode1(2)-pnode2(2))*(dpnode1(2,i)-dpnode2(2,i))
 
340
     &         +(pnode1(3)-pnode2(3))*(dpnode1(3,i)-dpnode2(3,i)))/h
 
341
      enddo
 
342
!
 
343
!     velocity of the parts adjoining the film
 
344
!     the axis or rotation is assumed to be the x-axis
 
345
!
 
346
      do i=1,3
 
347
         v1(i)=0.d0
 
348
      enddo
 
349
      v2(1)=0.d0
 
350
      v2(2)=-26000.d0*coords(3)/dsqrt(coords(2)**2+coords(3)**2)
 
351
      v2(3)=26000.d0*coords(2)/dsqrt(coords(2)**2+coords(3)**2)
 
352
!
 
353
!     density (oil, N-mm-s-K system)
 
354
!
 
355
      rho=890.d-9
 
356
!
 
357
!     body flux
 
358
!
 
359
      flux(1)=-rho*((v1(1)+v2(1))*dh(1)+
 
360
     &              (v1(2)+v2(2))*dh(2)+
 
361
     &              (v1(3)+v2(3))*dh(3))/2.d0
 
362
!
 
363
      iscale=0
 
364
!
 
365
      return
 
366
      end
 
367