SPINTO (i.e. Simplified PINTO)

by

Alexey Ginevsky and Brian Spalding

Contents

  1. Preliminary
  2. About SPINTO
  3. Methods of working with SPINTO
  4. Examples of the use of SPINTO
  5. Concluding remarks

1. Preliminary

1.1 The main idea

There has long existed a PHOENICS module called PINTO which allows large fine-grid simulations to be performed in stages.

At the first stage, a coarse grid is used; then interpolation in the resulting phi file produces a second phi file corresponding to a finer grid.

This file is used as the re-start input to a second-stage calculation; of which the resulting phi-file is again subjected to interpolation and used for a third-stage re-start.

This process continues until the desired finest grid is attained; and the total time of calculation is, if the optimum number of stages is employed, significantly less than if the fine-grid calculation had been started from scratch.

The final converged solution is of course entirely unaffected by the coarseness of the earlier-stage solutions; but it is achieved more rapidly because the finest-grid operation has started from nearly-correct initial fields.

1.2 Deficiencies

However the existing PINTO is unable to handle the large phi-files which are common in parallel computing.

Further, because PINTO was created well before the introduction of the PARSOL technique, it makes no provision for interpolating in the pbcl.dat file, which would be necessary if all the early-stage calculations were to be conducted with the current default setting: PARSOL=T, when facet-described objects are present.

1.3 Recent developments

A new version of PINTO has therefore been created which allows grid refinement without the just-mentioned termination, albeit with the following restrictions:
  1. Not all of the PINTO commands have been implemented. Therefore the new version of PINTO is named Simplified PINTO (SPINTO).

  2. For example, SPINTO can handle only 3D cases; but these are the ones which are in most need of its computer-time-reduction capabilities.

  3. SPINTO does not handle pbcl.dat . Nevertheless, it can be used for PARSOL-using simulations, PARSOL being set true only for the final (finest grid) stage.

2. About SPINTO

2.1 How to activate SPINTO

The SPINTO executable, spinto.exe, resides in /phoenics/d_utils/d_windf/d_exes.

It can be activated by issuing the DOS command:
   runspin

SPINTO then looks for a file, Q1SPIN, containing its instructions, and then for a phi file, and someties for a q1 file, on which to carry them out.

These operations can be those of either refinement or coarsening, for reasons which will be explained below; and the result of SPINTO's speedily-conducted operations is a new phi-format file called NPHI.

2.5 What SPINTO does

SPINTO

2.6 Commands recognised by SPINTO

SPINTO recognises the following set of commands in the file q1spin:

  1. REFINE(character*1,integer)
    of which the first argument is X, Y or Z; and
    the second argument is the multiplier to be applied to NX, NY or NZ, according to the direction;
    This command controls the refinement of the grid in the selected direction.

    Therefore if the user wants to split each cell of grid in X-direction into 2 parts then he should set command REFINE(X,2).

    If the user does not want to refine, for example in the X-direction, then he should either use the command: REFINE(X,1) or omit the x-direction command entirely.

  2. ORIGIN(real,real,real)
    of which the first argument is the X-coordinate of the new origin;
    the second argument is the Y-coordinate of the new origin; and
    the third argument is the Z-coordinate of the new origin.

    NOTE! The ORIGIN command should be used with REFINE commands only.

  3. SIZE(real,real,real)
    of which the first argument is the size of the new grid in the X-direction;
    the second argument is the size of the new grid in the Y-direction; and
    the third argument is the size of the new grid in the Z-direction.

    NOTE! Command SIZE should be used with REFINE commands only.

  4. COARSE(character*1,integer)
    of which the first argument is X, Y or Z; and
    the second argument is the number of old cells which will be changed into a single cell in the selected direction i.e. it is the number by which NX, NY or NZ must be divided.
    This command controls the coarsening of the grid in the selected direction.

    If the user does not want to coarsen, for example in X-direction, then he should either use the command: COARSE(X,1) or omit the x-direction command entirely.

    NOTE! The COARSE command should be used with SAVEGRD commands only (see below).

  5. SAVEGRD(character*8)
    of which the argument is the name of the file, without extension, which SPINTO will with the coarsened grid and PARSOL=F.
    NOTE 1! The command SAVEGRD can be used with commands COARSE only.
    NOTE 2! The command SAVEGRD makes some changes in Q1, namely:

  6. SAVEFINE
    which command, command without arguments, prints files:
    SAVEFINE should be a single command above the command STOP (see below).
  7. USEGRID(character*8)
    of which the argument is the name of the file, without extension, with the new grid which SPINTO will read and use for interpolation of file phi.

    NOTE! Command USEGRID should be single command besides command STOP (see below).

  8. 'DO INTERPOLATE', which is the default and 'DO NOT INTERPOLATE', each being followed by the name of a solved-for variable.
    For example, the script used for the example of section 4.1 below creates a Q1spin file containing such commands as can be seen by clicking here.

    These commands allow users to test whether it is indeed better to use interpolation (which sometimes involves extrapolation also) or simply to place the average values of the coarse cell into each of the finer cells into which it is split.
    Insufficient experience has been gathered so far to indicate which practice is the better one (if indeed such a general conclusion can be drawn).

    NOTE! These commands should be used only in conjunction with REFINE commands.

  9. STOP
    which is a command without arguments, placed always on the bottom line of file q1spin.
  10.  

3. Methods of working with SPINTO

SPINTO allows three methods of working.

Method 1.

If the user wishes to make runs with two levels of refinement, the refinement factor being two-fold in each direction, he should do the following:

  1. Prepare the file q1spin, containing the next lines:

    REFINE(X,2)
    REFINE(Y,2)
    REFINE(Z,2)
    STOP

  2. Run case on the initial coarse grid.
  3. Run SPINTO and copy NPHI to PHI.
  4. Remake q1 to be sure that it contains statement RESTRT(ALL) and parameters of new grid.
  5. Run satellite and earth.
  6. Run SPINTO and copy NPHI to PHI.
  7. Remake q1 to be sure that it contains parameters of new grid.
  8. Run satellite and earth.

It is method 1 which was used in all three examples of section 4 of this document above, whereby it should be mentioned that, for those two with PARSOL active, it was necessary to make an initial fine-grid two-sweep run so as to create a pbcl.dat file which could be stored for later use.

Method 2.

If the user wishes to make the following sequence of operations:

then he should do the following:

  1. Prepare the file q1spin with next lines:

    REFINE(X,2)
    REFINE(Y,2)
    REFINE(Z,2)
    ORIGIN(0.1,0.1,0.1)
    SIZE(0.8,0.8,0.8)
    
    STOP

  2. Run case on coarser grid.
  3. Run SPINTO and copy NPHI to PHI.
  4. Remake q1 to be sure that it contains statement RESTRT(ALL) and parameters of new grid.
  5. Run satellite and earth.
  6. Run SPINTO and copy NPHI to PHI.
  7. Remake q1 to be sure that it contains parameters of new grid.
  8. Run satellite and earth.

Method 2 has not been exemplified below; and indeed experience of using it is not yet extensive.

The underlying idea is that, in circumstances such as are represented by example 4.3 below, in which the region of interest is small in comparison with the whole domain, a coarse grid is quite sufficient for simulating the flow in regions remote from the body; consequently it is only the region which is close to the body which requires refinement.

Method 3.

The third method is useful when the user wishes to be sure that his coarser grids exactly correspond to the finest grid after refinement.
It is especially useful when the grid is non-uniform, being made so, perhaps, to conform with the bounding boxes of VR-objects.

In this case he should make the next sequence of operations.

  1. Prepare a first Q1 file with finest grid and LSWEEP = 2.
  2. Run the satellite and earth modules. A phi file will thus be created and also a pbcl.dat file. This should be stored for later use.
  3. Prepare a q1spin file containing the lines:

    SAVEFINE
    STOP
  4. Run SPINTO, thereby creating files FINE.grd and FINE.q1.
    However no NPHI file will be created.
    File FINE.grd contains finest grid.
    File FINE.q1 is copy of current Q1.
  5. Prepare a second q1spin file containing the next lines:

    COARSE(X,2)
    COARSE(Y,2)
    COARSE(Z,2)
    SAVEGRD(COARSE)
    STOP
  6. Run SPINTO, which will then create the files COARSE.grd and COARSE.q1.
    File COARSE.grd contains a coarsened grid.
    File COARSE.q1 corresponds to the coarsened grid and sets PARSOL = F.
  7. Copy COARSE.q1 to q1.
  8. Run satellite and earth. File phi will be created with results on the coarsened grid.
  9. Prepare a third q1spin file, containing the lines lines:

    USEGRID(FINE)
    STOP
  10. Run SPINTO. File NPHI will be created with fields which are interpolated on finest grid. The user should copy NPHI to PHI.
  11. Copy FINE.q1 to q1 and add statement RESTRT(ALL) (or, more correctly, RESTRT(list of solved variables)).
  12. Run satellite and earth. File phi will be created with outcomes on fine grid.

A script for Method 3

It would be tedious and error-prone for the user to be required to carry out all the above steps by himself, and for each new calculation. Therefore all the operations have been coded into the script SPIN_LEV.BAT.

This will now be described and presented.

It conducts a two-stage calculation with one coarse grid and one fine grid.
It is activated by the following command:

   SPIN_LEV.BAT 2

Files FINE.grd, FINE.PBC, FINE.q1, COARSE.q1 and COARSE.grd will then be created.
It is necessary to copy COARSE.q1 to q1, edit it if it is necessary to change parameters of relaxation, run satellite and earth to achive converged solution.
Thereafter it is necessary:

The text of the script is as follows:

@echo off
if %1*==* goto MES
if defined phoenics (set pho=%phoenics%) else set pho=\phoenics
SET UTILS=%pho%\d_utils\d_windf\

if not exist PHI goto MES1
if not exist Q1 goto MES2

ECHO SAVEFINE > Q1SPIN
ECHO STOP     >>Q1SPIN

call %UTILS%spin.bat
if exist SPINTO_LOG.FINE del SPINTO_LOG.FINE
ren SPINTO_LOG SPINTO_LOG.FINE

if %1*==1* goto STOP
if %1*==2* goto LEV2
if %1*==3* goto LEV3
if %1*==4* goto LEV4
:LEV2

ECHO COARSE(X,2)     > Q1SPIN
ECHO COARSE(Y,2)     >>Q1SPIN
ECHO COARSE(Z,2)     >>Q1SPIN
ECHO SAVEGRD(COARSE) >>Q1SPIN
ECHO STOP            >>Q1SPIN

call %UTILS%spin.bat
if exist SPINTO_LOG.1 del SPINTO_LOG.1
ren SPINTO_LOG SPINTO_LOG.1

goto STOP

:LEV3

ECHO COARSE(X,2)       > Q1SPIN
ECHO COARSE(Y,2)       >>Q1SPIN
ECHO COARSE(Z,2)       >>Q1SPIN
ECHO SAVEGRD(COARSE_1) >>Q1SPIN
ECHO STOP              >>Q1SPIN

call %UTILS%spin.bat
if exist SPINTO_LOG.1 del SPINTO_LOG.1
ren SPINTO_LOG SPINTO_LOG.1

ECHO COARSE(X,4)       > Q1SPIN
ECHO COARSE(Y,4)       >>Q1SPIN
ECHO COARSE(Z,4)       >>Q1SPIN
ECHO SAVEGRD(COARSE_2) >>Q1SPIN
ECHO STOP              >>Q1SPIN

call %UTILS%spin.bat
if exist SPINTO_LOG.2 del SPINTO_LOG.2
ren SPINTO_LOG SPINTO_LOG.2

goto STOP

:LEV4

ECHO COARSE(X,2)       > Q1SPIN
ECHO COARSE(Y,2)       >>Q1SPIN
ECHO COARSE(Z,2)       >>Q1SPIN
ECHO SAVEGRD(COARSE_1) >>Q1SPIN
ECHO STOP              >>Q1SPIN

call %UTILS%spin.bat
if exist SPINTO_LOG.1 del SPINTO_LOG.1
ren SPINTO_LOG SPINTO_LOG.1

ECHO COARSE(X,4)       > Q1SPIN
ECHO COARSE(Y,4)       >>Q1SPIN
ECHO COARSE(Z,4)       >>Q1SPIN
ECHO SAVEGRD(COARSE_2) >>Q1SPIN
ECHO STOP              >>Q1SPIN

call %UTILS%spin.bat
if exist SPINTO_LOG.2 del SPINTO_LOG.2
ren SPINTO_LOG SPINTO_LOG.2

ECHO COARSE(X,8)       > Q1SPIN
ECHO COARSE(Y,8)       >>Q1SPIN
ECHO COARSE(Z,8)       >>Q1SPIN
ECHO SAVEGRD(COARSE_3) >>Q1SPIN
ECHO STOP              >>Q1SPIN

call %UTILS%spin.bat
if exist SPINTO_LOG.3 del SPINTO_LOG.3
ren SPINTO_LOG SPINTO_LOG.3
goto STOP

:MES
echo Script SPIN_LEV.BAT should be run as
echo            SPIN_LEV.BAT [LEVEL]
echo where [LEVEL] - integer count levels of coarsening without brackets
echo    if [LEVEL] = 1 then script create only fine grid without coarsening
echo    if [LEVEL] = 2 then script create fine grid and 
echo                   one Q1 with coarsen grid by 2 in each direction
echo    if [LEVEL] = 3 then script create fine grid and 
echo                   two Q1s with coarsen grid by 2 and 4 in each direction
echo    if [LEVEL] = 4 then script create fine grid and 
echo                   three Q1s with coarsen grid by 2, 4 and 8 in each direction
echo    [LEVEL] more than four is not allowed. If you need more levels,
echo    please, edit script.
echo If you have problems with this script then be sure that line 
echo SET UTILS indicates to correct path on your PC and 
echo script spin.bat works properly.

goto FIN

:MES1
echo File PHI is absent in current directory. 
echo Please, place file PHI to current directory

goto FIN

:MES2
echo File Q1 is absent in current directory. 
echo Please, place file Q1 to current directory

goto FIN

:STOP
if not exist PHI goto FIN
if exist FINE.PHI del FINE.PHI
ren PHI FINE.PHI
if exist FINE.PBC del FINE.PBC
ren PBCL.DAT FINE.PBC

:FIN

4. Examples of the use of SPINTO

4.1 Input-file library case 274

The problem

The writing of a suitable script makes it possible to effect the grid-refinement automatically. This will now be ilustrated by reference to an example based on core library case 274, which concerns the steady flow past a crudely-represented vehicle placed in a wind-tunnel.
The Q1 file can be seen by clicking here.

If a long (400-sweep) run is made the graphical-monitor display of the convergence behaviour is as shown below:

Evidently, even after 400sweeps, with an associated computer time of 2283 seconds, the pressure field has not quite converged.
Its contours on the symmetry axis are shown below:

The script, which can be inspected by clicking here causes six 30-sweep runs to be performed as follows:

  1. An initial run with the original coarse grid of 8*12*20;
  2. a second re-start run with a finer grid of 16*24*40;
  3. a third re-start run with a still finer grid of32*48*80);
  4. a fourth re-start run with further refinement in the x-direction only of 64*48*80;
  5. a fifth re-start run with further refinement in the y-direction only of 64*96*160; and
  6. a sixth re-start run with further refinement in the z-direction only of 64*96*320 .
The total computer time for all these runs was 338 seconds.

The symmetry plane pressure distribution is shown below:

It is very similar to that of the 2283-second run. The final graphical-monitor output was as follows:

Evidently small sweep-to-sweep changes in the maximum and minimum variables are still occurring; but it can be concluded that the SPINTO-aided run series has produced a solution which is very nearly as good as that of the 400-sweep non-SPINTO run in less than a quarter of the computer time.

4.2 Input-file library case 805

The problem

Core-Input-Library case 805 concerns the steady flow of air around a sphere, with PARSOL=T. Its grid is defined by NX=18, NY=18; NZ=31, which is too coarse for accuracy.

Increasing each of NX, NY and NZ four-fold would improve the accuracy; but the computer time would increase by a much larger factor. Therefore the stage-by-stage coarsening allowed by PINTO may bring some advantage.

This has been investigated in the following manner:-

4.3 A third example

A more extensive investigation has been made of the steady flow over the wide obstacle shown below:

Of special interest is the flow in the immediate vicinity of the obstacle, shown in the following images:

Evidently PARSOL is active.

Many runs were made, both with SPINTO and without; and they showed convincingly that the use of SPINTO both increase the accuracy of the final calculation and significantly reduces the computer time needed to achieve it.

Sufficient proof is afforded by the following images, of which the first is the monitor screen of the fourth of four LSWEEP=50 runs, namely:

  1. a coarse-grid (20*20*6) run with PARSOL=F;
  2. a finer-grid (40*20*12) run with PARSOL=F, re-started from the 'spintoed' result of the first run;
  3. a finer-grid (80*20*24) run with PARSOL=F, re-started from the 'spintoed' result of the second run;
  4. a finer-grid (160*20*48) run with PARSOL=T, re-started from the 'spintoed' result of the third run.

The graphical monitor is being used in the whole-domain-maximum-and-minimum mode.

The left-hand box shows that the maximum pressure (red curve), for example, has varied between 2.9E3 and 3.3E3 pascals during the run, and has become 2.97E3 at its end.It has not quite stopped varying; but its change in the last sweep was 2.53E-1 pascals, i.e. less that 0.01 % of the absolute value.

The right-hand box shows that the minimum pressure has also almost settled to an unchanging value, its latest change being even less than that of the maximum pressure.

Inspection of the curves and values pertaining to the other variables gives a similar impression of near-convergence.

The computer times of the four runs were: 2, 9, 36, and 184 seconds respectively. i.e. 231 in total.

Those results were achieved by the use of SPINTO. Now let us examine the final monitor displays of a 400-sweep run in which SPINTO was not used, shown below.

At first glance it might appear that the convergence is not bad; for the right-hand halves of the red curves appear to be nearly horizontal. However this is explained by the fact that the ranges (i.e. differences between 'low' and 'high') are much bigger than before.

Inspection of the corresponding last-change values show that the domain-minimum values of pressure are still changing at the rate of 1.96 pascal per sweep; and that the minimum pressure (-5.26E3) is still a long way from the -4.66E3 pascals shown in the previous calculation.

It is therefore justifiable to claim that the 50-sweep 'spintoed' run gave a better solution than the 400-sweep run which did not use SPINTO.

Moreover the computer time for the latter was 1723 second, i.e. more than 7 times that of the total of all four runs of the SPINTO-using calculation.

5. Concluding remarks

Although experience with its use is still very limited, it appears that SPINTO can indeed be a valuable computer-time-saving utility, the reason being that it enables the final expensive fine-grid run to begin with a nearly-correct initial field.

There are many variants which have not yet been tried.This document must therefore be regarded as a report on work in progress.

Information about the experiences of others who experiment with SPINTO will be gratefully received by the authors.