diff --git a/jngcgc/.gitignore b/jngcgc/.gitignore new file mode 100644 index 0000000..181d655 --- /dev/null +++ b/jngcgc/.gitignore @@ -0,0 +1 @@ +.~lock* diff --git a/jngcgc/README.md b/jngcgc/README.md new file mode 100644 index 0000000..a277a5f --- /dev/null +++ b/jngcgc/README.md @@ -0,0 +1,13 @@ +# JNGCGC + +Journée Nationale Génie Côtier - Génie Civil + + +## Mise en forme + +* Compatible Microsoft Word +* Interligne 16pt +* Corps *Times New Roman* 12pt +* Titre *Times New Roman* 16pt +* Marges T:41mm, BLR:30mm +* Pas de notes de bas de page diff --git a/jngcgc/article.odt b/jngcgc/article.odt new file mode 100644 index 0000000..c5f3eb4 Binary files /dev/null and b/jngcgc/article.odt differ diff --git a/jngcgc/reference.doc b/jngcgc/reference.doc new file mode 100644 index 0000000..d7ad8ee Binary files /dev/null and b/jngcgc/reference.doc differ diff --git a/olaflow/config.ini b/olaflow/config.ini index 1b97257..9ea81cc 100644 --- a/olaflow/config.ini +++ b/olaflow/config.ini @@ -1,5 +1,5 @@ [swash] -np_out=../swash/inp_post/real_spec_interp +np_out=../swash/inp_post/ts_4lay_1h [bathy] bathy=../data/out_of/bathy.dat @@ -12,11 +12,11 @@ level=4.5 path=/opt/OpenFOAM/OpenFOAM-9/bin:/opt/OpenFOAM/OpenFOAM-9/platforms/linux64GccDPInt32Opt/bin root=of out=out_of -t0 = 13900 -tf = 14300 +t0 = 1300 +tf = 1900 x0 = -150 [post] -out = out_post_refined +out = out_post_ts_2 x = -50 z = 5 diff --git a/olaflow/of/constant/porosityDict b/olaflow/of/constant/porosityDict index 1d10f00..384f83d 100644 --- a/olaflow/of/constant/porosityDict +++ b/olaflow/of/constant/porosityDict @@ -17,8 +17,8 @@ FoamFile // Materials: clear region, core, secondary armour layer, primary armour layer // a,b,c: tuning parameters -a 2(0 50); -b 2(0 1.2); +a 2(0 5000); +b 2(0 2.0); c 2(0 0.34); // D50: mean nominal diameter diff --git a/olaflow/of/system/controlDict b/olaflow/of/system/controlDict index ca393bb..263303e 100644 --- a/olaflow/of/system/controlDict +++ b/olaflow/of/system/controlDict @@ -24,7 +24,7 @@ startTime 0; stopAt endTime; -endTime 400; +endTime 600; deltaT 0.1; diff --git a/olaflow/of/system/decomposeParDict b/olaflow/of/system/decomposeParDict index 3407e5d..580c28b 100644 --- a/olaflow/of/system/decomposeParDict +++ b/olaflow/of/system/decomposeParDict @@ -15,13 +15,13 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 4; +numberOfSubdomains 6; method simple; simpleCoeffs { - n ( 2 2 1 ); + n ( 3 1 2 ); delta 0.001; } @@ -34,7 +34,7 @@ hierarchicalCoeffs metisCoeffs { - processorWeights ( 1 1 1 1 ); + processorWeights ( 1 1 1 1 1 1 ); } manualCoeffs diff --git a/olaflow/of/system/graphUniform b/olaflow/of/system/graphUniform new file mode 100644 index 0000000..d2e315b --- /dev/null +++ b/olaflow/of/system/graphUniform @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Writes graph data for specified fields along a line, specified by start and + end points. A specified number of graph points are used, distributed + uniformly along the line. + +\*---------------------------------------------------------------------------*/ + +start (-50 0.5 -15); +end (-50 0.5 15); +nPoints 100; + +fields (alpha.water); + +axis z; + +#includeEtc "caseDicts/postProcessing/graphs/graphUniform.cfg" + +// ************************************************************************* // diff --git a/olaflow/of_short_ts/constant/porosityDict b/olaflow/of_short_ts/constant/porosityDict new file mode 100644 index 0000000..1d10f00 --- /dev/null +++ b/olaflow/of_short_ts/constant/porosityDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porosityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Materials: clear region, core, secondary armour layer, primary armour layer +// a,b,c: tuning parameters +a 2(0 50); +b 2(0 1.2); +c 2(0 0.34); + +// D50: mean nominal diameter +D50 2(1 4); +// porosity (phi) +porosity 2(1 0.4); + +// ************************************************************************* // diff --git a/olaflow/of_short_ts/system/blockMeshDict b/olaflow/of_short_ts/system/blockMeshDict new file mode 100644 index 0000000..ff77ee3 --- /dev/null +++ b/olaflow/of_short_ts/system/blockMeshDict @@ -0,0 +1,81 @@ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.7.1 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +vertices +( + (-150 0 -30) + (0 0 -30) + (0 0 30) + (-150 0 30) + (-150 1 -30) + (0 1 -30) + (0 1 30) + (-150 1 30) +); + +blocks +( + hex (0 1 5 4 3 2 6 7) (300 1 120) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + /*outlet + { + type patch; + faces + ( + (1 5 6 2) + ); + }*/ + wall1 + { + type wall; + faces + ( + (0 1 5 4) + ); + } + atmosphere + { + type patch; + faces + ( + (3 2 6 7) + (1 5 6 2) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/olaflow/of_short_ts/system/controlDict b/olaflow/of_short_ts/system/controlDict new file mode 100644 index 0000000..ca393bb --- /dev/null +++ b/olaflow/of_short_ts/system/controlDict @@ -0,0 +1,138 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.3 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + location "system"; + class dictionary; + object controlDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application olaFlow; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 400; + +deltaT 0.1; + +writeControl adjustableRunTime; + +writeInterval 0.5; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +compression on; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.45; +maxAlphaCo 0.45; + +maxDeltaT 0.5; +/* +functions +{ + gaugesVOF + { + type sets; + libs ("libsampling.so"); + writeControl outputTime; + writeInterval 1; + setFormat raw; + surfaceFormat raw; + interpolationScheme cell; + fields ( alpha.water ); + sets + ( + GaugeVOF01 + { + type lineCellFace; + axis xyz; + start ( 0.5 0.001 0 ); + end ( 0.5 0.001 1.2 ); + } + GaugeVOF02 + { + type lineCellFace; + axis xyz; + start ( 9.25 0.001 0 ); + end ( 9.25 0.001 1.2 ); + } + GaugeVOF03 + { + type lineCellFace; + axis xyz; + start ( 15.75 0.001 0 ); + end ( 15.75 0.001 1.2 ); + } + GaugeVOF04 + { + type lineCellFace; + axis xyz; + start ( 17.75 0.001 0 ); + end ( 17.75 0.001 1.2 ); + } + GaugeVOF05 + { + type lineCellFace; + axis xyz; + start ( 21.1 0.001 0 ); + end ( 21.1 0.001 1.2 ); + } + ); + } + gaugesP + { + type sets; + libs ("libsampling.so"); + writeControl outputTime; + writeInterval 1; + setFormat raw; + surfaceFormat raw; + interpolationScheme cellPointFace; + fields ( p ); + sets + ( + GaugesP + { + type boundaryPoints; + axis xyz; + patches 1(caisson); + points ((18.0 0.01 0.75) + (18.00 0.01 0.80) + (18.00 0.01 0.85) + (18.00 0.01 0.95) + (18.01 0.01 0.70) + (18.25 0.01 0.70) + (18.50 0.01 0.70) + (18.75 0.01 0.70)); + maxDistance 0.01; + } + ); + } +} +*/ +// ************************************************************************* // diff --git a/olaflow/of_short_ts/system/graphUniform b/olaflow/of_short_ts/system/graphUniform new file mode 100644 index 0000000..cb575db --- /dev/null +++ b/olaflow/of_short_ts/system/graphUniform @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Writes graph data for specified fields along a line, specified by start and + end points. A specified number of graph points are used, distributed + uniformly along the line. + +\*---------------------------------------------------------------------------*/ + +start (-50 0.5 -15); +end (-50 0.5 15); +nPoints 100; + +fields (alpha.water U); + +axis z; + +#includeEtc "caseDicts/postProcessing/graphs/graphUniform.cfg" + +// ************************************************************************* // diff --git a/olaflow/of_short_ts/system/graphUniform2 b/olaflow/of_short_ts/system/graphUniform2 new file mode 100644 index 0000000..185937c --- /dev/null +++ b/olaflow/of_short_ts/system/graphUniform2 @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Writes graph data for specified fields along a line, specified by start and + end points. A specified number of graph points are used, distributed + uniformly along the line. + +\*---------------------------------------------------------------------------*/ + +start (-20 0.5 -15); +end (-20 0.5 15); +nPoints 100; + +fields (alpha.water U); + +axis z; + +#includeEtc "caseDicts/postProcessing/graphs/graphUniform.cfg" + +// ************************************************************************* // diff --git a/olaflow/of_short_ts_1/constant/porosityDict b/olaflow/of_short_ts_1/constant/porosityDict new file mode 100644 index 0000000..d6e69dc --- /dev/null +++ b/olaflow/of_short_ts_1/constant/porosityDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porosityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Materials: clear region, core, secondary armour layer, primary armour layer +// a,b,c: tuning parameters +a 2(0 0); +b 2(0 1.2); +c 2(0 0.34); + +// D50: mean nominal diameter +D50 2(1 4); +// porosity (phi) +porosity 2(1 0.4); + +// ************************************************************************* // diff --git a/olaflow/of_short_ts_2/constant/porosityDict b/olaflow/of_short_ts_2/constant/porosityDict new file mode 100644 index 0000000..4917976 --- /dev/null +++ b/olaflow/of_short_ts_2/constant/porosityDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porosityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Materials: clear region, core, secondary armour layer, primary armour layer +// a,b,c: tuning parameters +a 2(0 5000); +b 2(0 1.2); +c 2(0 0.34); + +// D50: mean nominal diameter +D50 2(1 4); +// porosity (phi) +porosity 2(1 0.4); + +// ************************************************************************* // diff --git a/olaflow/of_short_ts_3/constant/porosityDict b/olaflow/of_short_ts_3/constant/porosityDict new file mode 100644 index 0000000..e8195b1 --- /dev/null +++ b/olaflow/of_short_ts_3/constant/porosityDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porosityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Materials: clear region, core, secondary armour layer, primary armour layer +// a,b,c: tuning parameters +a 2(0 50); +b 2(0 0); +c 2(0 0.34); + +// D50: mean nominal diameter +D50 2(1 4); +// porosity (phi) +porosity 2(1 0.4); + +// ************************************************************************* // diff --git a/olaflow/of_short_ts_3b/constant/porosityDict b/olaflow/of_short_ts_3b/constant/porosityDict new file mode 100644 index 0000000..ba99f54 --- /dev/null +++ b/olaflow/of_short_ts_3b/constant/porosityDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porosityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Materials: clear region, core, secondary armour layer, primary armour layer +// a,b,c: tuning parameters +a 2(0 50); +b 2(0 0.1); +c 2(0 0.34); + +// D50: mean nominal diameter +D50 2(1 4); +// porosity (phi) +porosity 2(1 0.4); + +// ************************************************************************* // diff --git a/olaflow/of_short_ts_4/constant/porosityDict b/olaflow/of_short_ts_4/constant/porosityDict new file mode 100644 index 0000000..b397cc5 --- /dev/null +++ b/olaflow/of_short_ts_4/constant/porosityDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porosityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Materials: clear region, core, secondary armour layer, primary armour layer +// a,b,c: tuning parameters +a 2(0 50); +b 2(0 3.0); +c 2(0 0.34); + +// D50: mean nominal diameter +D50 2(1 4); +// porosity (phi) +porosity 2(1 0.4); + +// ************************************************************************* // diff --git a/olaflow/of_short_ts_5/constant/porosityDict b/olaflow/of_short_ts_5/constant/porosityDict new file mode 100644 index 0000000..cff42b1 --- /dev/null +++ b/olaflow/of_short_ts_5/constant/porosityDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porosityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Materials: clear region, core, secondary armour layer, primary armour layer +// a,b,c: tuning parameters +a 2(0 50); +b 2(0 1.2); +c 2(0 0.34); + +// D50: mean nominal diameter +D50 2(1 2); +// porosity (phi) +porosity 2(1 0.4); + +// ************************************************************************* // diff --git a/olaflow/of_short_ts_6/constant/porosityDict b/olaflow/of_short_ts_6/constant/porosityDict new file mode 100644 index 0000000..71fe7c6 --- /dev/null +++ b/olaflow/of_short_ts_6/constant/porosityDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porosityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Materials: clear region, core, secondary armour layer, primary armour layer +// a,b,c: tuning parameters +a 2(0 50); +b 2(0 1.2); +c 2(0 0.34); + +// D50: mean nominal diameter +D50 2(1 4); +// porosity (phi) +porosity 2(1 0.25); + +// ************************************************************************* // diff --git a/olaflow/of_short_ts_kom/constant/turbulenceProperties_sst b/olaflow/of_short_ts_kom/constant/turbulenceProperties_sst new file mode 100644 index 0000000..187f845 --- /dev/null +++ b/olaflow/of_short_ts_kom/constant/turbulenceProperties_sst @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType RAS; + +RAS +{ + RASModel kOmegaSST; + + turbulence on; + + printCoeffs on; +} + +// ************************************************************************* // diff --git a/olaflow/of_ts_fine/constant/porosityDict b/olaflow/of_ts_fine/constant/porosityDict new file mode 100644 index 0000000..1d10f00 --- /dev/null +++ b/olaflow/of_ts_fine/constant/porosityDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porosityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Materials: clear region, core, secondary armour layer, primary armour layer +// a,b,c: tuning parameters +a 2(0 50); +b 2(0 1.2); +c 2(0 0.34); + +// D50: mean nominal diameter +D50 2(1 4); +// porosity (phi) +porosity 2(1 0.4); + +// ************************************************************************* // diff --git a/olaflow/of_ts_fine/constant/turbulenceProperties b/olaflow/of_ts_fine/constant/turbulenceProperties new file mode 100644 index 0000000..187f845 --- /dev/null +++ b/olaflow/of_ts_fine/constant/turbulenceProperties @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.1.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType RAS; + +RAS +{ + RASModel kOmegaSST; + + turbulence on; + + printCoeffs on; +} + +// ************************************************************************* // diff --git a/olaflow/of_ts_fine/system/blockMeshDict b/olaflow/of_ts_fine/system/blockMeshDict new file mode 100644 index 0000000..4fbff25 --- /dev/null +++ b/olaflow/of_ts_fine/system/blockMeshDict @@ -0,0 +1,81 @@ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.7.1 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +vertices +( + (-150 0 -30) + (0 0 -30) + (0 0 30) + (-150 0 30) + (-150 1 -30) + (0 1 -30) + (0 1 30) + (-150 1 30) +); + +blocks +( + hex (0 1 5 4 3 2 6 7) (1200 1 480) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + /*outlet + { + type patch; + faces + ( + (1 5 6 2) + ); + }*/ + wall1 + { + type wall; + faces + ( + (0 1 5 4) + ); + } + atmosphere + { + type patch; + faces + ( + (3 2 6 7) + (1 5 6 2) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/olaflow/of_ts_fine/system/controlDict b/olaflow/of_ts_fine/system/controlDict new file mode 100644 index 0000000..ca393bb --- /dev/null +++ b/olaflow/of_ts_fine/system/controlDict @@ -0,0 +1,138 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.3 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + location "system"; + class dictionary; + object controlDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application olaFlow; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 400; + +deltaT 0.1; + +writeControl adjustableRunTime; + +writeInterval 0.5; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +compression on; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.45; +maxAlphaCo 0.45; + +maxDeltaT 0.5; +/* +functions +{ + gaugesVOF + { + type sets; + libs ("libsampling.so"); + writeControl outputTime; + writeInterval 1; + setFormat raw; + surfaceFormat raw; + interpolationScheme cell; + fields ( alpha.water ); + sets + ( + GaugeVOF01 + { + type lineCellFace; + axis xyz; + start ( 0.5 0.001 0 ); + end ( 0.5 0.001 1.2 ); + } + GaugeVOF02 + { + type lineCellFace; + axis xyz; + start ( 9.25 0.001 0 ); + end ( 9.25 0.001 1.2 ); + } + GaugeVOF03 + { + type lineCellFace; + axis xyz; + start ( 15.75 0.001 0 ); + end ( 15.75 0.001 1.2 ); + } + GaugeVOF04 + { + type lineCellFace; + axis xyz; + start ( 17.75 0.001 0 ); + end ( 17.75 0.001 1.2 ); + } + GaugeVOF05 + { + type lineCellFace; + axis xyz; + start ( 21.1 0.001 0 ); + end ( 21.1 0.001 1.2 ); + } + ); + } + gaugesP + { + type sets; + libs ("libsampling.so"); + writeControl outputTime; + writeInterval 1; + setFormat raw; + surfaceFormat raw; + interpolationScheme cellPointFace; + fields ( p ); + sets + ( + GaugesP + { + type boundaryPoints; + axis xyz; + patches 1(caisson); + points ((18.0 0.01 0.75) + (18.00 0.01 0.80) + (18.00 0.01 0.85) + (18.00 0.01 0.95) + (18.01 0.01 0.70) + (18.25 0.01 0.70) + (18.50 0.01 0.70) + (18.75 0.01 0.70)); + maxDistance 0.01; + } + ); + } +} +*/ +// ************************************************************************* // diff --git a/olaflow/of_ts_fine/system/graphUniform b/olaflow/of_ts_fine/system/graphUniform new file mode 100644 index 0000000..cb575db --- /dev/null +++ b/olaflow/of_ts_fine/system/graphUniform @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Writes graph data for specified fields along a line, specified by start and + end points. A specified number of graph points are used, distributed + uniformly along the line. + +\*---------------------------------------------------------------------------*/ + +start (-50 0.5 -15); +end (-50 0.5 15); +nPoints 100; + +fields (alpha.water U); + +axis z; + +#includeEtc "caseDicts/postProcessing/graphs/graphUniform.cfg" + +// ************************************************************************* // diff --git a/olaflow/of_ts_fine/system/graphUniform2 b/olaflow/of_ts_fine/system/graphUniform2 new file mode 100644 index 0000000..185937c --- /dev/null +++ b/olaflow/of_ts_fine/system/graphUniform2 @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Writes graph data for specified fields along a line, specified by start and + end points. A specified number of graph points are used, distributed + uniformly along the line. + +\*---------------------------------------------------------------------------*/ + +start (-20 0.5 -15); +end (-20 0.5 15); +nPoints 100; + +fields (alpha.water U); + +axis z; + +#includeEtc "caseDicts/postProcessing/graphs/graphUniform.cfg" + +// ************************************************************************* // diff --git a/olaflow/processing/animate.py b/olaflow/processing/animate.py index 3cb3692..bf89e4d 100644 --- a/olaflow/processing/animate.py +++ b/olaflow/processing/animate.py @@ -1,5 +1,4 @@ import argparse -import configparser import gzip import logging import multiprocessing as mp @@ -16,16 +15,26 @@ from .olaflow import OFModel parser = argparse.ArgumentParser(description="Post-process olaflow results") parser.add_argument("-v", "--verbose", action="count", default=0) -parser.add_argument("-c", "--config", default="config.ini") +parser.add_argument( + "-o", + "--output", + type=pathlib.Path, + help="Output directory for pickled data", + required=True, +) +parser.add_argument( + "-m", + "--max", + help="Only compute maximum rather than animation", + action="store_true", +) args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) log = logging.getLogger("ola_post") log.info("Animating olaFlow output") -config = configparser.ConfigParser() -config.read(args.config) -out = pathlib.Path(config.get("post", "out")) +out = args.output out.mkdir(parents=True, exist_ok=True) with ( @@ -35,44 +44,41 @@ with ( ) as f: model = pickle.load(f) -x0 = config.getfloat("post", "x") -z0 = config.getfloat("post", "z") -i0 = np.argmin(np.abs((model.x - x0) + 1j * (model.z - z0))) - x0, idx0 = np.unique(model.x.astype(np.half), return_inverse=True) z0, idz0 = np.unique(model.z.astype(np.half), return_inverse=True) +ix0 = np.argsort(x0) +iz0 = np.argsort(z0)[::-1] + X, Z = np.meshgrid(x0, z0) P = np.full((model.t.size, *X.shape), np.nan) -P[:, idz0, idx0] = model.fields["porosity"] +P[:, iz0[idz0], ix0[idx0]] = model.fields["porosity"] AW = np.full((model.t.size, *X.shape), np.nan) -AW[:, idz0, idx0] = model.fields["alpha.water"] +AW[:, iz0[idz0], ix0[idx0]] = model.fields["alpha.water"] U = np.full((model.t.size, *X.shape), np.nan) -U[:, idz0, idx0] = np.linalg.norm(model.fields["U"], axis=1) +U[:, iz0[idz0], ix0[idx0]] = np.linalg.norm(model.fields["U"], axis=1) -fig = plt.figure(figsize=(19.2, 10.8), dpi=100) -gs = GridSpec(3, 1, figure=fig, height_ratios=[1, .05, .05]) +fig = plt.figure() +gs = GridSpec(3, 1, figure=fig, height_ratios=[1, 0.05, 0.05]) ax = fig.add_subplot(gs[0]) cax1 = fig.add_subplot(gs[1]) cax2 = fig.add_subplot(gs[2]) -tit = ax.text( - 0.5, - 0.95, - f"t={model.t[0]}s", - horizontalalignment="center", - verticalalignment="top", - transform=ax.transAxes, +aw_m = ax.imshow( + AW[0], + vmin=0, + vmax=1, + extent=(x0.min(), x0.max(), z0.min(), z0.max()), + cmap="Blues", + zorder=1, ) -aw_m = ax.pcolormesh(X, Z, AW[0], vmin=0, vmax=1, cmap="Blues", zorder=1) -p_m = ax.pcolormesh( - X, - Z, +p_m = ax.imshow( P[1], vmin=0, vmax=1, + extent=(x0.min(), x0.max(), z0.min(), z0.max()), cmap="Greys_r", alpha=(np.nan_to_num(1 - P[1]) / 2).clip(0, 1), zorder=1.1, @@ -86,62 +92,87 @@ ax.set(xlabel="x (m)", ylabel="z (m)", aspect="equal", facecolor="#000000") ax.grid(c="k", alpha=0.2) -def anim(i): - tit.set_text(f"t={model.t[i]}s") - aw_m.set_array(AW[i]) - - -figU = plt.figure(figsize=(19.2, 10.8), dpi=100) -gsU = GridSpec(3, 1, figure=figU, height_ratios=[1, .05, .05]) +figU = plt.figure() +gsU = GridSpec( + 2 if args.max else 3, + 1, + figure=figU, + height_ratios=[1, 0.05] if args.max else [1, 0.05, 0.05], +) axU = figU.add_subplot(gsU[0]) caxu1 = figU.add_subplot(gsU[1]) -caxu2 = figU.add_subplot(gsU[2]) -u_m = axU.pcolormesh( - X, - Z, +if not args.max: + caxu2 = figU.add_subplot(gsU[2]) +u_m = axU.imshow( U[0], cmap="BuPu", vmin=0, - vmax=np.nanquantile(U, 0.99), + vmax=20, + extent=(x0.min(), x0.max(), z0.min(), z0.max()), zorder=1, alpha=np.nan_to_num(AW[0]).clip(0, 1), ) -ur_m = axU.pcolormesh( - X, - Z, +ur_m = axU.imshow( U[0], cmap="YlOrBr", vmin=0, - vmax=np.nanquantile(U, 0.99), + vmax=20, + extent=(x0.min(), x0.max(), z0.min(), z0.max()), zorder=1, alpha=1 - np.nan_to_num(AW[0]).clip(0, 1), ) # aw_u = axU.contour(X, Z, AW[0], levels=(.5,)) axU.set(xlabel="x (m)", ylabel="z (m)", aspect="equal", facecolor="#bebebe") axU.grid(c="k", alpha=0.2) -titU = axU.text( - 0.5, - 0.95, - f"t={model.t[0]}s", - horizontalalignment="center", - verticalalignment="top", - transform=axU.transAxes, -) - figU.colorbar(u_m, label=r"$U_w$", cax=caxu1, shrink=0.6, orientation="horizontal") -figU.colorbar(ur_m, label=r"$U_a$", cax=caxu2, shrink=0.6, orientation="horizontal") -def animU(i): - titU.set_text(f"t={model.t[i]}s") - u_m.set_array(U[i]) - u_m.set_alpha(np.nan_to_num(AW[i]).clip(0, 1)) - ur_m.set_array(U[i]) - ur_m.set_alpha(1 - np.nan_to_num(AW[i]).clip(0, 1)) +if args.max: + aw_m.set_array(AW.max(axis=0)) + u_m.set_array(np.nanmax(np.where(AW > 0.5, U, np.nan), axis=0, initial=0)) + u_m.set_alpha(1) + u_m.set_cmap("hot_r") + ur_m.remove() -ani = animation.FuncAnimation(fig, anim, frames=model.t.size, interval=1/24) -aniU = animation.FuncAnimation(figU, animU, frames=model.t.size, interval=1/24) + fig.savefig(out.joinpath("max_aw.pdf")) + figU.savefig(out.joinpath("max_U.pdf")) +else: + fig.set(figwidth=19.2, figheight=10.8, dpi=100) + figU.set(figwidth=19.2, figheight=10.8, dpi=100) -ani.save(out.joinpath("anim.mp4"), fps=24) -aniU.save(out.joinpath("animU.mp4"), fps=24) + figU.colorbar(ur_m, label=r"$U_a$", cax=caxu2, shrink=0.6, orientation="horizontal") + + tit = ax.text( + 0.5, + 0.95, + f"t={model.t[0]}s", + horizontalalignment="center", + verticalalignment="top", + transform=ax.transAxes, + ) + titU = axU.text( + 0.5, + 0.95, + f"t={model.t[0]}s", + horizontalalignment="center", + verticalalignment="top", + transform=axU.transAxes, + ) + + def anim(i): + tit.set_text(f"t={model.t[i]}s") + aw_m.set_array(AW[i]) + + def animU(i): + titU.set_text(f"t={model.t[i]}s") + u_m.set_array(U[i]) + u_m.set_alpha(np.nan_to_num(AW[i]).clip(0, 1)) + ur_m.set_array(U[i]) + ur_m.set_alpha(1 - np.nan_to_num(AW[i]).clip(0, 1)) + + ani = animation.FuncAnimation(fig, anim, frames=model.t.size, interval=1 / 24) + aniU = animation.FuncAnimation(figU, animU, frames=model.t.size, interval=1 / 24) + + ani.save(out.joinpath("anim.mp4"), fps=24) + aniU.save(out.joinpath("animU.mp4"), fps=24) diff --git a/olaflow/processing/animateU.py b/olaflow/processing/animateU.py index 18c7298..35a9eb5 100644 --- a/olaflow/processing/animateU.py +++ b/olaflow/processing/animateU.py @@ -1,5 +1,4 @@ import argparse -import configparser import gzip import logging import multiprocessing as mp @@ -16,16 +15,20 @@ from .olaflow import OFModel parser = argparse.ArgumentParser(description="Post-process olaflow results") parser.add_argument("-v", "--verbose", action="count", default=0) -parser.add_argument("-c", "--config", default="config.ini") +parser.add_argument( + "-o", + "--output", + type=pathlib.Path, + help="Output directory for pickled data", + required=True, +) args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) log = logging.getLogger("ola_post") log.info("Animating olaFlow output") -config = configparser.ConfigParser() -config.read(args.config) -out = pathlib.Path(config.get("post", "out")) +out = args.output out.mkdir(parents=True, exist_ok=True) with ( @@ -35,9 +38,6 @@ with ( ) as f: model = pickle.load(f) -x0 = config.getfloat("post", "x") -z0 = config.getfloat("post", "z") - flt = np.where((model.x >= -60) & (model.x <= -20) & (model.z >= 0) & (model.z <= 10))[ 0 ] @@ -73,8 +73,8 @@ u_m = axU.quiver( *U[0], UU[0], alpha=alp[0], - cmap="spring", - clim=(0, np.nanquantile(UU, 0.99)), + cmap="inferno_r", + clim=(0, np.nanmax(UU)), ) # (wat_p,) = axU.plot(x0, watl[0]) diff --git a/olaflow/processing/diff.py b/olaflow/processing/diff.py new file mode 100644 index 0000000..6263143 --- /dev/null +++ b/olaflow/processing/diff.py @@ -0,0 +1,142 @@ +import argparse +import gzip +from itertools import starmap +import logging +from multiprocessing import pool +import pathlib +import pickle +import sys + +from cycler import cycler +import matplotlib.pyplot as plt +import matplotlib.gridspec as gridspec +import numpy as np +from scipy import interpolate + +from .olaflow import OFModel + +parser = argparse.ArgumentParser(description="Post-process olaflow results") +parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument( + "-o", + "--output", + action="append", + type=pathlib.Path, + help="Post-processing directory", + required=True, +) +parser.add_argument( + "-t", + "--timestep", + type=float, + help="Time-step to compare", +) +parser.add_argument( + "-f", + "--func", + type=str, + help="Post-process function to compare", + default="graphUniform", + choices=("graphUniform", "graphUniform2"), +) +parser.add_argument( + "-y", + "--field", + type=str, + help="Field to compare", + default="alpha.water", + choices=("alpha.water", "U"), +) + +args = parser.parse_args() + +logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) +log = logging.getLogger("ola_post") + +log.info("Plotting comparison of model output") + + +def get_pickle(out): + with ( + path.open("rb") + if (path := out.joinpath("pickle")).exists() + else gzip.open(path.with_suffix(".gz"), "rb") + ) as f: + return pickle.load(f) + + +models = list(map(get_pickle, args.output)) + + +fig, ax_ = plt.subplots( + len(models), + figsize=(6, 1.5 * len(models)), + dpi=100, + constrained_layout=True, + squeeze=False, +) +ax = ax_[:, 0] + +if args.timestep is None: + match args.field: + case "alpha.water": + for i, (_ax, _model) in enumerate(zip(ax, models)): + _ax.contour( + _model.t, + _model.post_fields[args.func][f"x_{args.field}"], + _model.post_fields[args.func][args.field].T, + (0.5,), + colors="k", + ) + case "U": + for i, (_ax, _model) in enumerate(zip(ax, models)): + _c = _ax.imshow( + np.where(_model.post_fields[args.func]["alpha.water"] > 0.5, np.linalg.norm(_model.post_fields[args.func][args.field], axis=2), np.nan).T[::-1], + vmin=0, + vmax=20, + cmap="inferno_r", + extent=( + _model.t.min(), + _model.t.max(), + _model.post_fields[args.func][f"x_{args.field}"].min(), + _model.post_fields[args.func][f"x_{args.field}"].max(), + ), + ) + fig.colorbar(_c, label=f"{args.field} (m/s)", ax=_ax) + case _: + log.error(f"Cannot plot field {args.field} from {args.func}") + sys.exit(1) + + for i, (_ax, _model) in enumerate(zip(ax, models)): + _ax.set(xlabel="t (s)", ylabel="z (m)", title=f"Case {i}") + _ax.grid(color="k", alpha=0.2) + + fig.savefig( + args.output[0].joinpath( + f"diff_{args.func}_{args.field}_{'_'.join([o.name for o in args.output])}.pdf" + ) + ) +else: + match args.field: + case "alpha.water": + for i, (_ax, _model) in enumerate(zip(ax, models)): + _ax.tricontour( + _model.x, + _model.z, + _model.fields[args.field][np.where(_model.t == args.timestep)[0]][0], + levels=(0.5,), + colors="k", + ) + case _: + log.error(f"Cannot plot field {args.field} from {args.func} at timestep") + sys.exit(1) + + for i, (_ax, _model) in enumerate(zip(ax, models)): + _ax.set(xlabel="x (m)", ylabel="z (m)", title=f"Case {i}") + _ax.grid() + + fig.savefig( + args.output[0].joinpath( + f"diff_t{args.timestep}_{'_'.join([o.name for o in args.output])}.pdf" + ) + ) diff --git a/olaflow/processing/olaflow.py b/olaflow/processing/olaflow.py index 2de1bc9..3dc10c1 100644 --- a/olaflow/processing/olaflow.py +++ b/olaflow/processing/olaflow.py @@ -9,6 +9,7 @@ class OFModel: def __init__(self, root): self._root = root self._fields = {} + self._post_fields = {} def read_mesh(self): self._x, self._y, self._z = readof.readmesh(str(self._root)) @@ -51,6 +52,25 @@ class OFModel: self.fields[field] = _field return _field + def read_post(self, func, field): + _ft = lambda _d: self._root.joinpath( + "postProcessing", func, _d, f"line_{field}.xy" + ) + _res_0 = np.loadtxt(_ft(self._t_dirs[0])) + _x = _res_0[:, 0] + _res = np.empty((self._t.size, _x.size, _res_0.shape[1] - 1)) + _res[0] = _res_0[:, 1:] + for _r, _dir in zip(_res[1:], self._t_dirs[1:]): + _r[:] = np.loadtxt(_ft(_dir))[:, 1:] + _dict = { + f"x_{field}": _x, + field: np.squeeze(_res), + } + if func not in self._post_fields.keys(): + self._post_fields[func] = {} + self._post_fields[func] |= _dict + return _dict + def write_field(self, field, values): with open(self._root.joinpath("0", field), "r") as aw_file: aw_raw = aw_file.read() @@ -106,12 +126,5 @@ class OFModel: return self._fields @property - def X(self): - return self._X - - @property - def Z(self): - return self._Z - - def FIELD(self, field): - return np.where(self._C > 0, field[:, C], np.nan) + def post_fields(self): + return self._post_fields diff --git a/olaflow/processing/pickle.py b/olaflow/processing/pickle.py index a82cb2b..e857ca3 100644 --- a/olaflow/processing/pickle.py +++ b/olaflow/processing/pickle.py @@ -1,6 +1,5 @@ import argparse import gzip -import configparser import logging import pathlib import pickle @@ -14,28 +13,47 @@ from .olaflow import OFModel parser = argparse.ArgumentParser(description="Post-process olaflow results") parser.add_argument("-v", "--verbose", action="count", default=0) -parser.add_argument("-c", "--config", default="config.ini") -parser.add_argument("-o", "--output", type=pathlib.Path) +parser.add_argument( + "-i", "--input", type=pathlib.Path, help="Olaflow output directory", required=True +) +parser.add_argument( + "-o", + "--output", + type=pathlib.Path, + help="Output directory for pickled data", + required=True, +) +parser.add_argument( + "-z", "--compress", action="store_true", help="Enable gzip compression" +) args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) log = logging.getLogger("ola_post") -log.info("Starting sws -> olaFlow converter") -config = configparser.ConfigParser() -config.read(args.config) -out = pathlib.Path(config.get("post", "out")) +log.info("Starting pickling") +out = args.output out.mkdir(parents=True, exist_ok=True) -olaflow_root = args.output +olaflow_root = args.input model = OFModel(olaflow_root) model.read_mesh() model.read_time() + model.read_field_all("alpha.water") model.read_field_all("porosity") model.read_field_all("p") model.read_field_all("p_rgh") model.read_field_all("U") -with gzip.open(out.joinpath("pickle.gz"), "wb") as f: +model.read_post("graphUniform", "alpha.water") +model.read_post("graphUniform", "U") +model.read_post("graphUniform2", "alpha.water") +model.read_post("graphUniform2", "U") + +with ( + gzip.open(out.joinpath("pickle.gz"), "wb") + if args.compress + else out.joinpath("pickle").open("wb") +) as f: pickle.dump(model, f) diff --git a/olaflow/processing/sws_wavedict_paddle.py b/olaflow/processing/sws_wavedict_paddle.py index 607d314..2fd2374 100644 --- a/olaflow/processing/sws_wavedict_paddle.py +++ b/olaflow/processing/sws_wavedict_paddle.py @@ -57,11 +57,11 @@ org = org.replace("{v}", "\n".join(v.astype(np.str_))) org = org.replace("{eta}", "\n".join(wl.astype(np.str_))) olaflow_root.joinpath("constant", "waveDict").write_text(org) -fig, ax = plt.subplots() +fig, (ax, ax2) = plt.subplots(2) ax.plot(t, wl) ax.autoscale(True, "x", tight=True) ax.set(xlabel="t (s)", ylabel="z (m)") -ax2 = ax.twinx() ax2.plot(t, v) -ax2.set(ylabel="U (m/s)") +ax2.autoscale(True, "x", tight=True) +ax2.set(xlabel="t (s)", ylabel="U (m/s)") fig.savefig(olaflow_root.joinpath("constant", "wave.pdf")) diff --git a/olaflow/run_ola.sh b/olaflow/run_ola.sh index 0b5eef2..7e2977d 100755 --- a/olaflow/run_ola.sh +++ b/olaflow/run_ola.sh @@ -1,10 +1,31 @@ #!/usr/bin/env sh -echo START -export inp="of" -read -p "Output: " out +export cas="$1" +export inp_of="of_$cas" +export out_of="out_of_$cas" +export out_post="out_post_$cas" -cp -r --reflink $inp $out -pushd $out +if [[ ! -d $inp_of ]] +then echo $inp_of not found + exit 1 +fi + +if [[ -d $out_of ]] +then echo $out_of already exists + mv $out_of "$out_of.bak" +fi + +if [[ -d $out_post ]] +then echo $out_post already exists + mv $out_post "$out_post.bak" +fi + +echo START +cp -r --reflink of $out_of +if [[ $2 ]] +then cp -r --reflink of_$2/* $out_of +fi +cp -r --reflink $inp_of/* $out_of +pushd $out_of source /opt/OpenFOAM/OpenFOAM-9/etc/bashrc mkdir log echo Generating mesh @@ -17,18 +38,26 @@ setFields > log/setFields.log popd echo Converting swash output to initial condition -python -m processing.sws_ola -o $out +python -m processing.sws_ola -o $out_of > $out_of/log/sws_ola.log echo Converting swash output to boundary condition -python -m processing.sws_wavedict_paddle -o $out -pushd $out +python -m processing.sws_wavedict_paddle -o $out_of > $out_of/log/sws_wave.log +pushd $out_of echo Generating parallel cases decomposePar > log/decomposePar.log echo Running model -mpirun -np 4 olaFlow -parallel > log/olaFlow.log +mpirun --use-hwthread-cpus -np 6 olaFlow -parallel > log/olaFlow.log echo Merging parallel cases reconstructPar > log/reconstructPar.log #echo Removing parallel cases #rm -r processor* +echo Running Openfoam post-process +postProcess -func graphUniform > log/postProcess.log +postProcess -func graphUniform2 > log/postProcess2.log + +popd +echo Pickling Olaflow output +python -m processing.pickle -i $out_of -o $out_post > $out_of/log/pickle.log + echo END diff --git a/report/chapters/olaflow.tex b/report/chapters/olaflow.tex index 23e8568..431c241 100644 --- a/report/chapters/olaflow.tex +++ b/report/chapters/olaflow.tex @@ -7,3 +7,120 @@ from the crest). A tool that allows mapping the output fields from swash to the initial fields in olaFlow was built. Alpha.water and U fields are mapped from swash to olaFlow. + +Boundary conditions are set using the output from the swash model. + +A regular mesh is generated and snapped to the bathymetry (mesh resolution: \SI{.5}{\m}). + +Simulation is run for 400 seconds using the largest wave from the swash model with the buoy spectrum as an input +(\autoref{fig:wave}). + +\begin{figure} + \centering + \includegraphics{wave.pdf} + \caption{Boundary condition for olaflow model.}\label{fig:wave} +\end{figure} + +Results are plotted using python \autoref{fig:resola}. +\begin{figure} + \centering + \includegraphics{resola.pdf} + \caption{Results from olaFlow model.}\label{fig:resola} +\end{figure} + +\subsection{Porosity parameters} +Several parameters should be calibrated in order to accurately model the porous media: $a$, $b$ and $c$ are friction +parameters in Forcheimer's equation; D50 is the median diameter of the elements constituting the porous media; $p$ is +the porosity of the media. + +7 cases were run with the values in \autoref{tab:porotest}. + +\begin{table} + \centering + \begin{tabular}{cccccc} + \toprule + \textbf{Case} & $a$ & $b$ & $c$ & D50 (\si{\m}) & $\phi$ \\ + \midrule + \textbf{0} & \num{50} & \num{1.2} & \num{0.34} & \num{4} & \num{0.4} \\ + \textbf{1} & \intersemibold\num{0} & \num{1.2} & \num{0.34} & \num{4} & \num{0.4} \\ + \textbf{2} & \intersemibold\num{5000} & \num{1.2} & \num{0.34} & \num{4} & \num{0.4} \\ + \textbf{3} & \num{50} & \intersemibold\num{0} & \num{0.34} & \num{4} & \num{0.4} \\ + \textbf{4} & \num{50} & \intersemibold\num{3.0} & \num{0.34} & \num{4} & \num{0.4} \\ + \textbf{5} & \num{50} & \num{1.2} & \num{0.34} & \intersemibold\num{2} & \num{0.4} \\ + \textbf{6} & \num{50} & \num{1.2} & \num{0.34} & \num{4} & \intersemibold\num{0.25} \\ + \bottomrule + \end{tabular} + \caption{Test cases for porosity parameters.}\label{tab:porotest} +\end{table} + +Some results are displayed in \autoref{fig:diff} and \autoref{fig:diff2}. No major differences are noticable +between cases (excepted for case 3, where $b=0$). + +\begin{figure} + \centering + \includegraphics{diff.pdf} + \caption{Tests for porosity parameters; water - air border at \SI{-50}{\m}.}\label{fig:diff} +\end{figure} +\begin{figure} + \centering + \includegraphics{diff2.pdf} + \caption{Tests for porosity parameters; water - air border at \SI{-20}{\m}.}\label{fig:diff2} +\end{figure} + +Another run with a different value for $b$ was made (\autoref{tab:porotestb}). Results are in \autoref{fig:diff3b}. +The value of $b$ seems to have a major effect how wave energy is dissipated / how waves break, as seen in +\autoref{fig:diff3b175}. + +\begin{table} + \centering + \begin{tabular}{cccccc} + \toprule + \textbf{Case} & $a$ & $b$ & $c$ & D50 (\si{\m}) & $\phi$ \\ + \midrule + \textbf{0} & \num{50} & \num{1.2} & \num{0.34} & \num{4} & \num{0.4} \\ + \textbf{1} & \num{50} & \intersemibold\num{0} & \num{0.34} & \num{4} & \num{0.4} \\ % 3 + \textbf{2} & \num{50} & \intersemibold\num{0.2} & \num{0.34} & \num{4} & \num{0.4} \\ % 3b + \bottomrule + \end{tabular} + \caption{Test cases for porosity parameters.}\label{tab:porotestb} +\end{table} + +\begin{figure} + \centering + \includegraphics{diff3b.pdf} + \caption{Tests for porosity parameters; water - air border at \SI{-20}{\m}.}\label{fig:diff3b} +\end{figure} +\begin{figure} + \centering + \includegraphics{diff3b175.pdf} + \caption{Tests for porosity parameters; water - air border at \SI{175}{\s}.}\label{fig:diff3b175} +\end{figure} + +\subsection{Turbulence model} +A case with the $k-\omega$ SST turbulence model was run to compare with the $k-\varepsilon$ model. +Results displayed in \autoref{fig:sst}. Significant differences are found between both models. + +Wave breaking as expected using SST model (\autoref{fig:sst175}). See +\url{https://public.edgarpierre.fr/anim_olaflow_kom.mp4} + +\begin{figure} + \centering + \includegraphics{diffsst.pdf} + \caption{$x=\SI{-50}{\m}$. Case 1: $k-\varepsilon$ model; case 2: $k-\omega$ SST model.}\label{fig:sst} +\end{figure} +\begin{figure} + \centering + \includegraphics{diffsst175.pdf} + \caption{$t=\SI{175}{\s}$. Case 1: $k-\varepsilon$ model; case 2: $k-\omega$ SST model.}\label{fig:sst175} +\end{figure} + +\subsection{Results} +Maximum flow velocity is displayed in \autoref{fig:maxu}. + +\begin{figure} + \centering + \includegraphics{maxu.pdf} + \caption{Maximum velocity.}\label{fig:maxu} +\end{figure} + +The flow reaches \SIrange{15}{20}{\m\per\s} velocity, which is in accordance with results from \textcite{amir}. diff --git a/report/chapters/swash.tex b/report/chapters/swash.tex index 0aa7a04..eed2d1e 100644 --- a/report/chapters/swash.tex +++ b/report/chapters/swash.tex @@ -124,5 +124,39 @@ Model runs with 4 layers. \autoref{fig:rests4lay}. \caption{Results with real timeseries, 4 layers.}\label{fig:rests4lay} \end{figure} +\section{Reflection coefficient verification} + +A small Python script has been written to generate theoretical wave height and homogenized velocity for a combination of +incident and reflected waves. + +The method was taken from \parencite{huntley1999use}. Incident waves are modelled by white noise, reflected waves are +incident waves shifted and multiplied by the reflection coefficient. Water level is the sum of incident waves and +reflected waves, velocity is the difference of reflected waves and incident waves. Additionnal noise is added to the +water level and velocity. + +Results are displayed in \autoref{fig:r_test}. + +\begin{figure} + \centering + \includegraphics{r_test.pdf} + \caption{Reflection coefficient testing (puv method from \cite{huntley1999use}).}\label{fig:r_test} +\end{figure} + +\section{Plotting orbitals from buoy measurements} +\autoref{fig:orbitals}. Orbital for the large wave have been plotted in the average motion plane of the buoy. + +\begin{figure} + \centering + \includegraphics{orbitals.pdf} + \caption{2Dv buoy trajectory for wave event of 20170228.}\label{fig:orbitals} +\end{figure} + +\subsection{Buoy spectrum} + +The swash model was run over 4 hours with the spectrum obtained from the buoy, with and without the breakwater. (2 +layers). + +A zero-crossing methods was implemented to find the largest waves. + %\subsection{2D Model} %Working on 2D model which might work with overtopping. diff --git a/report/cours.sty b/report/cours.sty index 22f4f6e..3e14943 100644 --- a/report/cours.sty +++ b/report/cours.sty @@ -170,6 +170,7 @@ %inter-unit-product = {.}, per-mode = power-positive-first, uncertainty-mode = separate, + reset-text-family = false, } \SendSettingsToPgf \DeclareSIUnit\met{met} diff --git a/report/fig/diff.pdf b/report/fig/diff.pdf new file mode 100644 index 0000000..3732b7d Binary files /dev/null and b/report/fig/diff.pdf differ diff --git a/report/fig/diff2.pdf b/report/fig/diff2.pdf new file mode 100644 index 0000000..88d2f1e Binary files /dev/null and b/report/fig/diff2.pdf differ diff --git a/report/fig/diff3b.pdf b/report/fig/diff3b.pdf new file mode 100644 index 0000000..785aa15 Binary files /dev/null and b/report/fig/diff3b.pdf differ diff --git a/report/fig/diff3b175.pdf b/report/fig/diff3b175.pdf new file mode 100644 index 0000000..2400885 Binary files /dev/null and b/report/fig/diff3b175.pdf differ diff --git a/report/fig/diffsst.pdf b/report/fig/diffsst.pdf new file mode 100644 index 0000000..1f319ac Binary files /dev/null and b/report/fig/diffsst.pdf differ diff --git a/report/fig/diffsst175.pdf b/report/fig/diffsst175.pdf new file mode 100644 index 0000000..76311bc Binary files /dev/null and b/report/fig/diffsst175.pdf differ diff --git a/report/fig/maxu.pdf b/report/fig/maxu.pdf new file mode 100644 index 0000000..bd7ed55 Binary files /dev/null and b/report/fig/maxu.pdf differ diff --git a/report/fig/orbitals.pdf b/report/fig/orbitals.pdf new file mode 100644 index 0000000..6c81c8e Binary files /dev/null and b/report/fig/orbitals.pdf differ diff --git a/report/fig/r_test.pdf b/report/fig/r_test.pdf new file mode 100644 index 0000000..7dc67f3 Binary files /dev/null and b/report/fig/r_test.pdf differ diff --git a/report/fig/resola.pdf b/report/fig/resola.pdf new file mode 100644 index 0000000..1231de8 Binary files /dev/null and b/report/fig/resola.pdf differ diff --git a/report/fig/wave.pdf b/report/fig/wave.pdf new file mode 100644 index 0000000..fa71b10 Binary files /dev/null and b/report/fig/wave.pdf differ diff --git a/swash/processing/transmission.py b/swash/processing/transmission.py new file mode 100644 index 0000000..b272a2d --- /dev/null +++ b/swash/processing/transmission.py @@ -0,0 +1,71 @@ +import argparse +import configparser +import logging +import pathlib + +import matplotlib.pyplot as plt +import numpy as np +import scipy.signal as sgl + +parser = argparse.ArgumentParser(description="Post-process swash output") +parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") +args = parser.parse_args() + +logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) +log = logging.getLogger("post") + +log.info("Starting post-processing") +config = configparser.ConfigParser() +config.read(args.config) + +inp = pathlib.Path(config.get("post", "inp")) +root = pathlib.Path(config.get("swash", "out")) + +log.info(f"Reading data from '{inp}'") +x = np.load(inp.joinpath("x.npy")) +t = np.load(inp.joinpath("t.npy")) + +botl = np.load(inp.joinpath("botl.npy")) +watl = np.load(inp.joinpath("watl.npy")) +vel = np.load(inp.joinpath("vel.npy"))[0] + +t0 = np.linspace(23 * 60 + 8, 23 * 60 + 8 + 100, 5) + +# Plotting +log.info("Plotting results") + +vlim = np.nanmin(np.maximum(watl, -botl)), np.nanmax(np.maximum(watl, -botl)) + +fig_x, ax = plt.subplots( + len(t0), figsize=(10 / 2.54, 4 / 3 * 10 / 2.54), constrained_layout=True +) +i0 = np.argmin(np.abs(t * 1e-3 - t0[0])) +for ax_x, t0_x in zip(ax, t0): + ax_x.plot(x, -botl, color="k") + i = np.argmin(np.abs(t * 1e-3 - t0_x)) + ax_x.plot( + x, + np.maximum(watl[i, :], -botl), + color="#0066ff", + ) + ax_x.axvline(-1450 + 1450 * ((t[i] - t[i0]) * 1e-3+5) / 100, color="k", alpha=0.2, lw=10) + ax_x.grid(color="k", alpha=0.2) + ax_x.set(ylabel="z (m)", ylim=vlim) + ax_x.text( + 0.95, + 0.95, + f"$T+{(t[i]-t[i0])*1e-3:.1f}s$", + horizontalalignment="right", + verticalalignment="top", + transform=ax_x.transAxes, + ) + ax_x.autoscale(axis="x", tight=True) + +out = pathlib.Path(config.get("post", "out")).joinpath(f"trans") +log.info(f"Saving plots in '{out}'") +out.mkdir(parents=True, exist_ok=True) + +fig_x.savefig(out.joinpath("x.pdf")) + +log.info("Finished post-processing") diff --git a/swash/processing/zero_cross.py b/swash/processing/zero_cross.py index dcfb46a..5d5c0e5 100644 --- a/swash/processing/zero_cross.py +++ b/swash/processing/zero_cross.py @@ -19,6 +19,7 @@ config = configparser.ConfigParser() config.read(args.config) inp = pathlib.Path(config.get("post", "inp")) +inp_comp = pathlib.Path(config.get("post", "compare")) root = pathlib.Path(config.get("swash", "out")) log.info(f"Reading data from '{inp}'") @@ -26,13 +27,16 @@ x = np.load(inp.joinpath("x.npy")) t = np.load(inp.joinpath("t.npy")) watl = np.load(inp.joinpath("watl.npy")) +watl_comp = np.load(inp_comp.joinpath("watl.npy")) # Cospectral calculations x0 = config.getint("post", "x0") arg_x0 = np.abs(x - x0).argmin() w0 = watl[:, arg_x0] +w0_comp = watl_comp[:, arg_x0] cr0 = np.where(np.diff(np.sign(w0)))[0] +cr0_comp = np.where(np.diff(np.sign(w0_comp)))[0] wave = np.fromiter( ( @@ -44,6 +48,16 @@ wave = np.fromiter( ), dtype=np.single, ) +wave_comp = np.fromiter( + ( + np.abs( + np.max(np.abs(w0_comp[cr0_comp[i - 1] : cr0_comp[i]])) + + np.max(np.abs(w0_comp[cr0_comp[i] : cr0_comp[i + 1]])) + ) + for i in range(1, len(cr0) - 1) + ), + dtype=np.single, +) i0 = np.argmax(wave) @@ -53,8 +67,22 @@ out.mkdir(parents=True, exist_ok=True) fig, ax = plt.subplots() ax.plot(t[cr0[1:-1]] * 1e-3, wave) +ax.set(xlabel="t (s)", ylabel="z (m)") +ax.autoscale(True, "x", True) +ax.grid() fig.savefig(out.joinpath("wsize.pdf")) -fig2, ax2 = plt.subplots() -ax2.plot(t[cr0[i0 - 5] : cr0[i0 + 7]], w0[cr0[i0 - 5] : cr0[i0 + 7]]) +fig2, ax2 = plt.subplots(figsize=(10/2.54, 2/3*10/2.54), constrained_layout=True) +ax2.plot(t[cr0[i0 - 5] : cr0[i0 + 7]] * 1e-3, w0[cr0[i0 - 5] : cr0[i0 + 7]], color="k", label="Case 1") +ax2.plot(t[cr0[i0 - 5] : cr0[i0 + 7]] * 1e-3, w0_comp[cr0[i0 - 5] : cr0[i0 + 7]], color="k", ls="-.", label="Case 2") +ax2.set(xlabel="t (s)", ylabel="z (m)") +ax2.autoscale(True, "x", True) +ax2.grid() +ax2.legend() fig2.savefig(out.joinpath("maxw.pdf")) +fig2.savefig(out.joinpath("maxw.jpg"), dpi=200) + +log.info(f"RMS difference: {np.sqrt(np.mean((w0_comp-w0)**2))}m ; {np.sqrt(np.mean((w0_comp-w0)**2))/(w0.max()-w0.min()):%}") +log.info(f"Bias: {np.mean(w0_comp-w0)}m") +log.info(f"Maximum wave size: {wave.max()}m ; {wave_comp.max()}m") +log.info(f"Maximum wave size difference: {abs(wave_comp.max()-wave.max())/wave.max():%}") diff --git a/swash/sws/TS_buoy.sws b/swash/sws/TS_buoy.sws index 73e21d7..3fd7617 100644 --- a/swash/sws/TS_buoy.sws +++ b/swash/sws/TS_buoy.sws @@ -40,20 +40,20 @@ TIMEI 0.2 0.6 $*********************** OUTPUTS ******************************************* SET OUTLEV 1 $BLOCK 'COMPGRID' HEAD 'test.txt' LAY 4 TSEC XP DEP BOTL WATL PRESS DISCH USTAR VEL VZ VELK ZK BRKP OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'tsec.dat' TSEC OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'xp.dat' XP OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'dep.dat' DEP OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'botl.dat' BOTL OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'watl.dat' WATL OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'press.dat' PRESS OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'nhprsk.dat' NHPRSK OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'pressk.dat' PRESSK OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'disch.dat' DISCH OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'ustar.dat' USTAR OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'vel.dat' VEL OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'vz.dat' VZ OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'velk.dat' VELK OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'zk.dat' ZK OUTPUT 000000.00 0.25 SEC -BLOCK 'COMPGRID' NOHEAD 'brkp.dat' BRKP OUTPUT 000000.00 0.25 SEC -COMPUTE 000000.000 0.015 SEC 006000.000 $timeini dtini unit timefin +BLOCK 'COMPGRID' NOHEAD 'tsec.mat' TSEC OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'xp.mat' XP OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'dep.mat' DEP OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'botl.mat' BOTL OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'watl.mat' WATL OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'press.mat' PRESS OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'nhprsk.mat' NHPRSK OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'pressk.mat' PRESSK OUTPUT 000000.00 0.25 SEC +$BLOCK 'COMPGRID' NOHEAD 'disch.mat' DISCH OUTPUT 000000.00 0.25 SEC +$BLOCK 'COMPGRID' NOHEAD 'ustar.mat' USTAR OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'vel.mat' VEL OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'vz.mat' VZ OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'velk.mat' VELK OUTPUT 000000.00 0.25 SEC +BLOCK 'COMPGRID' NOHEAD 'zk.mat' ZK OUTPUT 000000.00 0.25 SEC +$BLOCK 'COMPGRID' NOHEAD 'brkp.mat' BRKP OUTPUT 000000.00 0.25 SEC +COMPUTE 000000.000 0.015 SEC 010000.000 $timeini dtini unit timefin STOP