Encyclopaedia Index

SPINTO (i.e. Simplified PINTO)

by

Alexey Ginevsky and Brian Spalding

Contents

  1. Preliminary
    1. The PINTO idea
    2. Shortcomings of the original PINTO
    3. The new developments
  2. About SPINTO
    1. How to activate SPINTO
    2. What SPINTO does
    3. Commands recognised by SPINTO
    4. Examples of Q1SPIN files
  3. Methods of working with SPINTO
    1. Refinement of whole domain
    2. Refinement of selected parts of the domain
    3. Refinement with a final check of performance
    4. A script for Method 1
  4. Examples of the use of SPINTO
    1. Flow around a car; input-file library case 274
    2. Flow around a sphere; input-file library case 805
    3. Flow over a wide obstacle
  5. Concluding remarks

1. The PINTO idea

There has long existed a PHOENICS module called PINTO, the PHOENICS INTerpolation prOgram, 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 Shortcomings of the original PINTO

However the original PINTO was unable to handle the large phi-files which are nowadays common in CFD practice.

Further, because PINTO was created well before the introduction of the PARSOL technique, it made no provision for handling the pbcl.dat file, which expresses the extent to which cartesian cells are intersected by objects with curved surfaces.

1.3 The new developments

A new version of PINTO has therefore been created (during 2008) which allows successive grid-refinement without the just-mentioned limitations, albeit with the some restrictions of its own:

SPINTO is entirely compatible, it should be mentioned. with parallel-computing operation of PHOENICS.

It can also, as could PINTO before it, be employed for grid-coarsening operations, should be need for coarsening arise.

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; then for a phi file, and, when used for coarsening also 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.2 What SPINTO does

SPINTO

2.3 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 use with the coarsened grid and PARSOL=F. SPINTO will use with the coarsened grid and PARSOL=F.
    NOTE 1! The command SAVEGRD can be used with command COARSE only.
    NOTE 2! The command SAVEGRD makes some changes in Q1, namely:

  6. SAVEFINE
    which 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.  

2.4 Examples of Q1SPIN files

Lest the last section should give the impression that Q1SPIN files might long, and difficult to write, the file used for the first of the examples discussed in section is now listed as:
refine(x,2)            
refine(y,2)            
refine(z,2)            
do not interpolate p1  
do not interpolate u1  
do not terpolate v1    
do not interpolate w1  
stop

It is indeed extremely short.

3. Methods of working with SPINTO

SPINTO allows three methods of working. of which the first two are for users seeking to save computer time, and the third is for use in quality-assurance studies.

3.1 Method 1; refinement of whole domain

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.

3.2 Method 2; refinement of selected parts of the domain

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.

3.3 Method 3; with final check of performance

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.

3.4 A script for Method 1

It would be tedious and error-prone for the user to carry out all the above steps; and for each new calculation. Therefore all the operations have been coded into the WINDOWS DOS script SPINTO.BAT.

This will now be presented and commented upon.


REM The purpose of the script is to enable the advantage gained from the 
REM use of SPINTO to be established by obtaining first a non-SPINTO 
REM solution corresponding to a single restart (and therefore a total 
REM number of sweeps equal to 2*SWEEPS with the solution obtained after 
REM SPINTO-using sequence in which PARSOL=T only for the finest-grid run.

REM This file, simple.bat, organises a series of runs in which a coarse grid 
REM is refined twice for a Q1 in which there are facetted objects in the 
REM domain and PARSOL=t
REM Parsol is set =f for all the coarser-grid runs.
REM
REM LSWEEP is set equal to the environment variable SWEEPS for all runs.

REM the runs are:
REM 1. finest grid, parsol=t, lsweep=2 so as to create pbcl.dat
REM    This may be omitted if facetted objects are absent or if parsol has 
REM    been set =f in the original q1 

REM 2. coarsest grid, parsol=f, 

REM 3. SPINTO restart from run 2, finer grid (*2 in all directions), parsol=f 

REM 4. SPINTO restart from run 3, finest grid (*2 in all directions), parsol=t 

REM 5. finest grid, non-SPINTO, non-restart, parsol=t
Readers who are unfamiliar with DOS scripts (i.e. 'batch files', should note that only those lines which do not begin with REM (an abbreviation for 'remark') are acted upon.

THe execution of the script starts when 'spinto' is entered at the DOS prompt



REM The q1 is set up with the coarsest grid; and it contains an incl(spinxyz1) 
REM statement above its subsequent grid-setting statements.
REM The spinxyz1 file is written by the spinto executable each time it runs;
REM but the spixyz1 files for runs 1, 2, 6 and 7 are written by the present 
REM script.
REM The spinto executable also writes a spinxyz2 file. But this is not used.
REM Instead, the present script  puts all necessary additional instructions 
REM into the q2 file.
REM The present script also write the Q1spin file which gives SPINTO its 
REM instructions. 


REM If it is desired to terminate execution of this script at any stage, 
REM place the following 'goto end' at the desired location if this file, 
REM after first REMoving the 'REM'from in front of it.
REM goto end

REM The following environment variable, SWEEPS, is the number of sweeps
REM to be carried out in all runs
SET SWEEPS=5

REM When the following environment variable = 0, Run 1 is omitted.
REM When it equals 1, Run 1 is carried out
SET PARSOL=0
The environment variables are changed by editing the spinto,bat file; and it is possible to give SWEEPS a different value for each run if that is desired.

PARSOL must be set equal to 1 is facetted objects are to be handled by the PARSOL technique.


echo run started >log
GOTO %PARSOL%
:1
REM Run1, to make pbcl.dat
REM initialization of file INCLuded in the q1 by the statement 
REM  INCL(SPINXYZ1) 
REM which must appear there immediately after the statement which 
REM sets the values of NX, NY and NZ
REM the 4s correspond to the fact that 2 levels of refinement are to
REM be carried out, with refinement factors of 2 in each case
ECHO nx=4*nx; ny=4*ny; nz=4*nz > spinxyz1

REM Perform the first finest-grid run
ECHO TEXT(1 no restart; finest grid; make pbcl >Q2
echo lsweep=2 >>q2
echo run 1 starting >>log
CALL SE
copy pbcl.dat pbcl.sav
echo pbcl saved >>log

:0
REM Run 2, coarsest-grid 
REM initialization of file INCLuded in the q1
ECHO    no refinement > spinxyz1
ECHO TEXT(Run 2; no restart; coarsest grid >Q2
echo lsweep=%sweeps% >>q2
echo parsol=f >>q2
REM echo store(prps) >>q2

REM The following settings have no particular connection with SPINTO
REM They over-write those in the original Q1
relax(u1,falsdt,1.0) >>q2
relax(v1,falsdt,1.0) >>q2
relax(w1,falsdt,1.0) >>q2
conwiz=t
echo run 2 starting >>log
CALL SE
echo run 2 completed >>log


REM Prepare for SPINTO runs by echoing the necessary lines to q1spin
ECHO refine(x,2)            >Q1SPIN
ECHO refine(y,2)            >>Q1SPIN
ECHO refine(z,2)            >>Q1SPIN
ECHO do not interpolate p1  >>Q1SPIN
ECHO do not interpolate u1  >>Q1SPIN
ECHO do not interpolate v1  >>Q1SPIN
ECHO do not interpolate w1  >>Q1SPIN
ECHO stop                   >>Q1SPIN
echo q1spin written >>log
REM According to the above commands, SPINTO will double the cell 
REM numbers in each direction
REM It also: 1. writes the new values of NX, NY, NZ into the file
REM             spinxyz1, which is INCLuded in the Q1 file before the
REM             grid is created;
REM          2. declares the boolean variable NEWPHI and sets it = T
REM          3. reads the existing PHI file and creates therefrom
REM             a new file, NPHI, from which the next EARTH run restarts.
REM It also writes a file called spinxyz2 which is however no longer
REM INCLuded by the Q1 because its content more visible transmitted by
REM the following lines to the always-read Q2 file.
  
REM Run 3, the first re-start-with finer grid 
ECHO if(newphi) then                      >>Q2
The REMs in front of the PRPS-related statements should be removed if its is desired to call, at the end of the script, for a non-restart run with the finest grid. For then the original fiinit(prps) will be needed.

REM ECHO real(fiinprps)           >>Q2
REM ECHO fiinprps=fiinit(prps)    >>Q2 
ECHO restrt(all)                  >>Q2 
REM ECHO fiinit(prps)=fiinprps    >>Q2 
ECHO namfi=nphi                   >>Q2 
ECHO endif                        >>Q2 
ECHO TEXT(3  finer-grid restart   >>Q2
echo lsweep=%sweeps% >>q2
REM Call runspin to activate SPINTO, then se for SATELLITE and EARTH, 

CALL RUNSPIN
COPY NPHI NPHI3
echo run 3 starting >>log
CALL SE
echo run 3 completed >>log

REM Run 4, the second re-start with still-finer grid
copy pbcl.sav pbcl.dat
ECHO parsol=t                                    >>Q2
ECHO TEXT(4 finest-grid restart parsol=:parsol:  >>Q2
REM Call runspin to activate SPINTO, then se for SATELLITE and EARTH, 

CALL RUNSPIN
COPY NPHI NPHI4
echo run 4 starting >>log
CALL SE
echo run 4 completed >>log
:end
For ease of understanding, the above script has been stripped of other statements which it is usually found convenient to include, for example those which save the intermediate results for later study.

There is much which an adept script writer can include which saves himself and others needless labour.

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 Flow over a wide obstacle

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.