diff --git a/templates/cnoidal_wave/base/0/U b/templates/cnoidal_wave/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..ad3f3c7a2e16b4165bef1363293c54bd439d33e5 --- /dev/null +++ b/templates/cnoidal_wave/base/0/U @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + inlet + { + type waveVelocity; + value uniform (0 0 0); + } + + outlet + { + type waveVelocity; + value uniform (0 0 0); + } + + sides + { + type empty; + } + + ground + { + type fixedValue; + value uniform (0 0 0); + } + + top + { + type pressureInletOutletVelocity; + value uniform (0 0 0); + } +} + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/0/alpha.water b/templates/cnoidal_wave/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..37e6ffb99eca06b00d675988e975db0161a74991 --- /dev/null +++ b/templates/cnoidal_wave/base/0/alpha.water @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type waveAlpha; + value uniform 0; + } + + outlet + { + type zeroGradient; + } + + ground + { + type zeroGradient; + } + + sides + { + type empty; + } + + top + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } +} + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/0/p_rgh b/templates/cnoidal_wave/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..c124795bdca98817da9c7f591a4d2146f9c39bb0 --- /dev/null +++ b/templates/cnoidal_wave/base/0/p_rgh @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type fixedFluxPressure; + value uniform 0; + } + + outlet + { + type fixedFluxPressure; + value uniform 0; + } + + ground + { + type fixedFluxPressure; + value uniform 0; + } + + sides + { + type empty; + } + + top + { + type totalPressure; + p0 uniform 0; + } +} + + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/Allclean b/templates/cnoidal_wave/base/Allclean new file mode 100644 index 0000000000000000000000000000000000000000..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 --- /dev/null +++ b/templates/cnoidal_wave/base/Allclean @@ -0,0 +1,7 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 + +#------------------------------------------------------------------------------ diff --git a/templates/cnoidal_wave/base/Allrun b/templates/cnoidal_wave/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..28bf991e627511713c3b915ac0d9998f068ce030 --- /dev/null +++ b/templates/cnoidal_wave/base/Allrun @@ -0,0 +1,15 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +restore0Dir + +runApplication blockMesh + +runApplication decomposePar + +runParallel setFields + +runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/templates/cnoidal_wave/base/constant/g b/templates/cnoidal_wave/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..54e4bdd5e7ffb6753e42b2740e3e0c3a04dbf7bf --- /dev/null +++ b/templates/cnoidal_wave/base/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 0 -9.81 ); + + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/constant/transportProperties b/templates/cnoidal_wave/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..0b410ab971be20391ffc2b3be8b4758454104a2b --- /dev/null +++ b/templates/cnoidal_wave/base/constant/transportProperties @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1e-06; + rho 1000; +} + +air +{ + transportModel Newtonian; + nu 1.48e-05; + rho 1; +} + +sigma 0.07; + + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/constant/turbulenceProperties b/templates/cnoidal_wave/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..5df08c0e4378ccacccd38e40532970422bb70c19 --- /dev/null +++ b/templates/cnoidal_wave/base/constant/turbulenceProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/constant/waveProperties b/templates/cnoidal_wave/base/constant/waveProperties new file mode 100644 index 0000000000000000000000000000000000000000..b730f8c5b0957405f4dea74d26376fb91d6abab9 --- /dev/null +++ b/templates/cnoidal_wave/base/constant/waveProperties @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object waveProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inlet +{ + alpha alpha.water; + + waveModel cnoidal; + + nPaddle 1; + + waveHeight 0.1; + + waveAngle 0.0; + + rampTime 6.0; + + activeAbsorption yes; + + wavePeriod 4.0; +} + +outlet +{ + alpha alpha.water; + + waveModel shallowWaterAbsorption; + + nPaddle 1; +} + + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/system/blockMeshDict b/templates/cnoidal_wave/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..ada433883dfc28178df84297e5e14ab04500b152 --- /dev/null +++ b/templates/cnoidal_wave/base/system/blockMeshDict @@ -0,0 +1,89 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +vertices +( + ( 0.0 0.0 0.0) + ( 30.0 0.0 0.0) + ( 30.0 0.04 0.0) + ( 0.0 0.04 0.0) + ( 0.0 0.0 0.7) + ( 30.0 0.0 0.7) + ( 30.0 0.04 0.7) + ( 0.0 0.04 0.7) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (750 1 70) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + outlet + { + type patch; + faces + ( + (1 5 6 2) + ); + } + ground + { + type wall; + faces + ( + (0 1 2 3) + ); + } + top + { + type patch; + faces + ( + (4 5 6 7) + ); + } + sides + { + type empty; + faces + ( + (0 1 5 4) + (3 2 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/system/controlDict b/templates/cnoidal_wave/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..9920a18bbcf962950200e3f3579f5aff75f12fca --- /dev/null +++ b/templates/cnoidal_wave/base/system/controlDict @@ -0,0 +1,148 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application interFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 50.0; + +deltaT 0.01; + +writeControl adjustableRunTime; + +writeInterval 0.033; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.65; + +maxAlphaCo 0.65; + +maxDeltaT 0.05; + + +functions +{ + line + { + type sets; + libs ("libsampling.so"); + enabled true; + writeControl writeTime; + writeInterval 1; + + interpolationScheme cellPoint; + setFormat raw; + + sets + ( + line1 + { + type uniform; + axis distance; + start ( 1.0 0.005 0.0 ); + end ( 1.0 0.005 0.8 ); + nPoints 1001; + } + line2 + { + type uniform; + axis distance; + start ( 2.0 0.005 0.0 ); + end ( 2.0 0.005 0.8 ); + nPoints 1001; + } + line3 + { + type uniform; + axis distance; + start ( 3.0 0.005 0.0 ); + end ( 3.0 0.005 0.8 ); + nPoints 1001; + } + line4 + { + type uniform; + axis distance; + start ( 5.0 0.005 0.0 ); + end ( 5.0 0.005 0.8 ); + nPoints 1001; + } + line5 + { + type uniform; + axis distance; + start ( 7.5 0.005 0.0 ); + end ( 7.5 0.005 0.8 ); + nPoints 1001; + } + + line6 + { + type uniform; + axis distance; + start ( 10.0 0.005 0.0 ); + end ( 10.0 0.005 0.8 ); + nPoints 1001; + } + line7 + { + type uniform; + axis distance; + start ( 12.0 0.005 0.0 ); + end ( 12.0 0.005 0.8 ); + nPoints 1001; + } + line8 + { + type uniform; + axis distance; + start ( 14.0 0.005 0.0 ); + end ( 14.0 0.005 0.8 ); + nPoints 1001; + } + ); + + fixedLocations false; + fields + ( + U alpha.water + ); + } +} + + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/system/decomposeParDict b/templates/cnoidal_wave/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..169c92b30a46bcf98537b731d5db3033d7a857ab --- /dev/null +++ b/templates/cnoidal_wave/base/system/decomposeParDict @@ -0,0 +1,27 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method hierarchical; + +coeffs +{ + n (2 1 1); +} + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/system/fvSchemes b/templates/cnoidal_wave/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..7f2a9656dd3d1ca1994533d1e09dfbc8b1875121 --- /dev/null +++ b/templates/cnoidal_wave/base/system/fvSchemes @@ -0,0 +1,53 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/system/fvSolution b/templates/cnoidal_wave/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..cad6bd5ee5a86340b5914746937961c156a473f6 --- /dev/null +++ b/templates/cnoidal_wave/base/system/fvSolution @@ -0,0 +1,77 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 1; + nAlphaSubCycles 3; + cAlpha 1; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0; + } + + p_rgh + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0.1; + } + + p_rghFinal + { + solver GAMG; + smoother DIC; + tolerance 1e-7; + relTol 0; + } + + U + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0.1; + } + + UFinal + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0; + } +} + +PIMPLE +{ + momentumPredictor no; + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/templates/cnoidal_wave/base/system/setFieldsDict b/templates/cnoidal_wave/base/system/setFieldsDict new file mode 100644 index 0000000000000000000000000000000000000000..c156541f0ec08e843e32bb914895122a1f74e43f --- /dev/null +++ b/templates/cnoidal_wave/base/system/setFieldsDict @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha.water 0 +); + +regions +( + boxToCell + { + box (0 0 0) (30.0 1.0 0.4); + fieldValues + ( + volScalarFieldValue alpha.water 1 + ); + } +); + + +// ************************************************************************* // diff --git a/templates/dam_break/base/0/U b/templates/dam_break/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..84e0b72764234252d8d8fd7f11bf25fa8a5e11d3 --- /dev/null +++ b/templates/dam_break/base/0/U @@ -0,0 +1,41 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + leftWall + { + type noSlip; + } + + rightWall + { + type noSlip; + } + + lowerWall + { + type noSlip; + } + + upperWall + { + type pressureInletOutletVelocity; + phi phi; + value uniform (0 0 0); + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/dam_break/base/0/alpha.water b/templates/dam_break/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..bc790e2299995eb3ee186d46f21b8cc31c5df279 --- /dev/null +++ b/templates/dam_break/base/0/alpha.water @@ -0,0 +1,42 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} + +dimensions [0 0 0 0 0 0 0]; + +// 初始值:全部为空气(alpha=0),由 gen_init_conditions.py 覆盖水柱区域 +internalField uniform 0; + +boundaryField +{ + leftWall + { + type zeroGradient; + } + + rightWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + upperWall + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/dam_break/base/0/p_rgh b/templates/dam_break/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..9b65febce8d50c9eb58bfec64e491bf5312a117a --- /dev/null +++ b/templates/dam_break/base/0/p_rgh @@ -0,0 +1,45 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} + +dimensions [1 -1 -2 0 0 0 0]; + +// 注意: OpenFOAM 中 p_rgh = p/rho - g·x,此处为 kinematic pressure +internalField uniform 0; + +boundaryField +{ + leftWall + { + type fixedFluxPressure; + value uniform 0; + } + + rightWall + { + type fixedFluxPressure; + value uniform 0; + } + + lowerWall + { + type fixedFluxPressure; + value uniform 0; + } + + upperWall + { + type prghPressure; + p uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/dam_break/base/Allrun b/templates/dam_break/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..9f7e6e89423557ab20dbbacb661a3bea5d1a9382 --- /dev/null +++ b/templates/dam_break/base/Allrun @@ -0,0 +1,44 @@ +#!/bin/bash +# dam_break Allrun 脚本 +# 用法: bash Allrun [n_procs] +# 注意: 初始场文件(0/alpha.water, 0/U)由 gen_init_conditions.py 预生成 + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 + +N_PROCS=${1:-1} + +echo "=== dam_break: blockMesh ===" +blockMesh > log.blockMesh 2>&1 +if [ $? -ne 0 ]; then + echo "ERROR: blockMesh failed, see log.blockMesh" + exit 1 +fi +echo " blockMesh 完成" + +if [ "$N_PROCS" -gt 1 ]; then + echo "=== dam_break: decomposePar (np=$N_PROCS) ===" + decomposePar -force > log.decomposePar 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: decomposePar failed, see log.decomposePar" + exit 1 + fi + + echo "=== dam_break: interFoam (parallel, np=$N_PROCS) ===" + mpirun -np "$N_PROCS" interFoam -parallel > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed, see log.interFoam" + exit 1 + fi + + echo "=== dam_break: reconstructPar ===" + reconstructPar > log.reconstructPar 2>&1 +else + echo "=== dam_break: interFoam (serial) ===" + interFoam > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed, see log.interFoam" + exit 1 + fi +fi + +echo "=== dam_break 完成 ===" diff --git a/templates/dam_break/base/constant/g b/templates/dam_break/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..ca544e1f16118931911092a402c88e003b7baf84 --- /dev/null +++ b/templates/dam_break/base/constant/g @@ -0,0 +1,10 @@ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} + +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.81 0); diff --git a/templates/dam_break/base/constant/transportProperties b/templates/dam_break/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..0423705b6e38806eff4166ec0226482ccf195149 --- /dev/null +++ b/templates/dam_break/base/constant/transportProperties @@ -0,0 +1,29 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} + +// 两相流物性参数 +// 参考: OpenFOAM Foundation. OpenFOAM v9 User Guide, 2021. +// 水和空气的标准物理参数 + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1.0e-06; // 运动粘度 [m^2/s] (20 deg C) + rho 1000; // 密度 [kg/m^3] +} + +air +{ + transportModel Newtonian; + nu 1.48e-05; // 运动粘度 [m^2/s] (20 deg C) + rho 1.225; // 密度 [kg/m^3] +} + +sigma 0.07; // 表面张力系数 [N/m] (水-空气, 20 deg C) diff --git a/templates/dam_break/base/constant/turbulenceProperties b/templates/dam_break/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..b75c4953045b92eadd94bcd8b270d129262ccc78 --- /dev/null +++ b/templates/dam_break/base/constant/turbulenceProperties @@ -0,0 +1,9 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} + +simulationType laminar; diff --git a/templates/dam_break/base/system/blockMeshDict b/templates/dam_break/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..8eb82529fdd5a57762a1f5aba9004ecf537d3243 --- /dev/null +++ b/templates/dam_break/base/system/blockMeshDict @@ -0,0 +1,89 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// 溃坝算例 — 简化矩形域(去除原始 damBreakLaminar 教程中的中间障碍物) +// 参考: OpenFOAM Foundation. OpenFOAM v9 User Guide, 2021. +// Section 2.1.1 "Breaking of a dam" +// 域尺寸: 0.584m x 0.584m (X x Y), Z 方向单层(2D, empty 边界) +// 网格: 128 x 128 (X x Y) + +scale 1; // 坐标单位: m + +// 四个顶点 (Z=0 和 Z=0.001 两层构成退化 3D 网格) +vertices +( + (0 0 0) // 0: 左下前 + (0.584 0 0) // 1: 右下前 + (0.584 0.584 0) // 2: 右上前 + (0 0.584 0) // 3: 左上前 + (0 0 0.001) // 4: 左下后 + (0.584 0 0.001) // 5: 右下后 + (0.584 0.584 0.001) // 6: 右上后 + (0 0.584 0.001) // 7: 左上后 +); + +// 单一六面体块,128x128x1 网格 +// vertex ordering: 右手定则,从 0-3 (Z=0) 到 4-7 (Z=0.001) +blocks +( + hex (0 1 2 3 4 5 6 7) (128 128 1) simpleGrading (1 1 1) +); + +edges +( +); + +// 边界面定义 +boundary +( + leftWall + { + type wall; + faces + ( + (0 4 7 3) // X=0 面(左侧壁) + ); + } + + rightWall + { + type wall; + faces + ( + (1 2 6 5) // X=0.584 面(右侧壁) + ); + } + + lowerWall + { + type wall; + faces + ( + (0 1 5 4) // Y=0 面(底部壁) + ); + } + + upperWall + { + type patch; + faces + ( + (3 7 6 2) // Y=0.584 面(顶部开口) + ); + } + + defaultFaces + { + type empty; + faces + ( + (0 3 2 1) // Z=0 前面 + (4 5 6 7) // Z=0.001 后面 + ); + } +); diff --git a/templates/dam_break/base/system/controlDict b/templates/dam_break/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..5a1f807b054165f77156612558ed24395a0756b9 --- /dev/null +++ b/templates/dam_break/base/system/controlDict @@ -0,0 +1,36 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} + +application interFoam; + +startFrom startTime; +startTime 0; +stopAt endTime; +endTime 2.0; // 溃坝物理时长 [s] + +deltaT 0.002; // 初始时间步 [s](自适应调整) +writeControl adjustableRunTime; +writeInterval 0.08; // endTime/25 → 25 帧 + +purgeWrite 0; +writeFormat ascii; // ASCII 格式,便于后处理脚本读取 +writePrecision 8; +timeFormat general; +timePrecision 6; + +adjustTimeStep yes; // 自适应时间步 +maxCo 0.5; // Courant 数限制 +maxAlphaCo 0.5; // alpha Courant 数限制 +maxDeltaT 0.005; // 最大时间步上限 [s] + +functions {}; + +OptimisationSwitches +{ + trapFpe no; // 禁用浮点异常捕获(避免数值噪声导致崩溃) +} diff --git a/templates/dam_break/base/system/decomposeParDict b/templates/dam_break/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..40aa3873e13ef5298c8e597732b6e637299827f8 --- /dev/null +++ b/templates/dam_break/base/system/decomposeParDict @@ -0,0 +1,21 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +// 并行分解设置 +// 2D case: Z 方向仅 1 个分区(empty 边界限制) +// numberOfSubdomains 由 run_case.sh 传入,此处为默认值 +numberOfSubdomains 4; + +method hierarchical; + +hierarchicalCoeffs +{ + n (2 2 1); // X: 2分区, Y: 2分区, Z: 1分区 + delta 0.001; + order xyz; +} diff --git a/templates/dam_break/base/system/fvSchemes b/templates/dam_break/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..337672bb49af8489fb349098762b0914380b9202 --- /dev/null +++ b/templates/dam_break/base/system/fvSchemes @@ -0,0 +1,53 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + // 速度对流项:线性迎风(一阶稳定) + div(rhoPhi,U) Gauss linearUpwind grad(U); + + // alpha 方程:van Leer 界面压缩格式 + // gcnl: 人工压缩通量,保持界面锐利 + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss interfaceCompression vanLeer; + + // ESI v1906 粘性应力项 + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear corrected; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +wallDist +{ + method meshWave; +} diff --git a/templates/dam_break/base/system/fvSolution b/templates/dam_break/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..1312e19878acd8c7d78eff92fab8453ba40cd542 --- /dev/null +++ b/templates/dam_break/base/system/fvSolution @@ -0,0 +1,86 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 3; + nAlphaSubCycles 2; + cAlpha 1; + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + minIter 1; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-8; + relTol 0; + minIter 1; + } + + "pcorrFinal.*" + { + $pcorr; + relTol 0; + } + + "p_rgh.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-8; + relTol 0.001; + minIter 1; + } + + "p_rghFinal.*" + { + $p_rgh; + relTol 0; + } + + "U.*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + minIter 1; + } +} + +MULES +{ + nAlphaCorr 3; + nAlphaSubCycles 2; + cAlpha 1; +} + +PIMPLE +{ + nOuterCorrectors 1; + nCorrectors 3; + nNonOrthogonalCorrectors 0; + MULESCorr yes; + nLimiterIter 5; + momentumPredictor no; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + fields {}; + equations {}; +} diff --git a/templates/droplet_impact/base/0/U b/templates/droplet_impact/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..2cc60ed9ccbc0effc0f162e35da7f49740285416 --- /dev/null +++ b/templates/droplet_impact/base/0/U @@ -0,0 +1,46 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} + +dimensions [0 1 -1 0 0 0 0]; + +// 初始值:全零;液滴区域由 gen_init_conditions.py 设置为 (0, -1.5, 0) +internalField uniform (0 0 0); + +boundaryField +{ + bottomWall + { + type noSlip; // 撞击壁面:无滑移 + } + + topPatch + { + type pressureInletOutletVelocity; + phi phi; + value uniform (0 0 0); + } + + leftWall + { + type pressureInletOutletVelocity; + phi phi; + value uniform (0 0 0); + } + + rightWall + { + type pressureInletOutletVelocity; + phi phi; + value uniform (0 0 0); + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/droplet_impact/base/0/alpha.water b/templates/droplet_impact/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..f041796bd4425b61c69b0b7d0b07e2b97dadceda --- /dev/null +++ b/templates/droplet_impact/base/0/alpha.water @@ -0,0 +1,50 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} + +dimensions [0 0 0 0 0 0 0]; + +// 初始值:全部为空气(alpha=0) +// 液滴半球区域由 gen_init_conditions.py 设置为 1 +internalField uniform 0; + +boundaryField +{ + bottomWall + { + type constantAlphaContactAngle; + theta0 75; // Pasandideh-Fard (1996): stainless steel, theta_e ~ 70-80 deg + limit gradient; + value uniform 0; + } + + topPatch + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + leftWall + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + rightWall + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/droplet_impact/base/0/p_rgh b/templates/droplet_impact/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..22e88457644f991889f50d6b412eb1313475cc35 --- /dev/null +++ b/templates/droplet_impact/base/0/p_rgh @@ -0,0 +1,46 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + bottomWall + { + type fixedFluxPressure; + value uniform 0; + } + + topPatch + { + type prghPressure; + p uniform 0; + value uniform 0; + } + + leftWall + { + type prghPressure; + p uniform 0; + value uniform 0; + } + + rightWall + { + type prghPressure; + p uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/droplet_impact/base/Allrun b/templates/droplet_impact/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..f56bcc37b13b0cf3586604e404690a0e8a5f8435 --- /dev/null +++ b/templates/droplet_impact/base/Allrun @@ -0,0 +1,42 @@ +#!/bin/bash +# droplet_impact Allrun 脚本 +# 参考: Pasandideh-Fard, M. et al. (1998). Phys. Fluids, 10(3), 631-638. + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 + +N_PROCS=${1:-1} + +echo "=== droplet_impact: blockMesh ===" +blockMesh > log.blockMesh 2>&1 +if [ $? -ne 0 ]; then + echo "ERROR: blockMesh failed, see log.blockMesh" + exit 1 +fi + +if [ "$N_PROCS" -gt 1 ]; then + echo "=== droplet_impact: decomposePar (np=$N_PROCS) ===" + decomposePar -force > log.decomposePar 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: decomposePar failed" + exit 1 + fi + + echo "=== droplet_impact: interFoam (parallel, np=$N_PROCS) ===" + mpirun -np "$N_PROCS" interFoam -parallel > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed" + exit 1 + fi + + echo "=== droplet_impact: reconstructPar ===" + reconstructPar > log.reconstructPar 2>&1 +else + echo "=== droplet_impact: interFoam (serial) ===" + interFoam > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed" + exit 1 + fi +fi + +echo "=== droplet_impact 完成 ===" diff --git a/templates/droplet_impact/base/constant/g b/templates/droplet_impact/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..ca544e1f16118931911092a402c88e003b7baf84 --- /dev/null +++ b/templates/droplet_impact/base/constant/g @@ -0,0 +1,10 @@ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} + +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.81 0); diff --git a/templates/droplet_impact/base/constant/transportProperties b/templates/droplet_impact/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..1403078b1b3514592c8874d39805e528240fec1b --- /dev/null +++ b/templates/droplet_impact/base/constant/transportProperties @@ -0,0 +1,33 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} + +// 液滴撞击算例物性参数 +// 参考: Pasandideh-Fard, M. et al. (1996). "Capillary effects during +// droplet impact on a solid surface." Phys. Fluids, 8(3), 650-659. +// 水滴撞击固体壁面,We≈69, Re≈3360 + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1.005e-06; // 运动粘度 [m^2/s] (μ=1.003e-3 Pa·s / ρ=998 kg/m^3) + rho 998; // 密度 [kg/m^3] (20 deg C) +} + +air +{ + transportModel Newtonian; + nu 1.455e-05; // 运动粘度 [m^2/s] (μ=1.78e-5 Pa·s / ρ=1.225 kg/m^3) + rho 1.225; // 密度 [kg/m^3] +} + +sigma 0.0728; // 表面张力系数 [N/m] (水-空气, 20 deg C) +// Pasandideh-Fard Table I: σ = 0.0728 N/m +// 注: Foundation 版 OpenFOAM 不需要 wallAdhesion 关键字 +// interfaceProperties 自动检测 alphaContactAngle BC 并应用接触角修正 diff --git a/templates/droplet_impact/base/constant/turbulenceProperties b/templates/droplet_impact/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..b75c4953045b92eadd94bcd8b270d129262ccc78 --- /dev/null +++ b/templates/droplet_impact/base/constant/turbulenceProperties @@ -0,0 +1,9 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} + +simulationType laminar; diff --git a/templates/droplet_impact/base/system/blockMeshDict b/templates/droplet_impact/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..e3358d013fe778c63c0bbf4e81c8340837278cbd --- /dev/null +++ b/templates/droplet_impact/base/system/blockMeshDict @@ -0,0 +1,73 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// 液滴撞击算例 +// 参考: Pasandideh-Fard, M. et al. (1996). "Capillary effects during +// droplet impact on a solid surface." Phys. Fluids, 8(3), 650-659. +// 域尺寸: 0.05m x 0.05m (~22D, D=2.25mm, 足够铺展-回缩) +// 网格: 256 x 256 (~11 cells/D) + +scale 1; + +vertices +( + (0 0 0) // 0 + (0.05 0 0) // 1 + (0.05 0.05 0) // 2 + (0 0.05 0) // 3 + (0 0 0.001) // 4 + (0.05 0 0.001) // 5 + (0.05 0.05 0.001) // 6 + (0 0.05 0.001) // 7 +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (256 256 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + bottomWall + { + type wall; + faces ( (0 1 5 4) ); // Y=0 面(撞击壁面) + } + + topPatch + { + type patch; + faces ( (3 7 6 2) ); // Y=0.05 面(顶部开放边界) + } + + leftWall + { + type patch; + faces ( (0 4 7 3) ); // X=0 面(侧面开放边界) + } + + rightWall + { + type patch; + faces ( (1 2 6 5) ); // X=0.05 面(侧面开放边界) + } + + defaultFaces + { + type empty; + faces + ( + (0 3 2 1) // Z=0 + (4 5 6 7) // Z=0.001 + ); + } +); diff --git a/templates/droplet_impact/base/system/controlDict b/templates/droplet_impact/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..8226ec55be3e0f0680a7f37fcf1c8ecfeef0514e --- /dev/null +++ b/templates/droplet_impact/base/system/controlDict @@ -0,0 +1,31 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} + +application interFoam; + +startFrom startTime; +startTime 0; +stopAt endTime; +endTime 0.2; // 液滴撞击物理时长 [s](铺展+初始回弹,原 0.5s 过长) + +deltaT 5e-06; // 初始时间步 [s](撞击过程需小时间步) +writeControl adjustableRunTime; +writeInterval 0.008; // endTime/25 → 25 帧 + +purgeWrite 0; +writeFormat ascii; // ASCII 格式,便于后处理脚本读取 +writePrecision 8; +timeFormat general; +timePrecision 6; + +adjustTimeStep yes; +maxCo 0.5; +maxAlphaCo 0.5; +maxDeltaT 1e-04; // 最大时间步上限 + +functions {}; diff --git a/templates/droplet_impact/base/system/decomposeParDict b/templates/droplet_impact/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..97fe7fa7a23d65c50d647ee2e7ced029cbf9f5d4 --- /dev/null +++ b/templates/droplet_impact/base/system/decomposeParDict @@ -0,0 +1,18 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +numberOfSubdomains 4; + +method hierarchical; + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} diff --git a/templates/droplet_impact/base/system/fvSchemes b/templates/droplet_impact/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..9d9f9ed80ea021a61a84007d3754980f3da5f5da --- /dev/null +++ b/templates/droplet_impact/base/system/fvSchemes @@ -0,0 +1,47 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss interfaceCompression vanLeer; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear corrected; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +wallDist +{ + method meshWave; +} diff --git a/templates/droplet_impact/base/system/fvSolution b/templates/droplet_impact/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..d7fb516a6a4c93441213266abe679ae2e906b911 --- /dev/null +++ b/templates/droplet_impact/base/system/fvSolution @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 3; + nAlphaSubCycles 3; + cAlpha 1; + + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-5; + relTol 0; + } + + "pcorrFinal.*" + { + $pcorr; + relTol 0; + } + + "p_rgh.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-08; + relTol 0.01; + } + + "p_rghFinal.*" + { + $p_rgh; + relTol 0; + } + + "U.*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-06; + relTol 0; + } +} + +MULES +{ + nAlphaCorr 3; + nAlphaSubCycles 3; + cAlpha 1; +} + +PIMPLE +{ + nOuterCorrectors 1; + nCorrectors 3; + nNonOrthogonalCorrectors 0; + MULESCorr yes; + nLimiterIter 5; + momentumPredictor no; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + equations + { + ".*" 1; + } +} diff --git a/templates/rising_bubble/base/0/U b/templates/rising_bubble/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..ca48a6ac3545842eab70ec132439076cd6130023 --- /dev/null +++ b/templates/rising_bubble/base/0/U @@ -0,0 +1,39 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + leftWall + { + type slip; + } + + rightWall + { + type slip; + } + + lowerWall + { + type slip; // Hysing benchmark: 所有壁面均为自由滑移(对称面) + } + + upperWall + { + type slip; // Hysing benchmark: 所有壁面均为自由滑移(对称面) + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/rising_bubble/base/0/alpha.water b/templates/rising_bubble/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..68ec1b8b9e79ab2ecb87dfac5e08001eb1c790ab --- /dev/null +++ b/templates/rising_bubble/base/0/alpha.water @@ -0,0 +1,40 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} + +dimensions [0 0 0 0 0 0 0]; + +// 初始值:全部为水(alpha=1),气泡区域由 gen_init_conditions.py 设置为 0 +internalField uniform 1; + +boundaryField +{ + leftWall + { + type zeroGradient; + } + + rightWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + upperWall + { + type zeroGradient; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/rising_bubble/base/0/p_rgh b/templates/rising_bubble/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..65f5b4faa9e0b90d3b5a5f3fbe009d748c63882e --- /dev/null +++ b/templates/rising_bubble/base/0/p_rgh @@ -0,0 +1,43 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + leftWall + { + type fixedFluxPressure; + value uniform 0; + } + + rightWall + { + type fixedFluxPressure; + value uniform 0; + } + + lowerWall + { + type fixedFluxPressure; + value uniform 0; + } + + upperWall + { + type fixedFluxPressure; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/rising_bubble/base/Allrun b/templates/rising_bubble/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..798ea9ce6c9ec2f5dbdaa9fb028ea035af0f2374 --- /dev/null +++ b/templates/rising_bubble/base/Allrun @@ -0,0 +1,42 @@ +#!/bin/bash +# rising_bubble Allrun 脚本 +# 参考: Hysing, S. et al. (2009), Int. J. Numer. Meth. Fluids, 60(11), 1259-1288. + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 + +N_PROCS=${1:-1} + +echo "=== rising_bubble: blockMesh ===" +blockMesh > log.blockMesh 2>&1 +if [ $? -ne 0 ]; then + echo "ERROR: blockMesh failed, see log.blockMesh" + exit 1 +fi + +if [ "$N_PROCS" -gt 1 ]; then + echo "=== rising_bubble: decomposePar (np=$N_PROCS) ===" + decomposePar -force > log.decomposePar 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: decomposePar failed" + exit 1 + fi + + echo "=== rising_bubble: interFoam (parallel, np=$N_PROCS) ===" + mpirun -np "$N_PROCS" interFoam -parallel > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed" + exit 1 + fi + + echo "=== rising_bubble: reconstructPar ===" + reconstructPar > log.reconstructPar 2>&1 +else + echo "=== rising_bubble: interFoam (serial) ===" + interFoam > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed" + exit 1 + fi +fi + +echo "=== rising_bubble 完成 ===" diff --git a/templates/rising_bubble/base/constant/g b/templates/rising_bubble/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..cab240c7b55446cb5b9a031e548f1c8f0aefc713 --- /dev/null +++ b/templates/rising_bubble/base/constant/g @@ -0,0 +1,12 @@ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} + +dimensions [0 1 -2 0 0 0 0]; +value (0 -0.98 0); +// Hysing 无量纲 g*=-0.98; 有量纲值 g = g* × U_ref^2 / L_ref +// = -0.98 × 1^2 / 1 = -0.98 m/s^2 diff --git a/templates/rising_bubble/base/constant/transportProperties b/templates/rising_bubble/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..c9976bfc1e0beca3914c852f653fdc6a4e4e1dcc --- /dev/null +++ b/templates/rising_bubble/base/constant/transportProperties @@ -0,0 +1,38 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} + +// 浮力气泡算例物性参数 +// 参考: Hysing, S. et al. (2009). "Quantitative benchmark computations +// of two-dimensional bubble dynamics." Int. J. Numer. Meth. Fluids, +// 60(11), 1259-1288. +// +// Hysing Case 1 (低变形): 密度比 10:1, 粘度比 10:1 +// 无量纲参数: Re=35, Eo=10 +// Mo = g·μ₁⁴·Δρ/(ρ₁·σ³) ≈ 0.60(Clift 定义;不同 Mo 定义数值差异可达 15x) +// Eo 定义: Eo = ρ1 * g * D² / σ (Hysing 原文用 ρ1 而非 Δρ) +// 有量纲参数基于 L_ref=1m, U_ref=1m/s 换算 + +phases (water air); + +water +{ + transportModel Newtonian; + nu 0.01; // 运动粘度 [m^2/s] (μ=10 Pa·s, Hysing Case 1) + rho 1000; // 密度 [kg/m^3] +} + +air +{ + transportModel Newtonian; + nu 0.01; // 运动粘度 [m^2/s] (μ=1 Pa·s, ρ=100 kg/m³) + rho 100; // 密度 [kg/m^3] (密度比 10:1) +} + +sigma 24.5; // 表面张力系数 [N/m] +// Hysing Case 1: Eo = ρ1 × g × D² / σ = 10 +// σ = ρ1 × g × D² / Eo = 1000 × 0.98 × 0.25 / 10 = 24.5 N/m (D=2R=0.5, D²=0.25) diff --git a/templates/rising_bubble/base/constant/turbulenceProperties b/templates/rising_bubble/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..b75c4953045b92eadd94bcd8b270d129262ccc78 --- /dev/null +++ b/templates/rising_bubble/base/constant/turbulenceProperties @@ -0,0 +1,9 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} + +simulationType laminar; diff --git a/templates/rising_bubble/base/system/blockMeshDict b/templates/rising_bubble/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..53129bb605e6e9285cb0719f5ad786ddfc39dec9 --- /dev/null +++ b/templates/rising_bubble/base/system/blockMeshDict @@ -0,0 +1,74 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// 浮力气泡算例 — Hysing et al. (2009) Case 1 +// 参考: Hysing, S. et al. (2009). "Quantitative benchmark computations +// of two-dimensional bubble dynamics." Int. J. Numer. Meth. Fluids, +// 60(11), 1259-1288. +// 域尺寸: 1m x 2m (X x Y), Z 方向单层(2D, empty 边界) +// 网格: 128 x 256 + +scale 1; + +vertices +( + (0 0 0) // 0 + (1 0 0) // 1 + (1 2 0) // 2 + (0 2 0) // 3 + (0 0 0.001) // 4 + (1 0 0.001) // 5 + (1 2 0.001) // 6 + (0 2 0.001) // 7 +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (128 256 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + leftWall + { + type wall; + faces ( (0 4 7 3) ); + } + + rightWall + { + type wall; + faces ( (1 2 6 5) ); + } + + lowerWall + { + type wall; + faces ( (0 1 5 4) ); + } + + upperWall + { + type wall; + faces ( (3 7 6 2) ); + } + + defaultFaces + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ); + } +); diff --git a/templates/rising_bubble/base/system/controlDict b/templates/rising_bubble/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..6420ff91ead9219f48d1c75cafd26b9f84c048c3 --- /dev/null +++ b/templates/rising_bubble/base/system/controlDict @@ -0,0 +1,31 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} + +application interFoam; + +startFrom startTime; +startTime 0; +stopAt endTime; +endTime 3.0; // 气泡上升物理时长 [s](足够达到 terminal velocity) + +deltaT 0.002; // 初始时间步 [s](高粘度,需更小时间步) +writeControl adjustableRunTime; +writeInterval 0.12; // endTime/25 → 25 帧 + +purgeWrite 0; +writeFormat ascii; // ASCII 格式,便于后处理脚本读取 +writePrecision 8; +timeFormat general; +timePrecision 6; + +adjustTimeStep yes; +maxCo 0.5; +maxAlphaCo 0.5; +maxDeltaT 0.002; + +functions {}; diff --git a/templates/rising_bubble/base/system/decomposeParDict b/templates/rising_bubble/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..97fe7fa7a23d65c50d647ee2e7ced029cbf9f5d4 --- /dev/null +++ b/templates/rising_bubble/base/system/decomposeParDict @@ -0,0 +1,18 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +numberOfSubdomains 4; + +method hierarchical; + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} diff --git a/templates/rising_bubble/base/system/fvSchemes b/templates/rising_bubble/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..9d9f9ed80ea021a61a84007d3754980f3da5f5da --- /dev/null +++ b/templates/rising_bubble/base/system/fvSchemes @@ -0,0 +1,47 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss interfaceCompression vanLeer; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear corrected; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +wallDist +{ + method meshWave; +} diff --git a/templates/rising_bubble/base/system/fvSolution b/templates/rising_bubble/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..3183b94b1818ed729e220c7fb9e00c1a09b80a99 --- /dev/null +++ b/templates/rising_bubble/base/system/fvSolution @@ -0,0 +1,79 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 2; + nAlphaSubCycles 1; + cAlpha 1; + + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-5; + relTol 0; + } + + "pcorrFinal.*" + { + $pcorr; + relTol 0; + } + + "p_rgh.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-07; + relTol 0.05; + } + + "p_rghFinal.*" + { + $p_rgh; + relTol 0; + } + + "U.*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-06; + relTol 0; + } +} + +PIMPLE +{ + nOuterCorrectors 1; + nCorrectors 3; + nNonOrthogonalCorrectors 0; + pRefCell 0; + pRefValue 0; + + MULESCorr yes; + nLimiterIter 5; + momentumPredictor no; +} + +relaxationFactors +{ + equations + { + ".*" 1; + } +} diff --git a/templates/stokes_wave/base/0/U b/templates/stokes_wave/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..dd0c8bd3e6c260c47dddc17f918b84bbf7f8aaee --- /dev/null +++ b/templates/stokes_wave/base/0/U @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + inlet + { + type waveVelocity; + value uniform (0 0 0); + } + + outlet + { + type waveVelocity; + value uniform (0 0 0); + } + + sides + { + type empty; + } + + ground + { + type fixedValue; + value uniform (0 0 0); + } + + top + { + type pressureInletOutletVelocity; + value uniform (0 0 0); + } +} + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/0/alpha.water b/templates/stokes_wave/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..37e6ffb99eca06b00d675988e975db0161a74991 --- /dev/null +++ b/templates/stokes_wave/base/0/alpha.water @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type waveAlpha; + value uniform 0; + } + + outlet + { + type zeroGradient; + } + + ground + { + type zeroGradient; + } + + sides + { + type empty; + } + + top + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } +} + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/0/p_rgh b/templates/stokes_wave/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..c124795bdca98817da9c7f591a4d2146f9c39bb0 --- /dev/null +++ b/templates/stokes_wave/base/0/p_rgh @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type fixedFluxPressure; + value uniform 0; + } + + outlet + { + type fixedFluxPressure; + value uniform 0; + } + + ground + { + type fixedFluxPressure; + value uniform 0; + } + + sides + { + type empty; + } + + top + { + type totalPressure; + p0 uniform 0; + } +} + + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/Allclean b/templates/stokes_wave/base/Allclean new file mode 100644 index 0000000000000000000000000000000000000000..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 --- /dev/null +++ b/templates/stokes_wave/base/Allclean @@ -0,0 +1,7 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 + +#------------------------------------------------------------------------------ diff --git a/templates/stokes_wave/base/Allrun b/templates/stokes_wave/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..28bf991e627511713c3b915ac0d9998f068ce030 --- /dev/null +++ b/templates/stokes_wave/base/Allrun @@ -0,0 +1,15 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +restore0Dir + +runApplication blockMesh + +runApplication decomposePar + +runParallel setFields + +runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/templates/stokes_wave/base/constant/g b/templates/stokes_wave/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..2a0e091fcfc37ab04dd809daf9ea30e30f068203 --- /dev/null +++ b/templates/stokes_wave/base/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 0 -9.81 ); + + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/constant/transportProperties b/templates/stokes_wave/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..0b410ab971be20391ffc2b3be8b4758454104a2b --- /dev/null +++ b/templates/stokes_wave/base/constant/transportProperties @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1e-06; + rho 1000; +} + +air +{ + transportModel Newtonian; + nu 1.48e-05; + rho 1; +} + +sigma 0.07; + + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/constant/turbulenceProperties b/templates/stokes_wave/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..04190a72d650e35ad10e2e5d702a70839cf7e8ad --- /dev/null +++ b/templates/stokes_wave/base/constant/turbulenceProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/constant/waveProperties b/templates/stokes_wave/base/constant/waveProperties new file mode 100644 index 0000000000000000000000000000000000000000..67f0b47221be1dd26cb46db36a786d3b171c7805 --- /dev/null +++ b/templates/stokes_wave/base/constant/waveProperties @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object waveProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inlet +{ + alpha alpha.water; + + waveModel StokesV; + + nPaddle 1; + + waveHeight 0.1; + + waveAngle 0.0; + + rampTime 4.0; + + activeAbsorption yes; + + wavePeriod 2.0; +} + +outlet +{ + alpha alpha.water; + + waveModel shallowWaterAbsorption; + + nPaddle 1; +} + + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/system/blockMeshDict b/templates/stokes_wave/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..a4236b3a9f74e61a442124443ca5d9d21df2321a --- /dev/null +++ b/templates/stokes_wave/base/system/blockMeshDict @@ -0,0 +1,89 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +vertices +( + ( 0.0 0.0 0.0) + ( 30.0 0.0 0.0) + ( 30.0 0.04 0.0) + ( 0.0 0.04 0.0) + ( 0.0 0.0 0.7) + ( 30.0 0.0 0.7) + ( 30.0 0.04 0.7) + ( 0.0 0.04 0.7) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (750 1 70) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + outlet + { + type patch; + faces + ( + (1 5 6 2) + ); + } + ground + { + type wall; + faces + ( + (0 1 2 3) + ); + } + top + { + type patch; + faces + ( + (4 5 6 7) + ); + } + sides + { + type empty; + faces + ( + (0 1 5 4) + (3 2 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/system/controlDict b/templates/stokes_wave/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..eaa083566886fa66a7c28779d7bcacde43871451 --- /dev/null +++ b/templates/stokes_wave/base/system/controlDict @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application interFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 20.0; + +deltaT 0.01; + +writeControl adjustableRunTime; + +writeInterval 0.8; // endTime/25 → 25 帧 + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep on; + +maxCo 0.65; + +maxAlphaCo 0.65; + +maxDeltaT 0.05; + +functions {}; + + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/system/decomposeParDict b/templates/stokes_wave/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..169c92b30a46bcf98537b731d5db3033d7a857ab --- /dev/null +++ b/templates/stokes_wave/base/system/decomposeParDict @@ -0,0 +1,27 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method hierarchical; + +coeffs +{ + n (2 1 1); +} + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/system/fvSchemes b/templates/stokes_wave/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..7f2a9656dd3d1ca1994533d1e09dfbc8b1875121 --- /dev/null +++ b/templates/stokes_wave/base/system/fvSchemes @@ -0,0 +1,53 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/system/fvSolution b/templates/stokes_wave/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..cad6bd5ee5a86340b5914746937961c156a473f6 --- /dev/null +++ b/templates/stokes_wave/base/system/fvSolution @@ -0,0 +1,77 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 1; + nAlphaSubCycles 3; + cAlpha 1; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0; + } + + p_rgh + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0.1; + } + + p_rghFinal + { + solver GAMG; + smoother DIC; + tolerance 1e-7; + relTol 0; + } + + U + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0.1; + } + + UFinal + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0; + } +} + +PIMPLE +{ + momentumPredictor no; + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/templates/stokes_wave/base/system/setFieldsDict b/templates/stokes_wave/base/system/setFieldsDict new file mode 100644 index 0000000000000000000000000000000000000000..786db9e82dd436e61011334e5424d292df7a4575 --- /dev/null +++ b/templates/stokes_wave/base/system/setFieldsDict @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha.water 0 +); + +regions +( + boxToCell + { + box (0 0 0) (30.0 1.0 0.4); + fieldValues + ( + volScalarFieldValue alpha.water 1 + ); + } +); + + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/0/U b/templates/templates/cnoidal_wave/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..ad3f3c7a2e16b4165bef1363293c54bd439d33e5 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/0/U @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + inlet + { + type waveVelocity; + value uniform (0 0 0); + } + + outlet + { + type waveVelocity; + value uniform (0 0 0); + } + + sides + { + type empty; + } + + ground + { + type fixedValue; + value uniform (0 0 0); + } + + top + { + type pressureInletOutletVelocity; + value uniform (0 0 0); + } +} + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/0/alpha.water b/templates/templates/cnoidal_wave/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..37e6ffb99eca06b00d675988e975db0161a74991 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/0/alpha.water @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type waveAlpha; + value uniform 0; + } + + outlet + { + type zeroGradient; + } + + ground + { + type zeroGradient; + } + + sides + { + type empty; + } + + top + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } +} + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/0/p_rgh b/templates/templates/cnoidal_wave/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..c124795bdca98817da9c7f591a4d2146f9c39bb0 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/0/p_rgh @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type fixedFluxPressure; + value uniform 0; + } + + outlet + { + type fixedFluxPressure; + value uniform 0; + } + + ground + { + type fixedFluxPressure; + value uniform 0; + } + + sides + { + type empty; + } + + top + { + type totalPressure; + p0 uniform 0; + } +} + + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/Allclean b/templates/templates/cnoidal_wave/base/Allclean new file mode 100644 index 0000000000000000000000000000000000000000..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/Allclean @@ -0,0 +1,7 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 + +#------------------------------------------------------------------------------ diff --git a/templates/templates/cnoidal_wave/base/Allrun b/templates/templates/cnoidal_wave/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..28bf991e627511713c3b915ac0d9998f068ce030 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/Allrun @@ -0,0 +1,15 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +restore0Dir + +runApplication blockMesh + +runApplication decomposePar + +runParallel setFields + +runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/templates/templates/cnoidal_wave/base/constant/g b/templates/templates/cnoidal_wave/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..54e4bdd5e7ffb6753e42b2740e3e0c3a04dbf7bf --- /dev/null +++ b/templates/templates/cnoidal_wave/base/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 0 -9.81 ); + + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/constant/transportProperties b/templates/templates/cnoidal_wave/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..0b410ab971be20391ffc2b3be8b4758454104a2b --- /dev/null +++ b/templates/templates/cnoidal_wave/base/constant/transportProperties @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1e-06; + rho 1000; +} + +air +{ + transportModel Newtonian; + nu 1.48e-05; + rho 1; +} + +sigma 0.07; + + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/constant/turbulenceProperties b/templates/templates/cnoidal_wave/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..5df08c0e4378ccacccd38e40532970422bb70c19 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/constant/turbulenceProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/constant/waveProperties b/templates/templates/cnoidal_wave/base/constant/waveProperties new file mode 100644 index 0000000000000000000000000000000000000000..b730f8c5b0957405f4dea74d26376fb91d6abab9 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/constant/waveProperties @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object waveProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inlet +{ + alpha alpha.water; + + waveModel cnoidal; + + nPaddle 1; + + waveHeight 0.1; + + waveAngle 0.0; + + rampTime 6.0; + + activeAbsorption yes; + + wavePeriod 4.0; +} + +outlet +{ + alpha alpha.water; + + waveModel shallowWaterAbsorption; + + nPaddle 1; +} + + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/system/blockMeshDict b/templates/templates/cnoidal_wave/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..ada433883dfc28178df84297e5e14ab04500b152 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/system/blockMeshDict @@ -0,0 +1,89 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +vertices +( + ( 0.0 0.0 0.0) + ( 30.0 0.0 0.0) + ( 30.0 0.04 0.0) + ( 0.0 0.04 0.0) + ( 0.0 0.0 0.7) + ( 30.0 0.0 0.7) + ( 30.0 0.04 0.7) + ( 0.0 0.04 0.7) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (750 1 70) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + outlet + { + type patch; + faces + ( + (1 5 6 2) + ); + } + ground + { + type wall; + faces + ( + (0 1 2 3) + ); + } + top + { + type patch; + faces + ( + (4 5 6 7) + ); + } + sides + { + type empty; + faces + ( + (0 1 5 4) + (3 2 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/system/controlDict b/templates/templates/cnoidal_wave/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..9920a18bbcf962950200e3f3579f5aff75f12fca --- /dev/null +++ b/templates/templates/cnoidal_wave/base/system/controlDict @@ -0,0 +1,148 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application interFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 50.0; + +deltaT 0.01; + +writeControl adjustableRunTime; + +writeInterval 0.033; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.65; + +maxAlphaCo 0.65; + +maxDeltaT 0.05; + + +functions +{ + line + { + type sets; + libs ("libsampling.so"); + enabled true; + writeControl writeTime; + writeInterval 1; + + interpolationScheme cellPoint; + setFormat raw; + + sets + ( + line1 + { + type uniform; + axis distance; + start ( 1.0 0.005 0.0 ); + end ( 1.0 0.005 0.8 ); + nPoints 1001; + } + line2 + { + type uniform; + axis distance; + start ( 2.0 0.005 0.0 ); + end ( 2.0 0.005 0.8 ); + nPoints 1001; + } + line3 + { + type uniform; + axis distance; + start ( 3.0 0.005 0.0 ); + end ( 3.0 0.005 0.8 ); + nPoints 1001; + } + line4 + { + type uniform; + axis distance; + start ( 5.0 0.005 0.0 ); + end ( 5.0 0.005 0.8 ); + nPoints 1001; + } + line5 + { + type uniform; + axis distance; + start ( 7.5 0.005 0.0 ); + end ( 7.5 0.005 0.8 ); + nPoints 1001; + } + + line6 + { + type uniform; + axis distance; + start ( 10.0 0.005 0.0 ); + end ( 10.0 0.005 0.8 ); + nPoints 1001; + } + line7 + { + type uniform; + axis distance; + start ( 12.0 0.005 0.0 ); + end ( 12.0 0.005 0.8 ); + nPoints 1001; + } + line8 + { + type uniform; + axis distance; + start ( 14.0 0.005 0.0 ); + end ( 14.0 0.005 0.8 ); + nPoints 1001; + } + ); + + fixedLocations false; + fields + ( + U alpha.water + ); + } +} + + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/system/decomposeParDict b/templates/templates/cnoidal_wave/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..169c92b30a46bcf98537b731d5db3033d7a857ab --- /dev/null +++ b/templates/templates/cnoidal_wave/base/system/decomposeParDict @@ -0,0 +1,27 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method hierarchical; + +coeffs +{ + n (2 1 1); +} + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/system/fvSchemes b/templates/templates/cnoidal_wave/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..7f2a9656dd3d1ca1994533d1e09dfbc8b1875121 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/system/fvSchemes @@ -0,0 +1,53 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/system/fvSolution b/templates/templates/cnoidal_wave/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..cad6bd5ee5a86340b5914746937961c156a473f6 --- /dev/null +++ b/templates/templates/cnoidal_wave/base/system/fvSolution @@ -0,0 +1,77 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 1; + nAlphaSubCycles 3; + cAlpha 1; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0; + } + + p_rgh + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0.1; + } + + p_rghFinal + { + solver GAMG; + smoother DIC; + tolerance 1e-7; + relTol 0; + } + + U + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0.1; + } + + UFinal + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0; + } +} + +PIMPLE +{ + momentumPredictor no; + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/templates/templates/cnoidal_wave/base/system/setFieldsDict b/templates/templates/cnoidal_wave/base/system/setFieldsDict new file mode 100644 index 0000000000000000000000000000000000000000..c156541f0ec08e843e32bb914895122a1f74e43f --- /dev/null +++ b/templates/templates/cnoidal_wave/base/system/setFieldsDict @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha.water 0 +); + +regions +( + boxToCell + { + box (0 0 0) (30.0 1.0 0.4); + fieldValues + ( + volScalarFieldValue alpha.water 1 + ); + } +); + + +// ************************************************************************* // diff --git a/templates/templates/dam_break/base/0/U b/templates/templates/dam_break/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..84e0b72764234252d8d8fd7f11bf25fa8a5e11d3 --- /dev/null +++ b/templates/templates/dam_break/base/0/U @@ -0,0 +1,41 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + leftWall + { + type noSlip; + } + + rightWall + { + type noSlip; + } + + lowerWall + { + type noSlip; + } + + upperWall + { + type pressureInletOutletVelocity; + phi phi; + value uniform (0 0 0); + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/templates/dam_break/base/0/alpha.water b/templates/templates/dam_break/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..bc790e2299995eb3ee186d46f21b8cc31c5df279 --- /dev/null +++ b/templates/templates/dam_break/base/0/alpha.water @@ -0,0 +1,42 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} + +dimensions [0 0 0 0 0 0 0]; + +// 初始值:全部为空气(alpha=0),由 gen_init_conditions.py 覆盖水柱区域 +internalField uniform 0; + +boundaryField +{ + leftWall + { + type zeroGradient; + } + + rightWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + upperWall + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/templates/dam_break/base/0/p_rgh b/templates/templates/dam_break/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..9b65febce8d50c9eb58bfec64e491bf5312a117a --- /dev/null +++ b/templates/templates/dam_break/base/0/p_rgh @@ -0,0 +1,45 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} + +dimensions [1 -1 -2 0 0 0 0]; + +// 注意: OpenFOAM 中 p_rgh = p/rho - g·x,此处为 kinematic pressure +internalField uniform 0; + +boundaryField +{ + leftWall + { + type fixedFluxPressure; + value uniform 0; + } + + rightWall + { + type fixedFluxPressure; + value uniform 0; + } + + lowerWall + { + type fixedFluxPressure; + value uniform 0; + } + + upperWall + { + type prghPressure; + p uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/templates/dam_break/base/Allrun b/templates/templates/dam_break/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..9f7e6e89423557ab20dbbacb661a3bea5d1a9382 --- /dev/null +++ b/templates/templates/dam_break/base/Allrun @@ -0,0 +1,44 @@ +#!/bin/bash +# dam_break Allrun 脚本 +# 用法: bash Allrun [n_procs] +# 注意: 初始场文件(0/alpha.water, 0/U)由 gen_init_conditions.py 预生成 + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 + +N_PROCS=${1:-1} + +echo "=== dam_break: blockMesh ===" +blockMesh > log.blockMesh 2>&1 +if [ $? -ne 0 ]; then + echo "ERROR: blockMesh failed, see log.blockMesh" + exit 1 +fi +echo " blockMesh 完成" + +if [ "$N_PROCS" -gt 1 ]; then + echo "=== dam_break: decomposePar (np=$N_PROCS) ===" + decomposePar -force > log.decomposePar 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: decomposePar failed, see log.decomposePar" + exit 1 + fi + + echo "=== dam_break: interFoam (parallel, np=$N_PROCS) ===" + mpirun -np "$N_PROCS" interFoam -parallel > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed, see log.interFoam" + exit 1 + fi + + echo "=== dam_break: reconstructPar ===" + reconstructPar > log.reconstructPar 2>&1 +else + echo "=== dam_break: interFoam (serial) ===" + interFoam > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed, see log.interFoam" + exit 1 + fi +fi + +echo "=== dam_break 完成 ===" diff --git a/templates/templates/dam_break/base/constant/g b/templates/templates/dam_break/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..ca544e1f16118931911092a402c88e003b7baf84 --- /dev/null +++ b/templates/templates/dam_break/base/constant/g @@ -0,0 +1,10 @@ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} + +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.81 0); diff --git a/templates/templates/dam_break/base/constant/transportProperties b/templates/templates/dam_break/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..0423705b6e38806eff4166ec0226482ccf195149 --- /dev/null +++ b/templates/templates/dam_break/base/constant/transportProperties @@ -0,0 +1,29 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} + +// 两相流物性参数 +// 参考: OpenFOAM Foundation. OpenFOAM v9 User Guide, 2021. +// 水和空气的标准物理参数 + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1.0e-06; // 运动粘度 [m^2/s] (20 deg C) + rho 1000; // 密度 [kg/m^3] +} + +air +{ + transportModel Newtonian; + nu 1.48e-05; // 运动粘度 [m^2/s] (20 deg C) + rho 1.225; // 密度 [kg/m^3] +} + +sigma 0.07; // 表面张力系数 [N/m] (水-空气, 20 deg C) diff --git a/templates/templates/dam_break/base/constant/turbulenceProperties b/templates/templates/dam_break/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..b75c4953045b92eadd94bcd8b270d129262ccc78 --- /dev/null +++ b/templates/templates/dam_break/base/constant/turbulenceProperties @@ -0,0 +1,9 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} + +simulationType laminar; diff --git a/templates/templates/dam_break/base/system/blockMeshDict b/templates/templates/dam_break/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..8eb82529fdd5a57762a1f5aba9004ecf537d3243 --- /dev/null +++ b/templates/templates/dam_break/base/system/blockMeshDict @@ -0,0 +1,89 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// 溃坝算例 — 简化矩形域(去除原始 damBreakLaminar 教程中的中间障碍物) +// 参考: OpenFOAM Foundation. OpenFOAM v9 User Guide, 2021. +// Section 2.1.1 "Breaking of a dam" +// 域尺寸: 0.584m x 0.584m (X x Y), Z 方向单层(2D, empty 边界) +// 网格: 128 x 128 (X x Y) + +scale 1; // 坐标单位: m + +// 四个顶点 (Z=0 和 Z=0.001 两层构成退化 3D 网格) +vertices +( + (0 0 0) // 0: 左下前 + (0.584 0 0) // 1: 右下前 + (0.584 0.584 0) // 2: 右上前 + (0 0.584 0) // 3: 左上前 + (0 0 0.001) // 4: 左下后 + (0.584 0 0.001) // 5: 右下后 + (0.584 0.584 0.001) // 6: 右上后 + (0 0.584 0.001) // 7: 左上后 +); + +// 单一六面体块,128x128x1 网格 +// vertex ordering: 右手定则,从 0-3 (Z=0) 到 4-7 (Z=0.001) +blocks +( + hex (0 1 2 3 4 5 6 7) (128 128 1) simpleGrading (1 1 1) +); + +edges +( +); + +// 边界面定义 +boundary +( + leftWall + { + type wall; + faces + ( + (0 4 7 3) // X=0 面(左侧壁) + ); + } + + rightWall + { + type wall; + faces + ( + (1 2 6 5) // X=0.584 面(右侧壁) + ); + } + + lowerWall + { + type wall; + faces + ( + (0 1 5 4) // Y=0 面(底部壁) + ); + } + + upperWall + { + type patch; + faces + ( + (3 7 6 2) // Y=0.584 面(顶部开口) + ); + } + + defaultFaces + { + type empty; + faces + ( + (0 3 2 1) // Z=0 前面 + (4 5 6 7) // Z=0.001 后面 + ); + } +); diff --git a/templates/templates/dam_break/base/system/controlDict b/templates/templates/dam_break/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..5a1f807b054165f77156612558ed24395a0756b9 --- /dev/null +++ b/templates/templates/dam_break/base/system/controlDict @@ -0,0 +1,36 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} + +application interFoam; + +startFrom startTime; +startTime 0; +stopAt endTime; +endTime 2.0; // 溃坝物理时长 [s] + +deltaT 0.002; // 初始时间步 [s](自适应调整) +writeControl adjustableRunTime; +writeInterval 0.08; // endTime/25 → 25 帧 + +purgeWrite 0; +writeFormat ascii; // ASCII 格式,便于后处理脚本读取 +writePrecision 8; +timeFormat general; +timePrecision 6; + +adjustTimeStep yes; // 自适应时间步 +maxCo 0.5; // Courant 数限制 +maxAlphaCo 0.5; // alpha Courant 数限制 +maxDeltaT 0.005; // 最大时间步上限 [s] + +functions {}; + +OptimisationSwitches +{ + trapFpe no; // 禁用浮点异常捕获(避免数值噪声导致崩溃) +} diff --git a/templates/templates/dam_break/base/system/decomposeParDict b/templates/templates/dam_break/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..40aa3873e13ef5298c8e597732b6e637299827f8 --- /dev/null +++ b/templates/templates/dam_break/base/system/decomposeParDict @@ -0,0 +1,21 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +// 并行分解设置 +// 2D case: Z 方向仅 1 个分区(empty 边界限制) +// numberOfSubdomains 由 run_case.sh 传入,此处为默认值 +numberOfSubdomains 4; + +method hierarchical; + +hierarchicalCoeffs +{ + n (2 2 1); // X: 2分区, Y: 2分区, Z: 1分区 + delta 0.001; + order xyz; +} diff --git a/templates/templates/dam_break/base/system/fvSchemes b/templates/templates/dam_break/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..337672bb49af8489fb349098762b0914380b9202 --- /dev/null +++ b/templates/templates/dam_break/base/system/fvSchemes @@ -0,0 +1,53 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + // 速度对流项:线性迎风(一阶稳定) + div(rhoPhi,U) Gauss linearUpwind grad(U); + + // alpha 方程:van Leer 界面压缩格式 + // gcnl: 人工压缩通量,保持界面锐利 + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss interfaceCompression vanLeer; + + // ESI v1906 粘性应力项 + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear corrected; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +wallDist +{ + method meshWave; +} diff --git a/templates/templates/dam_break/base/system/fvSolution b/templates/templates/dam_break/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..1312e19878acd8c7d78eff92fab8453ba40cd542 --- /dev/null +++ b/templates/templates/dam_break/base/system/fvSolution @@ -0,0 +1,86 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 3; + nAlphaSubCycles 2; + cAlpha 1; + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + minIter 1; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-8; + relTol 0; + minIter 1; + } + + "pcorrFinal.*" + { + $pcorr; + relTol 0; + } + + "p_rgh.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-8; + relTol 0.001; + minIter 1; + } + + "p_rghFinal.*" + { + $p_rgh; + relTol 0; + } + + "U.*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + minIter 1; + } +} + +MULES +{ + nAlphaCorr 3; + nAlphaSubCycles 2; + cAlpha 1; +} + +PIMPLE +{ + nOuterCorrectors 1; + nCorrectors 3; + nNonOrthogonalCorrectors 0; + MULESCorr yes; + nLimiterIter 5; + momentumPredictor no; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + fields {}; + equations {}; +} diff --git a/templates/templates/droplet_impact/base/0/U b/templates/templates/droplet_impact/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..2cc60ed9ccbc0effc0f162e35da7f49740285416 --- /dev/null +++ b/templates/templates/droplet_impact/base/0/U @@ -0,0 +1,46 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} + +dimensions [0 1 -1 0 0 0 0]; + +// 初始值:全零;液滴区域由 gen_init_conditions.py 设置为 (0, -1.5, 0) +internalField uniform (0 0 0); + +boundaryField +{ + bottomWall + { + type noSlip; // 撞击壁面:无滑移 + } + + topPatch + { + type pressureInletOutletVelocity; + phi phi; + value uniform (0 0 0); + } + + leftWall + { + type pressureInletOutletVelocity; + phi phi; + value uniform (0 0 0); + } + + rightWall + { + type pressureInletOutletVelocity; + phi phi; + value uniform (0 0 0); + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/templates/droplet_impact/base/0/alpha.water b/templates/templates/droplet_impact/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..f041796bd4425b61c69b0b7d0b07e2b97dadceda --- /dev/null +++ b/templates/templates/droplet_impact/base/0/alpha.water @@ -0,0 +1,50 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} + +dimensions [0 0 0 0 0 0 0]; + +// 初始值:全部为空气(alpha=0) +// 液滴半球区域由 gen_init_conditions.py 设置为 1 +internalField uniform 0; + +boundaryField +{ + bottomWall + { + type constantAlphaContactAngle; + theta0 75; // Pasandideh-Fard (1996): stainless steel, theta_e ~ 70-80 deg + limit gradient; + value uniform 0; + } + + topPatch + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + leftWall + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + rightWall + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/templates/droplet_impact/base/0/p_rgh b/templates/templates/droplet_impact/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..22e88457644f991889f50d6b412eb1313475cc35 --- /dev/null +++ b/templates/templates/droplet_impact/base/0/p_rgh @@ -0,0 +1,46 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + bottomWall + { + type fixedFluxPressure; + value uniform 0; + } + + topPatch + { + type prghPressure; + p uniform 0; + value uniform 0; + } + + leftWall + { + type prghPressure; + p uniform 0; + value uniform 0; + } + + rightWall + { + type prghPressure; + p uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/templates/droplet_impact/base/Allrun b/templates/templates/droplet_impact/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..f56bcc37b13b0cf3586604e404690a0e8a5f8435 --- /dev/null +++ b/templates/templates/droplet_impact/base/Allrun @@ -0,0 +1,42 @@ +#!/bin/bash +# droplet_impact Allrun 脚本 +# 参考: Pasandideh-Fard, M. et al. (1998). Phys. Fluids, 10(3), 631-638. + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 + +N_PROCS=${1:-1} + +echo "=== droplet_impact: blockMesh ===" +blockMesh > log.blockMesh 2>&1 +if [ $? -ne 0 ]; then + echo "ERROR: blockMesh failed, see log.blockMesh" + exit 1 +fi + +if [ "$N_PROCS" -gt 1 ]; then + echo "=== droplet_impact: decomposePar (np=$N_PROCS) ===" + decomposePar -force > log.decomposePar 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: decomposePar failed" + exit 1 + fi + + echo "=== droplet_impact: interFoam (parallel, np=$N_PROCS) ===" + mpirun -np "$N_PROCS" interFoam -parallel > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed" + exit 1 + fi + + echo "=== droplet_impact: reconstructPar ===" + reconstructPar > log.reconstructPar 2>&1 +else + echo "=== droplet_impact: interFoam (serial) ===" + interFoam > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed" + exit 1 + fi +fi + +echo "=== droplet_impact 完成 ===" diff --git a/templates/templates/droplet_impact/base/constant/g b/templates/templates/droplet_impact/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..ca544e1f16118931911092a402c88e003b7baf84 --- /dev/null +++ b/templates/templates/droplet_impact/base/constant/g @@ -0,0 +1,10 @@ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} + +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.81 0); diff --git a/templates/templates/droplet_impact/base/constant/transportProperties b/templates/templates/droplet_impact/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..1403078b1b3514592c8874d39805e528240fec1b --- /dev/null +++ b/templates/templates/droplet_impact/base/constant/transportProperties @@ -0,0 +1,33 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} + +// 液滴撞击算例物性参数 +// 参考: Pasandideh-Fard, M. et al. (1996). "Capillary effects during +// droplet impact on a solid surface." Phys. Fluids, 8(3), 650-659. +// 水滴撞击固体壁面,We≈69, Re≈3360 + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1.005e-06; // 运动粘度 [m^2/s] (μ=1.003e-3 Pa·s / ρ=998 kg/m^3) + rho 998; // 密度 [kg/m^3] (20 deg C) +} + +air +{ + transportModel Newtonian; + nu 1.455e-05; // 运动粘度 [m^2/s] (μ=1.78e-5 Pa·s / ρ=1.225 kg/m^3) + rho 1.225; // 密度 [kg/m^3] +} + +sigma 0.0728; // 表面张力系数 [N/m] (水-空气, 20 deg C) +// Pasandideh-Fard Table I: σ = 0.0728 N/m +// 注: Foundation 版 OpenFOAM 不需要 wallAdhesion 关键字 +// interfaceProperties 自动检测 alphaContactAngle BC 并应用接触角修正 diff --git a/templates/templates/droplet_impact/base/constant/turbulenceProperties b/templates/templates/droplet_impact/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..b75c4953045b92eadd94bcd8b270d129262ccc78 --- /dev/null +++ b/templates/templates/droplet_impact/base/constant/turbulenceProperties @@ -0,0 +1,9 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} + +simulationType laminar; diff --git a/templates/templates/droplet_impact/base/system/blockMeshDict b/templates/templates/droplet_impact/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..e3358d013fe778c63c0bbf4e81c8340837278cbd --- /dev/null +++ b/templates/templates/droplet_impact/base/system/blockMeshDict @@ -0,0 +1,73 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// 液滴撞击算例 +// 参考: Pasandideh-Fard, M. et al. (1996). "Capillary effects during +// droplet impact on a solid surface." Phys. Fluids, 8(3), 650-659. +// 域尺寸: 0.05m x 0.05m (~22D, D=2.25mm, 足够铺展-回缩) +// 网格: 256 x 256 (~11 cells/D) + +scale 1; + +vertices +( + (0 0 0) // 0 + (0.05 0 0) // 1 + (0.05 0.05 0) // 2 + (0 0.05 0) // 3 + (0 0 0.001) // 4 + (0.05 0 0.001) // 5 + (0.05 0.05 0.001) // 6 + (0 0.05 0.001) // 7 +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (256 256 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + bottomWall + { + type wall; + faces ( (0 1 5 4) ); // Y=0 面(撞击壁面) + } + + topPatch + { + type patch; + faces ( (3 7 6 2) ); // Y=0.05 面(顶部开放边界) + } + + leftWall + { + type patch; + faces ( (0 4 7 3) ); // X=0 面(侧面开放边界) + } + + rightWall + { + type patch; + faces ( (1 2 6 5) ); // X=0.05 面(侧面开放边界) + } + + defaultFaces + { + type empty; + faces + ( + (0 3 2 1) // Z=0 + (4 5 6 7) // Z=0.001 + ); + } +); diff --git a/templates/templates/droplet_impact/base/system/controlDict b/templates/templates/droplet_impact/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..8226ec55be3e0f0680a7f37fcf1c8ecfeef0514e --- /dev/null +++ b/templates/templates/droplet_impact/base/system/controlDict @@ -0,0 +1,31 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} + +application interFoam; + +startFrom startTime; +startTime 0; +stopAt endTime; +endTime 0.2; // 液滴撞击物理时长 [s](铺展+初始回弹,原 0.5s 过长) + +deltaT 5e-06; // 初始时间步 [s](撞击过程需小时间步) +writeControl adjustableRunTime; +writeInterval 0.008; // endTime/25 → 25 帧 + +purgeWrite 0; +writeFormat ascii; // ASCII 格式,便于后处理脚本读取 +writePrecision 8; +timeFormat general; +timePrecision 6; + +adjustTimeStep yes; +maxCo 0.5; +maxAlphaCo 0.5; +maxDeltaT 1e-04; // 最大时间步上限 + +functions {}; diff --git a/templates/templates/droplet_impact/base/system/decomposeParDict b/templates/templates/droplet_impact/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..97fe7fa7a23d65c50d647ee2e7ced029cbf9f5d4 --- /dev/null +++ b/templates/templates/droplet_impact/base/system/decomposeParDict @@ -0,0 +1,18 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +numberOfSubdomains 4; + +method hierarchical; + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} diff --git a/templates/templates/droplet_impact/base/system/fvSchemes b/templates/templates/droplet_impact/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..9d9f9ed80ea021a61a84007d3754980f3da5f5da --- /dev/null +++ b/templates/templates/droplet_impact/base/system/fvSchemes @@ -0,0 +1,47 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss interfaceCompression vanLeer; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear corrected; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +wallDist +{ + method meshWave; +} diff --git a/templates/templates/droplet_impact/base/system/fvSolution b/templates/templates/droplet_impact/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..d7fb516a6a4c93441213266abe679ae2e906b911 --- /dev/null +++ b/templates/templates/droplet_impact/base/system/fvSolution @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 3; + nAlphaSubCycles 3; + cAlpha 1; + + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-5; + relTol 0; + } + + "pcorrFinal.*" + { + $pcorr; + relTol 0; + } + + "p_rgh.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-08; + relTol 0.01; + } + + "p_rghFinal.*" + { + $p_rgh; + relTol 0; + } + + "U.*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-06; + relTol 0; + } +} + +MULES +{ + nAlphaCorr 3; + nAlphaSubCycles 3; + cAlpha 1; +} + +PIMPLE +{ + nOuterCorrectors 1; + nCorrectors 3; + nNonOrthogonalCorrectors 0; + MULESCorr yes; + nLimiterIter 5; + momentumPredictor no; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + equations + { + ".*" 1; + } +} diff --git a/templates/templates/rising_bubble/base/0/U b/templates/templates/rising_bubble/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..ca48a6ac3545842eab70ec132439076cd6130023 --- /dev/null +++ b/templates/templates/rising_bubble/base/0/U @@ -0,0 +1,39 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + leftWall + { + type slip; + } + + rightWall + { + type slip; + } + + lowerWall + { + type slip; // Hysing benchmark: 所有壁面均为自由滑移(对称面) + } + + upperWall + { + type slip; // Hysing benchmark: 所有壁面均为自由滑移(对称面) + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/templates/rising_bubble/base/0/alpha.water b/templates/templates/rising_bubble/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..68ec1b8b9e79ab2ecb87dfac5e08001eb1c790ab --- /dev/null +++ b/templates/templates/rising_bubble/base/0/alpha.water @@ -0,0 +1,40 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} + +dimensions [0 0 0 0 0 0 0]; + +// 初始值:全部为水(alpha=1),气泡区域由 gen_init_conditions.py 设置为 0 +internalField uniform 1; + +boundaryField +{ + leftWall + { + type zeroGradient; + } + + rightWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + upperWall + { + type zeroGradient; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/templates/rising_bubble/base/0/p_rgh b/templates/templates/rising_bubble/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..65f5b4faa9e0b90d3b5a5f3fbe009d748c63882e --- /dev/null +++ b/templates/templates/rising_bubble/base/0/p_rgh @@ -0,0 +1,43 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + leftWall + { + type fixedFluxPressure; + value uniform 0; + } + + rightWall + { + type fixedFluxPressure; + value uniform 0; + } + + lowerWall + { + type fixedFluxPressure; + value uniform 0; + } + + upperWall + { + type fixedFluxPressure; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} diff --git a/templates/templates/rising_bubble/base/Allrun b/templates/templates/rising_bubble/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..798ea9ce6c9ec2f5dbdaa9fb028ea035af0f2374 --- /dev/null +++ b/templates/templates/rising_bubble/base/Allrun @@ -0,0 +1,42 @@ +#!/bin/bash +# rising_bubble Allrun 脚本 +# 参考: Hysing, S. et al. (2009), Int. J. Numer. Meth. Fluids, 60(11), 1259-1288. + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 + +N_PROCS=${1:-1} + +echo "=== rising_bubble: blockMesh ===" +blockMesh > log.blockMesh 2>&1 +if [ $? -ne 0 ]; then + echo "ERROR: blockMesh failed, see log.blockMesh" + exit 1 +fi + +if [ "$N_PROCS" -gt 1 ]; then + echo "=== rising_bubble: decomposePar (np=$N_PROCS) ===" + decomposePar -force > log.decomposePar 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: decomposePar failed" + exit 1 + fi + + echo "=== rising_bubble: interFoam (parallel, np=$N_PROCS) ===" + mpirun -np "$N_PROCS" interFoam -parallel > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed" + exit 1 + fi + + echo "=== rising_bubble: reconstructPar ===" + reconstructPar > log.reconstructPar 2>&1 +else + echo "=== rising_bubble: interFoam (serial) ===" + interFoam > log.interFoam 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: interFoam failed" + exit 1 + fi +fi + +echo "=== rising_bubble 完成 ===" diff --git a/templates/templates/rising_bubble/base/constant/g b/templates/templates/rising_bubble/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..cab240c7b55446cb5b9a031e548f1c8f0aefc713 --- /dev/null +++ b/templates/templates/rising_bubble/base/constant/g @@ -0,0 +1,12 @@ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} + +dimensions [0 1 -2 0 0 0 0]; +value (0 -0.98 0); +// Hysing 无量纲 g*=-0.98; 有量纲值 g = g* × U_ref^2 / L_ref +// = -0.98 × 1^2 / 1 = -0.98 m/s^2 diff --git a/templates/templates/rising_bubble/base/constant/transportProperties b/templates/templates/rising_bubble/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..c9976bfc1e0beca3914c852f653fdc6a4e4e1dcc --- /dev/null +++ b/templates/templates/rising_bubble/base/constant/transportProperties @@ -0,0 +1,38 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} + +// 浮力气泡算例物性参数 +// 参考: Hysing, S. et al. (2009). "Quantitative benchmark computations +// of two-dimensional bubble dynamics." Int. J. Numer. Meth. Fluids, +// 60(11), 1259-1288. +// +// Hysing Case 1 (低变形): 密度比 10:1, 粘度比 10:1 +// 无量纲参数: Re=35, Eo=10 +// Mo = g·μ₁⁴·Δρ/(ρ₁·σ³) ≈ 0.60(Clift 定义;不同 Mo 定义数值差异可达 15x) +// Eo 定义: Eo = ρ1 * g * D² / σ (Hysing 原文用 ρ1 而非 Δρ) +// 有量纲参数基于 L_ref=1m, U_ref=1m/s 换算 + +phases (water air); + +water +{ + transportModel Newtonian; + nu 0.01; // 运动粘度 [m^2/s] (μ=10 Pa·s, Hysing Case 1) + rho 1000; // 密度 [kg/m^3] +} + +air +{ + transportModel Newtonian; + nu 0.01; // 运动粘度 [m^2/s] (μ=1 Pa·s, ρ=100 kg/m³) + rho 100; // 密度 [kg/m^3] (密度比 10:1) +} + +sigma 24.5; // 表面张力系数 [N/m] +// Hysing Case 1: Eo = ρ1 × g × D² / σ = 10 +// σ = ρ1 × g × D² / Eo = 1000 × 0.98 × 0.25 / 10 = 24.5 N/m (D=2R=0.5, D²=0.25) diff --git a/templates/templates/rising_bubble/base/constant/turbulenceProperties b/templates/templates/rising_bubble/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..b75c4953045b92eadd94bcd8b270d129262ccc78 --- /dev/null +++ b/templates/templates/rising_bubble/base/constant/turbulenceProperties @@ -0,0 +1,9 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} + +simulationType laminar; diff --git a/templates/templates/rising_bubble/base/system/blockMeshDict b/templates/templates/rising_bubble/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..53129bb605e6e9285cb0719f5ad786ddfc39dec9 --- /dev/null +++ b/templates/templates/rising_bubble/base/system/blockMeshDict @@ -0,0 +1,74 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// 浮力气泡算例 — Hysing et al. (2009) Case 1 +// 参考: Hysing, S. et al. (2009). "Quantitative benchmark computations +// of two-dimensional bubble dynamics." Int. J. Numer. Meth. Fluids, +// 60(11), 1259-1288. +// 域尺寸: 1m x 2m (X x Y), Z 方向单层(2D, empty 边界) +// 网格: 128 x 256 + +scale 1; + +vertices +( + (0 0 0) // 0 + (1 0 0) // 1 + (1 2 0) // 2 + (0 2 0) // 3 + (0 0 0.001) // 4 + (1 0 0.001) // 5 + (1 2 0.001) // 6 + (0 2 0.001) // 7 +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (128 256 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + leftWall + { + type wall; + faces ( (0 4 7 3) ); + } + + rightWall + { + type wall; + faces ( (1 2 6 5) ); + } + + lowerWall + { + type wall; + faces ( (0 1 5 4) ); + } + + upperWall + { + type wall; + faces ( (3 7 6 2) ); + } + + defaultFaces + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ); + } +); diff --git a/templates/templates/rising_bubble/base/system/controlDict b/templates/templates/rising_bubble/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..6420ff91ead9219f48d1c75cafd26b9f84c048c3 --- /dev/null +++ b/templates/templates/rising_bubble/base/system/controlDict @@ -0,0 +1,31 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} + +application interFoam; + +startFrom startTime; +startTime 0; +stopAt endTime; +endTime 3.0; // 气泡上升物理时长 [s](足够达到 terminal velocity) + +deltaT 0.002; // 初始时间步 [s](高粘度,需更小时间步) +writeControl adjustableRunTime; +writeInterval 0.12; // endTime/25 → 25 帧 + +purgeWrite 0; +writeFormat ascii; // ASCII 格式,便于后处理脚本读取 +writePrecision 8; +timeFormat general; +timePrecision 6; + +adjustTimeStep yes; +maxCo 0.5; +maxAlphaCo 0.5; +maxDeltaT 0.002; + +functions {}; diff --git a/templates/templates/rising_bubble/base/system/decomposeParDict b/templates/templates/rising_bubble/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..97fe7fa7a23d65c50d647ee2e7ced029cbf9f5d4 --- /dev/null +++ b/templates/templates/rising_bubble/base/system/decomposeParDict @@ -0,0 +1,18 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +numberOfSubdomains 4; + +method hierarchical; + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} diff --git a/templates/templates/rising_bubble/base/system/fvSchemes b/templates/templates/rising_bubble/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..9d9f9ed80ea021a61a84007d3754980f3da5f5da --- /dev/null +++ b/templates/templates/rising_bubble/base/system/fvSchemes @@ -0,0 +1,47 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss interfaceCompression vanLeer; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear corrected; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +wallDist +{ + method meshWave; +} diff --git a/templates/templates/rising_bubble/base/system/fvSolution b/templates/templates/rising_bubble/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..3183b94b1818ed729e220c7fb9e00c1a09b80a99 --- /dev/null +++ b/templates/templates/rising_bubble/base/system/fvSolution @@ -0,0 +1,79 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 2; + nAlphaSubCycles 1; + cAlpha 1; + + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-5; + relTol 0; + } + + "pcorrFinal.*" + { + $pcorr; + relTol 0; + } + + "p_rgh.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-07; + relTol 0.05; + } + + "p_rghFinal.*" + { + $p_rgh; + relTol 0; + } + + "U.*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-06; + relTol 0; + } +} + +PIMPLE +{ + nOuterCorrectors 1; + nCorrectors 3; + nNonOrthogonalCorrectors 0; + pRefCell 0; + pRefValue 0; + + MULESCorr yes; + nLimiterIter 5; + momentumPredictor no; +} + +relaxationFactors +{ + equations + { + ".*" 1; + } +} diff --git a/templates/templates/stokes_wave/base/0/U b/templates/templates/stokes_wave/base/0/U new file mode 100644 index 0000000000000000000000000000000000000000..dd0c8bd3e6c260c47dddc17f918b84bbf7f8aaee --- /dev/null +++ b/templates/templates/stokes_wave/base/0/U @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + inlet + { + type waveVelocity; + value uniform (0 0 0); + } + + outlet + { + type waveVelocity; + value uniform (0 0 0); + } + + sides + { + type empty; + } + + ground + { + type fixedValue; + value uniform (0 0 0); + } + + top + { + type pressureInletOutletVelocity; + value uniform (0 0 0); + } +} + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/0/alpha.water b/templates/templates/stokes_wave/base/0/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..37e6ffb99eca06b00d675988e975db0161a74991 --- /dev/null +++ b/templates/templates/stokes_wave/base/0/alpha.water @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type waveAlpha; + value uniform 0; + } + + outlet + { + type zeroGradient; + } + + ground + { + type zeroGradient; + } + + sides + { + type empty; + } + + top + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } +} + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/0/p_rgh b/templates/templates/stokes_wave/base/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..c124795bdca98817da9c7f591a4d2146f9c39bb0 --- /dev/null +++ b/templates/templates/stokes_wave/base/0/p_rgh @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type fixedFluxPressure; + value uniform 0; + } + + outlet + { + type fixedFluxPressure; + value uniform 0; + } + + ground + { + type fixedFluxPressure; + value uniform 0; + } + + sides + { + type empty; + } + + top + { + type totalPressure; + p0 uniform 0; + } +} + + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/Allclean b/templates/templates/stokes_wave/base/Allclean new file mode 100644 index 0000000000000000000000000000000000000000..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 --- /dev/null +++ b/templates/templates/stokes_wave/base/Allclean @@ -0,0 +1,7 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase0 + +#------------------------------------------------------------------------------ diff --git a/templates/templates/stokes_wave/base/Allrun b/templates/templates/stokes_wave/base/Allrun new file mode 100644 index 0000000000000000000000000000000000000000..28bf991e627511713c3b915ac0d9998f068ce030 --- /dev/null +++ b/templates/templates/stokes_wave/base/Allrun @@ -0,0 +1,15 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +restore0Dir + +runApplication blockMesh + +runApplication decomposePar + +runParallel setFields + +runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/templates/templates/stokes_wave/base/constant/g b/templates/templates/stokes_wave/base/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..2a0e091fcfc37ab04dd809daf9ea30e30f068203 --- /dev/null +++ b/templates/templates/stokes_wave/base/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 0 -9.81 ); + + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/constant/transportProperties b/templates/templates/stokes_wave/base/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..0b410ab971be20391ffc2b3be8b4758454104a2b --- /dev/null +++ b/templates/templates/stokes_wave/base/constant/transportProperties @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1e-06; + rho 1000; +} + +air +{ + transportModel Newtonian; + nu 1.48e-05; + rho 1; +} + +sigma 0.07; + + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/constant/turbulenceProperties b/templates/templates/stokes_wave/base/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..04190a72d650e35ad10e2e5d702a70839cf7e8ad --- /dev/null +++ b/templates/templates/stokes_wave/base/constant/turbulenceProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/constant/waveProperties b/templates/templates/stokes_wave/base/constant/waveProperties new file mode 100644 index 0000000000000000000000000000000000000000..67f0b47221be1dd26cb46db36a786d3b171c7805 --- /dev/null +++ b/templates/templates/stokes_wave/base/constant/waveProperties @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object waveProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inlet +{ + alpha alpha.water; + + waveModel StokesV; + + nPaddle 1; + + waveHeight 0.1; + + waveAngle 0.0; + + rampTime 4.0; + + activeAbsorption yes; + + wavePeriod 2.0; +} + +outlet +{ + alpha alpha.water; + + waveModel shallowWaterAbsorption; + + nPaddle 1; +} + + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/system/blockMeshDict b/templates/templates/stokes_wave/base/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..a4236b3a9f74e61a442124443ca5d9d21df2321a --- /dev/null +++ b/templates/templates/stokes_wave/base/system/blockMeshDict @@ -0,0 +1,89 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +vertices +( + ( 0.0 0.0 0.0) + ( 30.0 0.0 0.0) + ( 30.0 0.04 0.0) + ( 0.0 0.04 0.0) + ( 0.0 0.0 0.7) + ( 30.0 0.0 0.7) + ( 30.0 0.04 0.7) + ( 0.0 0.04 0.7) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (750 1 70) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + outlet + { + type patch; + faces + ( + (1 5 6 2) + ); + } + ground + { + type wall; + faces + ( + (0 1 2 3) + ); + } + top + { + type patch; + faces + ( + (4 5 6 7) + ); + } + sides + { + type empty; + faces + ( + (0 1 5 4) + (3 2 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/system/controlDict b/templates/templates/stokes_wave/base/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..eaa083566886fa66a7c28779d7bcacde43871451 --- /dev/null +++ b/templates/templates/stokes_wave/base/system/controlDict @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application interFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 20.0; + +deltaT 0.01; + +writeControl adjustableRunTime; + +writeInterval 0.8; // endTime/25 → 25 帧 + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep on; + +maxCo 0.65; + +maxAlphaCo 0.65; + +maxDeltaT 0.05; + +functions {}; + + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/system/decomposeParDict b/templates/templates/stokes_wave/base/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..169c92b30a46bcf98537b731d5db3033d7a857ab --- /dev/null +++ b/templates/templates/stokes_wave/base/system/decomposeParDict @@ -0,0 +1,27 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method hierarchical; + +coeffs +{ + n (2 1 1); +} + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/system/fvSchemes b/templates/templates/stokes_wave/base/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..7f2a9656dd3d1ca1994533d1e09dfbc8b1875121 --- /dev/null +++ b/templates/templates/stokes_wave/base/system/fvSchemes @@ -0,0 +1,53 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/system/fvSolution b/templates/templates/stokes_wave/base/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..cad6bd5ee5a86340b5914746937961c156a473f6 --- /dev/null +++ b/templates/templates/stokes_wave/base/system/fvSolution @@ -0,0 +1,77 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 1; + nAlphaSubCycles 3; + cAlpha 1; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0; + } + + p_rgh + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0.1; + } + + p_rghFinal + { + solver GAMG; + smoother DIC; + tolerance 1e-7; + relTol 0; + } + + U + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0.1; + } + + UFinal + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0; + } +} + +PIMPLE +{ + momentumPredictor no; + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/templates/templates/stokes_wave/base/system/setFieldsDict b/templates/templates/stokes_wave/base/system/setFieldsDict new file mode 100644 index 0000000000000000000000000000000000000000..786db9e82dd436e61011334e5424d292df7a4575 --- /dev/null +++ b/templates/templates/stokes_wave/base/system/setFieldsDict @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1906 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha.water 0 +); + +regions +( + boxToCell + { + box (0 0 0) (30.0 1.0 0.4); + fieldValues + ( + volScalarFieldValue alpha.water 1 + ); + } +); + + +// ************************************************************************* //