16 WRITE(*,*)
'Inside MyDeprecatedTimeStepper ... '
19 DO interval = 1, timeintervals
20 stepcount = stepcount + timesteps(interval)
23 IF (myverbosity > 3)
THEN
24 WRITE(*,*)
'In TimeStepper'
25 WRITE(*,*)
'TimeIntervals = ', timeintervals
26 WRITE(*,*)
'global%nNodes = ', global%nNodes
31 DO interval = 1,timeintervals
33 IF (myverbosity > 3)
THEN
34 WRITE(*,*)
'interval = ', interval
37 IF ( transient .OR. scanning )
THEN
38 dt = timestepsizes(interval,1)
45 timeperiod = listgetcreal(currentmodel % Simulation,
'Time Period',gotit)
46 IF(.NOT.gotit) timeperiod = huge(timeperiod)
50 WRITE(*,*)
'Timesteps(interval) = ', timesteps(interval)
51 DO timestep = 1,timesteps(interval)
53 IF (myverbosity > 3)
THEN
54 WRITE(6,*)
'timestepper timestep = ', timestep
55 WRITE(6,*)
'sTime(1) = ', stime(1)
56 WRITE(6,*)
'dtfunc = ', dtfunc
57 WRITE(6,*)
'dt = ', dt
60 IF (myverbosity > 3)
WRITE(*,*)
'TimeStepper Calling &
64 cum_timestep = cum_timestep + 1
65 sstep(1) = cum_timestep
67 dtfunc = listgetconstreal( currentmodel % Simulation, &
68 'Timestep Function', gotit)
70 CALL warn(
'ExecSimulation',
'Obsolite keyword > Timestep Function < , use > Timestep Size < instead')
72 dtfunc = listgetcreal( currentmodel % Simulation, &
73 'Timestep Size', gotit)
78 stime(1) = stime(1) + dt
79 speriodic(1) = stime(1)
80 DO WHILE(speriodic(1) > timeperiod)
81 speriodic(1) = speriodic(1) - timeperiod
85 IF(timestep > 1 .OR. interval > 1)
THEN
86 DO i =
SIZE(sprevsizes,2),2,-1
87 sprevsizes(1,i) = sprevsizes(1,i-1)
89 sprevsizes(1,1) = ssize(1)
93 sinterval(1) = interval
94 IF (.NOT. transient ) steadyit(1) = steadyit(1) + 1
96 IF ( parenv % MyPE == 0 )
THEN
97 CALL info(
'MAIN',
' ', level=3 )
98 CALL info(
'MAIN',
'-------------------------------------', level=3 )
100 IF ( transient .OR. scanning )
THEN
101 WRITE( message, * )
'Time: ',trim(i2s(cum_timestep)),
'/', &
102 trim(i2s(stepcount)), stime(1)
103 CALL info(
'MAIN', message, level=3 )
107 IF( cum_timestep > 1 )
THEN
108 maxtime = listgetconstreal( currentmodel % Simulation,
'Real Time Max',gotit)
110 WRITE( message,
'(A,F8.3)')
'Fraction of real time left: ',&
111 1.0_dp-realtime() / maxtime
113 timeleft = nint((stepcount-(cum_timestep-1))*(newtime-prevtime)/60._dp);
114 IF (timeleft > 120)
THEN
115 WRITE( message, *)
'Estimated time left: ', &
116 trim(i2s(timeleft/60)),
' hours.'
117 ELSE IF(timeleft > 60)
THEN
118 WRITE( message, *)
'Estimated time left: 1 hour ', &
119 trim(i2s(mod(timeleft,60))),
' minutes.'
120 ELSE IF(timeleft >= 1)
THEN
121 WRITE( message, *)
'Estimated time left: ', &
122 trim(i2s(timeleft)),
' minutes.'
124 WRITE( message, *)
'Estimated time left: less than a minute.'
127 CALL info(
'MAIN', message, level=3 )
131 WRITE( message, * )
'Steady state iteration: ',cum_timestep
132 CALL info(
'MAIN', message, level=3 )
135 CALL info(
'MAIN',
'-------------------------------------', level=3 )
136 CALL info(
'MAIN',
' ', level=3 )
142 adaptivetime = listgetlogical( currentmodel % Simulation, &
143 'Adaptive Timestepping', gotit )
145 IF ( transient .AND. adaptivetime )
THEN
146 adaptivelimit = listgetconstreal( currentmodel % Simulation, &
147 'Adaptive Time Error', gotit )
149 IF ( .NOT. gotit )
THEN
150 WRITE( message, * )
'Adaptive Time Limit must be given for' // &
151 'adaptive stepping scheme.'
152 CALL fatal(
'ElmerSolver', message )
155 adaptivemaxtimestep = listgetconstreal( currentmodel % Simulation, &
156 'Adaptive Max Timestep', gotit )
157 IF ( .NOT. gotit ) adaptivemaxtimestep = dt
158 adaptivemaxtimestep = min(adaptivemaxtimestep, dt)
160 adaptivemintimestep = listgetconstreal( currentmodel % Simulation, &
161 'Adaptive Min Timestep', gotit )
163 adaptivekeepsmallest = listgetinteger( currentmodel % Simulation, &
164 'Adaptive Keep Smallest', gotit, minv=0 )
166 n = currentmodel % NumberOfSolvers
170 solver => currentmodel % Solvers(i)
171 IF (
ASSOCIATED( solver % Variable % Values ) )
THEN
172 IF (
ASSOCIATED( solver % Variable % PrevValues ) )
THEN
173 j = max( j,
SIZE( solver % Variable % PrevValues,2 ) )
175 k = max( k,
SIZE( solver % Variable % Values ) )
178 ALLOCATE( xx(n,k), yynrm(n), xxnrm(n), prevxx( n,k,j ) )
181 IF ( ddt == 0.0d0 .OR. ddt > adaptivemaxtimestep ) ddt = adaptivemaxtimestep
185 DO WHILE( cumtime < dt-1.0d-12 )
186 ddt = min( dt - cumtime, ddt )
188 DO i=1,currentmodel % NumberOFSolvers
189 solver => currentmodel % Solvers(i)
190 IF (
ASSOCIATED( solver % Variable % Values ) )
THEN
191 n =
SIZE( solver % Variable % Values )
192 xx(i,1:n) = solver % Variable % Values
193 xxnrm(i) = solver % Variable % Norm
194 IF (
ASSOCIATED( solver % Variable % PrevValues ) )
THEN
195 DO j=1,
SIZE( solver % Variable % PrevValues,2 )
196 prevxx(i,1:n,j) = solver % Variable % PrevValues(:,j)
202 stime(1) = s + cumtime + ddt
204 CALL solveequations( currentmodel, ddt, transient, &
205 coupledminiter, coupledmaxiter, steadystatereached, realtimestep )
208 maxerr = listgetconstreal( currentmodel % Simulation, &
209 'Adaptive Error Measure', gotit )
211 DO i=1,currentmodel % NumberOFSolvers
212 solver => currentmodel % Solvers(i)
213 IF (
ASSOCIATED( solver % Variable % Values ) )
THEN
214 n =
SIZE(solver % Variable % Values)
215 yynrm(i) = solver % Variable % Norm
216 solver % Variable % Values = xx(i,1:n)
217 IF (
ASSOCIATED( solver % Variable % PrevValues ) )
THEN
218 DO j=1,
SIZE( solver % Variable % PrevValues,2 )
219 solver % Variable % PrevValues(:,j) = prevxx(i,1:n,j)
226 stime(1) = s + cumtime + ddt/2
227 CALL solveequations( currentmodel, ddt/2, transient, &
228 coupledminiter, coupledmaxiter, steadystatereached, realtimestep )
229 stime(1) = s + cumtime + ddt
230 CALL solveequations( currentmodel, ddt/2, transient, &
231 coupledminiter, coupledmaxiter, steadystatereached, realtimestep )
233 maxerr = abs( maxerr - listgetconstreal( currentmodel % Simulation, &
234 'Adaptive Error Measure', gotit ) )
236 IF ( .NOT. gotit )
THEN
238 DO i=1,currentmodel % NumberOFSolvers
239 solver => currentmodel % Solvers(i)
240 IF (
ASSOCIATED( solver % Variable % Values ) )
THEN
241 IF ( yynrm(i) /= solver % Variable % Norm )
THEN
242 maxerr = max(maxerr,abs(yynrm(i)-solver % Variable % Norm)/yynrm(i))
248 IF ( maxerr < adaptivelimit .OR. ddt <= adaptivemintimestep )
THEN
249 cumtime = cumtime + ddt
250 realtimestep = realtimestep+1
251 IF ( smallestcount >= adaptivekeepsmallest .OR. stepcontrol > 0 )
THEN
252 ddt = min( 2*ddt, adaptivemaxtimestep )
257 smallestcount = smallestcount + 1
260 DO i=1,currentmodel % NumberOFSolvers
261 solver => currentmodel % Solvers(i)
262 IF (
ASSOCIATED( solver % Variable % Values ) )
THEN
263 n =
SIZE(solver % Variable % Values)
264 solver % Variable % Norm = xxnrm(i)
265 solver % Variable % Values = xx(i,1:n)
266 IF (
ASSOCIATED( solver % Variable % PrevValues ) )
THEN
267 DO j=1,
SIZE( solver % Variable % PrevValues,2 )
268 solver % Variable % PrevValues(:,j) = prevxx(i,1:n,j)
276 WRITE(*,
'(a,3e20.12)')
'Adaptive(cum,ddt,err): ', cumtime, ddt, maxerr
281 DEALLOCATE( xx, xxnrm, yynrm, prevxx )
283 IF (myverbosity > 3)
THEN
284 WRITE(*,*)
'Calling SolveEquations (no transient and no adaptive)'
286 CALL solveequations( currentmodel, dt, transient, &
287 coupledminiter, coupledmaxiter, steadystatereached, realtimestep )
288 realtimestep = realtimestep+1
296 IF( outputintervals(interval) /= 0 )
THEN
299 k = mod( timestep-1, outputintervals(interval) )
300 IF ( k == 0 .OR. steadystatereached )
THEN
302 DO i=1,currentmodel % NumberOfSolvers
303 solver => currentmodel % Solvers(i)
304 IF ( solver % PROCEDURE == 0 ) cycle
305 execthis = ( solver % SolverExecWhen == solver_exec_ahead_save)
306 when = listgetstring( solver % Values,
'Exec Solver', gotit )
307 IF ( gotit ) execthis = ( when ==
'before saving')
308 IF( execthis ) CALL solveractivate( currentmodel,solver,dt,transient )
314 DO i=1,currentmodel % NumberOfSolvers
315 solver => currentmodel % Solvers(i)
316 IF ( solver % PROCEDURE == 0 ) cycle
317 execthis = ( solver % SolverExecWhen == solver_exec_after_save)
318 when = listgetstring( solver % Values,
'Exec Solver', gotit )
319 IF ( gotit ) execthis = ( when ==
'after saving')
320 IF( execthis ) CALL solveractivate( currentmodel,solver,dt,transient )
326 maxtime = listgetcreal( currentmodel % Simulation,
'Real Time Max',gotit)
327 IF( gotit .AND. realtime() - rt0 > maxtime )
THEN
328 CALL info(
'ElmerSolver',
'Reached allowed maximum real time, exiting...')
332 exitcond = listgetcreal( currentmodel % Simulation,
'Exit Condition',gotit)
333 IF( gotit .AND. exitcond > 0.0_dp )
THEN
334 CALL info(
'ElmerSolver',
'Found a positive exit condition, exiting...')
340 IF ( steadystatereached .AND. .NOT. (transient .OR. scanning) )
THEN
341 IF ( timestep >= coupledminiter )
THEN
342 WRITE(6,*)
'SteadyStateReached, exiting'
354 IF (myverbosity > 3)
THEN
355 write(6,*)
'LastSaved = ', lastsaved
ElmerLib Elmer library routines
subroutine savecurrent(CurrentStep)
Saves current timestep to external files.
subroutine savetopost(CurrentStep)
Saves results file to post processing file of ElmerPost format, if requested.
subroutine updateloads(global, runs)
ElmerLib Elmer library routines
subroutine deprecatedtimestepper(global, runs)