-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeamIO.f90
executable file
·376 lines (296 loc) · 14.9 KB
/
BeamIO.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
! ================================================================================================================================================
! Beam Input/Output subroutines
! ================================================================================================================================================
subroutine InitBeamFiles()
use share_vars
use motion
implicit none
character(len=1) :: beamstr
integer :: i
if (iSaveBeam == 1) then
do i=1, iBeam
write(beamstr,'(i1)') i
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_x'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_y'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_vx'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_vy'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_pressure'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_theta'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_theta_dot'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_data'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
write (14,'(A)') "% beam data file, all quantities for the end point "
write (14,'(A)') "% time pressure(ns-1) pressure(3ns/4) pressure(ns/2) x-coordinate y-coordinate x-velocity y-velocity theta theta_dot drag lift drag_unst lift_unst F_press_x F_press_y E_kin_solid E_elastic_sol E_potential "
close (14)
enddo
elseif (iSaveBeam == 3) then
do i=1, iBeam
write(beamstr,'(i1)') i
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_data'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
write (14,'(A)') "% beam data file, all quantities for the end point "
write (14,'(A)') "% time pressure(ns-1) pressure(3ns/4) pressure(ns/2) x-coordinate y-coordinate x-velocity y-velocity theta theta_dot drag lift drag_unst lift_unst F_press_x F_press_y F_INERT_x F_INERT_y E_kin_solid E_elastic_sol E_potential "
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_complete'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
close (14)
enddo
endif
do i = 1, iBeam
write (beamstr,'(i1)') i
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'mouvement'//beamstr, status = 'replace')
call WriteHeaderToFile(14)
write (14,'(A)') " % time alpha alpha_t alpha_tt x-pos y-pos x-vel y-vel x-accel y-accel"
close (14)
enddo
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'energies', status = 'replace')
call WriteHeaderToFile(14)
write (14,'(A)') "% time dt vor_rms E_kinetic_f dissipation Penalty diss Inflow Solid Inflow Mean "
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'u_max', status = 'replace')
call WriteHeaderToFile(14)
write (14,'(A)') "% time dt u_max mean_ux mean_uy"
close (14)
call RewriteStopFile
!----------------------------------------------------------------------------------------------------------------------------
open (10, file = trim(dir_name)//'/'//trim(simulation_name)//"performance_details", status = 'replace')
write (10,'(A)') "% time_left runtime time dt sec / dt sum time_NST time_pressure time_mask time_solid"
close (10)
end subroutine InitBeamFiles
! =================================================================================================================================================================================
subroutine SaveBeamData( time, beams, dt1 )
use share_vars
use SolidSolver
use motion
implicit none
real (kind=pr), intent (in) :: time,dt1
type (solid), dimension(1:iBeam), intent (in) :: beams
character(len=16) :: format_ns1
character(len=3) :: ns1_string
character(len=1) :: beamstr
real (kind=pr) :: alpha, alpha_t, alpha_tt , dx, dy
real (kind=pr), dimension(1:6) :: LeadingEdge !LeadingEdge: x, y, vx, vy, ax, ay (Array)
integer :: n,step,i
dx=xl/real(nx)
dy=yl/real(ny)
! set up formats
write(ns1_string, '(I3)') ns+1
format_ns1 = '('//ns1_string//'(es12.5,1x))'
!--------------------------------------------------------------
! save the entire beam data ?
!--------------------------------------------------------------
if (iSaveBeam==1) then !save the entire beam
do i=1, iBeam
write (beamstr,'(i1)') i
step=1 ! save the entire beam? or only every 2..3 points?
! Save the pressure-jumps at the beampoint, after multiplying with startup conditioner
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_pressure'//beamstr, status = 'unknown', access = 'append')
write (14, format_ns1) time, (beams(i)%pressure_new(n), n=0,ns-1,step)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_theta'//beamstr, status = 'unknown', access = 'append')
write (14, format_ns1) time, (beams(i)%theta(n), n=0,ns-1,step)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_x'//beamstr, status = 'unknown', access = 'append')
write (14, format_ns1) time, (beams(i)%x(n), n=0,ns-1,step)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_y'//beamstr, status = 'unknown', access = 'append')
write (14, format_ns1) time, (beams(i)%y(n), n=0,ns-1,step)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_vx'//beamstr, status = 'unknown', access = 'append')
write (14, format_ns1) time, (beams(i)%vx(n), n=0,ns-1,step)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_vy'//beamstr, status = 'unknown', access = 'append')
write (14, format_ns1) time, (beams(i)%vy(n), n=0,ns-1,step)
close (14)
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_data'//beamstr, status = 'unknown', access = 'append')
write (14, '(21(es15.8,1x))') &
time,&
beams(i)%pressure_new(ns-1),&
beams(i)%pressure_new(3*ns/4),&
beams(i)%pressure_new(ns/2),&
beams(i)%x(ns-1),&
beams(i)%y(ns-1),&
beams(i)%vx(ns-1),&
beams(i)%vy(ns-1),&
beams(i)%theta(ns-1),&
beams(i)%theta_dot(ns-1),&
beams(i)%Force(1),&
beams(i)%Force(2),&
beams(i)%Force_unst(1),&
beams(i)%Force_unst(2),&
beams(i)%Force_press(1),&
beams(i)%Force_press(2),&
beams(i)%Inertial_Force(1),&
beams(i)%Inertial_Force(2),&
beams(i)%E_kinetic,&
beams(i)%E_elastic,&
beams(i)%E_pot
close (14)
enddo
!--------------------------------------------------------------
! save the end-point beam data ?
!--------------------------------------------------------------
elseif (iSaveBeam == 3) then !save only the last point
do i=1, iBeam ! loop over beams
! for naming files..
write (beamstr,'(i1)') i
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_data'//beamstr, status = 'unknown', access = 'append')
write (14, '(21(es15.8,1x))') &
time,&
beams(i)%pressure_new(ns-1),&
beams(i)%pressure_new(3*ns/4),&
beams(i)%pressure_new(ns/2),&
beams(i)%x(ns-1),&
beams(i)%y(ns-1),&
beams(i)%vx(ns-1),&
beams(i)%vy(ns-1),&
beams(i)%theta(ns-1),&
beams(i)%theta_dot(ns-1),&
beams(i)%Force(1),&
beams(i)%Force(2),&
beams(i)%Force_unst(1),&
beams(i)%Force_unst(2),&
beams(i)%Force_press(1),&
beams(i)%Force_press(2),&
beams(i)%Inertial_Force(1),&
beams(i)%Inertial_Force(2),&
beams(i)%E_kinetic,&
beams(i)%E_elastic,&
beams(i)%E_pot
close (14)
enddo
endif
!*********************
! the drag / lift is still saved
! in cases where no beam is present.
! however, as there will be no
!*********************
!--------------------------------------------------------------
! save leading edge motions
!--------------------------------------------------------------
do i=1, iBeam
write (beamstr,'(i1)') i
call mouvement(time, alpha, alpha_t, alpha_tt, LeadingEdge, beams(i) )
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'mouvement'//beamstr, status = 'unknown', access = 'append')
write (14, '(10(es15.8,1x))') time, alpha, alpha_t, alpha_tt, (LeadingEdge(n), n=1,6)
close (14)
enddo
end subroutine SaveBeamData
subroutine SaveDeflectionLine ( time, beams )
! --------------------------------------------------------------------------------------------------------
! just save deflection line (complete beam, full resolution)
! --------------------------------------------------------------------------------------------------------
use share_vars
implicit none
real (kind=pr), intent (in) :: time
character(len=22) :: format_ns
character(len=1) :: beamstr
type(solid), dimension(1:iBeam), intent(in) :: beams
integer :: n,i
do i = 1, iBeam
!--for naming files..
write (beamstr,'(i1)') i
write (format_ns, '("(",(i4.4),"(es12.5,1x))")') 2*ns+1
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_complete'//beamstr, status = 'unknown', access = 'append')
write (14, format_ns) time, (beams(i)%x(n), n=0,ns-1), (beams(i)%y(n), n=0,ns-1)
close (14)
enddo
end subroutine SaveDeflectionLine
subroutine SaveBeamPositions ( time, beams )
! --------------------------------------------------------------------------------------------------------
! this subroutine saves a complete deflection line, but it uses only 100 points (if there are enough)
! higher resolutions are not really required (and there may be buffer overflows in that case)
!
! corrected 05 apr 2012 now working correctly
!
! --------------------------------------------------------------------------------------------------------
use share_vars
implicit none
real (kind=pr), intent (in) :: time
type(solid), dimension(1:iBeam), intent(in) :: beams
character(len=16) :: format_ns
character(len=3) :: ns_string
character(len=1) :: beamstr
integer :: n,i,nsave=100, step, points
! loop over beams
do i = 1, iBeam
write(beamstr,'(i1)') i
if ((iSaveBeam==3).and.(ns>=100)) then
!more than 100 points on the beam
step=ns/nsave ! integer division
points = ns/step !integer division
write(ns_string, '(I3)') 2*points+1+4 !take a bit more place in the file (time+safety)
format_ns = '('//ns_string//'(es12.5,1x))'
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_complete'//beamstr, status = 'unknown', access = 'append')
write (14, format_ns) time, (beams(i)%x(n), n=0,ns-1,step), (beams(i)%y(n), n=0,ns-1,step)
close (14)
elseif ((iSaveBeam==3).and.(ns<100)) then
!less than 100 points
open (14, file = trim(dir_name)//'/'//trim(simulation_name)//'beam_complete'//beamstr, status = 'unknown', access = 'append')
write (14, '(201(es12.5,1x))') time, (beams(i)%x(n), n=0,ns-1), (beams(i)%y(n), n=0,ns-1)
close (14)
endif
enddo
end subroutine SaveBeamPositions
subroutine CreateHeader()
use share_vars
!----------------------------------------------------------------
! This routine reads in the PARAMS file and stores it in a
! global array. This array can now be written in every
! output file, for disambiguation.
!----------------------------------------------------------------
implicit none
integer, parameter :: Nchar = 256 ! remember to change in share_vars, too, if required.
integer :: io_error=0, linenumber=0,i=0
character (len=Nchar) :: dummy
!-------------------------------------------------------------------------------------------------------------
! first, lets determine how many entrys the PARAMS file has
open (14, file = 'PARAMS.m', status='old', action='read')
do while (io_error==0)
read (14,'(A)',iostat=io_error) dummy
linenumber=linenumber+1
enddo
linenumber=linenumber-1 !counted one too far
close (14)
!-------------------------------------------------------------------------------------------------------------
! then allocate the table for the header and fill the array
open (14, file = 'PARAMS.m', status='old', action='read')
allocate (Params_Header(1:linenumber+2))
Params_Header = ""
Params_Header(1) ="% ======================================PARAMS begin======================================================="
Params_Header(linenumber+2) ="% ======================================PARAMS END========================================================="
do i=2,linenumber+1
read (14,'(A)',iostat=io_error) dummy
Params_Header(i) = "% "//dummy
enddo
close (14)
!-------------------------------------------------------------------------------------------------------------
end subroutine CreateHeader
!================================================================================================================================================
subroutine WriteHeaderToFile(file_identifier)
!----------------------------------------------------------------
! This routine writes the PARAMS file as a backup in the specified file_identifier
!----------------------------------------------------------------
use share_vars
implicit none
integer, intent (in) :: file_identifier
integer :: i
!------------------------------------------------------------------
do i=1,size(Params_Header)
write(file_identifier,'(A)') Params_Header(i)
enddo
end subroutine WriteHeaderToFile