recurrence model: testing large, incomplete data bases

This is a small, simple tutorial for testing the implementation of
large, incomplete data bases.
In this tutorial case, rStatAnalysis is used as post-processor and
it uses a data base in memory, which is smaller than the number of
snapshots on disk.
This commit is contained in:
MarkoRamius
2018-03-08 16:49:34 +11:00
parent 4403f4e191
commit 48c2ac22c0
20 changed files with 919 additions and 0 deletions

View File

@ -0,0 +1,51 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
cylinder
{
type fixedValue;
value uniform (0 0 0);
}
inlet
{
type fixedValue;
value uniform (0.0040120 0 0); // Re = 200
}
outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
value uniform (0 0 0);
}
"side.*"
{
type slip;
}
frontBack
{
type empty;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
cylinder
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
"side.*"
{
type zeroGradient;
}
frontBack
{
type empty;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,23 @@
#!/bin/bash
#
# clean the case
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
# remove mesh
rm -rf constant/polyMesh/*
rm -rf 0 > /dev/null 2>&1
cleanCase
rm rec_jump.dat
rm recurrenceMatrix
rm recurrencePath
cd recMat
./clean.sh

View File

@ -0,0 +1,9 @@
#!/bin/bash
#
# run the case
./meshIt
./run
./post

View File

@ -0,0 +1,78 @@
# Test large, incomplete data bases
This tutorial tests the use of data bases (in memory), which are smaller
than the number of snaphots in the data base (on disk). This distinction
becomes important for cases with large meshes, a large number of snapshots,
or cases with both of these properties. In such cases, the memory (RAM) of
the computer might be too small to fit all snapshots.
In such a case - with *M*, the number of snapshots in memory, being smaller
than *N*, the number of snapshots on disk - we use the recurrence model
designed for large, complete data bases.
This tutorial is based on the *laminar flow over cylinder* tutorial. It is
rather small, but is nevertheless used to demonstrate the use of the large,
incomplete data bases feature.
## Case description
This case is run for a small amount of time, and then, the tool `rStatAnalysis`
is used as a post-processing tool to compute the recurrence matrix [1].
In this case, `rStatAnalysis` is run with a data base (in memory) smaller than
the number of snapshots on disk.
## Results
If we monitor the log file written by `rStatAnalysis`, we fill find the line
similar to the following:
`Checking all 20 fields`
This line tells us the total number of snapshots on disk, which will all be
checked for existence and readabiltiy.
Afterwards, when it is enured that all expected fields are present, the data
base in memory is filled with fields read from disk. However, as the data base
in memory is smaller than the number of snapshots on disk, the data base in
memory will be incomplete.
Thus, we will encounter a line similar to the following one, which tells us
that a number of fields is being read.
`Reading fields for 11 dataBase slots`
When computing the recurrence matrix, all *N* snapshots need to be compared
with each other. As the data base holds only *M* snapshots, with *M<N*, at
some point, the snapshots in the data base will need to be replaced with
other ones, wich have not been read at that point.
Such an operation is indicated by a line as shown below, provided the switch
`verboseVacate` is enabled in `recProperties`.
` --> vacate dataBase : 5`
After the recurrence matrix has been computed, the recurrence model prints
the total number of reads-from-disk to the Terminal. This is shown below:
`Nr. of reads from disk : 30; compared to a theoretical minimum of 20 reads.`
This indicates, that the total number of reads-from-disk is necessarily
larger that the number of snapshots. The total number of reads-from-disk
depends on the relative sizes of *N* and *M*. However, it will always be larger
than the theoretical minimum, which is achieved, when *M* is equal to *N*, i.e.
each field is read only once.
## Tested
This collection of cases has been tested with:
* OpenFOAM-5.0
## References
[1] T. Lichtenegger and S. Pirker. Recurrence CFD A novel approach to simulate
multiphase flows with strongly separated time scales. Chemical Engineering Science,
153:394-410, 2016.

View File

@ -0,0 +1,94 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.4 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object recProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//===========================================================================//
// sub-models & settings
//recModel standardRecModel;
recModel gerhardsRecModel;
verbose false;
recNorm sqrDiffNorm;
recPath simpleRandomPath;
volScalarFields
(
);
volVectorFields
(
U
);
surfaceScalarFields
(
);
//verbose;
//===========================================================================//
// sub-model properties
standardRecModelProps
{
dataBase ".";
skipZero on;
}
gerhardsRecModelProps
{
dataBase ".";
skipZero on;
numDataBaseFields 11;
verboseVacate on;
}
sqrDiffNormProps
{
fieldType "volVectorField";
fieldName U;
//verbose false;
}
simpleRandomPathProps
{
}
noRecStatAnalysis
{
}
// ************************************************************************* //

View File

@ -0,0 +1,25 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
// water, 20°C, VDI Wärmeatlas
nu nu [ 0 2 -1 0 0 0 0 ] 1.003e-06;
// ************************************************************************* //

View File

@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
// ************************************************************************* //

View File

@ -0,0 +1,6 @@
#!/bin/bash
blockMesh 2>&1 | tee log.blockMesh 2>&1
# renumber the mesh
renumberMesh -overwrite 2>&1 | tee log.renumberMesh 2>&1

View File

@ -0,0 +1,10 @@
#!/bin/bash
#
# run the post-processing
rStatAnalysis 2>&1 | tee log.rStatAnalysis 2>&1
cd recMat
./plot.sh

View File

@ -0,0 +1,7 @@
#!/bin/bash
rm -f *.log
rm -f *.aux
rm -f *.txt
rm -f *.pdf
rm -f myDistMatrix.tex

View File

@ -0,0 +1,75 @@
% open files
fid1 = fopen('../recurrenceMatrix');
% read dimensions
A1 = fscanf(fid1, '%g %g');
% skip the first two lines
tline = fgetl(fid1);
tline = fgetl(fid1);
% get dimensions
N1 = A1(1)
M1 = A1(2)
% allocate space
B0 = zeros(M1,N1);
% read data
for i=1:N1
B0(:,i) = fscanf(fid1, '%g', inf);
tline = fgetl(fid1);
tline = fgetl(fid1);
end
% close files
fclose(fid1);
% skip this many leading entries
sle = 0;
B1 = zeros(M1-sle,N1-sle);
B1 = B0(1+sle:M1,1+sle:N1);
maxval=0.0;
%for i=1:M1
% for j=1:N1
% if(B1(i,j)>maxval)
% maxval=B1(i,j);
% endif
% end
%end
maxval = 1.0;
for i=1:M1-sle
for j=1:N1-sle
B1(i,j)=1-B1(i,j)/maxval;
% B1(i,j)=B1(i,j)/maxval;
end
end
% write full matrix to simple text file
dlmwrite('myMatrix.txt',B1,'delimiter','\t','precision',3)
%plot(C1)
%saveas(gcf,'Plot','png')
%B1=B1*1;
%hold on
%colormap(jet(50))
%imagesc(B1)
%colorbar
%saveas(gcf,'Figure','png')

View File

@ -0,0 +1,7 @@
\documentclass[preview]{standalone}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\input{myDistMatrix}
\end{figure}
\end{document}

View File

@ -0,0 +1,4 @@
octave getRecMat.m
gnuplot plotDistMat.gnu
pdflatex makePlot.tex
pdfcrop makePlot.pdf distMatrix.pdf

View File

@ -0,0 +1,48 @@
reset
clear
set terminal cairolatex pdf dash dl 1
set pm3d map
set contour surface
set cntrparam levels discr 10
set samples 50
set isosamples 50
set palette maxcolors 8
set palette defined(\
0 0.2314 0.2980 0.7529,\
0.125000 0.384300 0.509800 0.917600,\
0.250000 0.552900 0.690200 0.996100,\
0.375000 0.721600 0.815700 0.976500,\
0.500000 0.866700 0.866700 0.866700,\
0.625000 0.960800 0.768600 0.678400,\
0.750000 0.956900 0.603900 0.482400,\
0.875000 0.870600 0.376500 0.302000,\
1 0.7059 0.0157 0.1490\
)
set cbtics 0.6
set mcbtics 8
#set cblabel 'distance'
#unset cbtics
set cbrange [0:0.6]
set format cb "%.1f"
#set xrange[0:3]
#set yrange[0:3]
set xlabel 't [s]'
set ylabel 't [s]'
# evil manual meddling with axes tics
set xtics ("0" 0, "500" 50, "1000" 100, "1500" 150, "2000" 199)
set ytics ("0" 0, "500" 50, "1000" 100, "1500" 150, "2000" 199)
#set mxtics 2
#set mytics 2
set size square
set out 'myDistMatrix.tex'
splot 'myMatrix.txt' matrix using ($1):($2):(1-$3) with image notitle

View File

@ -0,0 +1,12 @@
#!/bin/bash
#
# run the simulation
rm -rf 0
cp -r 0.org 0
# initialise solution
potentialFoam 2>&1 | tee log.potentialFoam 2>&1
# run simulation
pimpleFoam 2>&1 | tee log.pimpleFoam 2>&1

View File

@ -0,0 +1,145 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \ / O peration | Version: 2.1.x |
| \ / A nd | Web: www.OpenFOAM.org |
| \/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1.0;
vertices
(
( 0.0 -0.25 0.0 ) // x0y0z0 = 0
( 0.0 -0.25 0.01 ) // x0y0z1 = 1
( 0.0 0.25 0.0 ) // x0y1z0 = 2
( 0.0 0.25 0.01 ) // x0y1z1 = 3
( 0.15000000000000002 -0.25 0.0 ) // x1y0z0 = 4
( 0.15000000000000002 -0.25 0.01 ) // x1y0z1 = 5
( 0.15000000000000002 0.25 0.0 ) // x1y1z0 = 6
( 0.15000000000000002 0.25 0.01 ) // x1y1z1 = 7
( 0.65 -0.25 0.0 ) // x2y0z0 = 8
( 0.65 -0.25 0.01 ) // x2y0z1 = 9
( 0.65 0.25 0.0 ) // x2y1z0 = 10
( 0.65 0.25 0.01 ) // x2y1z1 = 11
( 1.5 -0.25 0.0 ) // x3y0z0 = 12
( 1.5 -0.25 0.01 ) // x3y0z1 = 13
( 1.5 0.25 0.0 ) // x3y1z0 = 14
( 1.5 0.25 0.01 ) // x3y1z1 = 15
( 0.41767766952966373 0.017677669529663688 0.0 ) // a0h0 = 16
( 0.3823223304703363 0.01767766952966369 0.0 ) // a1h0 = 17
( 0.3823223304703363 -0.017677669529663688 0.0 ) // a2h0 = 18
( 0.41767766952966373 -0.01767766952966369 0.0 ) // a3h0 = 19
( 0.41767766952966373 0.017677669529663688 0.01 ) // a0h1 = 20
( 0.3823223304703363 0.01767766952966369 0.01 ) // a1h1 = 21
( 0.3823223304703363 -0.017677669529663688 0.01 ) // a2h1 = 22
( 0.41767766952966373 -0.01767766952966369 0.01 ) // a3h1 = 23
);
blocks
(
hex ( 0 4 6 2 1 5 7 3 ) ( 6 20 1 ) simpleGrading ( 1 1 1 ) // 0 ['x0y0z0', 'x1y0z0', 'x1y1z0', 'x0y1z0']
hex ( 8 12 14 10 9 13 15 11 ) ( 34 20 1 ) simpleGrading ( 1 1 1 ) // 1 ['x2y0z0', 'x3y0z0', 'x3y1z0', 'x2y1z0']
// cylinder block
hex ( 16 10 6 17 20 11 7 21 ) ( 18 20 1 ) simpleGrading ( 1 1 1 ) // 2 ['a0h0', 'b0h0', 'b1h0', 'a1h0']
hex ( 17 6 4 18 21 7 5 22 ) ( 18 20 1 ) simpleGrading ( 1 1 1 ) // 3 ['a1h0', 'b1h0', 'b2h0', 'a2h0']
hex ( 18 4 8 19 22 5 9 23 ) ( 18 20 1 ) simpleGrading ( 1 1 1 ) // 4 ['a2h0', 'b2h0', 'b3h0', 'a3h0']
hex ( 19 8 10 16 23 9 11 20 ) ( 18 20 1 ) simpleGrading ( 1 1 1 ) // 5 ['a3h0', 'b3h0', 'b0h0', 'a0h0']
);
edges
(
arc 16 17 ( 0.4 0.025 0.0 )// cyl block
arc 17 18 ( 0.375 3.061616997868383e-18 0.0 )// cyl block
arc 18 19 ( 0.4 -0.025 0.0 )// cyl block
arc 19 16 ( 0.42500000000000004 -6.123233995736766e-18 0.0 )// cyl block
arc 20 21 ( 0.4 0.025 0.01 )// cyl block
arc 21 22 ( 0.375 3.061616997868383e-18 0.01 )// cyl block
arc 22 23 ( 0.4 -0.025 0.01 )// cyl block
arc 23 20 ( 0.42500000000000004 -6.123233995736766e-18 0.01 )// cyl block
);
boundary
(
inlet
{
type patch;
faces
(
( 0 2 3 1 ) // ['x0y0z0', 'x0y1z0', 'x0y1z1', 'x0y0z1']
);
}
outlet
{
type patch;
faces
(
( 12 14 15 13 ) // ['x3y0z0', 'x3y1z0', 'x3y1z1', 'x3y0z1']
);
}
cylinder
{
type wall;
faces
(
( 16 17 21 20 ) // ['a0h0', 'a1h0', 'a1h1', 'a0h1']
( 17 18 22 21 ) // ['a1h0', 'a2h0', 'a2h1', 'a1h1']
( 18 19 23 22 ) // ['a2h0', 'a3h0', 'a3h1', 'a2h1']
( 19 16 20 23 ) // ['a3h0', 'a0h0', 'a0h1', 'a3h1']
);
}
sides
{
type patch;
faces
(
( 0 4 5 1 ) // ['x0y0z0', 'x1y0z0', 'x1y0z1', 'x0y0z1']
( 2 6 7 3 ) // ['x0y1z0', 'x1y1z0', 'x1y1z1', 'x0y1z1']
( 4 8 9 5 ) // ['x1y0z0', 'x2y0z0', 'x2y0z1', 'x1y0z1']
( 6 10 11 7 ) // ['x1y1z0', 'x2y1z0', 'x2y1z1', 'x1y1z1']
( 8 12 13 9 ) // ['x2y0z0', 'x3y0z0', 'x3y0z1', 'x2y0z1']
( 10 14 15 11 ) // ['x2y1z0', 'x3y1z0', 'x3y1z1', 'x2y1z1']
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,90 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application twoPhaseEulerFoam;
startFrom latestTime;
startTime 0.1;
stopAt endTime;
//stopAt writeNow;
endTime 20;
deltaT 1.0e-2;
writeControl adjustableRunTime;
writeInterval 1;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
adjustTimeStep yes;
maxCo 0.25;
maxDeltaT 1;
functions
{
forces
{
type forceCoeffs;
functionObjectLibs ( "libforces.so" );
writeControl timeStep;
writeInterval 1;
patches
(
cylinder
);
directForceDensity no;
pName p;
UName U;
rhoName rhoInf;
//log true;
rhoInf 994.5;
rho rhoInf;
CofR ( 0 0 0 );
liftDir ( 0 1 0 );
dragDir ( 1 0 0 );
pitchAxis ( 0 0 1 );
magUInf 10.0;
lRef 0.04;
Aref 0.0157;
Aref1 0.004;
rhoRef 994.5;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(U) cellLimited Gauss linear 1;
}
divSchemes
{
default none;
div(phi,U) bounded Gauss linearUpwindV grad(U);
div((nuEff*dev2(T(grad(U))))) Gauss linear;
div((nuEff*dev(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear limited corrected 0.33;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
fluxRequired
{
default no;
p ;
Phi ;
}
// ************************************************************************* //

View File

@ -0,0 +1,105 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver GAMG;
tolerance 1e-08;
relTol 0.0001;
maxIter 100;
smoother DIC;
nPreSweeps 1;
nPostSweeps 2;
nFinestSweeps 2;
scaleCorrection true;
directSolveCoarsestLevel false;
cacheAgglomeration true;
nCellsInCoarsestLevel 330;
agglomerator faceAreaPair;
mergeLevels 1;
}
pFinal
{
$p;
relTol 0;
}
U
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-08;
relTol 0.001;
}
/*U
{
type coupled;
solver PBiCICG;
preconditioner DILU;
tolerance (1e-08 1e-08 1e-08);
relTol (0 0 0);
}*/
UFinal
{
$U;
}
Phi
{
solver PCG;
preconditioner DIC;
tolerance 1e-08;
relTol 0.001;
}
}
PIMPLE
{
nOuterCorrectors 10;
nCorrectors 1;
nNonOrthogonalCorrectors 1;
residualControl
{
U
{
relTol 0;
tolerance 0.00001;
}
}
}
relaxationFactors
{
/*equations
{
p 0.4;
U 0.6;
}*/
}
potentialFlow
{
nNonOrthogonalCorrectors 20;
}
// ************************************************************************* //