~gabriel1984sibiu/calculix/ccx

« back to all changes in this revision

Viewing changes to CalculiX/ccx_2.7/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-2014 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(9,6),ifacet(7,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
 
      data ifaceq /4,3,2,1,11,10,9,12,21,
118
 
     &            5,6,7,8,13,14,15,16,22,
119
 
     &            1,2,6,5,9,18,13,17,23,
120
 
     &            2,3,7,6,10,19,14,18,24,
121
 
     &            3,4,8,7,11,20,15,19,25,
122
 
     &            4,1,5,8,12,17,16,20,26/
123
 
      data ifacet /1,3,2,7,6,5,11,
124
 
     &             1,2,4,5,9,8,12,
125
 
     &             2,3,4,6,10,9,13,
126
 
     &             1,4,3,8,10,7,14/
127
 
      data ifacew /1,3,2,9,8,7,0,0,
128
 
     &             4,5,6,10,11,12,0,0,
129
 
     &             1,2,5,4,7,14,10,13,
130
 
     &             2,3,6,5,8,15,11,14,
131
 
     &             4,6,3,1,12,15,9,13/
132
 
      data iflag /3/
133
 
!
134
 
      include "gauss.f"
135
 
!
136
 
      nelem=noel
137
 
!
138
 
      if(lakonl(4:4).eq.'2') then
139
 
         nope=20
140
 
         nopes=8
141
 
      elseif(lakonl(4:4).eq.'8') then
142
 
         nope=8
143
 
         nopes=4
144
 
      elseif(lakonl(4:5).eq.'10') then
145
 
         nope=10
146
 
         nopes=6
147
 
      elseif(lakonl(4:4).eq.'4') then
148
 
         nope=4
149
 
         nopes=3
150
 
      elseif(lakonl(4:5).eq.'15') then
151
 
         nope=15
152
 
      elseif(lakonl(4:4).eq.'6') then
153
 
         nope=6
154
 
      endif
155
 
!     
156
 
!     treatment of wedge faces
157
 
!     
158
 
      if(lakonl(4:4).eq.'6') then
159
 
         if(ig.le.2) then
160
 
            nopes=3
161
 
         else
162
 
            nopes=4
163
 
         endif
164
 
      endif
165
 
      if(lakonl(4:5).eq.'15') then
166
 
         if(ig.le.2) then
167
 
            nopes=6
168
 
         else
169
 
            nopes=8
170
 
         endif
171
 
      endif
172
 
!
173
 
!     first side of the oil film
174
 
!     
175
 
      ig=1
176
 
!
177
 
      if((nope.eq.20).or.(nope.eq.8)) then
178
 
         do i=1,nopes
179
 
            node=konl(ifaceq(i,ig))
180
 
            idof=8*(node-1)+4
181
 
            call nident(ikmpc,idof,nmpc,id)
182
 
            if((id.eq.0).or.(ikmpc(id).ne.idof)) then
183
 
               write(*,*) '*ERROR in dflux: node ',node
184
 
               write(*,*) '       is not connected to the structure'
185
 
               stop
186
 
            endif
187
 
            node=nodempc(1,nodempc(3,ipompc(ilmpc(id))))
188
 
            do j=1,3
189
 
               xl21(j,i)=co(j,node)+
190
 
     &              vold(j,node)
191
 
            enddo
192
 
         enddo
193
 
      elseif((nope.eq.10).or.(nope.eq.4)) then
194
 
         write(*,*) '*ERROR in dload: tetrahedral elements'
195
 
         write(*,*) '       are not allowed'
196
 
         stop
197
 
      else
198
 
         do i=1,nopes
199
 
            node=konl(ifacew(i,ig))
200
 
            idof=8*(node-1)+4
201
 
            call nident(ikmpc,idof,nmpc,id)
202
 
            if((id.eq.0).or.(ikmpc(id).ne.idof)) then
203
 
               write(*,*) '*ERROR in dflux: node ',node
204
 
               write(*,*) '       is not connected to the structure'
205
 
               stop
206
 
            endif
207
 
            node=nodempc(1,nodempc(3,ipompc(ilmpc(id))))
208
 
            do j=1,3
209
 
               xl21(j,i)=co(j,node)+
210
 
     &              vold(j,node)
211
 
            enddo
212
 
         enddo
213
 
      endif
214
 
!
215
 
!     projecting the integration point on the first side of the
216
 
!     oil film
217
 
!
218
 
      do j=1,3
219
 
         pnode1(j)=coords(j)
220
 
      enddo
221
 
!
222
 
      call attach(xl21,pnode1,nopes,ratio,dist,xi,et)
223
 
224
 
!     derivative of the shape functions in (xi,et)
225
 
!    
226
 
      if(nopes.eq.8) then
227
 
         call shape8q(xi,et,xl21,xsj2,xs2,shp2,iflag)
228
 
      elseif(nopes.eq.4) then
229
 
         call shape4q(xi,et,xl21,xsj2,xs2,shp2,iflag)
230
 
      elseif(nopes.eq.6) then
231
 
         call shape6tri(xi,et,xl21,xsj2,xs2,shp2,iflag)
232
 
      else
233
 
         call shape3tri(xi,et,xl21,xsj2,xs2,shp2,iflag)
234
 
      endif
235
 
!
236
 
!     the gradient of pnode1 
237
 
!     dpnode1(j,k)=dpnode1(j)/dx(k)
238
 
!
239
 
      do i=1,3
240
 
         do j=1,3
241
 
            dpnode1(i,j)=0.d0
242
 
            do k=1,nopes
243
 
               dpnode1(i,j)=dpnode1(i,j)+shp2(j,k)*xl21(i,k)
244
 
            enddo
245
 
         enddo
246
 
      enddo
247
 
!
248
 
!     second side of the oil film
249
 
!     
250
 
      ig=2
251
 
!
252
 
      if((nope.eq.20).or.(nope.eq.8)) then
253
 
         do i=1,nopes
254
 
            node=konl(ifaceq(i,ig))
255
 
            idof=8*(node-1)+4
256
 
            call nident(ikmpc,idof,nmpc,id)
257
 
            if((id.eq.0).or.(ikmpc(id).ne.idof)) then
258
 
               write(*,*) '*ERROR in dflux: node ',node
259
 
               write(*,*) '       is not connected to the structure'
260
 
               stop
261
 
            endif
262
 
            node=nodempc(1,nodempc(3,ipompc(ilmpc(id))))
263
 
            do j=1,3
264
 
               xl22(j,i)=co(j,node)+
265
 
     &              vold(j,node)
266
 
            enddo
267
 
         enddo
268
 
      elseif((nope.eq.10).or.(nope.eq.4)) then
269
 
         write(*,*) '*ERROR in dload: tetrahedral elements'
270
 
         write(*,*) '       are not allowed'
271
 
         stop
272
 
      else
273
 
         do i=1,nopes
274
 
            node=konl(ifacew(i,ig))
275
 
            idof=8*(node-1)+4
276
 
            call nident(ikmpc,idof,nmpc,id)
277
 
            if((id.eq.0).or.(ikmpc(id).ne.idof)) then
278
 
               write(*,*) '*ERROR in dflux: node ',node
279
 
               write(*,*) '       is not connected to the structure'
280
 
               stop
281
 
            endif
282
 
            node=nodempc(1,nodempc(3,ipompc(ilmpc(id))))
283
 
            do j=1,3
284
 
               xl22(j,i)=co(j,node)+
285
 
     &              vold(j,node)
286
 
            enddo
287
 
         enddo
288
 
      endif
289
 
!
290
 
!     projecting the integration point on the second side of the
291
 
!     oil film
292
 
!
293
 
      do j=1,3
294
 
         pnode2(j)=coords(j)
295
 
      enddo
296
 
!
297
 
      call attach(xl22,pnode2,nopes,ratio,dist,xi,et)
298
 
299
 
!     derivative of the shape functions in (xi,et)
300
 
!    
301
 
      if(nopes.eq.8) then
302
 
         call shape8q(xi,et,xl22,xsj2,xs2,shp2,iflag)
303
 
      elseif(nopes.eq.4) then
304
 
         call shape4q(xi,et,xl22,xsj2,xs2,shp2,iflag)
305
 
      elseif(nopes.eq.6) then
306
 
         call shape6tri(xi,et,xl22,xsj2,xs2,shp2,iflag)
307
 
      else
308
 
         call shape3tri(xi,et,xl22,xsj2,xs2,shp2,iflag)
309
 
      endif
310
 
!
311
 
!     the gradient of pnode1 
312
 
!     dpnode2(j,k)=dpnode2(j)/dx(k)
313
 
!
314
 
      do i=1,3
315
 
         do j=1,3
316
 
            dpnode2(i,j)=0.d0
317
 
            do k=1,nopes
318
 
               dpnode2(i,j)=dpnode2(i,j)+shp2(j,k)*xl22(i,k)
319
 
            enddo
320
 
         enddo
321
 
      enddo
322
 
!
323
 
!     calculating the thickness of the oil film
324
 
!
325
 
      h=dsqrt((pnode1(1)-pnode2(1))**2+
326
 
     &        (pnode1(2)-pnode2(2))**2+
327
 
     &        (pnode1(3)-pnode2(3))**2)
328
 
!
329
 
!     calculating the gradient of the oil film thickness
330
 
!
331
 
      do i=1,3
332
 
         dh(i)=((pnode1(1)-pnode2(1))*(dpnode1(1,i)-dpnode2(1,i))
333
 
     &         +(pnode1(2)-pnode2(2))*(dpnode1(2,i)-dpnode2(2,i))
334
 
     &         +(pnode1(3)-pnode2(3))*(dpnode1(3,i)-dpnode2(3,i)))/h
335
 
      enddo
336
 
!
337
 
!     velocity of the parts adjoining the film
338
 
!     the axis or rotation is assumed to be the x-axis
339
 
!
340
 
      do i=1,3
341
 
         v1(i)=0.d0
342
 
      enddo
343
 
      v2(1)=0.d0
344
 
      v2(2)=-26000.d0*coords(3)/dsqrt(coords(2)**2+coords(3)**2)
345
 
      v2(3)=26000.d0*coords(2)/dsqrt(coords(2)**2+coords(3)**2)
346
 
!
347
 
!     density (oil, N-mm-s-K system)
348
 
!
349
 
      rho=890.d-9
350
 
!
351
 
!     body flux
352
 
!
353
 
      flux(1)=-rho*((v1(1)+v2(1))*dh(1)+
354
 
     &              (v1(2)+v2(2))*dh(2)+
355
 
     &              (v1(3)+v2(3))*dh(3))/2.d0
356
 
!
357
 
      iscale=0
358
 
!
359
 
      return
360
 
      end
361