ElmerFoamFSI  2.0
ElmerFoamFSI is fluid-solid interaction simulation application built up from OpenFOAM CFD and Elmer CSM coupled through the IMPACT multiphysics software integration infrastructure.
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Groups Pages
InitializeParallel.F90
Go to the documentation of this file.
1 !/*****************************************************************************/
2 ! *
3 ! * Elmer, A Finite Element Software for Multiphysical Problems
4 ! *
5 ! * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
6 ! *
7 ! * This library is free software; you can redistribute it and/or
8 ! * modify it under the terms of the GNU Lesser General Public
9 ! * License as published by the Free Software Foundation; either
10 ! * version 2.1 of the License, or (at your option) any later version.
11 ! *
12 ! * This library is distributed in the hope that it will be useful,
13 ! * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ! * Lesser General Public License for more details.
16 ! *
17 ! * You should have received a copy of the GNU Lesser General Public
18 ! * License along with this library (in file ../LGPL-2.1); if not, write
19 ! * to the Free Software Foundation, Inc., 51 Franklin Street,
20 ! * Fifth Floor, Boston, MA 02110-1301 USA
21 ! *
22 ! *****************************************************************************/
23 !
24 !/******************************************************************************
25 ! *
26 ! * ELMER/FEM Solver main program
27 ! *
28 ! ******************************************************************************
29 ! *
30 ! * Authors: Juha Ruokolainen
31 ! * Email: Juha.Ruokolainen@csc.fi
32 ! * Web: http://www.csc.fi/elmer
33 ! * Address: CSC - IT Center for Science Ltd.
34 ! * Keilaranta 14
35 ! * 02101 Espoo, Finland
36 ! *
37 ! * Original Date: 02 Jun 1997
38 ! *
39 ! *****************************************************************************/
40 
42 
44 
46 
48 
51 
52 !------------------------------------------------------------------------------
54 !------------------------------------------------------------------------------
55  SUBROUTINE elmerinitialize(runs, Comm)
56 !------------------------------------------------------------------------------
57  USE testobject
58  USE generalmodule
59  USE types
60 !------------------------------------------------------------------------------
61  IMPLICIT NONE
62 !------------------------------------------------------------------------------
63 
64 ! INTEGER :: Initialize
65  INTEGER :: comm
66 
67 !------------------------------------------------------------------------------
68 ! Local variables
69 !------------------------------------------------------------------------------
70 
71 ! INTEGER :: i,j,k,n,l,t,k1,k2,iter,Ndeg,istat,nproc,tlen,nthreads
72  CHARACTER(LEN=MAX_STRING_LEN) :: coordtransform
73 ! CHARACTER(LEN=MAX_STRING_LEN) :: threads
74 !
75 ! REAL(KIND=dp) :: s,dt,dtfunc
76 ! REAL(KIND=dP), POINTER :: WorkA(:,:,:) => NULL()
77 ! REAL(KIND=dp), POINTER, SAVE :: sTime(:), sStep(:), sInterval(:), sSize(:), &
78 ! steadyIt(:),nonlinIt(:),sPrevSizes(:,:),sPeriodic(:)
79 !
80 ! TYPE(Element_t),POINTER :: CurrentElement
81 !
82 ! LOGICAL :: GotIt,Transient,Scanning,LastSaved
83 !
84 ! INTEGER :: TimeIntervals,interval,timestep, &
85 ! TotalTimesteps,SavedSteps,CoupledMaxIter,CoupledMinIter
86 !
87 ! INTEGER, POINTER, SAVE :: Timesteps(:),OutputIntervals(:), ActiveSolvers(:)
88 ! REAL(KIND=dp), POINTER, SAVE :: TimestepSizes(:,:)
89 !
90 ! INTEGER(KIND=AddrInt) :: ControlProcedure
91 !
92 ! LOGICAL :: InitDirichlet, ExecThis
93 !
94 ! TYPE(ElementType_t),POINTER :: elmt
95 !
96 ! TYPE(ParEnv_t), POINTER :: ParallelEnv
97 !
98 ! CHARACTER(LEN=MAX_NAME_LEN) :: ModelName, eq, ExecCommand
99 ! CHARACTER(LEN=MAX_STRING_LEN) :: OutputFile, PostFile, RestartFile, &
100 ! OutputName=' ',PostName=' ', When, OptionString
101 !
102 ! TYPE(Variable_t), POINTER :: Var
103 ! TYPE(Mesh_t), POINTER :: Mesh
104 ! TYPE(Solver_t), POINTER :: Solver
105 !
106 ! REAL(KIND=dp) :: RealTime,CPUTime
107 !
108 ! LOGICAL :: FirstLoad = .TRUE., FirstTime=.TRUE., Found
109 ! LOGICAL :: Silent, Version, GotModelName
110 !
111  INTEGER :: iargc
112 !
113 ! INTEGER :: ExtrudeLevels
114 ! TYPE(Mesh_t), POINTER :: ExtrudedMesh
115 !
116 ! INTEGER :: omp_get_max_threads
117 !
118 !#ifdef HAVE_TRILINOS
119 !INTERFACE
120 ! SUBROUTINE TrilinosCleanup() BIND(C,name='TrilinosCleanup')
121 ! IMPLICIT NONE
122 ! END SUBROUTINE TrilinosCleanup
123 !END INTERFACE
124 !#endif
125 
126  INTEGER :: runs
127 
128 
129  firstload = .true.
130  firsttime=.true.
131  initialize = 0
132 
133  ! Start the watches, store later
134  !--------------------------------
135  rt0 = realtime()
136  ct0 = cputime()
137 
138 
139  ! If parallel execution requested, initialize parallel environment:
140  !------------------------------------------------------------------
141  !Set ElmerModuleComm to our communicator (we patched Elmer so it will
142  !use this variable for a communicator instead of MPI_COMM_WORLD)
143  elmermodulecomm = comm
144  parallelenv => parallelinit()
145  outputpe = parenv % MyPE
146 
147 !tt = realtime()
148  IF ( firsttime ) THEN
149  !
150  ! Print banner to output:
151 #include "../config.h"
152  ! -----------------------
153  noargs = iargc()
154  ! Info Level is always true until the model has been read!
155  ! This makes it possible to cast something
156  silent = .false.
157  version = .false.
158  IF( noargs > 0 ) THEN
159  DO i = 1, noargs
160  CALL getarg( i,optionstring )
161  silent = silent .OR. &
162  ( optionstring=='-s' .OR. optionstring=='--silent' )
163  version = version .OR. &
164  ( optionstring=='-v' .OR. optionstring == '--version' )
165  END DO
166  END IF
167 
168  ! Set number of OpenMP threads
169  nthreads = 1
170  !$ nthreads = omp_get_max_threads()
171  IF (nthreads > 1) THEN
172  ! Check if OMP_NUM_THREADS environment variable is set
173  CALL envir( 'OMP_NUM_THREADS'//char(0), threads, tlen )
174  IF (tlen==0) THEN
175  CALL warn('MAIN','OMP_NUM_THREADS not set. Using only 1 thread.')
176  nthreads = 1
177  ! Set number of threads to 1
178  !$ CALL omp_set_num_threads(nthreads)
179 #ifdef HAVE_MKL
180  CALL mkl_set_num_threads(nthreads)
181 #endif
182  END IF
183  END IF
184 
185 
186  IF( .NOT. silent ) THEN
187  CALL info( 'MAIN', ' ')
188  CALL info( 'MAIN', '=============================================================')
189  CALL info( 'MAIN', 'MyElmerSolver finite element software, Welcome! ')
190  CALL info( 'MAIN', 'This program is free software licensed under (L)GPL ')
191  CALL info( 'MAIN', 'Copyright 1st April 1995 - , CSC - IT Center for Science Ltd.')
192  CALL info( 'MAIN', 'Webpage http://www.csc.fi/elmer, Email elmeradm@csc.fi ')
193  CALL info( 'MAIN', 'Library version: ' // version &
194 #ifdef REVISION
195  // ' (Rev: ' // revision // ')' )
196 #else
197  )
198 #endif
199  IF ( parenv % PEs > 1 ) &
200  CALL info( 'MAIN', ' Running in parallel using ' // &
201  trim(i2s(parenv % PEs)) // ' tasks.')
202 
203  ! Print out number of threads in use
204  IF ( nthreads > 1 ) &
205  CALL info('MAIN', ' Running in parallel with ' // &
206  trim(i2s(nthreads)) // ' threads per task.')
207 
208 #ifdef HAVE_HYPRE
209  CALL info( 'MAIN', ' HYPRE library linked in.')
210 #endif
211 #ifdef HAVE_TRILINOS
212  CALL info( 'MAIN', ' Trilinos library linked in.')
213 #endif
214 #ifdef HAVE_MUMPS
215  CALL info( 'MAIN', ' MUMPS library linked in.')
216 #endif
217 #ifdef HAVE_CHOLMOD
218  CALL info( 'MAIN', ' CHOLMOD library linked in.')
219 #endif
220 #ifdef HAVE_SUPERLU
221  CALL info( 'MAIN', ' SUPERLU library linked in.')
222 #endif
223 #ifdef HAVE_PARDISO
224  CALL info( 'MAIN', ' PARDISO library linked in.')
225 #endif
226 #ifdef HAVE_MKL
227  CALL info( 'MAIN', ' Intel MKL linked in.' )
228 #endif
229  CALL info( 'MAIN', '=============================================================')
230  END IF
231 
232  IF( version ) RETURN
233 
234  CALL initializeelementdescriptions
235 
236  WRITE(*,*) "Initialize: Setting FirstTime to FALSE"
237  firsttime = .false.
238  END IF
239 
240  ! Read input file name either as an argument, or from the default file:
241  !----------------------------------------------------------------------
242  gotmodelname = .false.
243  IF ( parenv % PEs <= 1 .AND. noargs > 0 ) THEN
244  CALL getarg( 1,modelname )
245  IF( modelname(1:1) /= '-') THEN
246  gotmodelname = .true.
247  IF ( noargs > 1 ) CALL getarg( 2,eq )
248  END IF
249  END IF
250 
251  IF( .NOT. gotmodelname ) THEN
252  OPEN( 1, file='ELMERSOLVER_STARTINFO', status='OLD', err=10 )
253  READ(1,'(a)') modelname
254  CLOSE(1)
255  END IF
256 
257 !------------------------------------------------------------------------------
258 ! Read element definition file, and initialize element types
259 !------------------------------------------------------------------------------
260  IF ( initialize==1 ) THEN
261  CALL freemodel(currentmodel)
262  firstload=.true.
263  END IF
264 
265 
266 !------------------------------------------------------------------------------
267 ! Read Model and mesh from Elmer mesh data base
268 !------------------------------------------------------------------------------
269 ! DO WHILE( .TRUE. )
270 
271  IF ( initialize==2 ) goto 1
272 
273  IF( myverbosity > 3) WRITE(*,*) 'FirstLoad = ', firstload
274 
275  IF ( firstload ) THEN
276  IF( .NOT. silent ) THEN
277  CALL info( 'MAIN', ' ')
278  CALL info( 'MAIN', ' ')
279  CALL info( 'MAIN', '-------------------------------------')
280  CALL info( 'MAIN', 'Reading Model: '//trim( modelname) )
281  END IF
282 
283  INQUIRE(unit=infileunit, opened=gotit)
284  IF ( gotit ) CLOSE(infileunit)
285 
286  IF( myverbosity > 3) WRITE(*,*) 'ModelName = ', modelname
287 
288  OPEN( unit=infileunit, action='Read',file=modelname,status='OLD',err=20 )
289  IF( myverbosity > 3) WRITE(*,*) 'Before LoadModel call'
290  currentmodel => loadmodel(modelname,.false.,parenv % PEs,parenv % MyPE )
291  IF( myverbosity > 3) WRITE(*,*) 'After LoadModel call'
292 
293  ! Optionally perform simple extrusion to increase the dimension of the mesh
294  !----------------------------------------------------------------------------------
295  extrudelevels=getinteger(currentmodel % Simulation,'Extruded Mesh Levels',found)
296  IF(extrudelevels>1) THEN
297  extrudedmesh => meshextrude(currentmodel % Meshes, extrudelevels-2)
298  DO i=1,currentmodel % NumberOfSolvers
299  IF(ASSOCIATED(currentmodel % Solvers(i) % Mesh,currentmodel % Meshes)) &
300  currentmodel % Solvers(i) % Mesh => extrudedmesh
301  END DO
302  extrudedmesh % Next => currentmodel % Meshes % Next
303  currentmodel % Meshes => extrudedmesh
304 
305  ! If periodic BC given, compute boundary mesh projector:
306  ! ------------------------------------------------------
307  DO i = 1,currentmodel % NumberOfBCs
308  IF(ASSOCIATED(currentmodel % Bcs(i) % PMatrix)) &
309  CALL freematrix( currentmodel % BCs(i) % PMatrix )
310  currentmodel % BCs(i) % PMatrix => null()
311  k = listgetinteger( currentmodel % BCs(i) % Values, 'Periodic BC', gotit )
312  IF( gotit ) THEN
313  currentmodel % BCs(i) % PMatrix => periodicprojector( currentmodel, extrudedmesh, i, k )
314  END IF
315  END DO
316  END IF
317 
318  ! If requested perform coordinate transformation directly after is has been obtained.
319  ! Don't maintain the original mesh.
320  !----------------------------------------------------------------------------------
321  coordtransform = listgetstring(currentmodel % Simulation,'Coordinate Transformation',gotit)
322  IF( gotit ) THEN
323  ! Masoud
324  WRITE(*,*) 'Initialize: Coordinate Transformation is activated for Elmer.\n'
325  ! Masoud : End
326  CALL coordinatetransformation( currentmodel % Meshes, coordtransform, &
327  currentmodel % Simulation, .true. )
328  END IF
329  ! IF( ListCheckPresent(CurrentModel % Simulation,'Coordinate Transformation') ) THEN
330  ! CALL CoordinateTransformation( CurrentModel % Meshes, .TRUE. )
331  ! END IF
332 
333  IF(.NOT. silent ) THEN
334  CALL info( 'MAIN', '-------------------------------------')
335  END IF
336  ELSE
337  IF ( initialize==3 ) THEN
338  INQUIRE(unit=infileunit, opened=gotit)
339  IF ( gotit ) CLOSE(infileunit)
340  OPEN( unit=infileunit, action='Read', &
341  file=modelname,status='OLD',err=20 )
342  END IF
343 
344  IF (myverbosity > 3) THEN
345  WRITE(6,*) 'Initialize: CurrentModel % NumberOfNodes&
346  = ', currentmodel % NumberOfNodes
347  END IF
348 
349 ! IF ( .NOT.ReloadInputFile(CurrentModel) ) EXIT
350 
351  mesh => currentmodel % Meshes
352  DO WHILE( ASSOCIATED(mesh) )
353  mesh % SavesDone = 0
354  mesh => mesh % Next
355  END DO
356  END IF
357 
358 1 CONTINUE
359 
360  CALL listaddlogical( currentmodel % Simulation, &
361  'Initialization Phase', .true. )
362 
363  ! Save the start time to the list so that it may be retrieved when necessary
364  ! This could perhaps also be a global variable etc, but this will do for now.
365  !-------------------------------------------------------------------------
366  IF( listgetlogical( currentmodel % Simulation,'Simulation Timing',gotit) ) THEN
367  CALL listaddconstreal( currentmodel % Simulation,'cputime0',ct0 )
368  CALL listaddconstreal( currentmodel % Simulation,'realtime0',rt0 )
369  END IF
370 #if 0
371 !------------------------------------------------------------------------------
372 ! Check for transient case
373 !------------------------------------------------------------------------------
374  eq = listgetstring( currentmodel % Simulation, 'Simulation Type', gotit )
375  scanning = eq == 'scanning'
376  transient = eq == 'transient'
377 
378 
379 !------------------------------------------------------------------------------
380 ! To more conveniently support the use of VTK based visualization there
381 ! is a hack that recognizes VTU suffix and creates a instance of output solver.
382 ! Note that this is really quite a dirty hack, and is not a good example.
383 !-----------------------------------------------------------------------------
385 
386 !------------------------------------------------------------------------------
387 ! Figure out what (flow,heat,stress,...) should be computed, and get
388 ! memory for the dofs
389 !------------------------------------------------------------------------------
390  CALL addsolvers()
391 
392 !------------------------------------------------------------------------------
393 ! Time integration and/or steady state steps
394 !------------------------------------------------------------------------------
395  IF ( transient .OR. scanning ) THEN
396  timesteps => listgetintegerarray( currentmodel % Simulation, &
397  'Timestep Intervals', gotit )
398 
399  IF ( .NOT.gotit ) THEN
400  CALL fatal( ' ', 'Keyword > Timestep Intervals < MUST be ' // &
401  'defined for transient and scanning simulations' )
402  END IF
403  timestepsizes => listgetconstrealarray( currentmodel % Simulation, &
404  'Timestep Sizes', gotit )
405 
406  IF ( .NOT.gotit ) THEN
407  IF( scanning .OR. listcheckpresent( currentmodel % Simulation,'Timestep Size') ) THEN
408  ALLOCATE(timestepsizes(SIZE(timesteps),1))
409  timestepsizes = 1.0_dp
410  ELSE
411  CALL fatal( ' ', 'Keyword [Timestep Sizes] MUST be ' // &
412  'defined for time dependent simulations' )
413  stop
414  END IF
415  END IF
416 
417  timeintervals = SIZE(timesteps)
418 
419  coupledmaxiter = listgetinteger( currentmodel % Simulation, &
420  'Steady State Max Iterations', gotit, minv=1 )
421  IF ( .NOT. gotit ) coupledmaxiter = 1
422 !------------------------------------------------------------------------------
423  ELSE
424 !------------------------------------------------------------------------------
425 ! Steady state
426 !------------------------------------------------------------------------------
427  ALLOCATE(timesteps(1))
428 
429  timesteps(1) = listgetinteger( currentmodel % Simulation, &
430  'Steady State Max Iterations', gotit,minv=1 )
431  IF ( .NOT. gotit ) timesteps(1)=1
432 
433  ALLOCATE(timestepsizes(1,1))
434  timestepsizes(1,1) = 1.0d0
435 
436  coupledmaxiter = 1
437  timeintervals = 1
438  END IF
439 
440  IF ( firstload ) &
441  ALLOCATE( stime(1), sstep(1), sinterval(1), ssize(1), &
442  steadyit(1), nonlinit(1), sprevsizes(1,5), speriodic(1) )
443 
444  dt = 0._dp
445 
446  stime = 0._dp
447  sstep = 0
448  speriodic = 0._dp
449 
450  ssize = dt
451  sprevsizes = 0_dp
452 
453  sinterval = 0._dp
454 
455  steadyit = 0
456  nonlinit = 0
457 
458  coupledminiter = listgetinteger( currentmodel % Simulation, &
459  'Steady State Min Iterations', gotit )
460 
461 !------------------------------------------------------------------------------
462 ! Add coordinates and simulation time to list of variables so that
463 ! coordinate dependent parameter computing routines can ask for
464 ! them...
465 !------------------------------------------------------------------------------
466  IF ( firstload ) CALL addmeshcoordinatesandtime
467 
468 !------------------------------------------------------------------------------
469 ! Get Output File Options
470 !------------------------------------------------------------------------------
471 
472  outputintervals => listgetintegerarray( currentmodel % Simulation, &
473  'Output Intervals', gotit )
474  IF ( .NOT. gotit ) THEN
475  ALLOCATE( outputintervals(SIZE(timesteps)) )
476  outputintervals = 1
477  END IF
478 
479 
480  ! Initial Conditions:
481  ! -------------------
482  IF ( firstload ) CALL setinitialconditions
483 
484 
485  ! Compute the total number of steps that will be saved to the files
486  ! Particularly look if the last step will be saved, or if it has
487  ! to be saved separately.
488  !------------------------------------------------------------------
489  totaltimesteps = 0
490  lastsaved = .true.
491  DO interval=1,timeintervals
492  DO timestep = 1,timesteps(interval)
493  IF( outputintervals(interval) == 0 ) cycle
494  lastsaved = .false.
495  IF ( mod(timestep-1, outputintervals(interval))==0 ) THEN
496  lastsaved = .true.
497  totaltimesteps = totaltimesteps + 1
498  END IF
499  END DO
500  END DO
501 
502  DO i=1,currentmodel % NumberOfSolvers
503  solver => currentmodel % Solvers(i)
504  IF(.NOT.ASSOCIATED(solver % Variable)) cycle
505  IF(.NOT.ASSOCIATED(solver % Variable % Values)) cycle
506  when = listgetstring( solver % Values, 'Exec Solver', gotit )
507  IF ( gotit ) THEN
508  IF ( when == 'after simulation' .OR. when == 'after all' ) THEN
509  lastsaved = .false.
510  END IF
511  ELSE
512  IF ( solver % SolverExecWhen == solver_exec_after_all ) THEN
513  lastsaved = .false.
514  END IF
515  END IF
516  END DO
517 
518  IF ( .NOT.lastsaved ) totaltimesteps = totaltimesteps + 1
519  IF( totaltimesteps == 0 ) totaltimesteps = 1
520 
521  CALL listaddlogical( currentmodel % Simulation, &
522  'Initialization Phase', .false. )
523 
524  firstload = .false.
525  IF (myverbosity > 3) THEN
526  WRITE(6,*) 'MyElmerSolver 493 Initialize = ', initialize
527  END IF
528 ! IF ( Initialize == 1 ) EXIT
529 #endif
530 
531 ! END DO
532 
533  IF (myverbosity > 3) THEN
534  WRITE(6,*) 'MyRun: CurrentModel % NumberOfNodes = ', &
535  currentmodel % NumberOfNodes
536  END IF
537 
538 !------------------------------------------------------------------------------
539 ! Check for transient case
540 !------------------------------------------------------------------------------
541  eq = listgetstring( currentmodel % Simulation, 'Simulation Type', gotit )
542  scanning = eq == 'scanning'
543  transient = eq == 'transient'
544 
545 
546 !------------------------------------------------------------------------------
547 ! To more conveniently support the use of VTK based visualization there
548 ! is a hack that recognizes VTU suffix and creates a instance of output solver.
549 ! Note that this is really quite a dirty hack, and is not a good example.
550 !-----------------------------------------------------------------------------
551  IF (myverbosity > 3) THEN
552  write(6,*) 'calling AddVtuOutputSolverHack'
553  END IF
555  IF (myverbosity > 3) THEN
556  write(6,*) 'leaving AddVtuOutputSolverHack'
557  END IF
558 
559 !------------------------------------------------------------------------------
560 ! Figure out what (flow,heat,stress,...) should be computed, and get
561 ! memory for the dofs
562 !------------------------------------------------------------------------------
563  IF (myverbosity > 3) THEN
564  write(6,*) 'calling AddSolvers'
565  END IF
566  CALL addsolvers()
567  IF (myverbosity > 3) THEN
568  write(6,*) 'leaving AddSolvers'
569  END IF
570 
571 !------------------------------------------------------------------------------
572 ! Time integration and/or steady state steps
573 !------------------------------------------------------------------------------
574  IF ( transient .OR. scanning ) THEN
575  timesteps => listgetintegerarray( currentmodel % Simulation, &
576  'Timestep Intervals', gotit )
577 
578  IF ( .NOT.gotit ) THEN
579  CALL fatal( ' ', 'Keyword > Timestep Intervals < MUST be ' // &
580  'defined for transient and scanning simulations' )
581  END IF
582  timestepsizes => listgetconstrealarray( currentmodel % Simulation, &
583  'Timestep Sizes', gotit )
584 
585  IF ( .NOT.gotit ) THEN
586  IF( scanning .OR. listcheckpresent( currentmodel % Simulation,'Timestep Size') ) THEN
587  ALLOCATE(timestepsizes(SIZE(timesteps),1))
588  timestepsizes = 1.0_dp
589  ELSE
590  CALL fatal( ' ', 'Keyword [Timestep Sizes] MUST be ' // &
591  'defined for time dependent simulations' )
592  stop
593  END IF
594  END IF
595 
596  timeintervals = SIZE(timesteps)
597 
598  coupledmaxiter = listgetinteger( currentmodel % Simulation, &
599  'Steady State Max Iterations', gotit, minv=1 )
600  IF ( .NOT. gotit ) coupledmaxiter = 1
601 !------------------------------------------------------------------------------
602  ELSE
603 !------------------------------------------------------------------------------
604 ! Steady state
605 !------------------------------------------------------------------------------
606  ALLOCATE(timesteps(1))
607 
608  timesteps(1) = listgetinteger( currentmodel % Simulation, &
609  'Steady State Max Iterations', gotit,minv=1 )
610  IF ( .NOT. gotit ) timesteps(1)=1
611 
612  ALLOCATE(timestepsizes(1,1))
613  timestepsizes(1,1) = 1.0d0
614 
615  coupledmaxiter = 1
616  timeintervals = 1
617  END IF
618 
619  IF ( firstload ) &
620  ALLOCATE( stime(1), sstep(1), sinterval(1), ssize(1), &
621  steadyit(1), nonlinit(1), sprevsizes(1,5), speriodic(1) )
622 
623  dt = 0._dp
624 
625  stime = 0._dp
626  sstep = 0
627  speriodic = 0._dp
628 
629  ssize = dt
630  sprevsizes = 0_dp
631 
632  sinterval = 0._dp
633 
634  steadyit = 0
635  nonlinit = 0
636 
637  coupledminiter = listgetinteger( currentmodel % Simulation, &
638  'Steady State Min Iterations', gotit )
639 
640 !------------------------------------------------------------------------------
641 ! Add coordinates and simulation time to list of variables so that
642 ! coordinate dependent parameter computing routines can ask for
643 ! them...
644 !------------------------------------------------------------------------------
645  IF ( firstload ) CALL addmeshcoordinatesandtime
646 
647 !------------------------------------------------------------------------------
648 ! Get Output File Options
649 !------------------------------------------------------------------------------
650 
651  outputintervals => listgetintegerarray( currentmodel % Simulation, &
652  'Output Intervals', gotit )
653 
654  IF ( .NOT. gotit ) THEN
655  ALLOCATE( outputintervals(SIZE(timesteps)) )
656  outputintervals = 1
657  END IF
658 
659  IF (myverbosity > 3) THEN
660  write(6,*) 'MyRunI SIZE(OutputIntervals) =', SIZE(outputintervals)
661  write(6,*) 'MyRunI OutputIntervals(1) = ',outputintervals(1)
662  END IF
663 
664  ! Initial Conditions:
665  ! -------------------
666  IF ( firstload ) CALL setinitialconditions
667 
668 
669  ! Compute the total number of steps that will be saved to the files
670  ! Particularly look if the last step will be saved, or if it has
671  ! to be saved separately.
672  !------------------------------------------------------------------
673  totaltimesteps = 0
674  lastsaved = .true.
675  DO interval=1,timeintervals
676  DO timestep = 1,timesteps(interval)
677  IF( outputintervals(interval) == 0 ) cycle
678  lastsaved = .false.
679  IF ( mod(timestep-1, outputintervals(interval))==0 ) THEN
680  lastsaved = .true.
681  totaltimesteps = totaltimesteps + 1
682  END IF
683  END DO
684  END DO
685 
686  DO i=1,currentmodel % NumberOfSolvers
687  solver => currentmodel % Solvers(i)
688  IF(.NOT.ASSOCIATED(solver % Variable)) cycle
689  IF(.NOT.ASSOCIATED(solver % Variable % Values)) cycle
690  when = listgetstring( solver % Values, 'Exec Solver', gotit )
691  IF ( gotit ) THEN
692  IF ( when == 'after simulation' .OR. when == 'after all' ) THEN
693  lastsaved = .false.
694  END IF
695  ELSE
696  IF ( solver % SolverExecWhen == solver_exec_after_all ) THEN
697  lastsaved = .false.
698  END IF
699  END IF
700  END DO
701 
702  IF ( .NOT.lastsaved ) totaltimesteps = totaltimesteps + 1
703  IF( totaltimesteps == 0 ) totaltimesteps = 1
704 
705  CALL listaddlogical( currentmodel % Simulation, &
706  'Initialization Phase', .false. )
707 
708  firstload = .false.
709  IF (myverbosity > 3) THEN
710  WRITE(6,*) 'MyElmerSolver 493 Initialize = ', initialize
711  write(6,*) 'TimeIntervals from inside RunI = ', timeintervals
712  WRITE(*,*) 'NumberOfSolvers = ', currentmodel % NumberOfSolvers
713  END IF
714 
715 ! IF ( Initialize == 1 ) EXIT
716 
717  DO i=1,currentmodel % NumberOfSolvers
718  solver => currentmodel % Solvers(i)
719  IF (myverbosity > 3) THEN
720  WRITE(*,*) 'Solver % PROCEDURE = ', solver % PROCEDURE
721  END IF
722  IF ( solver % PROCEDURE==0 ) cycle
723  IF ( solver % SolverExecWhen == solver_exec_ahead_all ) THEN
724  IF (myverbosity > 3) THEN
725  WRITE(*,*) 'Calling SolverActivate for Solver', i
726  END IF
727  CALL solveractivate( currentmodel,solver,dt,transient )
728  END IF
729  END DO
730 
731  runs = runs + 1
732 
733  RETURN
734 
735 10 CONTINUE
736  CALL fatal( 'MyElmerSolver', 'Unable to find ELMERSOLVER_STARTINFO, can not execute.' )
737 
738 20 CONTINUE
739  CALL fatal( 'MyElmerSolver', 'Unable to find input file [' // &
740  trim(modelname) // '], can not execute.' )
741 
742 
743 !------------------------------------------------------------------------------
744  END SUBROUTINE elmerinitialize
745 !------------------------------------------------------------------------------
746 
subroutine setinitialconditions()
Sets initial conditions for the fields.
subroutine addvtuoutputsolverhack()
subroutine addsolvers()
Adds flags for active solvers.
subroutine addmeshcoordinatesandtime()
Adds coordinate and time variables to the current mesh structure.
subroutine elmerinitialize(runs)
ElmerLib Elmer library routines
Definition: Initialize.F90:55
ElmerLib Elmer library routines