Upload folder using huggingface_hub (part 9)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- raw/dam_break/t09/0/p_rghAdded+45
- raw/dam_break/t09/AllrunAdded+44
- raw/dam_break/t09/constant/gAdded+10
- raw/dam_break/t09/constant/polyMesh/boundaryAdded+56
- raw/dam_break/t09/constant/polyMesh/facesAdded
- raw/dam_break/t09/constant/polyMesh/neighbourAdded
- raw/dam_break/t09/constant/polyMesh/ownerAdded
- raw/dam_break/t09/constant/polyMesh/pointsAdded
- raw/dam_break/t09/constant/transportPropertiesAdded+29
- raw/dam_break/t09/constant/turbulencePropertiesAdded+9
- raw/dam_break/t09/system/blockMeshDictAdded+89
- raw/dam_break/t09/system/controlDictAdded+36
- raw/dam_break/t09/system/decomposeParDictAdded+21
- raw/dam_break/t09/system/fvSchemesAdded+53
- raw/dam_break/t09/system/fvSolutionAdded+86
- raw/dam_break/t10/0/UAdded
- raw/dam_break/t10/0/U.templateAdded+41
- raw/dam_break/t10/0/alpha.waterAdded
- raw/dam_break/t10/0/alpha.water.templateAdded+42
- raw/dam_break/t10/0/p_rghAdded+45
- raw/dam_break/t10/AllrunAdded+44
- raw/dam_break/t10/constant/gAdded+10
- raw/dam_break/t10/constant/polyMesh/boundaryAdded+56
- raw/dam_break/t10/constant/polyMesh/facesAdded
- raw/dam_break/t10/constant/polyMesh/neighbourAdded
- raw/dam_break/t10/constant/polyMesh/ownerAdded
- raw/dam_break/t10/constant/polyMesh/pointsAdded
- raw/dam_break/t10/constant/transportPropertiesAdded+29
- raw/dam_break/t10/constant/turbulencePropertiesAdded+9
- raw/dam_break/t10/system/blockMeshDictAdded+89
- raw/dam_break/t10/system/controlDictAdded+36
- raw/dam_break/t10/system/decomposeParDictAdded+21
- raw/dam_break/t10/system/fvSchemesAdded+53
- raw/dam_break/t10/system/fvSolutionAdded+86
- raw/dam_break/t11/0/UAdded
- raw/dam_break/t11/0/U.templateAdded+41
- raw/dam_break/t11/0/alpha.waterAdded
- raw/dam_break/t11/0/alpha.water.templateAdded+42
- raw/dam_break/t11/0/p_rghAdded+45
- raw/dam_break/t11/AllrunAdded+44
- raw/dam_break/t11/constant/gAdded+10
- raw/dam_break/t11/constant/polyMesh/boundaryAdded+56
- raw/dam_break/t11/constant/polyMesh/facesAdded
- raw/dam_break/t11/constant/polyMesh/neighbourAdded
- raw/dam_break/t11/constant/polyMesh/ownerAdded
- raw/dam_break/t11/constant/polyMesh/pointsAdded
- raw/dam_break/t11/constant/transportPropertiesAdded+29
- raw/dam_break/t11/constant/turbulencePropertiesAdded+9
- raw/dam_break/t11/system/blockMeshDictAdded+89
- raw/dam_break/t11/system/controlDictAdded+36
123456789101112131415161718192021222324252627282930313233343536373839404142434445FoamFile{ 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 pressureinternalField 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; }}1234567891011121314151617181920212223242526272829303132333435363738394041424344#!/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>&1if [ $? -ne 0 ]; then echo "ERROR: blockMesh failed, see log.blockMesh" exit 1fiecho " 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>&1else echo "=== dam_break: interFoam (serial) ===" interFoam > log.interFoam 2>&1 if [ $? -ne 0 ]; then echo "ERROR: interFoam failed, see log.interFoam" exit 1 fifi
echo "=== dam_break 完成 ==="12345678910FoamFile{ version 2.0; format ascii; class uniformDimensionedVectorField; object g;}
dimensions [0 1 -2 0 0 0 0];value (0 -9.81 0);1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556/*--------------------------------*- C++ -*----------------------------------*\| ========= | || \\ / F ield | OpenFOAM: The Open Source CFD Toolbox || \\ / O peration | Version: || \\ / A nd | Web: www.OpenFOAM.com || \\/ M anipulation | |\*---------------------------------------------------------------------------*/FoamFile{ version 2.0; format ascii; class polyBoundaryMesh; location "constant/polyMesh"; object boundary;}// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
5( leftWall { type wall; inGroups 1(wall); nFaces 128; startFace 32512; } rightWall { type wall; inGroups 1(wall); nFaces 128; startFace 32640; } lowerWall { type wall; inGroups 1(wall); nFaces 128; startFace 32768; } upperWall { type patch; nFaces 128; startFace 32896; } defaultFaces { type empty; inGroups 1(empty); nFaces 32768; startFace 33024; })
// ************************************************************************* //1234567891011121314151617181920212223242526272829FoamFile{ 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)123456789FoamFile{ version 2.0; format ascii; class dictionary; object turbulenceProperties;}
simulationType laminar;1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889FoamFile{ 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 后面 ); });123456789101112131415161718192021222324252627282930313233343536FoamFile{ 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; // 每 0.01s 保存一帧 → 200 帧(统一 10ms 间隔)
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; // 禁用浮点异常捕获(避免数值噪声导致崩溃)}123456789101112131415161718192021FoamFile{ version 2.0; format ascii; class dictionary; object decomposeParDict;}
// 并行分解设置// 2D case: Z 方向仅 1 个分区(empty 边界限制)// numberOfSubdomains 16由 run_case.sh 传入,此处为默认值numberOfSubdomains 16;
method hierarchical;
hierarchicalCoeffs{ n (4 4 1); // X: 2分区, Y: 2分区, Z: 1分区 delta 0.001; order xyz;}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253FoamFile{ 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;}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586FoamFile{ 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 {};}1234567891011121314151617181920212223242526272829303132333435363738394041FoamFile{ 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; }}123456789101112131415161718192021222324252627282930313233343536373839404142FoamFile{ 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; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445FoamFile{ 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 pressureinternalField 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; }}1234567891011121314151617181920212223242526272829303132333435363738394041424344#!/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>&1if [ $? -ne 0 ]; then echo "ERROR: blockMesh failed, see log.blockMesh" exit 1fiecho " 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>&1else echo "=== dam_break: interFoam (serial) ===" interFoam > log.interFoam 2>&1 if [ $? -ne 0 ]; then echo "ERROR: interFoam failed, see log.interFoam" exit 1 fifi
echo "=== dam_break 完成 ==="12345678910FoamFile{ version 2.0; format ascii; class uniformDimensionedVectorField; object g;}
dimensions [0 1 -2 0 0 0 0];value (0 -9.81 0);1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556/*--------------------------------*- C++ -*----------------------------------*\| ========= | || \\ / F ield | OpenFOAM: The Open Source CFD Toolbox || \\ / O peration | Version: || \\ / A nd | Web: www.OpenFOAM.com || \\/ M anipulation | |\*---------------------------------------------------------------------------*/FoamFile{ version 2.0; format ascii; class polyBoundaryMesh; location "constant/polyMesh"; object boundary;}// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
5( leftWall { type wall; inGroups 1(wall); nFaces 128; startFace 32512; } rightWall { type wall; inGroups 1(wall); nFaces 128; startFace 32640; } lowerWall { type wall; inGroups 1(wall); nFaces 128; startFace 32768; } upperWall { type patch; nFaces 128; startFace 32896; } defaultFaces { type empty; inGroups 1(empty); nFaces 32768; startFace 33024; })
// ************************************************************************* //1234567891011121314151617181920212223242526272829FoamFile{ 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)123456789FoamFile{ version 2.0; format ascii; class dictionary; object turbulenceProperties;}
simulationType laminar;1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889FoamFile{ 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 后面 ); });123456789101112131415161718192021222324252627282930313233343536FoamFile{ 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; // 每 0.01s 保存一帧 → 200 帧(统一 10ms 间隔)
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; // 禁用浮点异常捕获(避免数值噪声导致崩溃)}123456789101112131415161718192021FoamFile{ version 2.0; format ascii; class dictionary; object decomposeParDict;}
// 并行分解设置// 2D case: Z 方向仅 1 个分区(empty 边界限制)// numberOfSubdomains 16由 run_case.sh 传入,此处为默认值numberOfSubdomains 16;
method hierarchical;
hierarchicalCoeffs{ n (4 4 1); // X: 2分区, Y: 2分区, Z: 1分区 delta 0.001; order xyz;}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253FoamFile{ 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;}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586FoamFile{ 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 {};}1234567891011121314151617181920212223242526272829303132333435363738394041FoamFile{ 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; }}123456789101112131415161718192021222324252627282930313233343536373839404142FoamFile{ 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; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445FoamFile{ 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 pressureinternalField 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; }}1234567891011121314151617181920212223242526272829303132333435363738394041424344#!/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>&1if [ $? -ne 0 ]; then echo "ERROR: blockMesh failed, see log.blockMesh" exit 1fiecho " 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>&1else echo "=== dam_break: interFoam (serial) ===" interFoam > log.interFoam 2>&1 if [ $? -ne 0 ]; then echo "ERROR: interFoam failed, see log.interFoam" exit 1 fifi
echo "=== dam_break 完成 ==="12345678910FoamFile{ version 2.0; format ascii; class uniformDimensionedVectorField; object g;}
dimensions [0 1 -2 0 0 0 0];value (0 -9.81 0);1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556/*--------------------------------*- C++ -*----------------------------------*\| ========= | || \\ / F ield | OpenFOAM: The Open Source CFD Toolbox || \\ / O peration | Version: || \\ / A nd | Web: www.OpenFOAM.com || \\/ M anipulation | |\*---------------------------------------------------------------------------*/FoamFile{ version 2.0; format ascii; class polyBoundaryMesh; location "constant/polyMesh"; object boundary;}// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
5( leftWall { type wall; inGroups 1(wall); nFaces 128; startFace 32512; } rightWall { type wall; inGroups 1(wall); nFaces 128; startFace 32640; } lowerWall { type wall; inGroups 1(wall); nFaces 128; startFace 32768; } upperWall { type patch; nFaces 128; startFace 32896; } defaultFaces { type empty; inGroups 1(empty); nFaces 32768; startFace 33024; })
// ************************************************************************* //1234567891011121314151617181920212223242526272829FoamFile{ 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)123456789FoamFile{ version 2.0; format ascii; class dictionary; object turbulenceProperties;}
simulationType laminar;1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889FoamFile{ 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 后面 ); });123456789101112131415161718192021222324252627282930313233343536FoamFile{ 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; // 每 0.01s 保存一帧 → 200 帧(统一 10ms 间隔)
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; // 禁用浮点异常捕获(避免数值噪声导致崩溃)}raw/dam_break/t09/0/p_rghAdded+45
raw/dam_break/t09/AllrunAdded+44
raw/dam_break/t09/constant/gAdded+10
raw/dam_break/t09/constant/polyMesh/boundaryAdded+56
raw/dam_break/t09/constant/polyMesh/facesAdded
raw/dam_break/t09/constant/polyMesh/neighbourAdded
raw/dam_break/t09/constant/polyMesh/ownerAdded
raw/dam_break/t09/constant/polyMesh/pointsAdded
raw/dam_break/t09/constant/transportPropertiesAdded+29
raw/dam_break/t09/constant/turbulencePropertiesAdded+9
raw/dam_break/t09/system/blockMeshDictAdded+89
raw/dam_break/t09/system/controlDictAdded+36
raw/dam_break/t09/system/decomposeParDictAdded+21
raw/dam_break/t09/system/fvSchemesAdded+53
raw/dam_break/t09/system/fvSolutionAdded+86
raw/dam_break/t10/0/UAdded
raw/dam_break/t10/0/U.templateAdded+41
raw/dam_break/t10/0/alpha.waterAdded
raw/dam_break/t10/0/alpha.water.templateAdded+42
raw/dam_break/t10/0/p_rghAdded+45
raw/dam_break/t10/AllrunAdded+44
raw/dam_break/t10/constant/gAdded+10
raw/dam_break/t10/constant/polyMesh/boundaryAdded+56
raw/dam_break/t10/constant/polyMesh/facesAdded
raw/dam_break/t10/constant/polyMesh/neighbourAdded
raw/dam_break/t10/constant/polyMesh/ownerAdded
raw/dam_break/t10/constant/polyMesh/pointsAdded
raw/dam_break/t10/constant/transportPropertiesAdded+29
raw/dam_break/t10/constant/turbulencePropertiesAdded+9
raw/dam_break/t10/system/blockMeshDictAdded+89
raw/dam_break/t10/system/controlDictAdded+36
raw/dam_break/t10/system/decomposeParDictAdded+21
raw/dam_break/t10/system/fvSchemesAdded+53
raw/dam_break/t10/system/fvSolutionAdded+86
raw/dam_break/t11/0/UAdded
raw/dam_break/t11/0/U.templateAdded+41
raw/dam_break/t11/0/alpha.waterAdded
raw/dam_break/t11/0/alpha.water.templateAdded+42
raw/dam_break/t11/0/p_rghAdded+45
raw/dam_break/t11/AllrunAdded+44
raw/dam_break/t11/constant/gAdded+10
raw/dam_break/t11/constant/polyMesh/boundaryAdded+56
raw/dam_break/t11/constant/polyMesh/facesAdded
raw/dam_break/t11/constant/polyMesh/neighbourAdded
raw/dam_break/t11/constant/polyMesh/ownerAdded
raw/dam_break/t11/constant/polyMesh/pointsAdded
raw/dam_break/t11/constant/transportPropertiesAdded+29
raw/dam_break/t11/constant/turbulencePropertiesAdded+9
raw/dam_break/t11/system/blockMeshDictAdded+89
raw/dam_break/t11/system/controlDictAdded+36