Archive CFD workflow 2026-10-12: _seiler_ref
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -10
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/U +3 -88
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/k +3 -60
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/nut +3 -59
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/omega +3 -62
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/p +3 -56
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/U +3 -88
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/k +3 -60
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/nut +3 -59
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/omega +3 -62
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/p +3 -55
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/constant/extendedFeatureEdgeMesh/car.extendedFeatureEdgeMesh +3 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/constant/transportProperties +20 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/constant/triSurface/car.stl.ori +3 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/constant/turbulenceProperties +24 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/forceCoeffs_car +20 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/forces +18 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/include/.DS_Store +0 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/include/config +38 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/include/geometry +56 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/plots.sh +6 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/residuals +15 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/run_all_shm.sh +72 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/run_mesh_shm.sh +30 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/run_solver_shm.sh +32 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/simulation.done +0 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/.DS_Store +0 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/._snappyHexMeshDict +0 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/blockMeshDict +121 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/controlDict +319 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/decomposeParDict +19 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/fvConstraints +28 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/fvSchemes +69 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/fvSolution +181 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/meshQualityDict +48 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/snappyHexMeshDict +322 -0
- cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/surfaceFeaturesDict +34 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/compute_force_chair.py +259 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/compute_force_table.py +154 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/compute_metrics.py +169 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/force_web_ui.py +733 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_alternate_me.py +0 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_alternate_me_better.py +0 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_dflow_me.py +0 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_ictm_me.py +0 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_sdedit_me.py +0 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_sgo_me.py +0 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/sample_hunyuan.py +222 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/sample_hunyuan_from_folder.py +223 -0
- cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/test_init_compliance.py +0 -0
.gitattributes
CHANGED
|
@@ -11422,13 +11422,4 @@ cfd_workflow_20261012/**/wallShearStress filter=lfs diff=lfs merge=lfs -text
|
|
| 11422 |
cfd_workflow_20261012/**/wallShearStressMean filter=lfs diff=lfs merge=lfs -text
|
| 11423 |
cfd_workflow_20261012/**/yPlus filter=lfs diff=lfs merge=lfs -text
|
| 11424 |
cfd_workflow_20261012/**/yPlusMean filter=lfs diff=lfs merge=lfs -text
|
| 11425 |
-
cfd_workflow_20261012/
|
| 11426 |
-
cfd_workflow_20261012/anchorgen_side60_20260923_v1/results/pair0342_source057/target/prepared/constant/triSurface/car.stl filter=lfs diff=lfs merge=lfs -text
|
| 11427 |
-
cfd_workflow_20261012/anchorgen_side60_20260923_v1/results/pair0428_source071/final60/prepared/constant/triSurface/car.stl filter=lfs diff=lfs merge=lfs -text
|
| 11428 |
-
cfd_workflow_20261012/anchorgen_side60_20260923_v1/results/pair0428_source071/initial/prepared/constant/triSurface/car.stl filter=lfs diff=lfs merge=lfs -text
|
| 11429 |
-
cfd_workflow_20261012/anchorgen_side60_20260923_v1/results/pair0428_source071/target/prepared/constant/triSurface/car.stl filter=lfs diff=lfs merge=lfs -text
|
| 11430 |
-
cfd_workflow_20261012/anchorgen_side60_20260923_v1/results/pair0478_source079/final60/prepared/constant/triSurface/car.stl filter=lfs diff=lfs merge=lfs -text
|
| 11431 |
-
cfd_workflow_20261012/anchorgen_side60_20260923_v1/results/pair0478_source079/initial/prepared/constant/triSurface/car.stl filter=lfs diff=lfs merge=lfs -text
|
| 11432 |
-
cfd_workflow_20261012/anchorgen_side60_20260923_v1/results/pair0478_source079/target/prepared/constant/triSurface/car.stl filter=lfs diff=lfs merge=lfs -text
|
| 11433 |
-
cfd_workflow_20261012/anchorgen_side60_20260923_v1/results/pair0503_source083/final60/prepared/constant/triSurface/car.stl filter=lfs diff=lfs merge=lfs -text
|
| 11434 |
-
cfd_workflow_20261012/anchorgen_side60_20260923_v1/results/pair0503_source083/initial/prepared/constant/triSurface/car.stl filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 11422 |
cfd_workflow_20261012/**/wallShearStressMean filter=lfs diff=lfs merge=lfs -text
|
| 11423 |
cfd_workflow_20261012/**/yPlus filter=lfs diff=lfs merge=lfs -text
|
| 11424 |
cfd_workflow_20261012/**/yPlusMean filter=lfs diff=lfs merge=lfs -text
|
| 11425 |
+
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/constant/triSurface/car.stl.ori filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/U
CHANGED
|
@@ -1,88 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volVectorField;
|
| 13 |
-
object U;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 1 -1 0 0 0 0 ];
|
| 18 |
-
internalField uniform (30 0.0 0.0);
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
#includeEtc "caseDicts/setConstraintTypes"
|
| 23 |
-
inlet
|
| 24 |
-
{
|
| 25 |
-
|
| 26 |
-
type fixedValue;
|
| 27 |
-
value uniform ( 30.0 0.0 0.0 );
|
| 28 |
-
|
| 29 |
-
/*
|
| 30 |
-
type uniformFixedValue;
|
| 31 |
-
uniformValue table
|
| 32 |
-
(
|
| 33 |
-
(0 (5 0 0))
|
| 34 |
-
//(20 (10 0 0))
|
| 35 |
-
//(40 (15 0 0))
|
| 36 |
-
//(60 (20 0 0))
|
| 37 |
-
//(80 (25 0 0))
|
| 38 |
-
(100 (30 0 0))
|
| 39 |
-
);
|
| 40 |
-
*/
|
| 41 |
-
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
outlet
|
| 45 |
-
{
|
| 46 |
-
//type zeroGradient;
|
| 47 |
-
//value uniform ( 0.0 0.0 0.0 );
|
| 48 |
-
|
| 49 |
-
type inletOutlet;
|
| 50 |
-
inletValue uniform (30 0 0);
|
| 51 |
-
value uniform (30 0 0);
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
sides
|
| 55 |
-
{
|
| 56 |
-
type slip;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
ground
|
| 60 |
-
{
|
| 61 |
-
type fixedValue;
|
| 62 |
-
value uniform ( 30.0 0.0 0.0 );
|
| 63 |
-
|
| 64 |
-
/*
|
| 65 |
-
type uniformFixedValue;
|
| 66 |
-
uniformValue table
|
| 67 |
-
(
|
| 68 |
-
(0 (5 0 0))
|
| 69 |
-
//(20 (10 0 0))
|
| 70 |
-
//(40 (15 0 0))
|
| 71 |
-
//(60 (20 0 0))
|
| 72 |
-
//(80 (25 0 0))
|
| 73 |
-
(100 (30 0 0))
|
| 74 |
-
);
|
| 75 |
-
*/
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
top
|
| 79 |
-
{
|
| 80 |
-
type slip;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
car
|
| 84 |
-
{
|
| 85 |
-
type fixedValue;
|
| 86 |
-
value uniform ( 0 0 0);
|
| 87 |
-
}
|
| 88 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:562432c8ef08dd9d7a5c4aaa55e256f8c8c996c414fc0d50ac67bad22fb40f95
|
| 3 |
+
size 1907
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/k
CHANGED
|
@@ -1,60 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volScalarField;
|
| 13 |
-
object k;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 2 -2 0 0 0 0 ];
|
| 18 |
-
internalField uniform 3.375;
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
#includeEtc "caseDicts/setConstraintTypes"
|
| 23 |
-
inlet
|
| 24 |
-
{
|
| 25 |
-
type fixedValue;
|
| 26 |
-
value uniform 3.375;
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
outlet
|
| 30 |
-
{
|
| 31 |
-
type zeroGradient;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
sides
|
| 35 |
-
{
|
| 36 |
-
//type kqRWallFunction;
|
| 37 |
-
//value uniform 1e-20;
|
| 38 |
-
type slip;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
ground
|
| 42 |
-
{
|
| 43 |
-
type kqRWallFunction;
|
| 44 |
-
value uniform 3.375;
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
top
|
| 48 |
-
{
|
| 49 |
-
//type kqRWallFunction;
|
| 50 |
-
//value uniform 1e-20;
|
| 51 |
-
type slip;
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
car
|
| 55 |
-
{
|
| 56 |
-
type kqRWallFunction;
|
| 57 |
-
value uniform 3.375;
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b599768ea2ecec8b6d2f699ceea9336af32b3aba20826ec502df66fb0f175b7e
|
| 3 |
+
size 1367
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/nut
CHANGED
|
@@ -1,59 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volScalarField;
|
| 13 |
-
object nut;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 2 -1 0 0 0 0 ];
|
| 18 |
-
internalField uniform 0.0001;
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
#includeEtc "caseDicts/setConstraintTypes"
|
| 23 |
-
inlet
|
| 24 |
-
{
|
| 25 |
-
type zeroGradient;
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
outlet
|
| 29 |
-
{
|
| 30 |
-
type zeroGradient;
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
sides
|
| 34 |
-
{
|
| 35 |
-
//type nutUSpaldingWallFunction;
|
| 36 |
-
//value uniform 0.001;
|
| 37 |
-
type slip;
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
ground
|
| 41 |
-
{
|
| 42 |
-
type nutUSpaldingWallFunction;
|
| 43 |
-
value uniform 0.0001;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
top
|
| 47 |
-
{
|
| 48 |
-
//type nutUSpaldingWallFunction;
|
| 49 |
-
//value uniform 0.001;
|
| 50 |
-
type slip;
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
car
|
| 54 |
-
{
|
| 55 |
-
type nutUSpaldingWallFunction;
|
| 56 |
-
value uniform 0.0001;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e29a89f75f157ff99c42b2f5338511921f757a91452575b5b1dc7a2366f289f7
|
| 3 |
+
size 1388
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/omega
CHANGED
|
@@ -1,62 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volScalarField;
|
| 13 |
-
object omega;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 0 -1 0 0 0 0 ];
|
| 18 |
-
internalField uniform 9000;
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
#includeEtc "caseDicts/setConstraintTypes"
|
| 23 |
-
inlet
|
| 24 |
-
{
|
| 25 |
-
type fixedValue;
|
| 26 |
-
value uniform 9000;
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
outlet
|
| 30 |
-
{
|
| 31 |
-
type zeroGradient;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
sides
|
| 35 |
-
{
|
| 36 |
-
//type omegaWallFunction;
|
| 37 |
-
//value uniform 1;
|
| 38 |
-
type slip;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
ground
|
| 42 |
-
{
|
| 43 |
-
type omegaWallFunction;
|
| 44 |
-
//value uniform 9000;
|
| 45 |
-
value uniform 500000;
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
top
|
| 49 |
-
{
|
| 50 |
-
//type omegaWallFunction;
|
| 51 |
-
//value uniform 1;
|
| 52 |
-
type slip;
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
car
|
| 56 |
-
{
|
| 57 |
-
type omegaWallFunction;
|
| 58 |
-
//value uniform 9000;
|
| 59 |
-
value uniform 500000;
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cbe61f8b4dd72db7cd569310c1810f959328b0797ecbbcc3469ea58b67e6798c
|
| 3 |
+
size 1442
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0/p
CHANGED
|
@@ -1,56 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volScalarField;
|
| 13 |
-
object p;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 2 -2 0 0 0 0 ];
|
| 18 |
-
internalField uniform 0.0;
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
#includeEtc "caseDicts/setConstraintTypes"
|
| 23 |
-
inlet
|
| 24 |
-
{
|
| 25 |
-
type zeroGradient;
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
outlet
|
| 29 |
-
{
|
| 30 |
-
type fixedValue;
|
| 31 |
-
value uniform 0.0;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
sides
|
| 35 |
-
{
|
| 36 |
-
//type zeroGradient;
|
| 37 |
-
type slip;
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
ground
|
| 41 |
-
{
|
| 42 |
-
type zeroGradient;
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
top
|
| 46 |
-
{
|
| 47 |
-
//type zeroGradient;
|
| 48 |
-
type slip;
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
car
|
| 52 |
-
{
|
| 53 |
-
type zeroGradient;
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b2c076ebfbd5801985fc179c56b02dafab1b1bc1043a9d5286aaf549b25a3088
|
| 3 |
+
size 1238
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/U
CHANGED
|
@@ -1,88 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volVectorField;
|
| 13 |
-
object U;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 1 -1 0 0 0 0 ];
|
| 18 |
-
internalField uniform (30 0.0 0.0);
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
#includeEtc "caseDicts/setConstraintTypes"
|
| 23 |
-
inlet
|
| 24 |
-
{
|
| 25 |
-
|
| 26 |
-
type fixedValue;
|
| 27 |
-
value uniform ( 30.0 0.0 0.0 );
|
| 28 |
-
|
| 29 |
-
/*
|
| 30 |
-
type uniformFixedValue;
|
| 31 |
-
uniformValue table
|
| 32 |
-
(
|
| 33 |
-
(0 (5 0 0))
|
| 34 |
-
//(20 (10 0 0))
|
| 35 |
-
//(40 (15 0 0))
|
| 36 |
-
//(60 (20 0 0))
|
| 37 |
-
//(80 (25 0 0))
|
| 38 |
-
(100 (30 0 0))
|
| 39 |
-
);
|
| 40 |
-
*/
|
| 41 |
-
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
outlet
|
| 45 |
-
{
|
| 46 |
-
//type zeroGradient;
|
| 47 |
-
//value uniform ( 0.0 0.0 0.0 );
|
| 48 |
-
|
| 49 |
-
type inletOutlet;
|
| 50 |
-
inletValue uniform (30 0 0);
|
| 51 |
-
value uniform (30 0 0);
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
sides
|
| 55 |
-
{
|
| 56 |
-
type slip;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
ground
|
| 60 |
-
{
|
| 61 |
-
type fixedValue;
|
| 62 |
-
value uniform ( 30.0 0.0 0.0 );
|
| 63 |
-
|
| 64 |
-
/*
|
| 65 |
-
type uniformFixedValue;
|
| 66 |
-
uniformValue table
|
| 67 |
-
(
|
| 68 |
-
(0 (5 0 0))
|
| 69 |
-
//(20 (10 0 0))
|
| 70 |
-
//(40 (15 0 0))
|
| 71 |
-
//(60 (20 0 0))
|
| 72 |
-
//(80 (25 0 0))
|
| 73 |
-
(100 (30 0 0))
|
| 74 |
-
);
|
| 75 |
-
*/
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
top
|
| 79 |
-
{
|
| 80 |
-
type slip;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
car
|
| 84 |
-
{
|
| 85 |
-
type fixedValue;
|
| 86 |
-
value uniform ( 0 0 0);
|
| 87 |
-
}
|
| 88 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:562432c8ef08dd9d7a5c4aaa55e256f8c8c996c414fc0d50ac67bad22fb40f95
|
| 3 |
+
size 1907
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/k
CHANGED
|
@@ -1,60 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volScalarField;
|
| 13 |
-
object k;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 2 -2 0 0 0 0 ];
|
| 18 |
-
internalField uniform 3.375;
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
#includeEtc "caseDicts/setConstraintTypes"
|
| 23 |
-
inlet
|
| 24 |
-
{
|
| 25 |
-
type fixedValue;
|
| 26 |
-
value uniform 3.375;
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
outlet
|
| 30 |
-
{
|
| 31 |
-
type zeroGradient;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
sides
|
| 35 |
-
{
|
| 36 |
-
//type kqRWallFunction;
|
| 37 |
-
//value uniform 1e-20;
|
| 38 |
-
type slip;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
ground
|
| 42 |
-
{
|
| 43 |
-
type kqRWallFunction;
|
| 44 |
-
value uniform 3.375;
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
top
|
| 48 |
-
{
|
| 49 |
-
//type kqRWallFunction;
|
| 50 |
-
//value uniform 1e-20;
|
| 51 |
-
type slip;
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
car
|
| 55 |
-
{
|
| 56 |
-
type kqRWallFunction;
|
| 57 |
-
value uniform 3.375;
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b599768ea2ecec8b6d2f699ceea9336af32b3aba20826ec502df66fb0f175b7e
|
| 3 |
+
size 1367
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/nut
CHANGED
|
@@ -1,59 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volScalarField;
|
| 13 |
-
object nut;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 2 -1 0 0 0 0 ];
|
| 18 |
-
internalField uniform 0.0001;
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
#includeEtc "caseDicts/setConstraintTypes"
|
| 23 |
-
inlet
|
| 24 |
-
{
|
| 25 |
-
type zeroGradient;
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
outlet
|
| 29 |
-
{
|
| 30 |
-
type zeroGradient;
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
sides
|
| 34 |
-
{
|
| 35 |
-
//type nutUSpaldingWallFunction;
|
| 36 |
-
//value uniform 0.001;
|
| 37 |
-
type slip;
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
ground
|
| 41 |
-
{
|
| 42 |
-
type nutUSpaldingWallFunction;
|
| 43 |
-
value uniform 0.0001;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
top
|
| 47 |
-
{
|
| 48 |
-
//type nutUSpaldingWallFunction;
|
| 49 |
-
//value uniform 0.001;
|
| 50 |
-
type slip;
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
car
|
| 54 |
-
{
|
| 55 |
-
type nutUSpaldingWallFunction;
|
| 56 |
-
value uniform 0.0001;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e29a89f75f157ff99c42b2f5338511921f757a91452575b5b1dc7a2366f289f7
|
| 3 |
+
size 1388
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/omega
CHANGED
|
@@ -1,62 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volScalarField;
|
| 13 |
-
object omega;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 0 -1 0 0 0 0 ];
|
| 18 |
-
internalField uniform 9000;
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
#includeEtc "caseDicts/setConstraintTypes"
|
| 23 |
-
inlet
|
| 24 |
-
{
|
| 25 |
-
type fixedValue;
|
| 26 |
-
value uniform 9000;
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
outlet
|
| 30 |
-
{
|
| 31 |
-
type zeroGradient;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
sides
|
| 35 |
-
{
|
| 36 |
-
//type omegaWallFunction;
|
| 37 |
-
//value uniform 1;
|
| 38 |
-
type slip;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
ground
|
| 42 |
-
{
|
| 43 |
-
type omegaWallFunction;
|
| 44 |
-
//value uniform 9000;
|
| 45 |
-
value uniform 500000;
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
top
|
| 49 |
-
{
|
| 50 |
-
//type omegaWallFunction;
|
| 51 |
-
//value uniform 1;
|
| 52 |
-
type slip;
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
car
|
| 56 |
-
{
|
| 57 |
-
type omegaWallFunction;
|
| 58 |
-
//value uniform 9000;
|
| 59 |
-
value uniform 500000;
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cbe61f8b4dd72db7cd569310c1810f959328b0797ecbbcc3469ea58b67e6798c
|
| 3 |
+
size 1442
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/0_org/p
CHANGED
|
@@ -1,55 +1,3 @@
|
|
| 1 |
-
/
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
| \\ / O peration | Version: 7 |
|
| 5 |
-
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
-
| \\/ M anipulation | |
|
| 7 |
-
\*---------------------------------------------------------------------------*/
|
| 8 |
-
FoamFile
|
| 9 |
-
{
|
| 10 |
-
version 2.0;
|
| 11 |
-
format ascii;
|
| 12 |
-
class volScalarField;
|
| 13 |
-
object p;
|
| 14 |
-
}
|
| 15 |
-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
-
|
| 17 |
-
dimensions [ 0 2 -2 0 0 0 0 ];
|
| 18 |
-
internalField uniform 0.0;
|
| 19 |
-
|
| 20 |
-
boundaryField
|
| 21 |
-
{
|
| 22 |
-
inlet
|
| 23 |
-
{
|
| 24 |
-
type zeroGradient;
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
outlet
|
| 28 |
-
{
|
| 29 |
-
type fixedValue;
|
| 30 |
-
value uniform 0.0;
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
sides
|
| 34 |
-
{
|
| 35 |
-
//type zeroGradient;
|
| 36 |
-
type slip;
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
ground
|
| 40 |
-
{
|
| 41 |
-
type zeroGradient;
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
top
|
| 45 |
-
{
|
| 46 |
-
//type zeroGradient;
|
| 47 |
-
type slip;
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
car
|
| 51 |
-
{
|
| 52 |
-
type zeroGradient;
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
}
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a9933435039a1b90677edd393878dabf3c809b34703fb0fd42d30260c2c68999
|
| 3 |
+
size 1191
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/constant/extendedFeatureEdgeMesh/car.extendedFeatureEdgeMesh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:09a7e990bf7cd605eeec3173c7f4f94649a58498d99427c2e177de8850b27a57
|
| 3 |
+
size 214444
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/constant/transportProperties
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
| ========= | |
|
| 3 |
+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| 4 |
+
| \\ / O peration | Version: 7 |
|
| 5 |
+
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
+
| \\/ M anipulation | |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
version 2.0;
|
| 11 |
+
format ascii;
|
| 12 |
+
class dictionary;
|
| 13 |
+
object transportProperties;
|
| 14 |
+
}
|
| 15 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
+
|
| 17 |
+
transportModel Newtonian;
|
| 18 |
+
|
| 19 |
+
nu nu [0 2 -1 0 0 0 0 ] 1.5881327800829875E-5;
|
| 20 |
+
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/constant/triSurface/car.stl.ori
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:75cee1fd8f57047f8d7879a10c62f84245c2b7855d00b0ab02ba1020ccecc743
|
| 3 |
+
size 2193184
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/constant/turbulenceProperties
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
| ========= | |
|
| 3 |
+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| 4 |
+
| \\ / O peration | Version: 7 |
|
| 5 |
+
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
+
| \\/ M anipulation | |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
version 2.0;
|
| 11 |
+
format ascii;
|
| 12 |
+
class dictionary;
|
| 13 |
+
object turbulenceProperties;
|
| 14 |
+
}
|
| 15 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
+
|
| 17 |
+
simulationType RAS;
|
| 18 |
+
|
| 19 |
+
RAS
|
| 20 |
+
{
|
| 21 |
+
RASModel kOmegaSST;
|
| 22 |
+
turbulence on;
|
| 23 |
+
printCoeffs on;
|
| 24 |
+
}
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/forceCoeffs_car
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#set yr [0:0.25]
|
| 2 |
+
set term pngcairo
|
| 3 |
+
set output "./images/forceCoeffs.png"
|
| 4 |
+
#set xr [0:3000]
|
| 5 |
+
set yr [0:2.0]
|
| 6 |
+
set key bottom right
|
| 7 |
+
set xlabel "Simulation time [s]"
|
| 8 |
+
set ylabel "forceCoeff [-]"
|
| 9 |
+
set title "Plot of forceCoeffs over simulationtime"
|
| 10 |
+
set grid
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
#plot "./postProcessing/car/0/forceCoeffs_0.dat" using ($1):($4) with lines title "lift_{coeff}",\
|
| 14 |
+
"./postProcessing/car/0/forceCoeffs_0.dat" using ($1):($3) with lines title "drag_{coeff}"
|
| 15 |
+
|
| 16 |
+
plot "./postProcessing/car/0/forceCoeffs.dat" using ($1):($4) with lines title "lift_{coeff}",\
|
| 17 |
+
"./postProcessing/car/0/forceCoeffs.dat" using ($1):($3) with lines title "drag_{coeff}"
|
| 18 |
+
|
| 19 |
+
#pause -1
|
| 20 |
+
#reread
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/forces
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#set yr [0:0.25]
|
| 2 |
+
set term pngcairo
|
| 3 |
+
set output "./images/forces.png"
|
| 4 |
+
#set xr [0:2000]
|
| 5 |
+
set yr [0:500]
|
| 6 |
+
set key bottom right
|
| 7 |
+
set xlabel "Simulation time [s]"
|
| 8 |
+
set ylabel "forces [N]"
|
| 9 |
+
set title "Plot of forces over simulationtime"
|
| 10 |
+
set grid
|
| 11 |
+
|
| 12 |
+
#plot "./postProcessing/forces/0/forces_0.dat" using ($1):($4) with lines title "lift",\
|
| 13 |
+
"./postProcessing/forces/0/forces_0.dat" using ($1):($3) with lines title "drag"
|
| 14 |
+
|
| 15 |
+
plot "./postProcessing/forces/0/forces.dat" using ($1):($4) with lines title "lift",\
|
| 16 |
+
"./postProcessing/forces/0/forces.dat" using ($1):($3) with lines title "drag"
|
| 17 |
+
#pause -1
|
| 18 |
+
#reread
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/include/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/include/config
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
========= |
|
| 3 |
+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
| 4 |
+
\\ / O peration | Website: https://openfoam.org
|
| 5 |
+
\\ / A nd | Version: 9
|
| 6 |
+
\\/ M anipulation |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
version 2.0;
|
| 11 |
+
format ascii;
|
| 12 |
+
class dictionary;
|
| 13 |
+
object config;
|
| 14 |
+
}
|
| 15 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
+
|
| 17 |
+
config
|
| 18 |
+
{
|
| 19 |
+
/* controlDict */
|
| 20 |
+
// Area of reference (projected area in x)
|
| 21 |
+
Aref 2.303064;
|
| 22 |
+
|
| 23 |
+
/* snappyHexMeshDict */
|
| 24 |
+
// Refinement regions
|
| 25 |
+
vr1_min ( -7.50 -3.00 -0.30 );
|
| 26 |
+
vr1_max ( 25.00 3.00 3.70 );
|
| 27 |
+
|
| 28 |
+
vr2_min ( -2.13 -1.99 -0.30 );
|
| 29 |
+
vr2_max ( 8.88 1.99 1.79 );
|
| 30 |
+
|
| 31 |
+
vr3_min ( 1.29 -1.49 -0.30 );
|
| 32 |
+
vr3_max ( 7.38 1.49 1.49 );
|
| 33 |
+
|
| 34 |
+
vr4_min ( 1.29 -0.99 -0.30 );
|
| 35 |
+
vr4_max ( 6.08 0.99 1.19 );
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
// ************************************************************************* //
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/include/geometry
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
| ========= | |
|
| 3 |
+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| 4 |
+
| \\ / O peration | Version: 5 |
|
| 5 |
+
| \\ / A nd | Web: www.OpenFOAM.org |
|
| 6 |
+
| \\/ M anipulation | |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
|
| 9 |
+
//Name of .stl
|
| 10 |
+
name_stl car.stl;
|
| 11 |
+
|
| 12 |
+
// Computational domain coordinates
|
| 13 |
+
x_min -15.0;
|
| 14 |
+
x_max 25.0;
|
| 15 |
+
|
| 16 |
+
y_min -15.0;
|
| 17 |
+
y_max 15.0;
|
| 18 |
+
|
| 19 |
+
z_min -0.3;
|
| 20 |
+
z_max 14.7;
|
| 21 |
+
|
| 22 |
+
cell_division (80 60 30);
|
| 23 |
+
// Refinement box coordinates
|
| 24 |
+
|
| 25 |
+
//fine box close to the car
|
| 26 |
+
x_min_ref -1.25;
|
| 27 |
+
x_max_ref 2.0;
|
| 28 |
+
|
| 29 |
+
y_min_ref -1.25;
|
| 30 |
+
y_max_ref 1.25;
|
| 31 |
+
|
| 32 |
+
z_min_ref -0.3;
|
| 33 |
+
z_max_ref 1.75;
|
| 34 |
+
|
| 35 |
+
//medium box further away
|
| 36 |
+
x_min_ref_medium -2.0;
|
| 37 |
+
x_max_ref_medium 10.0;
|
| 38 |
+
|
| 39 |
+
y_min_ref_medium -1.75;
|
| 40 |
+
y_max_ref_medium 1.75;
|
| 41 |
+
|
| 42 |
+
z_min_ref_medium -0.3;
|
| 43 |
+
z_max_ref_medium 2.25;
|
| 44 |
+
|
| 45 |
+
//coarse box just before far field
|
| 46 |
+
x_min_ref_coarse -3.0;
|
| 47 |
+
x_max_ref_coarse 15.0;
|
| 48 |
+
|
| 49 |
+
y_min_ref_coarse -2.75;
|
| 50 |
+
y_max_ref_coarse 2.75;
|
| 51 |
+
|
| 52 |
+
z_min_ref_coarse -0.3;
|
| 53 |
+
z_max_ref_coarse 2.75;
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
// ************************************************************************* //
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/plots.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
dict=$1
|
| 3 |
+
mkdir -p ./images
|
| 4 |
+
#gnuplot $dict/forces
|
| 5 |
+
gnuplot $dict/forceCoeffs_car
|
| 6 |
+
gnuplot $dict/residuals
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/residuals
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set term pngcairo
|
| 2 |
+
set output "./images/residuals.png"
|
| 3 |
+
set logscale y
|
| 4 |
+
set yr [0.0000001:1]
|
| 5 |
+
set title "Residuals"
|
| 6 |
+
set ylabel 'Residual'
|
| 7 |
+
set xlabel 'Iteration'
|
| 8 |
+
plot "< cat logs/log.solver | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines,\
|
| 9 |
+
"< cat logs/log.solver | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines,\
|
| 10 |
+
"< cat logs/log.solver | grep 'Solving for Uz' | cut -d' ' -f9 | tr -d ','" title 'Uz' with lines,\
|
| 11 |
+
"< cat logs/log.solver | grep 'Solving for omega' | cut -d' ' -f9 | tr -d ','" title 'omega' with lines,\
|
| 12 |
+
"< cat logs/log.solver | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines,\
|
| 13 |
+
#"< cat logs/log.solver | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines
|
| 14 |
+
#pause -1
|
| 15 |
+
#reread
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/run_all_shm.sh
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Verify if already finished by checking the plotting folder
|
| 4 |
+
ITERMAX=$(grep -o "endTime *[0-9]* *;" system/controlDict | grep -o "[0-9]*")
|
| 5 |
+
if [[ -d images ]] && [[ -d $ITERMAX ]] && [[ -f simulation.done ]]; then
|
| 6 |
+
echo "Experiment at $(pwd) is already finished! Passing..."
|
| 7 |
+
exit 0
|
| 8 |
+
fi
|
| 9 |
+
|
| 10 |
+
mkdir -p logs
|
| 11 |
+
|
| 12 |
+
# Following tries to recover automatically the numberOfSubdomains from system/decomposeParDict
|
| 13 |
+
procs=$(grep -o "numberOfSubdomains *[0-9]* *;" system/decomposeParDict | grep -o "[0-9]*")
|
| 14 |
+
# If doesn't work, set it manually here
|
| 15 |
+
if [ -z $procs ]; then
|
| 16 |
+
echo "Couldn't read 'numberOfSubdomains' from 'system/decomposeParDict'."
|
| 17 |
+
procs=12
|
| 18 |
+
fi
|
| 19 |
+
echo "procs set to $procs."
|
| 20 |
+
MAXITER=2500 # max iter of the simulations
|
| 21 |
+
|
| 22 |
+
# If car.foam exists, then must have at least meshed -> skip
|
| 23 |
+
if [[ ! -f car.foam ]]; then
|
| 24 |
+
foamCleanTutorials
|
| 25 |
+
#rm -rf 0 > /dev/null 2>&1
|
| 26 |
+
|
| 27 |
+
#PART DEDICATED TO MESHING
|
| 28 |
+
surfaceFeatures | tee logs/log.surfaceFeatures
|
| 29 |
+
blockMesh | tee logs/log.blockMesh
|
| 30 |
+
|
| 31 |
+
decomposePar
|
| 32 |
+
(time (mpirun -np $procs snappyHexMesh -parallel -overwrite)) 2>&1 | tee logs/log.shm
|
| 33 |
+
mpirun -np $procs checkMesh -parallel | tee logs/log.checkMesh
|
| 34 |
+
|
| 35 |
+
reconstructParMesh -constant
|
| 36 |
+
rm -r ./processor*
|
| 37 |
+
|
| 38 |
+
touch car.foam
|
| 39 |
+
fi
|
| 40 |
+
|
| 41 |
+
#PART DEDICATED TO SOLVER
|
| 42 |
+
# If processor0 exists -> must have been doing solver (assuming not already finished and removed!)
|
| 43 |
+
if [[ ! -d processor0 ]]; then
|
| 44 |
+
decomposePar -force -copyZero
|
| 45 |
+
|
| 46 |
+
mpirun -np $procs renumberMesh -parallel -overwrite | tee logs/log.renumber
|
| 47 |
+
mpirun -np $procs potentialFoam -parallel -writep | tee logs/log.potential
|
| 48 |
+
fi
|
| 49 |
+
(time (mpirun -np $procs simpleFoam -parallel)) 2>&1 | tee logs/log.solver
|
| 50 |
+
|
| 51 |
+
# If solver has finished, do rest
|
| 52 |
+
ENDTIME=$(grep -o "endTime *[0-9]* *;" system/controlDict | grep -o "[0-9]*")
|
| 53 |
+
if [[ -d processor0/$ENDTIME ]]; then
|
| 54 |
+
reconstructPar -latestTime
|
| 55 |
+
|
| 56 |
+
rm -r ./processor*
|
| 57 |
+
|
| 58 |
+
./plots.sh .
|
| 59 |
+
|
| 60 |
+
touch car.foam
|
| 61 |
+
|
| 62 |
+
touch simulation.done
|
| 63 |
+
fi
|
| 64 |
+
|
| 65 |
+
# # Copy UMean as U to compute vorticity on UMean automatically
|
| 66 |
+
# cp $MAXITER/UMean $MAXITER/U
|
| 67 |
+
|
| 68 |
+
# # Compute vorticity
|
| 69 |
+
# postProcess -func vorticity -latestTime
|
| 70 |
+
|
| 71 |
+
# # Remove copied U (ignore if non-existent)
|
| 72 |
+
# rm -f $MAXITER/U
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/run_mesh_shm.sh
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Following tries to recover automatically the numberOfSubdomains from system/decomposeParDict
|
| 4 |
+
procs=$(grep -o "numberOfSubdomains *[0-9]* *;" system/decomposeParDict | grep -o "[0-9]*")
|
| 5 |
+
# If doesn't work, set it manually here
|
| 6 |
+
if [ -z $procs ]; then
|
| 7 |
+
echo "Couldn't read 'numberOfSubdomains' from 'system/decomposeParDict'."
|
| 8 |
+
procs=12
|
| 9 |
+
fi
|
| 10 |
+
echo "procs set to $procs."
|
| 11 |
+
|
| 12 |
+
# If car.foam, then must have at least meshed -> skip
|
| 13 |
+
if [[ ! -f car.foam ]]; then
|
| 14 |
+
foamCleanTutorials
|
| 15 |
+
#rm -rf 0 > /dev/null 2>&1
|
| 16 |
+
|
| 17 |
+
surfaceFeatures | tee logs/log.surfaceFeatures
|
| 18 |
+
blockMesh | tee logs/log.blockMesh
|
| 19 |
+
|
| 20 |
+
decomposePar
|
| 21 |
+
(time (mpirun -np $procs snappyHexMesh -parallel -overwrite)) 2>&1 | tee logs/log.shm
|
| 22 |
+
mpirun -np $procs checkMesh -parallel | tee logs/log.checkMesh
|
| 23 |
+
|
| 24 |
+
reconstructParMesh -constant
|
| 25 |
+
# rm -rf 0 > /dev/null 2>&1
|
| 26 |
+
# cp -r 0_org 0 > /dev/null 2>&1
|
| 27 |
+
rm -r ./processor*
|
| 28 |
+
|
| 29 |
+
touch car.foam
|
| 30 |
+
fi
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/run_solver_shm.sh
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Following tries to recover automatically the numberOfSubdomains from system/decomposeParDict
|
| 4 |
+
procs=$(grep -o "numberOfSubdomains *[0-9]* *;" system/decomposeParDict | grep -o "[0-9]*")
|
| 5 |
+
# If doesn't work, set it manually here
|
| 6 |
+
if [ -z $procs ]; then
|
| 7 |
+
echo "Couldn't read 'numberOfSubdomains' from 'system/decomposeParDict'."
|
| 8 |
+
procs=12
|
| 9 |
+
fi
|
| 10 |
+
echo "procs set to $procs."
|
| 11 |
+
|
| 12 |
+
#PART DEDICATED TO SOLVER
|
| 13 |
+
# If processor0 -> must have been doing solver (assuming not already finished and removed!)
|
| 14 |
+
if [[ ! -d processor0 ]]; then
|
| 15 |
+
decomposePar -force -copyZero
|
| 16 |
+
|
| 17 |
+
mpirun -np $procs renumberMesh -parallel -overwrite | tee logs/log.renumber
|
| 18 |
+
mpirun -np $procs potentialFoam -parallel -writep | tee logs/log.potential
|
| 19 |
+
fi
|
| 20 |
+
(time (mpirun -np $procs simpleFoam -parallel)) 2>&1 | tee logs/log.solver
|
| 21 |
+
|
| 22 |
+
# If solver has finished, do rest
|
| 23 |
+
ENDTIME=$(grep -o "endTime *[0-9]* *;" system/controlDict | grep -o "[0-9]*")
|
| 24 |
+
if [[ -d processor0/$ENDTIME ]]; then
|
| 25 |
+
reconstructPar -latestTime
|
| 26 |
+
|
| 27 |
+
rm -r ./processor*
|
| 28 |
+
|
| 29 |
+
./plots.sh .
|
| 30 |
+
|
| 31 |
+
touch car.foam
|
| 32 |
+
fi
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/simulation.done
ADDED
|
File without changes
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/._snappyHexMeshDict
ADDED
|
Binary file (4.1 kB). View file
|
|
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/blockMeshDict
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
========= |
|
| 3 |
+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
| 4 |
+
\\ / O peration | Website: https://openfoam.org
|
| 5 |
+
\\ / A nd | Version: 9
|
| 6 |
+
\\/ M anipulation |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
format ascii;
|
| 11 |
+
class dictionary;
|
| 12 |
+
object blockMeshDict;
|
| 13 |
+
}
|
| 14 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 15 |
+
|
| 16 |
+
convertToMeters 1;
|
| 17 |
+
|
| 18 |
+
x_min -12;
|
| 19 |
+
x_max 32;
|
| 20 |
+
y_min -4;
|
| 21 |
+
y_max 4;
|
| 22 |
+
z_min -0.3;
|
| 23 |
+
z_max 6.4;
|
| 24 |
+
|
| 25 |
+
//xcells 22;
|
| 26 |
+
//ycells 4;
|
| 27 |
+
//zcells 4;
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
//deltax 0.2; //0.05
|
| 31 |
+
//deltay 0.2; //0.05
|
| 32 |
+
//deltaz 0.2; //0.05
|
| 33 |
+
//
|
| 34 |
+
//lx #calc "($xmax) - ($xmin)";
|
| 35 |
+
//ly #calc "($ymax) - ($ymin)";
|
| 36 |
+
//lz #calc "($zmax) - ($zmin)";
|
| 37 |
+
//
|
| 38 |
+
//xcells #calc "round(($lx)/($deltax))";
|
| 39 |
+
//ycells #calc "round(($ly)/($deltay))";
|
| 40 |
+
//zcells #calc "round(($lz)/($deltaz))";
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
xcells 220; // MANUALLY CALCULATED BECAUSE WMAKE FAILED
|
| 44 |
+
ycells 40;
|
| 45 |
+
zcells 34;
|
| 46 |
+
|
| 47 |
+
vertices
|
| 48 |
+
(
|
| 49 |
+
($x_min $y_min $z_min)
|
| 50 |
+
($x_max $y_min $z_min)
|
| 51 |
+
($x_max $y_max $z_min)
|
| 52 |
+
($x_min $y_max $z_min)
|
| 53 |
+
($x_min $y_min $z_max)
|
| 54 |
+
($x_max $y_min $z_max)
|
| 55 |
+
($x_max $y_max $z_max)
|
| 56 |
+
($x_min $y_max $z_max)
|
| 57 |
+
);
|
| 58 |
+
|
| 59 |
+
blocks
|
| 60 |
+
(
|
| 61 |
+
hex (0 1 2 3 4 5 6 7) ($xcells $ycells $zcells) simpleGrading (1 1 1)
|
| 62 |
+
);
|
| 63 |
+
|
| 64 |
+
edges
|
| 65 |
+
(
|
| 66 |
+
);
|
| 67 |
+
|
| 68 |
+
boundary
|
| 69 |
+
(
|
| 70 |
+
inlet
|
| 71 |
+
{
|
| 72 |
+
type patch;
|
| 73 |
+
faces
|
| 74 |
+
(
|
| 75 |
+
(0 4 7 3)
|
| 76 |
+
);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
outlet
|
| 80 |
+
{
|
| 81 |
+
type patch;
|
| 82 |
+
faces
|
| 83 |
+
(
|
| 84 |
+
(2 6 5 1)
|
| 85 |
+
);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
sides
|
| 89 |
+
{
|
| 90 |
+
type patch;
|
| 91 |
+
faces
|
| 92 |
+
(
|
| 93 |
+
(3 7 6 2)
|
| 94 |
+
(0 1 5 4)
|
| 95 |
+
);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
ground
|
| 99 |
+
{
|
| 100 |
+
type wall;
|
| 101 |
+
faces
|
| 102 |
+
(
|
| 103 |
+
(0 3 2 1)
|
| 104 |
+
);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
top
|
| 108 |
+
{
|
| 109 |
+
type patch;
|
| 110 |
+
faces
|
| 111 |
+
(
|
| 112 |
+
(4 5 6 7)
|
| 113 |
+
);
|
| 114 |
+
}
|
| 115 |
+
);
|
| 116 |
+
|
| 117 |
+
mergePatchPairs
|
| 118 |
+
(
|
| 119 |
+
);
|
| 120 |
+
|
| 121 |
+
// ************************************************************************* //
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/controlDict
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
| ========= | |
|
| 3 |
+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| 4 |
+
| \\ / O peration | Version: 7 |
|
| 5 |
+
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
+
| \\/ M anipulation | |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
version 2.0;
|
| 11 |
+
format ascii;
|
| 12 |
+
class dictionary;
|
| 13 |
+
object controlDict;
|
| 14 |
+
}
|
| 15 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
+
#include "../include/config"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
application simpleFoam;
|
| 20 |
+
|
| 21 |
+
// startFrom startTime;
|
| 22 |
+
startFrom latestTime;
|
| 23 |
+
|
| 24 |
+
startTime 0;
|
| 25 |
+
|
| 26 |
+
stopAt endTime;
|
| 27 |
+
|
| 28 |
+
endTime 2500; //1000-3000-5000
|
| 29 |
+
averageStart 1500; // 1K iters before the end
|
| 30 |
+
|
| 31 |
+
deltaT 1;
|
| 32 |
+
|
| 33 |
+
writeControl timeStep;
|
| 34 |
+
|
| 35 |
+
writeInterval 100;
|
| 36 |
+
|
| 37 |
+
/*
|
| 38 |
+
secondaryWriteControl cpuTime;
|
| 39 |
+
secondaryWriteInterval 1000;
|
| 40 |
+
secondaryPurgeWrite 1;
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
purgeWrite 2;
|
| 44 |
+
|
| 45 |
+
writeFormat binary;
|
| 46 |
+
|
| 47 |
+
writePrecision 12;
|
| 48 |
+
|
| 49 |
+
writeCompression off; //uncompressed
|
| 50 |
+
|
| 51 |
+
timeFormat general;
|
| 52 |
+
|
| 53 |
+
timePrecision 6;
|
| 54 |
+
|
| 55 |
+
runTimeModifiable yes;
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
// ************************************************************************* //
|
| 61 |
+
|
| 62 |
+
functions
|
| 63 |
+
{
|
| 64 |
+
|
| 65 |
+
///////////////////////////////////////////////////////////////////////////
|
| 66 |
+
car
|
| 67 |
+
{
|
| 68 |
+
log yes;
|
| 69 |
+
enabled yes;
|
| 70 |
+
|
| 71 |
+
type forceCoeffs;
|
| 72 |
+
functionObjectLibs ( "libforces.so");
|
| 73 |
+
|
| 74 |
+
patches ( "car");
|
| 75 |
+
|
| 76 |
+
rho rhoInf;
|
| 77 |
+
rhoInf 1.205;
|
| 78 |
+
|
| 79 |
+
CofR ( 0 0 0);
|
| 80 |
+
liftDir ( 0 0 1);
|
| 81 |
+
dragDir ( 1 0 0);
|
| 82 |
+
pitchAxis ( 0 1 0);
|
| 83 |
+
magUInf 30;
|
| 84 |
+
lRef 1; //length in x //1;
|
| 85 |
+
Aref $!config/Aref; //projected area in x //drivAer=2.146952
|
| 86 |
+
writeControl timeStep;
|
| 87 |
+
writeInterval 1;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
///////////////////////////////////////////////////////////////////////////
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
///////////////////////////////////////////////////////////////////////////
|
| 94 |
+
|
| 95 |
+
yplus
|
| 96 |
+
{
|
| 97 |
+
type yPlus;
|
| 98 |
+
functionObjectLibs ("libfieldFunctionObjects.so");
|
| 99 |
+
|
| 100 |
+
enabled true;
|
| 101 |
+
|
| 102 |
+
writeControl outputTime;
|
| 103 |
+
//writeControl timeStep;
|
| 104 |
+
writeInterval 25;
|
| 105 |
+
|
| 106 |
+
log true;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
///////////////////////////////////////////////////////////////////////////
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
///////////////////////////////////////////////////////////////////////////
|
| 113 |
+
Q
|
| 114 |
+
{
|
| 115 |
+
type Q;
|
| 116 |
+
functionObjectLibs ("libutilityFunctionObjects.so");
|
| 117 |
+
|
| 118 |
+
enabled true;
|
| 119 |
+
|
| 120 |
+
writeControl outputTime;
|
| 121 |
+
//writeControl timeStep;
|
| 122 |
+
//writeInterval 1;
|
| 123 |
+
|
| 124 |
+
//log true;
|
| 125 |
+
}
|
| 126 |
+
///////////////////////////////////////////////////////////////////////////
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
///////////////////////////////////////////////////////////////////////////
|
| 130 |
+
|
| 131 |
+
minmaxdomain_scalar
|
| 132 |
+
{
|
| 133 |
+
type volFieldValue;
|
| 134 |
+
libs ("libfieldFunctionObjects.so");
|
| 135 |
+
|
| 136 |
+
enabled true; //true or false
|
| 137 |
+
log true; //write to screen
|
| 138 |
+
|
| 139 |
+
//writeControl writeTime;
|
| 140 |
+
writeControl timeStep;
|
| 141 |
+
writeInterval 1;
|
| 142 |
+
|
| 143 |
+
writeFields false; //write solution to field value - Not needed when only reporting value to screen
|
| 144 |
+
|
| 145 |
+
writeLocation true; //write location in the output file
|
| 146 |
+
|
| 147 |
+
//mode component;
|
| 148 |
+
|
| 149 |
+
regionType all;
|
| 150 |
+
|
| 151 |
+
operation none;
|
| 152 |
+
|
| 153 |
+
fields
|
| 154 |
+
(
|
| 155 |
+
p k omega nut
|
| 156 |
+
);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
///////////////////////////////////////////////////////////////////////////
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
///////////////////////////////////////////////////////////////////////////
|
| 163 |
+
|
| 164 |
+
wallShearStress1
|
| 165 |
+
{
|
| 166 |
+
type wallShearStress;
|
| 167 |
+
functionObjectLibs ("libutilityFunctionObjects.so");
|
| 168 |
+
|
| 169 |
+
enabled true;
|
| 170 |
+
|
| 171 |
+
writeControl outputTime;
|
| 172 |
+
//writeControl timeStep;
|
| 173 |
+
//writeInterval 1;
|
| 174 |
+
|
| 175 |
+
//log true;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
///////////////////////////////////////////////////////////////////////////
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
///////////////////////////////////////////////////////////////////////////
|
| 182 |
+
|
| 183 |
+
fieldAverage
|
| 184 |
+
{
|
| 185 |
+
type fieldAverage;
|
| 186 |
+
functionObjectLibs ("libfieldFunctionObjects.so");
|
| 187 |
+
enabled true;
|
| 188 |
+
writeControl outputTime;
|
| 189 |
+
|
| 190 |
+
//writeControl timeStep;
|
| 191 |
+
//writeInterval 100;
|
| 192 |
+
|
| 193 |
+
//cleanRestart true;
|
| 194 |
+
|
| 195 |
+
timeStart $!averageStart; // see top of file, should be 1K iters before endTime
|
| 196 |
+
//timeEnd 1000;
|
| 197 |
+
|
| 198 |
+
fields
|
| 199 |
+
(
|
| 200 |
+
U
|
| 201 |
+
{
|
| 202 |
+
mean on;
|
| 203 |
+
prime2Mean on;
|
| 204 |
+
base time;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
p
|
| 208 |
+
{
|
| 209 |
+
mean on;
|
| 210 |
+
prime2Mean on;
|
| 211 |
+
base time;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
nut
|
| 215 |
+
{
|
| 216 |
+
mean on;
|
| 217 |
+
prime2Mean on;
|
| 218 |
+
base time;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
k
|
| 222 |
+
{
|
| 223 |
+
mean on;
|
| 224 |
+
prime2Mean off;
|
| 225 |
+
base time;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
omega
|
| 229 |
+
{
|
| 230 |
+
mean on;
|
| 231 |
+
prime2Mean off;
|
| 232 |
+
base time;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
Q
|
| 236 |
+
{
|
| 237 |
+
mean on;
|
| 238 |
+
prime2Mean off;
|
| 239 |
+
base time;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
yPlus
|
| 243 |
+
{
|
| 244 |
+
mean on;
|
| 245 |
+
prime2Mean off;
|
| 246 |
+
base time;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
wallShearStress
|
| 250 |
+
{
|
| 251 |
+
mean on;
|
| 252 |
+
prime2Mean off;
|
| 253 |
+
base time;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
);
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
///////////////////////////////////////////////////////////////////////////
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
///////////////////////////////////////////////////////////////////////////
|
| 263 |
+
|
| 264 |
+
minmaxdomain_vector
|
| 265 |
+
{
|
| 266 |
+
type volFieldValue;
|
| 267 |
+
libs ("libfieldFunctionObjects.so");
|
| 268 |
+
|
| 269 |
+
enabled true; //true or false
|
| 270 |
+
log true; //write to screen
|
| 271 |
+
|
| 272 |
+
//writeControl writeTime;
|
| 273 |
+
writeControl timeStep;
|
| 274 |
+
writeInterval 1;
|
| 275 |
+
|
| 276 |
+
writeFields false; //write solution to field value - Not needed when only reporting value to screen
|
| 277 |
+
|
| 278 |
+
writeLocation true; //write location in the output file
|
| 279 |
+
|
| 280 |
+
//mode component;
|
| 281 |
+
|
| 282 |
+
regionType all;
|
| 283 |
+
|
| 284 |
+
operation none;
|
| 285 |
+
|
| 286 |
+
fields
|
| 287 |
+
(
|
| 288 |
+
U
|
| 289 |
+
);
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
mindomain_scalar
|
| 293 |
+
{
|
| 294 |
+
$minmaxdomain_scalar
|
| 295 |
+
operation min;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
mindomain_vector
|
| 299 |
+
{
|
| 300 |
+
$minmaxdomain_vector
|
| 301 |
+
operation minMag;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
maxdomain_scalar
|
| 305 |
+
{
|
| 306 |
+
$minmaxdomain_scalar
|
| 307 |
+
operation max;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
maxdomain_vector
|
| 311 |
+
{
|
| 312 |
+
$minmaxdomain_vector
|
| 313 |
+
operation maxMag;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
///////////////////////////////////////////////////////////////////////////
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
};
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/decomposeParDict
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
| ========= | |
|
| 3 |
+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| 4 |
+
| \\ / O peration | Version: 7 |
|
| 5 |
+
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
+
| \\/ M anipulation | |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
version 2.0;
|
| 11 |
+
format ascii;
|
| 12 |
+
class dictionary;
|
| 13 |
+
object decomposeParDict;
|
| 14 |
+
}
|
| 15 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
+
|
| 17 |
+
numberOfSubdomains 12;
|
| 18 |
+
method scotch;
|
| 19 |
+
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/fvConstraints
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
========= |
|
| 3 |
+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
| 4 |
+
\\ / O peration | Website: https://openfoam.org
|
| 5 |
+
\\ / A nd | Version: 9
|
| 6 |
+
\\/ M anipulation |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
format ascii;
|
| 11 |
+
class dictionary;
|
| 12 |
+
object fvConstraints;
|
| 13 |
+
}
|
| 14 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 15 |
+
|
| 16 |
+
//To control on/off just modify the value.
|
| 17 |
+
//In this case a large value is like off
|
| 18 |
+
//Use from the begining so the object it is created
|
| 19 |
+
|
| 20 |
+
limitU
|
| 21 |
+
{
|
| 22 |
+
type limitVelocity;
|
| 23 |
+
selectionMode all;
|
| 24 |
+
max 200; //100 - 10000 (large value is off)
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
//************************************************************************** //
|
| 28 |
+
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/fvSchemes
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
========= |
|
| 3 |
+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
| 4 |
+
\\ / O peration | Website: https://openfoam.org
|
| 5 |
+
\\ / A nd | Version: 9
|
| 6 |
+
\\/ M anipulation |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
format ascii;
|
| 11 |
+
class dictionary;
|
| 12 |
+
object fvSchemes;
|
| 13 |
+
}
|
| 14 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 15 |
+
|
| 16 |
+
ddtSchemes
|
| 17 |
+
{
|
| 18 |
+
default steadyState;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
gradSchemes
|
| 22 |
+
{
|
| 23 |
+
//default Gauss linear;
|
| 24 |
+
default cellLimited Gauss linear 1;
|
| 25 |
+
grad(U) cellLimited Gauss linear 1;
|
| 26 |
+
grad(k) cellLimited Gauss linear 1;
|
| 27 |
+
grad(omega) cellLimited Gauss linear 1;
|
| 28 |
+
grad(p) cellLimited Gauss linear 0.333;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
divSchemes
|
| 32 |
+
{
|
| 33 |
+
default none;
|
| 34 |
+
|
| 35 |
+
//div(phi,U) bounded Gauss linearUpwindV grad(U);
|
| 36 |
+
div(phi,U) bounded Gauss linearUpwind grad(U);
|
| 37 |
+
|
| 38 |
+
//div(phi,k) bounded Gauss linearUpwind grad(k);
|
| 39 |
+
//div(phi,omega) bounded Gauss linearUpwind grad(omega);
|
| 40 |
+
div(phi,k) bounded Gauss upwind;
|
| 41 |
+
div(phi,omega) bounded Gauss upwind;
|
| 42 |
+
|
| 43 |
+
div((nuEff*dev2(T(grad(U))))) Gauss linear;
|
| 44 |
+
|
| 45 |
+
//For potentialFoam
|
| 46 |
+
div(div(phi,U)) Gauss linear;
|
| 47 |
+
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
interpolationSchemes
|
| 51 |
+
{
|
| 52 |
+
//default linear;
|
| 53 |
+
default skewCorrected linear;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
laplacianSchemes
|
| 57 |
+
{
|
| 58 |
+
default Gauss linear limited 0.5;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
snGradSchemes
|
| 62 |
+
{
|
| 63 |
+
default limited 0.5;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
wallDist
|
| 67 |
+
{
|
| 68 |
+
method meshWave;
|
| 69 |
+
}
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/fvSolution
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
========= |
|
| 3 |
+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
| 4 |
+
\\ / O peration | Website: https://openfoam.org
|
| 5 |
+
\\ / A nd | Version: 9
|
| 6 |
+
\\/ M anipulation |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
format ascii;
|
| 11 |
+
class dictionary;
|
| 12 |
+
object fvSolution;
|
| 13 |
+
}
|
| 14 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 15 |
+
|
| 16 |
+
solvers
|
| 17 |
+
{
|
| 18 |
+
p
|
| 19 |
+
{
|
| 20 |
+
|
| 21 |
+
solver GAMG;
|
| 22 |
+
tolerance 1e-06;
|
| 23 |
+
relTol 0.01;
|
| 24 |
+
smoother GaussSeidel;
|
| 25 |
+
nPreSweeps 0;
|
| 26 |
+
nPostSweeps 2;
|
| 27 |
+
nFinestSweeps 2;
|
| 28 |
+
cacheAgglomeration on;
|
| 29 |
+
nCellsInCoarsestLevel 10;
|
| 30 |
+
agglomerator faceAreaPair;
|
| 31 |
+
mergeLevels 1;
|
| 32 |
+
/*
|
| 33 |
+
|
| 34 |
+
solver PCG;
|
| 35 |
+
preconditioner
|
| 36 |
+
{
|
| 37 |
+
preconditioner GAMG;
|
| 38 |
+
tolerance 1e-06; //1e-06 1e-08
|
| 39 |
+
relTol 0.0; //0.01 0
|
| 40 |
+
nVcycles 2;
|
| 41 |
+
smoother GaussSeidel;
|
| 42 |
+
nPreSweeps 0;
|
| 43 |
+
nPostSweeps 2;
|
| 44 |
+
nFinestSweeps 2;
|
| 45 |
+
cacheAgglomeration false;
|
| 46 |
+
nCellsInCoarsestLevel 10;
|
| 47 |
+
agglomerator faceAreaPair;
|
| 48 |
+
mergeLevels 1;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
tolerance 1e-06;
|
| 52 |
+
relTol 0.01;
|
| 53 |
+
//maxIter 20;
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
solver PCG;
|
| 57 |
+
preconditioner DIC;
|
| 58 |
+
tolerance 1e-6;
|
| 59 |
+
relTol 0.01;
|
| 60 |
+
*/
|
| 61 |
+
|
| 62 |
+
minIter 3;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
U
|
| 66 |
+
{
|
| 67 |
+
solver PBiCGStab;
|
| 68 |
+
preconditioner DILU;
|
| 69 |
+
tolerance 1e-08; //1e-08
|
| 70 |
+
relTol 0.001; //0.1 0.01
|
| 71 |
+
|
| 72 |
+
minIter 3;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
k
|
| 76 |
+
{
|
| 77 |
+
solver PBiCGStab;
|
| 78 |
+
preconditioner DILU;
|
| 79 |
+
tolerance 1e-08; //1e-08
|
| 80 |
+
relTol 0.001; //0.1 0.01
|
| 81 |
+
|
| 82 |
+
minIter 3;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
omega
|
| 86 |
+
{
|
| 87 |
+
solver PBiCGStab;
|
| 88 |
+
preconditioner DILU;
|
| 89 |
+
tolerance 1e-08; //1e-08
|
| 90 |
+
relTol 0.001; //0.1 0.01
|
| 91 |
+
|
| 92 |
+
minIter 3;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/*
|
| 96 |
+
Phi
|
| 97 |
+
{
|
| 98 |
+
$p;
|
| 99 |
+
}
|
| 100 |
+
*/
|
| 101 |
+
|
| 102 |
+
Phi
|
| 103 |
+
{
|
| 104 |
+
solver GAMG;
|
| 105 |
+
agglomerator faceAreaPair;
|
| 106 |
+
mergeLevels 1;
|
| 107 |
+
cacheAgglomeration true;
|
| 108 |
+
nCellsInCoarsestLevel 200;
|
| 109 |
+
tolerance 1e-8;
|
| 110 |
+
relTol 0.001;
|
| 111 |
+
smoother GaussSeidel;
|
| 112 |
+
nPreSweeps 0;
|
| 113 |
+
nPostSweeps 2;
|
| 114 |
+
nFinestSweeps 2;
|
| 115 |
+
minIter 3;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
potentialFlow
|
| 121 |
+
{
|
| 122 |
+
nNonOrthogonalCorrectors 10;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
SIMPLE
|
| 126 |
+
{
|
| 127 |
+
consistent yes;
|
| 128 |
+
nNonOrthogonalCorrectors 2;
|
| 129 |
+
|
| 130 |
+
pRefCell 0;
|
| 131 |
+
pRefValue 0;
|
| 132 |
+
|
| 133 |
+
residualControl
|
| 134 |
+
{
|
| 135 |
+
p 1.0e-4;
|
| 136 |
+
U 1.0e-4;
|
| 137 |
+
k 1.0e-4;
|
| 138 |
+
omega 1.0e-4;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
//SIMPLE
|
| 144 |
+
/*
|
| 145 |
+
relaxationFactors
|
| 146 |
+
{
|
| 147 |
+
fields
|
| 148 |
+
{
|
| 149 |
+
p 0.3;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
equations
|
| 153 |
+
{
|
| 154 |
+
U 0.7;
|
| 155 |
+
k 0.5;
|
| 156 |
+
omega 0.5;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
}
|
| 160 |
+
*/
|
| 161 |
+
|
| 162 |
+
//SIMPLEC
|
| 163 |
+
|
| 164 |
+
relaxationFactors
|
| 165 |
+
{
|
| 166 |
+
fields
|
| 167 |
+
{
|
| 168 |
+
//".*" 0.7;
|
| 169 |
+
p 0.9;
|
| 170 |
+
}
|
| 171 |
+
equations
|
| 172 |
+
{
|
| 173 |
+
//".*" 0.7;
|
| 174 |
+
p 0.9;
|
| 175 |
+
U 0.7;
|
| 176 |
+
k 0.7;
|
| 177 |
+
omega 0.7;
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/meshQualityDict
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
========= |
|
| 3 |
+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
| 4 |
+
\\ / O peration | Website: https://openfoam.org
|
| 5 |
+
\\ / A nd | Version: 9
|
| 6 |
+
\\/ M anipulation |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
format ascii;
|
| 11 |
+
class dictionary;
|
| 12 |
+
object meshQualityDict;
|
| 13 |
+
}
|
| 14 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
maxNonOrtho 75;
|
| 18 |
+
maxBoundarySkewness 4; //Original 20 for better quality 4
|
| 19 |
+
maxInternalSkewness 4;
|
| 20 |
+
|
| 21 |
+
/*
|
| 22 |
+
maxNonOrtho 180;
|
| 23 |
+
maxBoundarySkewness -1;
|
| 24 |
+
maxInternalSkewness -1;
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
maxConcave 80;
|
| 28 |
+
|
| 29 |
+
minVol 1e-13;
|
| 30 |
+
|
| 31 |
+
minTetQuality -1e+30;
|
| 32 |
+
|
| 33 |
+
minArea -1;
|
| 34 |
+
|
| 35 |
+
minTwist 0.02;
|
| 36 |
+
|
| 37 |
+
minDeterminant 0.001;
|
| 38 |
+
|
| 39 |
+
minFaceWeight 0.05;
|
| 40 |
+
//minFaceWeight 0.02;
|
| 41 |
+
|
| 42 |
+
minVolRatio 0.01;
|
| 43 |
+
|
| 44 |
+
minTriangleTwist -1;
|
| 45 |
+
|
| 46 |
+
//minFlatness 0.5;
|
| 47 |
+
|
| 48 |
+
// ************************************************************************* //
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/snappyHexMeshDict
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
| ========= | |
|
| 3 |
+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| 4 |
+
| \\ / O peration | Version: 7 |
|
| 5 |
+
| \\ / A nd | Web: www.OpenFOAM.com |
|
| 6 |
+
| \\/ M anipulation | |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
version 2.0;
|
| 11 |
+
format ascii;
|
| 12 |
+
class dictionary;
|
| 13 |
+
object snappyHexMeshDict;
|
| 14 |
+
}
|
| 15 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 16 |
+
#include "../include/config"
|
| 17 |
+
|
| 18 |
+
/***************************************************/
|
| 19 |
+
castellatedMesh true;
|
| 20 |
+
snap true;
|
| 21 |
+
addLayers true;
|
| 22 |
+
/***************************************************/
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
/***************************************************/
|
| 27 |
+
|
| 28 |
+
geometry
|
| 29 |
+
{
|
| 30 |
+
|
| 31 |
+
car.stl
|
| 32 |
+
{
|
| 33 |
+
type triSurfaceMesh;
|
| 34 |
+
name car;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
vr1
|
| 39 |
+
{
|
| 40 |
+
type searchableBox;
|
| 41 |
+
min $!config/vr1_min;
|
| 42 |
+
max $!config/vr1_max;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
vr2
|
| 46 |
+
{
|
| 47 |
+
type searchableBox;
|
| 48 |
+
min $!config/vr2_min;
|
| 49 |
+
max $!config/vr2_max;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
vr3
|
| 53 |
+
{
|
| 54 |
+
type searchableBox;
|
| 55 |
+
min $!config/vr3_min;
|
| 56 |
+
max $!config/vr3_max;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
vr4
|
| 60 |
+
{
|
| 61 |
+
type searchableBox;
|
| 62 |
+
min $!config/vr4_min;
|
| 63 |
+
max $!config/vr4_max;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
/*
|
| 68 |
+
vr1
|
| 69 |
+
{
|
| 70 |
+
type searchableBox;
|
| 71 |
+
min ( -7.5 -3.0 -0.3 );
|
| 72 |
+
max ( 25.0 3.0 3.7 );
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
vr2
|
| 76 |
+
{
|
| 77 |
+
type searchableBox;
|
| 78 |
+
//min ( -3.0 0.0 0.0 );
|
| 79 |
+
//max ( 15.0 2.0 3.0 );
|
| 80 |
+
min ( -2.0 -2.0 -0.3 );
|
| 81 |
+
max ( 9.0 2.0 1.7 ); // 6.0 2.0 1.7
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
vr3
|
| 85 |
+
{
|
| 86 |
+
type searchableBox;
|
| 87 |
+
min ( 2.5 -1.5 -0.3 );
|
| 88 |
+
max ( 7.5 1.5 1.4 ); // 6.5 1.5 1.4
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
vr4
|
| 92 |
+
{
|
| 93 |
+
type searchableBox;
|
| 94 |
+
min ( 3.2 -1 -0.3 );
|
| 95 |
+
max ( 6.2 1.0 1.0 ); // 5.2 1.0 1.0
|
| 96 |
+
}
|
| 97 |
+
*/
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/***************************************************/
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
/***************************************************/
|
| 105 |
+
|
| 106 |
+
castellatedMeshControls
|
| 107 |
+
{
|
| 108 |
+
|
| 109 |
+
maxLocalCells 5000000;
|
| 110 |
+
maxGlobalCells 30000000; //*******
|
| 111 |
+
minRefinementCells 0;
|
| 112 |
+
nCellsBetweenLevels 10; // 5
|
| 113 |
+
resolveFeatureAngle 30.0; //curvature
|
| 114 |
+
allowFreeStandingZoneFaces true;
|
| 115 |
+
planarAngle 30.0;
|
| 116 |
+
maxLoadUnbalance 0.1;
|
| 117 |
+
|
| 118 |
+
locationInMesh (10.0 1.0 1.0 );
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
//////////////////////////////////////
|
| 122 |
+
features
|
| 123 |
+
(
|
| 124 |
+
|
| 125 |
+
{
|
| 126 |
+
file "car.eMesh";
|
| 127 |
+
levels ((0.025 0));
|
| 128 |
+
//level 0;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
);
|
| 132 |
+
//////////////////////////////////////
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
//////////////////////////////////////
|
| 136 |
+
refinementSurfaces
|
| 137 |
+
{
|
| 138 |
+
car
|
| 139 |
+
{
|
| 140 |
+
level ( 4 5 ); // 2 4 - 4 4
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
}
|
| 144 |
+
//////////////////////////////////////
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
//////////////////////////////////////
|
| 148 |
+
refinementRegions
|
| 149 |
+
{
|
| 150 |
+
|
| 151 |
+
vr1
|
| 152 |
+
{
|
| 153 |
+
mode inside;
|
| 154 |
+
levels (( 1E5 1 ));
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
vr2
|
| 158 |
+
{
|
| 159 |
+
mode inside;
|
| 160 |
+
levels (( 1E5 2 ));
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
vr3
|
| 164 |
+
{
|
| 165 |
+
mode inside;
|
| 166 |
+
levels (( 1E5 3 ));
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
vr4
|
| 170 |
+
{
|
| 171 |
+
mode inside;
|
| 172 |
+
levels (( 1E5 4 )); // 1E5 4
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
}
|
| 176 |
+
//////////////////////////////////////
|
| 177 |
+
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
/***************************************************/
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
/***************************************************/
|
| 185 |
+
|
| 186 |
+
snapControls
|
| 187 |
+
{
|
| 188 |
+
|
| 189 |
+
// Number of patch smoothing iterations before finding correspondence
|
| 190 |
+
// to surface
|
| 191 |
+
nSmoothPatch 3; //recommended
|
| 192 |
+
//nSmoothPatch 10; //improved
|
| 193 |
+
|
| 194 |
+
tolerance 2.0;
|
| 195 |
+
//tolerance 1.0;
|
| 196 |
+
|
| 197 |
+
nSolveIter 30; //recommended
|
| 198 |
+
//nSolveIter 100; //improved
|
| 199 |
+
|
| 200 |
+
nRelaxIter 5; //default
|
| 201 |
+
//nRelaxIter 10; //improved 10-20-50
|
| 202 |
+
|
| 203 |
+
// Feature snapping
|
| 204 |
+
|
| 205 |
+
// Number of feature edge snapping iterations.
|
| 206 |
+
// Leave out altogether to disable.
|
| 207 |
+
nFeatureSnapIter 10; //recommended
|
| 208 |
+
//nFeatureSnapIter 100; //improved 20-50-100
|
| 209 |
+
|
| 210 |
+
// Detect (geometric only) features by sampling the surface
|
| 211 |
+
// (default=false).
|
| 212 |
+
implicitFeatureSnap false;
|
| 213 |
+
|
| 214 |
+
// Use castellatedMeshControls::features (default = true)
|
| 215 |
+
explicitFeatureSnap true;
|
| 216 |
+
|
| 217 |
+
// Detect features between multiple surfaces
|
| 218 |
+
// (only for explicitFeatureSnap, default = false)
|
| 219 |
+
multiRegionFeatureSnap false;
|
| 220 |
+
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
/***************************************************/
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
/***************************************************/
|
| 229 |
+
|
| 230 |
+
addLayersControls
|
| 231 |
+
{
|
| 232 |
+
|
| 233 |
+
/////////////////////////////////////////////
|
| 234 |
+
relativeSizes true;
|
| 235 |
+
|
| 236 |
+
expansionRatio 1.2; //1.0;
|
| 237 |
+
finalLayerThickness 0.3;
|
| 238 |
+
minThickness 0.01; //0.1 0.25
|
| 239 |
+
/////////////////////////////////////////////
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
layers
|
| 243 |
+
{
|
| 244 |
+
|
| 245 |
+
car
|
| 246 |
+
{
|
| 247 |
+
nSurfaceLayers 6;
|
| 248 |
+
expansionRatio 1.1;
|
| 249 |
+
finalLayerThickness 0.3;
|
| 250 |
+
minThickness 0.01;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
ground
|
| 254 |
+
{
|
| 255 |
+
nSurfaceLayers 6;
|
| 256 |
+
expansionRatio 1.2;
|
| 257 |
+
finalLayerThickness 0.3;
|
| 258 |
+
minThickness 0.01;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
/////////////////////////////////////////////
|
| 265 |
+
nGrow 0;
|
| 266 |
+
|
| 267 |
+
featureAngle 130.0;
|
| 268 |
+
|
| 269 |
+
maxFaceThicknessRatio 0.5;
|
| 270 |
+
|
| 271 |
+
nSmoothSurfaceNormals 1;
|
| 272 |
+
nSmoothNormals 3;
|
| 273 |
+
nSmoothThickness 10;
|
| 274 |
+
|
| 275 |
+
slipFeatureAngle 30.0;
|
| 276 |
+
nRelaxIter 5;
|
| 277 |
+
|
| 278 |
+
maxThicknessToMedialRatio 0.3;
|
| 279 |
+
|
| 280 |
+
minMedialAxisAngle 90;
|
| 281 |
+
minMedianAxisAngle 90;
|
| 282 |
+
|
| 283 |
+
nBufferCellsNoExtrude 0;
|
| 284 |
+
nLayerIter 50;
|
| 285 |
+
nRelaxedIter 20;
|
| 286 |
+
|
| 287 |
+
//writeVTK false;
|
| 288 |
+
//noErrors false;
|
| 289 |
+
//layerRecovery 1;
|
| 290 |
+
//growZoneLayers false;
|
| 291 |
+
//projectGrownUp 0.0;
|
| 292 |
+
/////////////////////////////////////////////
|
| 293 |
+
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
/***************************************************/
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
/***************************************************/
|
| 302 |
+
|
| 303 |
+
meshQualityControls
|
| 304 |
+
{
|
| 305 |
+
#include "meshQualityDict"
|
| 306 |
+
|
| 307 |
+
nSmoothScale 4;
|
| 308 |
+
errorReduction 0.75;
|
| 309 |
+
|
| 310 |
+
relaxed
|
| 311 |
+
{
|
| 312 |
+
maxNonOrtho 75;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
/***************************************************/
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
debug 0;
|
| 321 |
+
mergeTolerance 1.0E-6;
|
| 322 |
+
//autoBlockMesh false;
|
cfd_workflow_20261012/_seiler_ref/example_INIT_30_sim/system/surfaceFeaturesDict
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*--------------------------------*- C++ -*----------------------------------*\
|
| 2 |
+
========= |
|
| 3 |
+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
| 4 |
+
\\ / O peration | Website: https://openfoam.org
|
| 5 |
+
\\ / A nd | Version: 9
|
| 6 |
+
\\/ M anipulation |
|
| 7 |
+
\*---------------------------------------------------------------------------*/
|
| 8 |
+
FoamFile
|
| 9 |
+
{
|
| 10 |
+
format ascii;
|
| 11 |
+
class dictionary;
|
| 12 |
+
object surfaceFeatureExtractDict;
|
| 13 |
+
}
|
| 14 |
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
| 15 |
+
|
| 16 |
+
surfaces ("car.stl");
|
| 17 |
+
|
| 18 |
+
extractionMethod extractFromSurface;
|
| 19 |
+
|
| 20 |
+
includedAngle 150;
|
| 21 |
+
|
| 22 |
+
subsetFeatures
|
| 23 |
+
{
|
| 24 |
+
// Keep nonManifold edges (edges with >2 connected faces)
|
| 25 |
+
nonManifoldEdges yes;
|
| 26 |
+
|
| 27 |
+
// Keep open edges (edges with 1 connected face)
|
| 28 |
+
openEdges yes;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
// Write features to obj format for postprocessing
|
| 32 |
+
writeObj yes;
|
| 33 |
+
|
| 34 |
+
// ************************************************************************* //
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/compute_force_chair.py
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import trimesh
|
| 3 |
+
import numpy as np
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
+
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
|
| 6 |
+
import os
|
| 7 |
+
import json
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def detect_seat_bbox_auto(mesh_path, up_axis=1, shrink_factor=0.60):
|
| 11 |
+
"""
|
| 12 |
+
Détecte la Bounding Box de l'assise d'une chaise avec calcul automatique de l'épaisseur.
|
| 13 |
+
- shrink_factor: Réduit la taille (X, Z) pour analyser uniquement le "cœur" de l'assise
|
| 14 |
+
et éviter de prendre en compte les pieds sur les côtés. (0.60 = 60% du centre)
|
| 15 |
+
"""
|
| 16 |
+
# 1. Charger le mesh
|
| 17 |
+
mesh = trimesh.load(mesh_path, force='mesh')
|
| 18 |
+
up_vector = np.zeros(3)
|
| 19 |
+
up_vector[up_axis] = 1.0
|
| 20 |
+
bounds_min, bounds_max = mesh.bounds
|
| 21 |
+
mesh.vertices = (mesh.vertices - bounds_min) / (bounds_max - bounds_min)
|
| 22 |
+
|
| 23 |
+
# 2. Filtrer les faces horizontales
|
| 24 |
+
dot_products = np.dot(mesh.face_normals, up_vector)
|
| 25 |
+
horizontal_faces_mask = dot_products > 0.85
|
| 26 |
+
|
| 27 |
+
if not np.any(horizontal_faces_mask):
|
| 28 |
+
return None, None, mesh
|
| 29 |
+
|
| 30 |
+
horizontal_faces = mesh.faces[horizontal_faces_mask]
|
| 31 |
+
horizontal_vertices = mesh.vertices[np.unique(horizontal_faces.flatten())]
|
| 32 |
+
|
| 33 |
+
# 3. Trouver la hauteur principale de l'assise
|
| 34 |
+
heights = horizontal_vertices[:, up_axis]
|
| 35 |
+
hist, bin_edges = np.histogram(heights, bins=30, range=(0, 1))
|
| 36 |
+
peak_bin = np.argmax(hist)
|
| 37 |
+
seat_height_center = (bin_edges[peak_bin] + bin_edges[peak_bin + 1]) / 2.0
|
| 38 |
+
|
| 39 |
+
# 4. Isoler les sommets de la surface de l'assise
|
| 40 |
+
seat_vertices = horizontal_vertices[np.abs(horizontal_vertices[:, up_axis] - seat_height_center) < 0.05]
|
| 41 |
+
if len(seat_vertices) == 0:
|
| 42 |
+
return None, None, mesh
|
| 43 |
+
|
| 44 |
+
# Bounding Box de base de la surface
|
| 45 |
+
min_bounds = np.min(seat_vertices, axis=0)
|
| 46 |
+
max_bounds = np.max(seat_vertices, axis=0)
|
| 47 |
+
|
| 48 |
+
# 5. Réduire vers le centre sur les axes horizontaux
|
| 49 |
+
axes_horizontaux = [i for i in range(3) if i != up_axis]
|
| 50 |
+
for axis in axes_horizontaux:
|
| 51 |
+
center = (max_bounds[axis] + min_bounds[axis]) / 2.0
|
| 52 |
+
length = max_bounds[axis] - min_bounds[axis]
|
| 53 |
+
min_bounds[axis] = center - (length * shrink_factor / 2.0)
|
| 54 |
+
max_bounds[axis] = center + (length * shrink_factor / 2.0)
|
| 55 |
+
|
| 56 |
+
# --- 6. CALCUL AUTOMATIQUE DE L'ÉPAISSEUR ---
|
| 57 |
+
|
| 58 |
+
# On récupère les limites X et Z de notre "colonne" centrale
|
| 59 |
+
min_h1, min_h2 = min_bounds[axes_horizontaux[0]], min_bounds[axes_horizontaux[1]]
|
| 60 |
+
max_h1, max_h2 = max_bounds[axes_horizontaux[0]], max_bounds[axes_horizontaux[1]]
|
| 61 |
+
|
| 62 |
+
# On sélectionne tous les points du mesh complet qui sont dans cette colonne
|
| 63 |
+
col_mask = (mesh.vertices[:, axes_horizontaux[0]] >= min_h1) & \
|
| 64 |
+
(mesh.vertices[:, axes_horizontaux[0]] <= max_h1) & \
|
| 65 |
+
(mesh.vertices[:, axes_horizontaux[1]] >= min_h2) & \
|
| 66 |
+
(mesh.vertices[:, axes_horizontaux[1]] <= max_h2)
|
| 67 |
+
column_vertices = mesh.vertices[col_mask]
|
| 68 |
+
|
| 69 |
+
y_values = column_vertices[:, up_axis]
|
| 70 |
+
|
| 71 |
+
def find_boundary(y_array, direction, gap_threshold=0.04):
|
| 72 |
+
# direction: -1 pour chercher vers le bas, 1 pour chercher vers le haut
|
| 73 |
+
if len(y_array) == 0:
|
| 74 |
+
return seat_height_center
|
| 75 |
+
|
| 76 |
+
# Trier les hauteurs (décroissant si on va vers le bas, croissant si on va vers le haut)
|
| 77 |
+
if direction == -1:
|
| 78 |
+
y_sorted = np.sort(y_array[y_array <= seat_height_center + 0.01])[::-1]
|
| 79 |
+
else:
|
| 80 |
+
y_sorted = np.sort(y_array[y_array >= seat_height_center - 0.01])
|
| 81 |
+
|
| 82 |
+
if len(y_sorted) < 2:
|
| 83 |
+
return y_sorted[0] if len(y_sorted)>0 else seat_height_center
|
| 84 |
+
|
| 85 |
+
# Calculer l'espace (gap) entre chaque point consécutif
|
| 86 |
+
gaps = np.abs(y_sorted[:-1] - y_sorted[1:])
|
| 87 |
+
|
| 88 |
+
# Trouver le premier endroit où le trou est plus grand que notre seuil
|
| 89 |
+
large_gaps = np.where(gaps > gap_threshold)[0]
|
| 90 |
+
|
| 91 |
+
if len(large_gaps) > 0:
|
| 92 |
+
return y_sorted[large_gaps[0]] # On renvoie le point juste avant le vide
|
| 93 |
+
return y_sorted[-1] # Si c'est un bloc plein jusqu'au bout, on prend la fin
|
| 94 |
+
|
| 95 |
+
# 1. Calculer le bas et le haut EXACTS de l'assise
|
| 96 |
+
# (Attention, j'ai remis gap_threshold=0.04 pour le bottom, tu avais mis 0.4 dans ton message,
|
| 97 |
+
# ce qui risquait de faire descendre la boîte jusqu'au sol !)
|
| 98 |
+
seat_bottom_exact = find_boundary(y_values, direction=-1, gap_threshold=0.4)
|
| 99 |
+
seat_top_exact = find_boundary(y_values, direction=1, gap_threshold=0.04)
|
| 100 |
+
|
| 101 |
+
# 2. Définir tes marges (ex: 0.02 = 2% de la hauteur totale de la chaise)
|
| 102 |
+
margin_bottom = 0.02
|
| 103 |
+
margin_top = 0.02
|
| 104 |
+
|
| 105 |
+
# 3. Appliquer les marges tout en restant dans les limites normalisées (0.0 à 1.0)
|
| 106 |
+
seat_bottom = max(0.0, seat_bottom_exact - margin_bottom)
|
| 107 |
+
seat_top = min(1.0, seat_top_exact + margin_top)
|
| 108 |
+
|
| 109 |
+
min_bounds[up_axis] = seat_bottom
|
| 110 |
+
max_bounds[up_axis] = seat_top
|
| 111 |
+
|
| 112 |
+
return min_bounds, max_bounds, mesh
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def get_box_faces(min_b, max_b):
|
| 116 |
+
"""Génère les 6 faces d'une Bounding Box 3D pour matplotlib."""
|
| 117 |
+
x0, y0, z0 = min_b
|
| 118 |
+
x1, y1, z1 = max_b
|
| 119 |
+
verts = [
|
| 120 |
+
[x0, y0, z0], [x1, y0, z0], [x1, y1, z0], [x0, y1, z0],
|
| 121 |
+
[x0, y0, z1], [x1, y0, z1], [x1, y1, z1], [x0, y1, z1]
|
| 122 |
+
]
|
| 123 |
+
faces = [
|
| 124 |
+
[verts[0], verts[1], verts[2], verts[3]],
|
| 125 |
+
[verts[4], verts[5], verts[6], verts[7]],
|
| 126 |
+
[verts[0], verts[1], verts[5], verts[4]],
|
| 127 |
+
[verts[2], verts[3], verts[7], verts[6]],
|
| 128 |
+
[verts[1], verts[2], verts[6], verts[5]],
|
| 129 |
+
[verts[0], verts[3], verts[7], verts[4]]
|
| 130 |
+
]
|
| 131 |
+
return faces
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def render_chair_bbox(mesh, min_bound, max_bound, output_filename):
|
| 135 |
+
"""Génère 1 seule image contenant les 3 rendus avec correction de l'axe vertical (Y -> Z)."""
|
| 136 |
+
|
| 137 |
+
# 1. Échantillonner le mesh
|
| 138 |
+
num_vertices = len(mesh.vertices)
|
| 139 |
+
step = max(1, num_vertices // 5000)
|
| 140 |
+
sampled_vertices = mesh.vertices[::step]
|
| 141 |
+
|
| 142 |
+
# --- L'ASTUCE EST ICI ---
|
| 143 |
+
# On isole les axes et on échange Y et Z pour l'affichage matplotlib
|
| 144 |
+
x_plot = sampled_vertices[:, 0]
|
| 145 |
+
y_plot = sampled_vertices[:, 2] # La profondeur du mesh devient l'axe Y de matplotlib
|
| 146 |
+
z_plot = sampled_vertices[:, 1] # La hauteur du mesh (Y) devient l'axe vertical Z de matplotlib
|
| 147 |
+
|
| 148 |
+
# 2. Récupérer les faces de la boîte et échanger aussi Y et Z
|
| 149 |
+
box_faces = get_box_faces(min_bound, max_bound)
|
| 150 |
+
box_faces_z_up = []
|
| 151 |
+
for face in box_faces:
|
| 152 |
+
# Pour chaque point [x, y, z], on crée [x, z, y]
|
| 153 |
+
new_face = [[v[0], v[2], v[1]] for v in face]
|
| 154 |
+
box_faces_z_up.append(new_face)
|
| 155 |
+
|
| 156 |
+
# 3. Récupérer les limites et échanger Y et Z
|
| 157 |
+
b = mesh.bounds
|
| 158 |
+
min_x, max_x = b[0][0], b[1][0]
|
| 159 |
+
min_y, max_y = b[0][2], b[1][2] # Ancien Z
|
| 160 |
+
min_z, max_z = b[0][1], b[1][1] # Ancien Y
|
| 161 |
+
|
| 162 |
+
# 4. Définir les vues adaptées (Maintenant que Z est bien en haut)
|
| 163 |
+
views = [
|
| 164 |
+
{"name": "Isométrique", "elev": 20, "azim": -45},
|
| 165 |
+
{"name": "Face", "elev": 0, "azim": -90}, # Regarde l'avant de la chaise
|
| 166 |
+
{"name": "Profil", "elev": 0, "azim": 0} # Regarde le côté
|
| 167 |
+
]
|
| 168 |
+
|
| 169 |
+
fig = plt.figure(figsize=(18, 6))
|
| 170 |
+
|
| 171 |
+
for i, view in enumerate(views, start=1):
|
| 172 |
+
ax = fig.add_subplot(1, 3, i, projection='3d')
|
| 173 |
+
|
| 174 |
+
# A. Dessiner la chaise avec nos axes modifiés
|
| 175 |
+
ax.scatter(
|
| 176 |
+
x_plot, y_plot, z_plot,
|
| 177 |
+
c='gray', s=2, alpha=0.4, marker='.'
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
# B. Dessiner la Bounding Box avec nos axes modifiés
|
| 181 |
+
box_col = Poly3DCollection(box_faces_z_up, alpha=0.4, facecolors='red', edgecolors='darkred')
|
| 182 |
+
ax.add_collection3d(box_col)
|
| 183 |
+
|
| 184 |
+
# C. Cadrage de la caméra
|
| 185 |
+
ax.set_xlim(min_x, max_x)
|
| 186 |
+
ax.set_ylim(min_y, max_y)
|
| 187 |
+
ax.set_zlim(min_z, max_z)
|
| 188 |
+
|
| 189 |
+
# Conserver les proportions
|
| 190 |
+
try:
|
| 191 |
+
ax.set_box_aspect((max_x-min_x, max_y-min_y, max_z-min_z))
|
| 192 |
+
except AttributeError:
|
| 193 |
+
pass
|
| 194 |
+
|
| 195 |
+
# Appliquer l'angle de vue
|
| 196 |
+
ax.view_init(elev=view["elev"], azim=view["azim"])
|
| 197 |
+
ax.set_title(f"Vue : {view['name']}")
|
| 198 |
+
ax.set_axis_off()
|
| 199 |
+
|
| 200 |
+
plt.tight_layout()
|
| 201 |
+
plt.savefig(output_filename, dpi=150, bbox_inches='tight')
|
| 202 |
+
plt.close(fig)
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
def main():
|
| 206 |
+
parser = argparse.ArgumentParser(description="Batch process chair meshes to extract seat bbox.")
|
| 207 |
+
parser.add_argument("--folder", required=True, help="Input directory containing chair folders.")
|
| 208 |
+
parser.add_argument("--instance-file", required=True, help="File with instance to optimize")
|
| 209 |
+
parser.add_argument("-s", "--shrink", type=float, default=0.60, help="Shrink factor for bbox (default: 0.60).")
|
| 210 |
+
parser.add_argument("-r", "--rotation", choices=['none', 'x_up', 'y_up'], default='y_up', help="Rotation fix (default: y_up).")
|
| 211 |
+
args = parser.parse_args()
|
| 212 |
+
|
| 213 |
+
# Chemins ajustés
|
| 214 |
+
input_folder = f"/scratch/cvlab/home/seiler/physiopt_new/output/hunyuan_gen/{args.folder}"
|
| 215 |
+
output_folder = f"/scratch/cvlab/home/seiler/physiopt_new/output_force/hunyuan_gen/{args.folder}"
|
| 216 |
+
os.makedirs(output_folder, exist_ok=True)
|
| 217 |
+
print(f"Processing folders in: {input_folder}")
|
| 218 |
+
|
| 219 |
+
with open(os.path.join("file_for_exp", args.instance_file), "r") as f:
|
| 220 |
+
instance_optimize = json.load(f)
|
| 221 |
+
count = 0
|
| 222 |
+
|
| 223 |
+
for folder_name in os.listdir(input_folder):
|
| 224 |
+
if folder_name in instance_optimize:
|
| 225 |
+
input_subdir = os.path.join(input_folder, folder_name)
|
| 226 |
+
mesh_file = os.path.join(input_subdir, "generated_mesh.obj")
|
| 227 |
+
|
| 228 |
+
if os.path.isdir(input_subdir) and os.path.exists(mesh_file):
|
| 229 |
+
out_subdir = os.path.join(output_folder, folder_name)
|
| 230 |
+
os.makedirs(out_subdir, exist_ok=True)
|
| 231 |
+
|
| 232 |
+
try:
|
| 233 |
+
# Traitement de la chaise
|
| 234 |
+
min_bounds, max_bounds, mesh = detect_seat_bbox_auto(mesh_file)
|
| 235 |
+
# Construction de l'output force [x_min, x_max, y_min, y_max, z_min, z_max]
|
| 236 |
+
config = {
|
| 237 |
+
"force": [0.0, -300000.0, 0.0],
|
| 238 |
+
"force_region_mode": "bbox",
|
| 239 |
+
"force_bbox_ratio": [
|
| 240 |
+
float(min_bounds[0]), float(max_bounds[0]),
|
| 241 |
+
float(min_bounds[1]), float(max_bounds[1]),
|
| 242 |
+
float(min_bounds[2]), float(max_bounds[2])
|
| 243 |
+
]
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
with open(os.path.join(out_subdir, "force_config.json"), 'w') as f:
|
| 247 |
+
json.dump(config, f, indent=2)
|
| 248 |
+
|
| 249 |
+
render_chair_bbox(mesh, min_bounds, max_bounds, os.path.join(out_subdir, "plot.png"))
|
| 250 |
+
print(f"✅ Success: {folder_name}")
|
| 251 |
+
count += 1
|
| 252 |
+
|
| 253 |
+
except Exception as e:
|
| 254 |
+
print(f"❌ Failed: {folder_name} | Error: {e}")
|
| 255 |
+
|
| 256 |
+
print(f"🎉 Batch processing complete for {count} shapes")
|
| 257 |
+
|
| 258 |
+
if __name__ == "__main__":
|
| 259 |
+
main()
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/compute_force_table.py
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import trimesh
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
import matplotlib.pyplot as plt
|
| 6 |
+
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
|
| 7 |
+
import os
|
| 8 |
+
import json
|
| 9 |
+
|
| 10 |
+
def process_mesh(mesh_path, rot_fix, margin):
|
| 11 |
+
"""Loads mesh, fixes orientation, normalizes Z, and calculates t_final."""
|
| 12 |
+
mesh = trimesh.load(mesh_path, force='mesh')
|
| 13 |
+
|
| 14 |
+
# Fix orientation
|
| 15 |
+
if rot_fix == 'y_up':
|
| 16 |
+
q = trimesh.transformations.quaternion_about_axis(np.radians(90), [1, 0, 0])
|
| 17 |
+
mesh.apply_transform(trimesh.transformations.quaternion_matrix(q))
|
| 18 |
+
elif rot_fix == 'x_up':
|
| 19 |
+
q = trimesh.transformations.quaternion_about_axis(np.radians(-90), [1, 0, 0])
|
| 20 |
+
mesh.apply_transform(trimesh.transformations.quaternion_matrix(q))
|
| 21 |
+
|
| 22 |
+
# Normalize Z axis between 0 and 1
|
| 23 |
+
z_min, z_max = mesh.vertices[:, 2].min(), mesh.vertices[:, 2].max()
|
| 24 |
+
mesh.vertices[:, 2] = (mesh.vertices[:, 2] - z_min) / (z_max - z_min)
|
| 25 |
+
|
| 26 |
+
# Find downward-facing faces in the upper half of the mesh
|
| 27 |
+
mask = (mesh.face_normals[:, 2] < -0.8) & (mesh.triangles_center[:, 2] > 0.5)
|
| 28 |
+
z_vals = np.round(mesh.triangles_center[mask, 2], decimals=3)
|
| 29 |
+
areas = mesh.area_faces[mask]
|
| 30 |
+
|
| 31 |
+
# Find the Z level with the largest flat area
|
| 32 |
+
unique_z = np.unique(z_vals)
|
| 33 |
+
t_exact = unique_z[np.argmax([np.sum(areas[z_vals == z]) for z in unique_z])]
|
| 34 |
+
|
| 35 |
+
# Calculate t_final with the adaptive margin
|
| 36 |
+
t_final = float(t_exact - ((1.0 - t_exact) * margin))
|
| 37 |
+
return mesh, t_final
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def save_plot(mesh, t, save_path):
|
| 41 |
+
"""Saves a 3D PNG plot instantly using a point cloud for the mesh."""
|
| 42 |
+
fig = plt.figure(figsize=(18, 6))
|
| 43 |
+
|
| 44 |
+
# 1. Obtenir les limites pour la taille du plan
|
| 45 |
+
b = mesh.bounds
|
| 46 |
+
mx, my = (b[1] - b[0])[:2] * 0.2
|
| 47 |
+
min_x, max_x = b[0][0] - mx, b[1][0] + mx
|
| 48 |
+
min_y, max_y = b[0][1] - my, b[1][1] + my
|
| 49 |
+
|
| 50 |
+
plane_verts = [[
|
| 51 |
+
(min_x, min_y, t), (max_x, min_y, t),
|
| 52 |
+
(max_x, max_y, t), (min_x, max_y, t)
|
| 53 |
+
]]
|
| 54 |
+
|
| 55 |
+
# --- L'ASTUCE EST ICI ---
|
| 56 |
+
# Au lieu d'extraire les faces, on prend juste les sommets (vertices).
|
| 57 |
+
# On calcule un 'step' pour ne garder qu'environ 5000 points maximum.
|
| 58 |
+
# C'est largement suffisant pour voir la forme de la table sans faire ramer le PC.
|
| 59 |
+
num_vertices = len(mesh.vertices)
|
| 60 |
+
step = max(1, num_vertices // 5000)
|
| 61 |
+
sampled_vertices = mesh.vertices[::step]
|
| 62 |
+
# ------------------------
|
| 63 |
+
|
| 64 |
+
views = [
|
| 65 |
+
{"title": "Vue Isométrique", "elev": 30, "azim": 45},
|
| 66 |
+
{"title": "Vue de Profil (Z)", "elev": 0, "azim": 0},
|
| 67 |
+
{"title": "Vue de Dessous", "elev": -90, "azim": 0}
|
| 68 |
+
]
|
| 69 |
+
|
| 70 |
+
for i, view in enumerate(views, start=1):
|
| 71 |
+
ax = fig.add_subplot(1, 3, i, projection='3d')
|
| 72 |
+
|
| 73 |
+
# Afficher la table comme un nuage de points (ultra rapide)
|
| 74 |
+
ax.scatter(
|
| 75 |
+
sampled_vertices[:, 0], sampled_vertices[:, 1], sampled_vertices[:, 2],
|
| 76 |
+
c='gray', s=1, alpha=0.3, marker='.'
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
# Le plan reste un polygone (il n'a que 4 sommets, donc c'est instantané)
|
| 80 |
+
plane_col = Poly3DCollection(plane_verts, alpha=0.5, facecolors='red')
|
| 81 |
+
ax.add_collection3d(plane_col)
|
| 82 |
+
|
| 83 |
+
ax.set_xlim(min_x, max_x)
|
| 84 |
+
ax.set_ylim(min_y, max_y)
|
| 85 |
+
ax.set_zlim(b[0][2], b[1][2])
|
| 86 |
+
|
| 87 |
+
try:
|
| 88 |
+
ax.set_box_aspect((max_x-min_x, max_y-min_y, b[1][2]-b[0][2]))
|
| 89 |
+
except AttributeError:
|
| 90 |
+
pass
|
| 91 |
+
|
| 92 |
+
ax.view_init(elev=view["elev"], azim=view["azim"])
|
| 93 |
+
ax.set_title(view["title"])
|
| 94 |
+
ax.set_xlabel('X')
|
| 95 |
+
ax.set_ylabel('Y')
|
| 96 |
+
ax.set_zlabel('Z')
|
| 97 |
+
|
| 98 |
+
plt.suptitle(f"Table Bottom Z = {t:.3f}", fontsize=16)
|
| 99 |
+
|
| 100 |
+
plt.tight_layout()
|
| 101 |
+
plt.savefig(save_path, dpi=150, bbox_inches='tight')
|
| 102 |
+
plt.close(fig)
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def main():
|
| 106 |
+
# --- Parse Command Line Arguments ---
|
| 107 |
+
parser = argparse.ArgumentParser(description="Batch process table meshes to extract bottom T value.")
|
| 108 |
+
parser.add_argument("--folder", required=True, help="Input directory containing table folders.")
|
| 109 |
+
parser.add_argument("--instance-file", required=True, help="File with instance to optimize")
|
| 110 |
+
parser.add_argument("-m", "--margin", type=float, default=0.5, help="Margin percentage (default: 0.5).")
|
| 111 |
+
parser.add_argument("-r", "--rotation", choices=['none', 'x_up', 'y_up'], default='y_up', help="Rotation fix (default: y_up).")
|
| 112 |
+
args = parser.parse_args()
|
| 113 |
+
|
| 114 |
+
input_folder = "/scratch/cvlab/home/seiler/physiopt_new/output/hunyuan_gen" + f"/{args.folder}"
|
| 115 |
+
output_folder = "/scratch/cvlab/home/seiler/physiopt_new/output_force/hunyuan_gen" + f"/{args.folder}"
|
| 116 |
+
os.makedirs(output_folder, exist_ok=True)
|
| 117 |
+
print(f"Processing folders in: {input_folder}")
|
| 118 |
+
|
| 119 |
+
with open(os.path.join("file_for_exp", args.instance_file), "r") as f:
|
| 120 |
+
instance_optimize = json.load(f)
|
| 121 |
+
count = 0
|
| 122 |
+
|
| 123 |
+
# --- Batch Processing Loop ---
|
| 124 |
+
for folder_name in os.listdir(input_folder):
|
| 125 |
+
if folder_name in instance_optimize:
|
| 126 |
+
input_subdir = os.path.join(input_folder, folder_name)
|
| 127 |
+
mesh_file = os.path.join(input_subdir, "generated_mesh.obj")
|
| 128 |
+
|
| 129 |
+
if os.path.isdir(input_subdir) and os.path.exists(mesh_file):
|
| 130 |
+
out_subdir = os.path.join(output_folder, folder_name)
|
| 131 |
+
os.makedirs(out_subdir, exist_ok=True)
|
| 132 |
+
|
| 133 |
+
try:
|
| 134 |
+
mesh, t_final = process_mesh(mesh_file, args.rotation, args.margin)
|
| 135 |
+
|
| 136 |
+
config = {
|
| 137 |
+
"force": [0.0, -100000.0, 0.0],
|
| 138 |
+
"force_region_mode": "bbox",
|
| 139 |
+
"force_bbox_ratio": [0.0, 1.0, 1.0, t_final, 0.0, 1.0]
|
| 140 |
+
}
|
| 141 |
+
with open(os.path.join(out_subdir, "force_config.json"), 'w') as f:
|
| 142 |
+
json.dump(config, f, indent=2)
|
| 143 |
+
|
| 144 |
+
save_plot(mesh, t_final, os.path.join(out_subdir, "plot.png"))
|
| 145 |
+
print(f"✅ Success: {folder_name} (t_final={t_final:.3f})")
|
| 146 |
+
count += 1
|
| 147 |
+
|
| 148 |
+
except Exception as e:
|
| 149 |
+
print(f"❌ Failed: {folder_name} | Error: {e}")
|
| 150 |
+
|
| 151 |
+
print(f"🎉 Batch processing complete for {count} shape")
|
| 152 |
+
|
| 153 |
+
if __name__ == "__main__":
|
| 154 |
+
main()
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/compute_metrics.py
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import argparse
|
| 3 |
+
import logging
|
| 4 |
+
import json
|
| 5 |
+
import torch
|
| 6 |
+
import trimesh
|
| 7 |
+
from tqdm.auto import tqdm
|
| 8 |
+
|
| 9 |
+
# Custom imports (ensure these are available in your PYTHONPATH)
|
| 10 |
+
import sys
|
| 11 |
+
sys.path.append("../smoothSDF")
|
| 12 |
+
from src_optimization.global_metrics import compute_final_distribution_metrics
|
| 13 |
+
from src_optimization.features_extractor import PointNetExtractor, DINOv2Extractor, InceptionV3Extractor
|
| 14 |
+
from src_optimization.features_extractor import extract_features_step
|
| 15 |
+
|
| 16 |
+
def setup_logging():
|
| 17 |
+
"""Sets up the logging configuration to output to the console."""
|
| 18 |
+
logging.basicConfig(
|
| 19 |
+
level=logging.INFO,
|
| 20 |
+
format="%(asctime)s [%(levelname)s] %(message)s",
|
| 21 |
+
datefmt="%Y-%m-%d %H:%M:%S",
|
| 22 |
+
handlers=[logging.StreamHandler()]
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
def parse_args():
|
| 26 |
+
"""Parses command-line arguments."""
|
| 27 |
+
parser = argparse.ArgumentParser(description="Extract features and compute distribution metrics for optimized 3D meshes.")
|
| 28 |
+
|
| 29 |
+
# Paths and folders
|
| 30 |
+
parser.add_argument("--base_dir", type=str, default="/scratch/cvlab/home/seiler/physiopt_new", help="Base directory of the project")
|
| 31 |
+
parser.add_argument("--experiment_folder", type=str, default="table_experiment", help="Name of the experiment folder")
|
| 32 |
+
parser.add_argument("--model_folder", type=str, default="gd_physiopt_64_180", help="Name of the subfolder containing optimized meshes")
|
| 33 |
+
|
| 34 |
+
# Extraction parameters
|
| 35 |
+
parser.add_argument("--max_meshes", type=int, default=9, help="Maximum number of 'decrease' meshes per instance to process")
|
| 36 |
+
parser.add_argument("--num_points", type=int, default=2048, help="Number of sample points for PointNet extraction")
|
| 37 |
+
parser.add_argument("--seed", type=int, default=42, help="Random seed for reproducibility")
|
| 38 |
+
|
| 39 |
+
# Debug/Testing
|
| 40 |
+
parser.add_argument("--test_mode", action="store_true", help="If set, only runs on hardcoded test instances instead of the full folder")
|
| 41 |
+
|
| 42 |
+
return parser.parse_args()
|
| 43 |
+
|
| 44 |
+
def main():
|
| 45 |
+
args = parse_args()
|
| 46 |
+
setup_logging()
|
| 47 |
+
|
| 48 |
+
logging.info("Starting feature extraction and metric computation...")
|
| 49 |
+
logging.info(f"Experiment: {args.experiment_folder} | Model Folder: {args.model_folder}")
|
| 50 |
+
|
| 51 |
+
# Set random seeds
|
| 52 |
+
torch.manual_seed(args.seed)
|
| 53 |
+
torch.cuda.manual_seed(args.seed)
|
| 54 |
+
|
| 55 |
+
# Initialize models
|
| 56 |
+
logging.info("Loading feature extraction models...")
|
| 57 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 58 |
+
logging.info(f"Using device: {device}")
|
| 59 |
+
|
| 60 |
+
model_point = PointNetExtractor().to(device)
|
| 61 |
+
model_dino = DINOv2Extractor().to(device)
|
| 62 |
+
model_inception = InceptionV3Extractor().to(device)
|
| 63 |
+
|
| 64 |
+
models = {
|
| 65 |
+
"pointE": model_point,
|
| 66 |
+
"inception": model_inception,
|
| 67 |
+
"dino": model_dino
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
# Setup paths
|
| 71 |
+
path_folder_experiment = os.path.join(args.base_dir, "output", "hunyuan_gen", args.experiment_folder)
|
| 72 |
+
metrics_path_dir = os.path.join(args.base_dir, "metrics", "hunyuan_gen", args.experiment_folder)
|
| 73 |
+
|
| 74 |
+
os.makedirs(metrics_path_dir, exist_ok=True)
|
| 75 |
+
|
| 76 |
+
# Determine instances to process
|
| 77 |
+
if args.test_mode:
|
| 78 |
+
logging.info("Running in TEST MODE. Only processing specific test instances.")
|
| 79 |
+
instance_list = ["table_0_test", "table_1_test"]
|
| 80 |
+
else:
|
| 81 |
+
if not os.path.exists(path_folder_experiment):
|
| 82 |
+
logging.error(f"Experiment folder not found: {path_folder_experiment}")
|
| 83 |
+
return
|
| 84 |
+
instance_list = sorted([d for d in os.listdir(path_folder_experiment) if os.path.isdir(os.path.join(path_folder_experiment, d))])
|
| 85 |
+
|
| 86 |
+
logging.info(f"Found {len(instance_list)} instances to process.")
|
| 87 |
+
|
| 88 |
+
# Data structures to hold features
|
| 89 |
+
global_features = {"pointE": [], "inception": [], "dino": []}
|
| 90 |
+
number_data = [0 for _ in range(args.max_meshes)]
|
| 91 |
+
|
| 92 |
+
# Feature Extraction Loop
|
| 93 |
+
for instance in tqdm(instance_list, desc="Processing instances"):
|
| 94 |
+
mesh_folder = os.path.join(path_folder_experiment, instance, args.model_folder)
|
| 95 |
+
|
| 96 |
+
if not os.path.exists(mesh_folder):
|
| 97 |
+
logging.warning(f"Mesh folder missing for instance {instance}. Skipping...")
|
| 98 |
+
continue
|
| 99 |
+
|
| 100 |
+
instance_features = {"pointE": [], "inception": [], "dino": []}
|
| 101 |
+
|
| 102 |
+
# Get sorted list of decrease meshes
|
| 103 |
+
decrease_meshes = sorted([m for m in os.listdir(mesh_folder) if m.startswith('decrease') and m.endswith('.obj')])
|
| 104 |
+
|
| 105 |
+
for i, mesh_filename in enumerate(decrease_meshes):
|
| 106 |
+
if i >= args.max_meshes:
|
| 107 |
+
break # Do not exceed max expected meshes
|
| 108 |
+
|
| 109 |
+
mesh_path = os.path.join(mesh_folder, mesh_filename)
|
| 110 |
+
mesh = trimesh.load(mesh_path)
|
| 111 |
+
number_data[i] += 1
|
| 112 |
+
|
| 113 |
+
with torch.no_grad():
|
| 114 |
+
features = extract_features_step(mesh, models, {"SamplePoints": args.num_points}, device)
|
| 115 |
+
instance_features["pointE"].append(features["pointE"])
|
| 116 |
+
instance_features["inception"].append(features["inception"])
|
| 117 |
+
instance_features["dino"].append(features["dino"])
|
| 118 |
+
|
| 119 |
+
# Padding with zeros if fewer meshes were found than expected
|
| 120 |
+
for k in ["pointE", "inception", "dino"]:
|
| 121 |
+
if len(instance_features[k]) == 0:
|
| 122 |
+
logging.warning(f"No features extracted for {k} in instance {instance}.")
|
| 123 |
+
continue
|
| 124 |
+
|
| 125 |
+
dim = instance_features[k][0].shape
|
| 126 |
+
while len(instance_features[k]) < args.max_meshes:
|
| 127 |
+
instance_features[k].append(torch.zeros(dim, dtype=torch.float32).to(device))
|
| 128 |
+
|
| 129 |
+
# Stack features for this instance and append to global tracking
|
| 130 |
+
instance_features[k] = torch.stack(instance_features[k])
|
| 131 |
+
global_features[k].append(instance_features[k])
|
| 132 |
+
|
| 133 |
+
# Computing Global Metrics
|
| 134 |
+
distribution_metrics = {}
|
| 135 |
+
metric_map = [
|
| 136 |
+
("pointE", os.path.join(metrics_path_dir, "pointnetE_features.npy")),
|
| 137 |
+
("inception", os.path.join(metrics_path_dir, "inceptionv3_features.npy")),
|
| 138 |
+
("dino", os.path.join(metrics_path_dir, "dinov2_vits14_features.npy"))
|
| 139 |
+
]
|
| 140 |
+
|
| 141 |
+
logging.info("Starting global metrics computation...")
|
| 142 |
+
for feat_name, spec_key_path in metric_map:
|
| 143 |
+
if not global_features[feat_name]:
|
| 144 |
+
logging.warning(f"No global features collected for {feat_name}. Skipping metrics.")
|
| 145 |
+
continue
|
| 146 |
+
|
| 147 |
+
logging.info(f"Computing global metrics for {feat_name}...")
|
| 148 |
+
try:
|
| 149 |
+
res = compute_final_distribution_metrics(
|
| 150 |
+
global_features[feat_name],
|
| 151 |
+
spec_key_path,
|
| 152 |
+
feat_name
|
| 153 |
+
)
|
| 154 |
+
distribution_metrics.update(res)
|
| 155 |
+
except Exception as e:
|
| 156 |
+
logging.error(f"Failed to compute metrics for {feat_name}: {e}")
|
| 157 |
+
|
| 158 |
+
# Save Results
|
| 159 |
+
distribution_metrics["number_data"] = number_data
|
| 160 |
+
output_json = os.path.join(metrics_path_dir, "metrics.json")
|
| 161 |
+
|
| 162 |
+
with open(output_json, "w") as f:
|
| 163 |
+
json.dump(distribution_metrics, f, indent=4)
|
| 164 |
+
|
| 165 |
+
logging.info(f"Successfully saved metrics to: {output_json}")
|
| 166 |
+
logging.info("Done!")
|
| 167 |
+
|
| 168 |
+
if __name__ == "__main__":
|
| 169 |
+
main()
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/force_web_ui.py
ADDED
|
@@ -0,0 +1,733 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import hashlib
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
import re
|
| 6 |
+
import shutil
|
| 7 |
+
|
| 8 |
+
import numpy as np
|
| 9 |
+
import gradio as gr
|
| 10 |
+
import trimesh
|
| 11 |
+
|
| 12 |
+
POINT_PREVIEW_MAX = 12000
|
| 13 |
+
POINT_PREVIEW_SIZE_RATIO = 0.004
|
| 14 |
+
ROTATE_X_CCW_90 = trimesh.transformations.rotation_matrix(
|
| 15 |
+
np.deg2rad(270.0), [1.0, 0.0, 0.0]
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def _normalize_out_path(out_path: str) -> str:
|
| 20 |
+
out_path = (out_path or "").strip()
|
| 21 |
+
if not out_path:
|
| 22 |
+
out_path = "force_config.json"
|
| 23 |
+
if out_path.endswith(os.sep) or os.path.isdir(out_path):
|
| 24 |
+
out_path = os.path.join(out_path, "force_config.json")
|
| 25 |
+
return out_path
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _parse_force_lines(text: str):
|
| 29 |
+
forces = []
|
| 30 |
+
for raw_line in (text or "").splitlines():
|
| 31 |
+
line = raw_line.strip()
|
| 32 |
+
if not line or line.startswith("#"):
|
| 33 |
+
continue
|
| 34 |
+
parts = [p for p in re.split(r"[,\s]+", line) if p]
|
| 35 |
+
if len(parts) != 3:
|
| 36 |
+
continue
|
| 37 |
+
try:
|
| 38 |
+
vec = [float(v) for v in parts]
|
| 39 |
+
except Exception:
|
| 40 |
+
continue
|
| 41 |
+
forces.append(vec)
|
| 42 |
+
return forces
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def _save_config(
|
| 46 |
+
out_path: str,
|
| 47 |
+
fx: float,
|
| 48 |
+
fy: float,
|
| 49 |
+
fz: float,
|
| 50 |
+
extra_forces_text: str,
|
| 51 |
+
mode: str,
|
| 52 |
+
top_percent: float,
|
| 53 |
+
hr_min: float,
|
| 54 |
+
hr_max: float,
|
| 55 |
+
bx0: float,
|
| 56 |
+
bx1: float,
|
| 57 |
+
by0: float,
|
| 58 |
+
by1: float,
|
| 59 |
+
bz0: float,
|
| 60 |
+
bz1: float,
|
| 61 |
+
brx0: float,
|
| 62 |
+
brx1: float,
|
| 63 |
+
bry0: float,
|
| 64 |
+
bry1: float,
|
| 65 |
+
brz0: float,
|
| 66 |
+
brz1: float,
|
| 67 |
+
force_entries,
|
| 68 |
+
):
|
| 69 |
+
out_path = _normalize_out_path(out_path)
|
| 70 |
+
os.makedirs(os.path.dirname(out_path) or ".", exist_ok=True)
|
| 71 |
+
|
| 72 |
+
force_entries = list(force_entries or [])
|
| 73 |
+
if force_entries:
|
| 74 |
+
entries = force_entries
|
| 75 |
+
else:
|
| 76 |
+
entries = [
|
| 77 |
+
_build_force_entry(
|
| 78 |
+
fx,
|
| 79 |
+
fy,
|
| 80 |
+
fz,
|
| 81 |
+
extra_forces_text,
|
| 82 |
+
mode,
|
| 83 |
+
top_percent,
|
| 84 |
+
hr_min,
|
| 85 |
+
hr_max,
|
| 86 |
+
bx0,
|
| 87 |
+
bx1,
|
| 88 |
+
by0,
|
| 89 |
+
by1,
|
| 90 |
+
bz0,
|
| 91 |
+
bz1,
|
| 92 |
+
brx0,
|
| 93 |
+
brx1,
|
| 94 |
+
bry0,
|
| 95 |
+
bry1,
|
| 96 |
+
brz0,
|
| 97 |
+
brz1,
|
| 98 |
+
)
|
| 99 |
+
]
|
| 100 |
+
|
| 101 |
+
all_forces = _flatten_entry_forces(entries)
|
| 102 |
+
|
| 103 |
+
if len(entries) == 1:
|
| 104 |
+
cfg = dict(entries[0])
|
| 105 |
+
else:
|
| 106 |
+
cfg = {"force_entries": entries}
|
| 107 |
+
if len(all_forces) > 1:
|
| 108 |
+
cfg["forces"] = all_forces
|
| 109 |
+
cfg["force"] = [float(sum(v[i] for v in all_forces)) for i in range(3)]
|
| 110 |
+
elif len(all_forces) == 1:
|
| 111 |
+
cfg["force"] = all_forces[0]
|
| 112 |
+
|
| 113 |
+
with open(out_path, "w") as f:
|
| 114 |
+
json.dump(cfg, f, indent=2)
|
| 115 |
+
|
| 116 |
+
cmd = f"python scripts/viewer_hunyuan_web_alternate.py --latents <latents.pt> --use_physics --force_config {out_path}"
|
| 117 |
+
return f"Saved to {out_path}", json.dumps(cfg, indent=2), cmd
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def _toggle_groups(mode: str):
|
| 121 |
+
return (
|
| 122 |
+
gr.update(visible=mode == "top_percent"),
|
| 123 |
+
gr.update(visible=mode == "height_ratio"),
|
| 124 |
+
gr.update(visible=mode == "bbox_abs"),
|
| 125 |
+
gr.update(visible=mode == "bbox_ratio"),
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def _build_force_entry(
|
| 130 |
+
fx: float,
|
| 131 |
+
fy: float,
|
| 132 |
+
fz: float,
|
| 133 |
+
extra_forces_text: str,
|
| 134 |
+
mode: str,
|
| 135 |
+
top_percent: float,
|
| 136 |
+
hr_min: float,
|
| 137 |
+
hr_max: float,
|
| 138 |
+
bx0: float,
|
| 139 |
+
bx1: float,
|
| 140 |
+
by0: float,
|
| 141 |
+
by1: float,
|
| 142 |
+
bz0: float,
|
| 143 |
+
bz1: float,
|
| 144 |
+
brx0: float,
|
| 145 |
+
brx1: float,
|
| 146 |
+
bry0: float,
|
| 147 |
+
bry1: float,
|
| 148 |
+
brz0: float,
|
| 149 |
+
brz1: float,
|
| 150 |
+
):
|
| 151 |
+
base_force = [float(fx), float(fy), float(fz)]
|
| 152 |
+
extra_forces = _parse_force_lines(extra_forces_text)
|
| 153 |
+
forces = []
|
| 154 |
+
base_nonzero = any(abs(v) > 0 for v in base_force)
|
| 155 |
+
if base_nonzero or not extra_forces:
|
| 156 |
+
forces.append(base_force)
|
| 157 |
+
forces.extend(extra_forces)
|
| 158 |
+
|
| 159 |
+
entry = {}
|
| 160 |
+
if len(forces) > 1:
|
| 161 |
+
entry["forces"] = forces
|
| 162 |
+
entry["force"] = [float(sum(v[i] for v in forces)) for i in range(3)]
|
| 163 |
+
else:
|
| 164 |
+
entry["force"] = forces[0]
|
| 165 |
+
|
| 166 |
+
if mode == "global":
|
| 167 |
+
entry["force_region_mode"] = "global"
|
| 168 |
+
entry["global_loading"] = True
|
| 169 |
+
elif mode == "top_percent":
|
| 170 |
+
entry["force_region_mode"] = "top_percent"
|
| 171 |
+
entry["force_top_percent"] = float(top_percent)
|
| 172 |
+
elif mode == "height_ratio":
|
| 173 |
+
entry["force_region_mode"] = "height_ratio"
|
| 174 |
+
entry["seat_height_min_ratio"] = float(hr_min)
|
| 175 |
+
entry["seat_height_max_ratio"] = float(hr_max)
|
| 176 |
+
elif mode == "bbox_abs":
|
| 177 |
+
entry["force_region_mode"] = "bbox"
|
| 178 |
+
entry["force_bbox"] = [
|
| 179 |
+
float(bx0),
|
| 180 |
+
float(bx1),
|
| 181 |
+
float(by0),
|
| 182 |
+
float(by1),
|
| 183 |
+
float(bz0),
|
| 184 |
+
float(bz1),
|
| 185 |
+
]
|
| 186 |
+
elif mode == "bbox_ratio":
|
| 187 |
+
entry["force_region_mode"] = "bbox"
|
| 188 |
+
entry["force_bbox_ratio"] = [
|
| 189 |
+
float(brx0),
|
| 190 |
+
float(brx1),
|
| 191 |
+
float(bry0),
|
| 192 |
+
float(bry1),
|
| 193 |
+
float(brz0),
|
| 194 |
+
float(brz1),
|
| 195 |
+
]
|
| 196 |
+
return entry
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
def _flatten_entry_forces(entries):
|
| 200 |
+
all_forces = []
|
| 201 |
+
for entry in entries:
|
| 202 |
+
if not isinstance(entry, dict):
|
| 203 |
+
continue
|
| 204 |
+
if "forces" in entry and isinstance(entry["forces"], list):
|
| 205 |
+
all_forces.extend(entry["forces"])
|
| 206 |
+
elif "force" in entry:
|
| 207 |
+
all_forces.append(entry["force"])
|
| 208 |
+
return all_forces
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
def _add_force_entry(
|
| 212 |
+
force_entries,
|
| 213 |
+
fx: float,
|
| 214 |
+
fy: float,
|
| 215 |
+
fz: float,
|
| 216 |
+
extra_forces_text: str,
|
| 217 |
+
mode: str,
|
| 218 |
+
top_percent: float,
|
| 219 |
+
hr_min: float,
|
| 220 |
+
hr_max: float,
|
| 221 |
+
bx0: float,
|
| 222 |
+
bx1: float,
|
| 223 |
+
by0: float,
|
| 224 |
+
by1: float,
|
| 225 |
+
bz0: float,
|
| 226 |
+
bz1: float,
|
| 227 |
+
brx0: float,
|
| 228 |
+
brx1: float,
|
| 229 |
+
bry0: float,
|
| 230 |
+
bry1: float,
|
| 231 |
+
brz0: float,
|
| 232 |
+
brz1: float,
|
| 233 |
+
):
|
| 234 |
+
entries = list(force_entries or [])
|
| 235 |
+
entry = _build_force_entry(
|
| 236 |
+
fx,
|
| 237 |
+
fy,
|
| 238 |
+
fz,
|
| 239 |
+
extra_forces_text,
|
| 240 |
+
mode,
|
| 241 |
+
top_percent,
|
| 242 |
+
hr_min,
|
| 243 |
+
hr_max,
|
| 244 |
+
bx0,
|
| 245 |
+
bx1,
|
| 246 |
+
by0,
|
| 247 |
+
by1,
|
| 248 |
+
bz0,
|
| 249 |
+
bz1,
|
| 250 |
+
brx0,
|
| 251 |
+
brx1,
|
| 252 |
+
bry0,
|
| 253 |
+
bry1,
|
| 254 |
+
brz0,
|
| 255 |
+
brz1,
|
| 256 |
+
)
|
| 257 |
+
entries.append(entry)
|
| 258 |
+
preview = json.dumps(entries, indent=2)
|
| 259 |
+
status = f"✅ Added load location #{len(entries)}"
|
| 260 |
+
return entries, preview, status
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
def _clear_force_entries():
|
| 264 |
+
return [], "[]", "🧹 Cleared all load locations"
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
def _copy_to_tmp(mesh_path: str) -> str:
|
| 268 |
+
abs_path = os.path.abspath(os.path.expanduser(mesh_path))
|
| 269 |
+
stat = os.stat(abs_path)
|
| 270 |
+
key = f"{abs_path}|{stat.st_size}|{stat.st_mtime_ns}"
|
| 271 |
+
digest = hashlib.sha256(key.encode("utf-8")).hexdigest()[:16]
|
| 272 |
+
tmp_dir = os.path.join("./tmp", "force_web_ui_cache")
|
| 273 |
+
os.makedirs(tmp_dir, exist_ok=True)
|
| 274 |
+
dst_name = f"{digest}_{os.path.basename(abs_path)}"
|
| 275 |
+
dst_path = os.path.join(tmp_dir, dst_name)
|
| 276 |
+
if not os.path.exists(dst_path):
|
| 277 |
+
shutil.copy2(abs_path, dst_path)
|
| 278 |
+
return dst_path
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def _prepare_preview_mesh(mesh, mesh_path: str, rotated: bool):
|
| 282 |
+
"""Export preview mesh to ./tmp as GLB (fallback to original file)."""
|
| 283 |
+
abs_path = os.path.abspath(os.path.expanduser(mesh_path))
|
| 284 |
+
stat = os.stat(abs_path)
|
| 285 |
+
key = f"{abs_path}|{stat.st_size}|{stat.st_mtime_ns}|rotated={int(bool(rotated))}|preview_v1"
|
| 286 |
+
digest = hashlib.sha256(key.encode("utf-8")).hexdigest()[:16]
|
| 287 |
+
tmp_dir = os.path.join("./tmp", "force_web_ui_cache")
|
| 288 |
+
os.makedirs(tmp_dir, exist_ok=True)
|
| 289 |
+
glb_path = os.path.join(tmp_dir, f"{digest}.glb")
|
| 290 |
+
if not os.path.exists(glb_path):
|
| 291 |
+
try:
|
| 292 |
+
mesh_to_export = mesh
|
| 293 |
+
if isinstance(mesh, trimesh.Scene):
|
| 294 |
+
geoms = [g for g in mesh.dump() if isinstance(g, trimesh.Trimesh)]
|
| 295 |
+
if len(geoms) > 0:
|
| 296 |
+
mesh_to_export = trimesh.util.concatenate(geoms)
|
| 297 |
+
mesh_to_export.export(glb_path)
|
| 298 |
+
except Exception:
|
| 299 |
+
return _copy_to_tmp(mesh_path), "⚠️ Preview GLB export failed; using the original file instead"
|
| 300 |
+
return glb_path, None
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
def _reduce_faces(mesh: trimesh.Trimesh, target_faces: int) -> trimesh.Trimesh:
|
| 304 |
+
if not isinstance(mesh, trimesh.Trimesh) or mesh.faces is None:
|
| 305 |
+
return mesh
|
| 306 |
+
face_count = int(mesh.faces.shape[0])
|
| 307 |
+
if face_count <= target_faces:
|
| 308 |
+
return mesh
|
| 309 |
+
idx = np.linspace(0, face_count - 1, target_faces, dtype=np.int64)
|
| 310 |
+
faces = mesh.faces[idx]
|
| 311 |
+
mesh_small = trimesh.Trimesh(vertices=mesh.vertices, faces=faces, process=False)
|
| 312 |
+
try:
|
| 313 |
+
mesh_small.remove_unreferenced_vertices()
|
| 314 |
+
except Exception:
|
| 315 |
+
pass
|
| 316 |
+
return mesh_small
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
def _extract_points_and_mesh(loaded):
|
| 320 |
+
if loaded is None:
|
| 321 |
+
return None, None
|
| 322 |
+
if isinstance(loaded, trimesh.Trimesh):
|
| 323 |
+
pts = loaded.vertices if hasattr(loaded, "vertices") else None
|
| 324 |
+
return (np.asarray(pts) if pts is not None else None), loaded
|
| 325 |
+
if isinstance(loaded, trimesh.points.PointCloud):
|
| 326 |
+
pts = loaded.vertices if hasattr(loaded, "vertices") else loaded.points
|
| 327 |
+
return (np.asarray(pts) if pts is not None else None), None
|
| 328 |
+
if isinstance(loaded, trimesh.Scene):
|
| 329 |
+
meshes = []
|
| 330 |
+
points = []
|
| 331 |
+
for geom in loaded.dump():
|
| 332 |
+
if isinstance(geom, trimesh.Trimesh):
|
| 333 |
+
meshes.append(geom)
|
| 334 |
+
elif isinstance(geom, trimesh.points.PointCloud):
|
| 335 |
+
pts = geom.vertices if hasattr(geom, "vertices") else geom.points
|
| 336 |
+
if pts is not None:
|
| 337 |
+
points.append(np.asarray(pts))
|
| 338 |
+
if meshes:
|
| 339 |
+
mesh = trimesh.util.concatenate(meshes)
|
| 340 |
+
pts = mesh.vertices if hasattr(mesh, "vertices") else None
|
| 341 |
+
return (np.asarray(pts) if pts is not None else None), mesh
|
| 342 |
+
if points:
|
| 343 |
+
return np.concatenate(points, axis=0), None
|
| 344 |
+
return None, None
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def _rotate_points_and_mesh(points, mesh, enable_rotation: bool):
|
| 348 |
+
if not enable_rotation:
|
| 349 |
+
return points, mesh
|
| 350 |
+
|
| 351 |
+
rot = np.asarray(ROTATE_X_CCW_90, dtype=np.float64)
|
| 352 |
+
|
| 353 |
+
rotated_points = None
|
| 354 |
+
if points is not None:
|
| 355 |
+
rotated_points = trimesh.transform_points(np.asarray(points, dtype=np.float64), rot)
|
| 356 |
+
|
| 357 |
+
rotated_mesh = None
|
| 358 |
+
if mesh is not None:
|
| 359 |
+
rotated_mesh = mesh.copy()
|
| 360 |
+
rotated_mesh.apply_transform(rot)
|
| 361 |
+
|
| 362 |
+
return rotated_points, rotated_mesh
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
def _make_preview_mesh_from_points(points: np.ndarray):
|
| 366 |
+
if points is None or len(points) == 0:
|
| 367 |
+
return None, "⚠️ The point cloud is empty and cannot be previewed"
|
| 368 |
+
points = np.asarray(points, dtype=np.float32)
|
| 369 |
+
total = int(points.shape[0])
|
| 370 |
+
if total > POINT_PREVIEW_MAX:
|
| 371 |
+
idx = np.linspace(0, total - 1, POINT_PREVIEW_MAX, dtype=np.int64)
|
| 372 |
+
pts = points[idx]
|
| 373 |
+
sample_note = f" (sampled {POINT_PREVIEW_MAX}/{total})"
|
| 374 |
+
else:
|
| 375 |
+
pts = points
|
| 376 |
+
sample_note = f" ({total} pts)"
|
| 377 |
+
min_b = points.min(axis=0)
|
| 378 |
+
max_b = points.max(axis=0)
|
| 379 |
+
max_range = float(np.max(max_b - min_b))
|
| 380 |
+
if not np.isfinite(max_range) or max_range <= 0:
|
| 381 |
+
max_range = 1.0
|
| 382 |
+
point_size = max(max_range * POINT_PREVIEW_SIZE_RATIO, 1e-4)
|
| 383 |
+
try:
|
| 384 |
+
base = trimesh.creation.box(extents=[point_size, point_size, point_size])
|
| 385 |
+
v = base.vertices
|
| 386 |
+
f = base.faces
|
| 387 |
+
num = int(pts.shape[0])
|
| 388 |
+
verts = (v[None, :, :] + pts[:, None, :]).reshape(-1, 3)
|
| 389 |
+
faces = (f[None, :, :] + (np.arange(num) * len(v))[:, None, None]).reshape(-1, 3)
|
| 390 |
+
cloud_mesh = trimesh.Trimesh(vertices=verts, faces=faces, process=False)
|
| 391 |
+
cloud_mesh.visual.face_colors = [120, 120, 120, 100]
|
| 392 |
+
return cloud_mesh, f"✅ Point-cloud preview{sample_note}, point size≈{point_size:.4f}"
|
| 393 |
+
except Exception as e:
|
| 394 |
+
extents = np.maximum(max_b - min_b, 1e-6)
|
| 395 |
+
center = (min_b + max_b) * 0.5
|
| 396 |
+
transform = trimesh.transformations.translation_matrix(center)
|
| 397 |
+
box = trimesh.creation.box(extents=extents, transform=transform)
|
| 398 |
+
box.visual.face_colors = [160, 160, 160, 60]
|
| 399 |
+
return box, f"⚠️ Point-cloud preview failed; using a bounding box instead: {e}"
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
def _load_mesh(mesh_path: str, z_up: bool):
|
| 403 |
+
mesh_path = (mesh_path or "").strip()
|
| 404 |
+
if not mesh_path:
|
| 405 |
+
return "⚠️ Please enter a mesh path", "", None, None, None
|
| 406 |
+
if not os.path.exists(mesh_path):
|
| 407 |
+
return f"⚠️ Path does not exist: {mesh_path}", "", None, None, None
|
| 408 |
+
try:
|
| 409 |
+
loaded = trimesh.load(mesh_path, force="scene")
|
| 410 |
+
points, mesh = _extract_points_and_mesh(loaded)
|
| 411 |
+
if points is None or len(points) == 0:
|
| 412 |
+
return "⚠️ The mesh is empty or failed to load", "", None, None, None
|
| 413 |
+
points, mesh = _rotate_points_and_mesh(points, mesh, enable_rotation=bool(z_up))
|
| 414 |
+
status_prefix = "✅ Mesh loaded"
|
| 415 |
+
preview_note = None
|
| 416 |
+
target_faces = 100000
|
| 417 |
+
if isinstance(mesh, trimesh.Trimesh) and mesh.faces is not None:
|
| 418 |
+
face_count = int(mesh.faces.shape[0])
|
| 419 |
+
if face_count == 0:
|
| 420 |
+
preview_mesh, preview_note = _make_preview_mesh_from_points(points)
|
| 421 |
+
mesh = preview_mesh
|
| 422 |
+
status_prefix = "✅ Point cloud loaded"
|
| 423 |
+
elif face_count > target_faces:
|
| 424 |
+
try:
|
| 425 |
+
mesh = mesh.simplify_quadratic_decimation(target_faces)
|
| 426 |
+
status_prefix += f" (simplified: {face_count} -> {mesh.faces.shape[0]} faces)"
|
| 427 |
+
except Exception:
|
| 428 |
+
mesh = _reduce_faces(mesh, target_faces)
|
| 429 |
+
if hasattr(mesh, "faces") and mesh.faces is not None:
|
| 430 |
+
status_prefix += f" (sample-based reduction: {face_count} -> {mesh.faces.shape[0]} faces)"
|
| 431 |
+
else:
|
| 432 |
+
status_prefix += f" (⚠️ simplification failed, faces={face_count})"
|
| 433 |
+
elif mesh is None:
|
| 434 |
+
preview_mesh, preview_note = _make_preview_mesh_from_points(points)
|
| 435 |
+
mesh = preview_mesh
|
| 436 |
+
status_prefix = "✅ Point cloud loaded"
|
| 437 |
+
|
| 438 |
+
min_b = points.min(axis=0)
|
| 439 |
+
max_b = points.max(axis=0)
|
| 440 |
+
size = max_b - min_b
|
| 441 |
+
info = (
|
| 442 |
+
f"min: [{min_b[0]:.4f}, {min_b[1]:.4f}, {min_b[2]:.4f}]\n"
|
| 443 |
+
f"max: [{max_b[0]:.4f}, {max_b[1]:.4f}, {max_b[2]:.4f}]\n"
|
| 444 |
+
f"size: [{size[0]:.4f}, {size[1]:.4f}, {size[2]:.4f}]"
|
| 445 |
+
)
|
| 446 |
+
bbox = [float(min_b[0]), float(max_b[0]), float(min_b[1]), float(max_b[1]), float(min_b[2]), float(max_b[2])]
|
| 447 |
+
preview_path, warn = _prepare_preview_mesh(mesh, mesh_path, rotated=bool(z_up))
|
| 448 |
+
status_parts = [status_prefix]
|
| 449 |
+
if z_up:
|
| 450 |
+
status_parts.append("↻ Rotated 90 degrees counterclockwise around the +X axis")
|
| 451 |
+
if warn is not None:
|
| 452 |
+
status_parts.append(warn)
|
| 453 |
+
if preview_note is not None:
|
| 454 |
+
status_parts.append(preview_note)
|
| 455 |
+
status = "\n".join(status_parts)
|
| 456 |
+
return status, info, preview_path, bbox, preview_path
|
| 457 |
+
except Exception as e:
|
| 458 |
+
return f"⚠️ Load failed: {e}", "", None, None, None
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
def _set_bbox_abs_from_bounds(bounds):
|
| 462 |
+
if not bounds or len(bounds) != 6:
|
| 463 |
+
return [gr.update() for _ in range(6)]
|
| 464 |
+
return [bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]]
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
def _bbox_from_ratio(bounds, ratio):
|
| 468 |
+
if not bounds or len(bounds) != 6 or not ratio or len(ratio) != 6:
|
| 469 |
+
return None
|
| 470 |
+
x0, x1, y0, y1, z0, z1 = [float(v) for v in bounds]
|
| 471 |
+
rx0, rx1, ry0, ry1, rz0, rz1 = [float(v) for v in ratio]
|
| 472 |
+
return [
|
| 473 |
+
x0 + rx0 * (x1 - x0),
|
| 474 |
+
x0 + rx1 * (x1 - x0),
|
| 475 |
+
y0 + ry0 * (y1 - y0),
|
| 476 |
+
y0 + ry1 * (y1 - y0),
|
| 477 |
+
z0 + rz0 * (z1 - z0),
|
| 478 |
+
z0 + rz1 * (z1 - z0),
|
| 479 |
+
]
|
| 480 |
+
|
| 481 |
+
|
| 482 |
+
def _preview_bbox(
|
| 483 |
+
preview_path: str,
|
| 484 |
+
bounds,
|
| 485 |
+
mode: str,
|
| 486 |
+
bx0: float,
|
| 487 |
+
bx1: float,
|
| 488 |
+
by0: float,
|
| 489 |
+
by1: float,
|
| 490 |
+
bz0: float,
|
| 491 |
+
bz1: float,
|
| 492 |
+
brx0: float,
|
| 493 |
+
brx1: float,
|
| 494 |
+
bry0: float,
|
| 495 |
+
bry1: float,
|
| 496 |
+
brz0: float,
|
| 497 |
+
brz1: float,
|
| 498 |
+
):
|
| 499 |
+
if not preview_path or not os.path.exists(preview_path):
|
| 500 |
+
return gr.update(), "⚠️ Please load a mesh first"
|
| 501 |
+
mode = (mode or "").lower()
|
| 502 |
+
if mode not in ("bbox_abs", "bbox_ratio"):
|
| 503 |
+
return gr.update(), "⚠️ Preview is only available in bbox mode"
|
| 504 |
+
if mode == "bbox_ratio":
|
| 505 |
+
bbox = _bbox_from_ratio(bounds, [brx0, brx1, bry0, bry1, brz0, brz1])
|
| 506 |
+
if bbox is None:
|
| 507 |
+
return gr.update(), "⚠️ bbox_ratio is missing bounds or parameters"
|
| 508 |
+
else:
|
| 509 |
+
bbox = [bx0, bx1, by0, by1, bz0, bz1]
|
| 510 |
+
x0, x1 = sorted([float(bbox[0]), float(bbox[1])])
|
| 511 |
+
y0, y1 = sorted([float(bbox[2]), float(bbox[3])])
|
| 512 |
+
z0, z1 = sorted([float(bbox[4]), float(bbox[5])])
|
| 513 |
+
if x1 - x0 <= 0 or y1 - y0 <= 0 or z1 - z0 <= 0:
|
| 514 |
+
return gr.update(), "⚠️ Invalid bbox size"
|
| 515 |
+
|
| 516 |
+
try:
|
| 517 |
+
base = trimesh.load(preview_path, force="scene")
|
| 518 |
+
scene = base if isinstance(base, trimesh.Scene) else trimesh.Scene(base)
|
| 519 |
+
center = np.array([(x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2], dtype=np.float64)
|
| 520 |
+
extents = np.array([x1 - x0, y1 - y0, z1 - z0], dtype=np.float64)
|
| 521 |
+
transform = trimesh.transformations.translation_matrix(center)
|
| 522 |
+
box = trimesh.creation.box(extents=extents, transform=transform)
|
| 523 |
+
box.visual.face_colors = [255, 0, 0, 60]
|
| 524 |
+
scene.add_geometry(box, node_name="bbox")
|
| 525 |
+
|
| 526 |
+
stat = os.stat(preview_path)
|
| 527 |
+
key = f"{preview_path}|{stat.st_size}|{stat.st_mtime_ns}|{x0},{x1},{y0},{y1},{z0},{z1}"
|
| 528 |
+
digest = hashlib.sha256(key.encode("utf-8")).hexdigest()[:16]
|
| 529 |
+
tmp_dir = os.path.join("./tmp", "force_web_ui_cache")
|
| 530 |
+
os.makedirs(tmp_dir, exist_ok=True)
|
| 531 |
+
out_path = os.path.join(tmp_dir, f"bbox_{digest}.glb")
|
| 532 |
+
scene.export(out_path)
|
| 533 |
+
return out_path, "✅ Updated bbox preview"
|
| 534 |
+
except Exception as e:
|
| 535 |
+
return gr.update(), f"⚠️ Bbox preview failed: {e}"
|
| 536 |
+
|
| 537 |
+
|
| 538 |
+
def build_ui(default_out: str, z_up: bool):
|
| 539 |
+
with gr.Blocks(title="Force Config UI") as demo:
|
| 540 |
+
gr.Markdown(
|
| 541 |
+
"Set force vector(s) (Y-up) and region. "
|
| 542 |
+
"Use 'Add Force Entry' to create multiple locations; "
|
| 543 |
+
"Save JSON will use entries if any exist."
|
| 544 |
+
)
|
| 545 |
+
|
| 546 |
+
mesh_bounds_state = gr.State(None)
|
| 547 |
+
mesh_preview_state = gr.State(None)
|
| 548 |
+
force_entries_state = gr.State([])
|
| 549 |
+
|
| 550 |
+
out_path = gr.Textbox(label="Output JSON Path", value=default_out)
|
| 551 |
+
mesh_path = gr.Textbox(label="Mesh Path (server)", placeholder="/path/to/mesh.obj")
|
| 552 |
+
with gr.Row():
|
| 553 |
+
load_mesh_btn = gr.Button("Load Mesh")
|
| 554 |
+
fill_bbox_btn = gr.Button("Use Mesh Bounds for BBox")
|
| 555 |
+
mesh_status = gr.Textbox(label="Mesh Status", interactive=False)
|
| 556 |
+
mesh_bounds = gr.Textbox(label="Mesh Bounds", interactive=False)
|
| 557 |
+
mesh_view = gr.Model3D(label="Mesh Preview")
|
| 558 |
+
bbox_status = gr.Textbox(label="BBox Preview Status", interactive=False)
|
| 559 |
+
|
| 560 |
+
if z_up:
|
| 561 |
+
with gr.Row():
|
| 562 |
+
fx = gr.Number(label="Fx (N)", value=0.0)
|
| 563 |
+
fy = gr.Number(label="Fy (N)", value=0.0)
|
| 564 |
+
fz = gr.Number(label="Fz (N)", value=-100000.0)
|
| 565 |
+
else:
|
| 566 |
+
with gr.Row():
|
| 567 |
+
fx = gr.Number(label="Fx (N)", value=0.0)
|
| 568 |
+
fy = gr.Number(label="Fy (N)", value=-100000.0)
|
| 569 |
+
fz = gr.Number(label="Fz (N)", value=0.0)
|
| 570 |
+
extra_forces = gr.Textbox(
|
| 571 |
+
label="Extra Forces (one per line: fx fy fz)",
|
| 572 |
+
placeholder="0 0 -500\n100 0 0",
|
| 573 |
+
lines=3,
|
| 574 |
+
)
|
| 575 |
+
|
| 576 |
+
mode = gr.Radio(
|
| 577 |
+
["global", "top_percent", "height_ratio", "bbox_abs", "bbox_ratio"],
|
| 578 |
+
value="top_percent",
|
| 579 |
+
label="Region Mode",
|
| 580 |
+
)
|
| 581 |
+
|
| 582 |
+
with gr.Group(visible=True) as top_group:
|
| 583 |
+
top_percent = gr.Slider(0.01, 0.5, value=0.05, step=0.01, label="Top Percent")
|
| 584 |
+
|
| 585 |
+
with gr.Group(visible=False) as height_group:
|
| 586 |
+
hr_min = gr.Slider(0.0, 1.0, value=0.3, step=0.01, label="Height Min Ratio")
|
| 587 |
+
hr_max = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Height Max Ratio")
|
| 588 |
+
|
| 589 |
+
with gr.Group(visible=False) as bbox_abs_group:
|
| 590 |
+
gr.Markdown("BBox (abs) order: x_min, x_max, y_min, y_max, z_min, z_max")
|
| 591 |
+
with gr.Row():
|
| 592 |
+
bx0 = gr.Number(label="x_min", value=-0.2)
|
| 593 |
+
bx1 = gr.Number(label="x_max", value=0.2)
|
| 594 |
+
by0 = gr.Number(label="y_min", value=0.2)
|
| 595 |
+
by1 = gr.Number(label="y_max", value=0.4)
|
| 596 |
+
bz0 = gr.Number(label="z_min", value=-0.2)
|
| 597 |
+
bz1 = gr.Number(label="z_max", value=0.2)
|
| 598 |
+
|
| 599 |
+
with gr.Group(visible=False) as bbox_ratio_group:
|
| 600 |
+
gr.Markdown("BBox (ratio 0-1) order: x_min, x_max, y_min, y_max, z_min, z_max")
|
| 601 |
+
with gr.Row():
|
| 602 |
+
brx0 = gr.Slider(0.0, 1.0, value=0.4, step=0.01, label="x_min")
|
| 603 |
+
brx1 = gr.Slider(0.0, 1.0, value=0.6, step=0.01, label="x_max")
|
| 604 |
+
bry0 = gr.Slider(0.0, 1.0, value=0.4, step=0.01, label="y_min")
|
| 605 |
+
bry1 = gr.Slider(0.0, 1.0, value=0.6, step=0.01, label="y_max")
|
| 606 |
+
brz0 = gr.Slider(0.0, 1.0, value=0.4, step=0.01, label="z_min")
|
| 607 |
+
brz1 = gr.Slider(0.0, 1.0, value=0.6, step=0.01, label="z_max")
|
| 608 |
+
|
| 609 |
+
save_btn = gr.Button("Save JSON", variant="primary")
|
| 610 |
+
add_force_btn = gr.Button("Add Force Entry")
|
| 611 |
+
clear_force_btn = gr.Button("Clear Force Entries")
|
| 612 |
+
preview_bbox_btn = gr.Button("Preview BBox")
|
| 613 |
+
status = gr.Textbox(label="Status")
|
| 614 |
+
force_entries_preview = gr.Code(label="Force Entries", language="json", value="[]")
|
| 615 |
+
preview = gr.Code(label="JSON Preview", language="json")
|
| 616 |
+
cmd = gr.Textbox(label="Command Preview")
|
| 617 |
+
|
| 618 |
+
mode.change(
|
| 619 |
+
_toggle_groups,
|
| 620 |
+
inputs=mode,
|
| 621 |
+
outputs=[top_group, height_group, bbox_abs_group, bbox_ratio_group],
|
| 622 |
+
)
|
| 623 |
+
load_mesh_btn.click(
|
| 624 |
+
_load_mesh,
|
| 625 |
+
inputs=[mesh_path, gr.State(z_up)],
|
| 626 |
+
outputs=[mesh_status, mesh_bounds, mesh_view, mesh_bounds_state, mesh_preview_state],
|
| 627 |
+
)
|
| 628 |
+
fill_bbox_btn.click(
|
| 629 |
+
_set_bbox_abs_from_bounds,
|
| 630 |
+
inputs=[mesh_bounds_state],
|
| 631 |
+
outputs=[bx0, bx1, by0, by1, bz0, bz1],
|
| 632 |
+
)
|
| 633 |
+
preview_bbox_btn.click(
|
| 634 |
+
_preview_bbox,
|
| 635 |
+
inputs=[
|
| 636 |
+
mesh_preview_state,
|
| 637 |
+
mesh_bounds_state,
|
| 638 |
+
mode,
|
| 639 |
+
bx0,
|
| 640 |
+
bx1,
|
| 641 |
+
by0,
|
| 642 |
+
by1,
|
| 643 |
+
bz0,
|
| 644 |
+
bz1,
|
| 645 |
+
brx0,
|
| 646 |
+
brx1,
|
| 647 |
+
bry0,
|
| 648 |
+
bry1,
|
| 649 |
+
brz0,
|
| 650 |
+
brz1,
|
| 651 |
+
],
|
| 652 |
+
outputs=[mesh_view, bbox_status],
|
| 653 |
+
)
|
| 654 |
+
|
| 655 |
+
add_force_btn.click(
|
| 656 |
+
_add_force_entry,
|
| 657 |
+
inputs=[
|
| 658 |
+
force_entries_state,
|
| 659 |
+
fx,
|
| 660 |
+
fy,
|
| 661 |
+
fz,
|
| 662 |
+
extra_forces,
|
| 663 |
+
mode,
|
| 664 |
+
top_percent,
|
| 665 |
+
hr_min,
|
| 666 |
+
hr_max,
|
| 667 |
+
bx0,
|
| 668 |
+
bx1,
|
| 669 |
+
by0,
|
| 670 |
+
by1,
|
| 671 |
+
bz0,
|
| 672 |
+
bz1,
|
| 673 |
+
brx0,
|
| 674 |
+
brx1,
|
| 675 |
+
bry0,
|
| 676 |
+
bry1,
|
| 677 |
+
brz0,
|
| 678 |
+
brz1,
|
| 679 |
+
],
|
| 680 |
+
outputs=[force_entries_state, force_entries_preview, status],
|
| 681 |
+
)
|
| 682 |
+
clear_force_btn.click(
|
| 683 |
+
_clear_force_entries,
|
| 684 |
+
inputs=[],
|
| 685 |
+
outputs=[force_entries_state, force_entries_preview, status],
|
| 686 |
+
)
|
| 687 |
+
|
| 688 |
+
save_btn.click(
|
| 689 |
+
_save_config,
|
| 690 |
+
inputs=[
|
| 691 |
+
out_path,
|
| 692 |
+
fx,
|
| 693 |
+
fy,
|
| 694 |
+
fz,
|
| 695 |
+
extra_forces,
|
| 696 |
+
mode,
|
| 697 |
+
top_percent,
|
| 698 |
+
hr_min,
|
| 699 |
+
hr_max,
|
| 700 |
+
bx0,
|
| 701 |
+
bx1,
|
| 702 |
+
by0,
|
| 703 |
+
by1,
|
| 704 |
+
bz0,
|
| 705 |
+
bz1,
|
| 706 |
+
brx0,
|
| 707 |
+
brx1,
|
| 708 |
+
bry0,
|
| 709 |
+
bry1,
|
| 710 |
+
brz0,
|
| 711 |
+
brz1,
|
| 712 |
+
force_entries_state,
|
| 713 |
+
],
|
| 714 |
+
outputs=[status, preview, cmd],
|
| 715 |
+
)
|
| 716 |
+
return demo
|
| 717 |
+
|
| 718 |
+
|
| 719 |
+
def main():
|
| 720 |
+
parser = argparse.ArgumentParser(description="Force config web UI")
|
| 721 |
+
parser.add_argument("--out", type=str, default="force_config.json", help="Output JSON path")
|
| 722 |
+
parser.add_argument("--server_name", type=str, default="0.0.0.0", help="Gradio server name")
|
| 723 |
+
parser.add_argument("--server_port", type=int, default=7860, help="Gradio server port")
|
| 724 |
+
parser.add_argument("--share", action="store_true", help="Enable Gradio share link")
|
| 725 |
+
parser.add_argument("--z_up", action="store_true", help="Enable z_up mode")
|
| 726 |
+
args = parser.parse_args()
|
| 727 |
+
|
| 728 |
+
demo = build_ui(args.out, args.z_up)
|
| 729 |
+
demo.launch(server_name=args.server_name, server_port=args.server_port, share=args.share)
|
| 730 |
+
|
| 731 |
+
|
| 732 |
+
if __name__ == "__main__":
|
| 733 |
+
main()
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_alternate_me.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_alternate_me_better.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_dflow_me.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_ictm_me.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_sdedit_me.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/hunyuan_sgo_me.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/sample_hunyuan.py
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Hunyuan3D-2.1 Shape Generation Script
|
| 3 |
+
Generate a 3D shape and save latent tokens for later physics optimization.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
# python scripts/sample_hunyuan.py --image /scratch/cvlab/home/seiler/physiopt_new/input/new_york.png --out_folder /scratch/cvlab/home/seiler/physiopt_new/output/hunyuan_gen/new_york
|
| 7 |
+
|
| 8 |
+
import os
|
| 9 |
+
# os.environ['TORCH_HOME'] = '/mnt/cvlab/scratch/cvlab/home/hantzhan/.torch'
|
| 10 |
+
import sys
|
| 11 |
+
|
| 12 |
+
# Add Hunyuan3D-2.1 to the Python path.
|
| 13 |
+
hunyuan_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../Hunyuan3D-2.1"))
|
| 14 |
+
print(hunyuan_path)
|
| 15 |
+
if os.path.exists(hunyuan_path):
|
| 16 |
+
sys.path.insert(0, hunyuan_path)
|
| 17 |
+
print(f"✅ Added Hunyuan3D-2.1 to the Python path: {hunyuan_path}")
|
| 18 |
+
else:
|
| 19 |
+
print(f"⚠️ Warning: Hunyuan3D-2.1 path does not exist: {hunyuan_path}")
|
| 20 |
+
print(f" Please make sure Hunyuan3D-2.1 has been cloned to the correct location")
|
| 21 |
+
|
| 22 |
+
sys.path.append("..")
|
| 23 |
+
|
| 24 |
+
import torch
|
| 25 |
+
import trimesh
|
| 26 |
+
import numpy as np
|
| 27 |
+
from PIL import Image
|
| 28 |
+
from argparse import ArgumentParser
|
| 29 |
+
|
| 30 |
+
try:
|
| 31 |
+
from hy3dgen.rembg import BackgroundRemover
|
| 32 |
+
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
|
| 33 |
+
from hy3dgen.shapegen.models.autoencoders import ShapeVAE
|
| 34 |
+
except ImportError as e:
|
| 35 |
+
print(f"❌ Failed to import the Hunyuan3D modules: {e}")
|
| 36 |
+
print(f"\nPlease set up Hunyuan3D-2.1 with the following steps:")
|
| 37 |
+
print(f"1. cd {os.path.dirname(hunyuan_path)}")
|
| 38 |
+
print(f"2. git clone https://github.com/Tencent/Hunyuan3D-2.git Hunyuan3D-2.1")
|
| 39 |
+
print(f"3. cd Hunyuan3D-2.1")
|
| 40 |
+
print(f"4. pip install -e .")
|
| 41 |
+
sys.exit(1)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
parser = ArgumentParser()
|
| 46 |
+
parser.add_argument("--image", type=str, required=True, help="Input image path")
|
| 47 |
+
parser.add_argument("--out_folder", type=str, default="../out/hunyuan_tmp", help="Output directory")
|
| 48 |
+
parser.add_argument("--seed", type=int, default=42, help="Random seed (base value)")
|
| 49 |
+
parser.add_argument("--num_results", type=int, default=1, help="Number of generated results (different seeds)")
|
| 50 |
+
parser.add_argument("--num_inference_steps", type=int, default=50, help="Number of inference steps")
|
| 51 |
+
parser.add_argument("--guidance_scale", type=float, default=7.5, help="CFG strength")
|
| 52 |
+
parser.add_argument("--model_path", type=str, default="tencent/Hunyuan3D-2.1", help="Model path (using v2.1)")
|
| 53 |
+
parser.add_argument("--subfolder", type=str, default="hunyuan3d-dit-v2-1", help="Model subfolder")
|
| 54 |
+
parser.add_argument("--use_safetensors", action="store_true", help="Use safetensors format (default is ckpt)")
|
| 55 |
+
parser.add_argument("--octree_resolution", type=int, default=384, help="Octree resolution (higher is finer but slower)")
|
| 56 |
+
parser.add_argument("--mc_level", type=float, default=0, help="Marching Cubes threshold")
|
| 57 |
+
args = parser.parse_args()
|
| 58 |
+
|
| 59 |
+
# Create the output directory.
|
| 60 |
+
os.makedirs(args.out_folder, exist_ok=True)
|
| 61 |
+
|
| 62 |
+
# Print configuration details.
|
| 63 |
+
print("\n" + "="*60)
|
| 64 |
+
print("Hunyuan3D-2.1 configuration:")
|
| 65 |
+
print(f" - Model: {args.model_path}/{args.subfolder}")
|
| 66 |
+
print(f" - Model format: {'safetensors' if args.use_safetensors else 'checkpoint (.ckpt)'}")
|
| 67 |
+
print(f" - Inference steps: {args.num_inference_steps} (recommended: 50-100)")
|
| 68 |
+
print(f" - Result count: {args.num_results}")
|
| 69 |
+
print(f" - CFG strength: {args.guidance_scale} (recommended: 7.0-10.0)")
|
| 70 |
+
print(f" - Octree resolution: {args.octree_resolution} (recommended: 384-512)")
|
| 71 |
+
print(f" - MC threshold: {args.mc_level:.6f}")
|
| 72 |
+
print("="*60 + "\n")
|
| 73 |
+
|
| 74 |
+
# ==================== Load the model ====================
|
| 75 |
+
print("🔧 Loading the Hunyuan3D-2.1 model...")
|
| 76 |
+
print(f" Model path: {args.model_path}")
|
| 77 |
+
print(f" Subfolder: {args.subfolder}")
|
| 78 |
+
|
| 79 |
+
try:
|
| 80 |
+
# Use the v2.1 model (newer and stronger).
|
| 81 |
+
# v2.1 uses the .ckpt format, so use_safetensors=False is required.
|
| 82 |
+
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(
|
| 83 |
+
args.model_path,
|
| 84 |
+
subfolder=args.subfolder,
|
| 85 |
+
torch_dtype=torch.float16,
|
| 86 |
+
use_safetensors=args.use_safetensors
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
if pipeline is None:
|
| 90 |
+
raise ValueError("Pipeline loading failed and returned None")
|
| 91 |
+
|
| 92 |
+
print(" ✅ Pipeline loaded successfully")
|
| 93 |
+
|
| 94 |
+
# Note: to() may not return self, so do not reassign pipeline.
|
| 95 |
+
pipeline.to('cuda')
|
| 96 |
+
print(" ✅ Model moved to CUDA (dtype: fp16)")
|
| 97 |
+
|
| 98 |
+
except Exception as e:
|
| 99 |
+
print(f"\n❌ Model loading failed: {e}")
|
| 100 |
+
print(f"\nPossible causes:")
|
| 101 |
+
print(f"1. The model has not been downloaded yet - the first run fetches it from Hugging Face")
|
| 102 |
+
print(f"2. Network issues - make sure huggingface.co is reachable")
|
| 103 |
+
print(f"3. Insufficient disk space")
|
| 104 |
+
print(f"\nSuggested fixes:")
|
| 105 |
+
print(f"1. Set a Hugging Face token if the model requires one:")
|
| 106 |
+
print(f" huggingface-cli login")
|
| 107 |
+
print(f"2. Or download the model manually:")
|
| 108 |
+
print(f" git lfs install")
|
| 109 |
+
print(f" git clone https://huggingface.co/tencent/Hunyuan3D-2.1")
|
| 110 |
+
print(f" Then use --model_path ./Hunyuan3D-2.1 --subfolder hunyuan3d-dit-v2-1")
|
| 111 |
+
print(f"3. Or use the v2.0 model instead:")
|
| 112 |
+
print(f" --model_path tencent/Hunyuan3D-2 --subfolder hunyuan3d-dit-v2-0")
|
| 113 |
+
import traceback
|
| 114 |
+
traceback.print_exc()
|
| 115 |
+
sys.exit(1)
|
| 116 |
+
|
| 117 |
+
# Get the VAE for later mesh generation.
|
| 118 |
+
vae = pipeline.vae
|
| 119 |
+
print(f" ✅ VAE acquired successfully")
|
| 120 |
+
|
| 121 |
+
# ==================== Prepare the input image ====================
|
| 122 |
+
print(f"📷 Loading image: {args.image}")
|
| 123 |
+
image = Image.open(args.image).convert("RGBA")
|
| 124 |
+
|
| 125 |
+
# If this is an RGB image, remove the background with rembg.
|
| 126 |
+
if image.mode == 'RGB':
|
| 127 |
+
print(" Removing background...")
|
| 128 |
+
rembg = BackgroundRemover()
|
| 129 |
+
image = rembg(image)
|
| 130 |
+
|
| 131 |
+
# Save the processed image.
|
| 132 |
+
image.save(os.path.join(args.out_folder, "input_image.png"))
|
| 133 |
+
|
| 134 |
+
# ==================== Generate the 3D shape ====================
|
| 135 |
+
print(f"🎨 Generating a 3D shape (steps={args.num_inference_steps}, cfg={args.guidance_scale})...")
|
| 136 |
+
num_results = max(1, int(args.num_results))
|
| 137 |
+
|
| 138 |
+
for idx in range(num_results):
|
| 139 |
+
sample_seed = args.seed + idx
|
| 140 |
+
sample_out = args.out_folder if num_results == 1 else os.path.join(args.out_folder, f"sample_{idx:02d}")
|
| 141 |
+
os.makedirs(sample_out, exist_ok=True)
|
| 142 |
+
|
| 143 |
+
if num_results > 1:
|
| 144 |
+
image.save(os.path.join(sample_out, "input_image.png"))
|
| 145 |
+
|
| 146 |
+
print(f"\n=== Sample {idx+1}/{num_results} | seed={sample_seed} ===")
|
| 147 |
+
|
| 148 |
+
# Set random seeds.
|
| 149 |
+
torch.manual_seed(sample_seed)
|
| 150 |
+
np.random.seed(sample_seed)
|
| 151 |
+
|
| 152 |
+
# Use the simplified pipeline call, consistent with sample_hunyuan_simple.py.
|
| 153 |
+
# Step 1: generate and save latents.
|
| 154 |
+
latents = pipeline(
|
| 155 |
+
image=image,
|
| 156 |
+
num_inference_steps=args.num_inference_steps,
|
| 157 |
+
guidance_scale=args.guidance_scale,
|
| 158 |
+
generator=torch.Generator(device='cuda').manual_seed(sample_seed),
|
| 159 |
+
output_type='latent', # Return latents only; do not decode to mesh yet.
|
| 160 |
+
)
|
| 161 |
+
|
| 162 |
+
print("✅ Latent generation completed!")
|
| 163 |
+
|
| 164 |
+
# ==================== Save latents for physics optimization ====================
|
| 165 |
+
latents_path = os.path.join(sample_out, "latents.pt")
|
| 166 |
+
|
| 167 |
+
# Save latents and the image.
|
| 168 |
+
save_dict = {
|
| 169 |
+
'latents': latents.cpu() if isinstance(latents, torch.Tensor) else latents,
|
| 170 |
+
'image': np.array(image)
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
torch.save(save_dict, latents_path)
|
| 174 |
+
print(f"✅ Saved latents to: {latents_path}")
|
| 175 |
+
if isinstance(latents, torch.Tensor):
|
| 176 |
+
print(f" - Latents shape: {latents.shape}")
|
| 177 |
+
print(f" - Latents range: [{latents.min().item():.3f}, {latents.max().item():.3f}]")
|
| 178 |
+
|
| 179 |
+
# Step 2: decode latents to a mesh with _export().
|
| 180 |
+
print(f"🎭 Decoding latents into a mesh...")
|
| 181 |
+
print(f" Using parameters: octree_resolution={args.octree_resolution}, mc_level={args.mc_level:.6f}")
|
| 182 |
+
mesh = pipeline._export(
|
| 183 |
+
latents,
|
| 184 |
+
output_type='trimesh',
|
| 185 |
+
box_v=1.01,
|
| 186 |
+
mc_level=args.mc_level,
|
| 187 |
+
num_chunks=20000,
|
| 188 |
+
octree_resolution=args.octree_resolution,
|
| 189 |
+
mc_algo='mc',
|
| 190 |
+
enable_pbar=True
|
| 191 |
+
)[0]
|
| 192 |
+
|
| 193 |
+
print("✅ Decoding completed!")
|
| 194 |
+
|
| 195 |
+
# ==================== Save the mesh ====================
|
| 196 |
+
mesh_path = os.path.join(sample_out, "generated_mesh.obj")
|
| 197 |
+
mesh.export(mesh_path)
|
| 198 |
+
print(f"💾 Saved mesh to: {mesh_path}")
|
| 199 |
+
|
| 200 |
+
# Save GLB as well.
|
| 201 |
+
glb_path = os.path.join(sample_out, "generated_mesh.glb")
|
| 202 |
+
mesh.export(glb_path)
|
| 203 |
+
print(f"💾 Saved GLB to: {glb_path}")
|
| 204 |
+
|
| 205 |
+
# ==================== Print summary statistics ====================
|
| 206 |
+
print("\n📊 Generation summary:")
|
| 207 |
+
print(f" - Vertices: {len(mesh.vertices)}")
|
| 208 |
+
print(f" - Faces: {len(mesh.faces)}")
|
| 209 |
+
if isinstance(latents, torch.Tensor):
|
| 210 |
+
print(f" - Latent shape: {latents.shape}")
|
| 211 |
+
|
| 212 |
+
# Free GPU memory.
|
| 213 |
+
del mesh
|
| 214 |
+
if torch.cuda.is_available():
|
| 215 |
+
torch.cuda.empty_cache()
|
| 216 |
+
|
| 217 |
+
print(f"\n✅ All done! Outputs were saved to: {args.out_folder}")
|
| 218 |
+
if num_results == 1:
|
| 219 |
+
print(f" - You can use latents.pt for physics optimization")
|
| 220 |
+
print(f" - Run: python viewer_hunyuan_web.py --latents {latents_path}")
|
| 221 |
+
else:
|
| 222 |
+
print(f" - Each sample is stored in its own sample_XX subdirectory")
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/sample_hunyuan_from_folder.py
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Hunyuan3D-2.1 Shape Generation Script
|
| 3 |
+
Generate a 3D shape and save latent tokens for later physics optimization.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import sys
|
| 8 |
+
import glob
|
| 9 |
+
import logging
|
| 10 |
+
import torch
|
| 11 |
+
import trimesh
|
| 12 |
+
import numpy as np
|
| 13 |
+
from PIL import Image
|
| 14 |
+
from argparse import ArgumentParser
|
| 15 |
+
|
| 16 |
+
# Configure logging
|
| 17 |
+
logging.basicConfig(
|
| 18 |
+
level=logging.INFO,
|
| 19 |
+
format='%(asctime)s - %(levelname)s - %(message)s',
|
| 20 |
+
handlers=[logging.StreamHandler(sys.stdout)]
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Add Hunyuan3D-2.1 to the Python path.
|
| 24 |
+
hunyuan_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../Hunyuan3D-2.1"))
|
| 25 |
+
|
| 26 |
+
if os.path.exists(hunyuan_path):
|
| 27 |
+
sys.path.insert(0, hunyuan_path)
|
| 28 |
+
logging.info(f"✅ Added Hunyuan3D-2.1 to the Python path: {hunyuan_path}")
|
| 29 |
+
else:
|
| 30 |
+
logging.warning(f"⚠️ Hunyuan3D-2.1 path does not exist: {hunyuan_path}")
|
| 31 |
+
logging.warning(" Please make sure Hunyuan3D-2.1 has been cloned to the correct location")
|
| 32 |
+
|
| 33 |
+
sys.path.append("..")
|
| 34 |
+
|
| 35 |
+
try:
|
| 36 |
+
from hy3dgen.rembg import BackgroundRemover
|
| 37 |
+
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
|
| 38 |
+
from hy3dgen.shapegen.models.autoencoders import ShapeVAE
|
| 39 |
+
except ImportError as e:
|
| 40 |
+
logging.error(f"❌ Failed to import the Hunyuan3D modules: {e}")
|
| 41 |
+
logging.info("\nPlease set up Hunyuan3D-2.1 with the following steps:")
|
| 42 |
+
logging.info(f"1. cd {os.path.dirname(hunyuan_path)}")
|
| 43 |
+
logging.info("2. git clone https://github.com/Tencent/Hunyuan3D-2.git Hunyuan3D-2.1")
|
| 44 |
+
logging.info("3. cd Hunyuan3D-2.1")
|
| 45 |
+
logging.info("4. pip install -e .")
|
| 46 |
+
sys.exit(1)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
if __name__ == "__main__":
|
| 50 |
+
parser = ArgumentParser()
|
| 51 |
+
parser.add_argument("--input", type=str, required=True, help="Input image path OR input folder path containing images")
|
| 52 |
+
parser.add_argument("--seed", type=int, default=42, help="Random seed (base value)")
|
| 53 |
+
parser.add_argument("--num_results", type=int, default=1, help="Number of generated results (different seeds)")
|
| 54 |
+
parser.add_argument("--num_inference_steps", type=int, default=50, help="Number of inference steps")
|
| 55 |
+
parser.add_argument("--guidance_scale", type=float, default=7.5, help="CFG strength")
|
| 56 |
+
parser.add_argument("--model_path", type=str, default="tencent/Hunyuan3D-2.1", help="Model path (using v2.1)")
|
| 57 |
+
parser.add_argument("--subfolder", type=str, default="hunyuan3d-dit-v2-1", help="Model subfolder")
|
| 58 |
+
parser.add_argument("--use_safetensors", action="store_true", help="Use safetensors format (default is ckpt)")
|
| 59 |
+
parser.add_argument("--octree_resolution", type=int, default=384, help="Octree resolution (higher is finer but slower)")
|
| 60 |
+
parser.add_argument("--mc_level", type=float, default=0, help="Marching Cubes threshold")
|
| 61 |
+
args = parser.parse_args()
|
| 62 |
+
|
| 63 |
+
# Log configuration details
|
| 64 |
+
logging.info("="*60)
|
| 65 |
+
logging.info("Hunyuan3D-2.1 configuration:")
|
| 66 |
+
logging.info(f" - Model: {args.model_path}/{args.subfolder}")
|
| 67 |
+
logging.info(f" - Model format: {'safetensors' if args.use_safetensors else 'checkpoint (.ckpt)'}")
|
| 68 |
+
logging.info(f" - Inference steps: {args.num_inference_steps}")
|
| 69 |
+
logging.info(f" - Result count: {args.num_results}")
|
| 70 |
+
logging.info(f" - CFG strength: {args.guidance_scale}")
|
| 71 |
+
logging.info(f" - Octree resolution: {args.octree_resolution}")
|
| 72 |
+
logging.info(f" - MC threshold: {args.mc_level:.6f}")
|
| 73 |
+
logging.info("="*60)
|
| 74 |
+
|
| 75 |
+
# ==================== Load the model ====================
|
| 76 |
+
logging.info("🔧 Loading the Hunyuan3D-2.1 model...")
|
| 77 |
+
|
| 78 |
+
try:
|
| 79 |
+
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(
|
| 80 |
+
args.model_path,
|
| 81 |
+
subfolder=args.subfolder,
|
| 82 |
+
torch_dtype=torch.float16,
|
| 83 |
+
use_safetensors=args.use_safetensors
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
if pipeline is None:
|
| 87 |
+
raise ValueError("Pipeline loading failed and returned None")
|
| 88 |
+
|
| 89 |
+
logging.info(" ✅ Pipeline loaded successfully")
|
| 90 |
+
pipeline.to('cuda')
|
| 91 |
+
logging.info(" ✅ Model moved to CUDA (dtype: fp16)")
|
| 92 |
+
|
| 93 |
+
except Exception as e:
|
| 94 |
+
logging.error(f"❌ Model loading failed: {e}")
|
| 95 |
+
import traceback
|
| 96 |
+
logging.error(traceback.format_exc())
|
| 97 |
+
sys.exit(1)
|
| 98 |
+
|
| 99 |
+
vae = pipeline.vae
|
| 100 |
+
logging.info(" ✅ VAE acquired successfully")
|
| 101 |
+
|
| 102 |
+
# Init Background Remover once (optimization)
|
| 103 |
+
logging.info(" 🔧 Initializing Background Remover...")
|
| 104 |
+
rembg = BackgroundRemover()
|
| 105 |
+
|
| 106 |
+
# ==================== Gather Input Images & Set Up Folders ====================
|
| 107 |
+
# Build absolute path for the input folder
|
| 108 |
+
input_folder = os.path.join("/scratch/cvlab/home/seiler/physiopt_new/input", args.input)
|
| 109 |
+
|
| 110 |
+
# Check if the absolute path is a valid existing directory
|
| 111 |
+
if os.path.isdir(input_folder):
|
| 112 |
+
logging.info(f"📁 Input is a directory. Searching for images in: {input_folder}")
|
| 113 |
+
# Build image paths
|
| 114 |
+
image_paths = sorted([
|
| 115 |
+
os.path.join(input_folder, f) for f in os.listdir(input_folder)
|
| 116 |
+
if f.lower().endswith(('.png', '.jpg', '.jpeg', '.webp'))
|
| 117 |
+
])
|
| 118 |
+
|
| 119 |
+
# Base output folder takes the name of the input argument
|
| 120 |
+
base_out_folder = os.path.join("/scratch/cvlab/home/seiler/physiopt_new/output/hunyuan_gen", args.input)
|
| 121 |
+
else:
|
| 122 |
+
logging.error(f"❌ Error: Input path must be a valid folder. Could not find: {input_folder}")
|
| 123 |
+
sys.exit(1)
|
| 124 |
+
|
| 125 |
+
if not image_paths:
|
| 126 |
+
logging.error(f"❌ No images found in {input_folder}")
|
| 127 |
+
sys.exit(1)
|
| 128 |
+
|
| 129 |
+
logging.info(f"✅ Found {len(image_paths)} image(s) to process.")
|
| 130 |
+
|
| 131 |
+
# Create the root output directory
|
| 132 |
+
os.makedirs(base_out_folder, exist_ok=True)
|
| 133 |
+
|
| 134 |
+
# ==================== Main Loop over Images ====================
|
| 135 |
+
for img_path in image_paths:
|
| 136 |
+
img_name = os.path.splitext(os.path.basename(img_path))[0]
|
| 137 |
+
current_out_folder = os.path.join(base_out_folder, img_name)
|
| 138 |
+
|
| 139 |
+
# Skip if output already exists
|
| 140 |
+
check_file = os.path.join(current_out_folder, "latents.pt")
|
| 141 |
+
if os.path.exists(check_file):
|
| 142 |
+
logging.info(f"⏭️ Skipping: Output already exists for {img_name} ({check_file})")
|
| 143 |
+
continue
|
| 144 |
+
|
| 145 |
+
os.makedirs(current_out_folder, exist_ok=True)
|
| 146 |
+
|
| 147 |
+
logging.info("="*60)
|
| 148 |
+
logging.info(f"📷 Processing image: {img_path}")
|
| 149 |
+
logging.info(f"📁 Output will be saved to: {current_out_folder}")
|
| 150 |
+
|
| 151 |
+
# Load and process image
|
| 152 |
+
image = Image.open(img_path).convert("RGBA")
|
| 153 |
+
|
| 154 |
+
if image.mode == 'RGB':
|
| 155 |
+
logging.info(" Removing background...")
|
| 156 |
+
image = rembg(image)
|
| 157 |
+
|
| 158 |
+
# Save the processed image
|
| 159 |
+
image.save(os.path.join(current_out_folder, "input_image.png"))
|
| 160 |
+
|
| 161 |
+
# ==================== Generate the 3D shape ====================
|
| 162 |
+
logging.info("🎨 Generating 3D shape(s)...")
|
| 163 |
+
num_results = max(1, int(args.num_results))
|
| 164 |
+
|
| 165 |
+
for idx in range(num_results):
|
| 166 |
+
sample_seed = args.seed + idx
|
| 167 |
+
# Handle subfolders for multiple results
|
| 168 |
+
if num_results == 1:
|
| 169 |
+
sample_out = current_out_folder
|
| 170 |
+
else:
|
| 171 |
+
sample_out = os.path.join(current_out_folder, f"sample_{idx:02d}")
|
| 172 |
+
os.makedirs(sample_out, exist_ok=True)
|
| 173 |
+
image.save(os.path.join(sample_out, "input_image.png"))
|
| 174 |
+
|
| 175 |
+
logging.info(f" === Sample {idx+1}/{num_results} | seed={sample_seed} ===")
|
| 176 |
+
torch.manual_seed(sample_seed)
|
| 177 |
+
np.random.seed(sample_seed)
|
| 178 |
+
|
| 179 |
+
# Step 1: generate and save latents
|
| 180 |
+
latents = pipeline(
|
| 181 |
+
image=image,
|
| 182 |
+
num_inference_steps=args.num_inference_steps,
|
| 183 |
+
guidance_scale=args.guidance_scale,
|
| 184 |
+
generator=torch.Generator(device='cuda').manual_seed(sample_seed),
|
| 185 |
+
output_type='latent',
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
# Save latents
|
| 189 |
+
latents_path = os.path.join(sample_out, "latents.pt")
|
| 190 |
+
save_dict = {
|
| 191 |
+
'latents': latents.cpu() if isinstance(latents, torch.Tensor) else latents,
|
| 192 |
+
'image': np.array(image)
|
| 193 |
+
}
|
| 194 |
+
torch.save(save_dict, latents_path)
|
| 195 |
+
logging.info(f" ✅ Saved latents to: {latents_path}")
|
| 196 |
+
|
| 197 |
+
# Step 2: decode latents to a mesh
|
| 198 |
+
logging.info(" 🎭 Decoding latents into a mesh...")
|
| 199 |
+
mesh = pipeline._export(
|
| 200 |
+
latents,
|
| 201 |
+
output_type='trimesh',
|
| 202 |
+
box_v=1.01,
|
| 203 |
+
mc_level=args.mc_level,
|
| 204 |
+
num_chunks=20000,
|
| 205 |
+
octree_resolution=args.octree_resolution,
|
| 206 |
+
mc_algo='mc',
|
| 207 |
+
enable_pbar=False # Avoid progress bar spam
|
| 208 |
+
)[0]
|
| 209 |
+
|
| 210 |
+
# Save the mesh
|
| 211 |
+
mesh.export(os.path.join(sample_out, "generated_mesh.obj"))
|
| 212 |
+
mesh.export(os.path.join(sample_out, "generated_mesh.glb"))
|
| 213 |
+
logging.info(" 💾 Saved OBJ and GLB meshes")
|
| 214 |
+
|
| 215 |
+
# Free memory
|
| 216 |
+
del mesh
|
| 217 |
+
del latents
|
| 218 |
+
if torch.cuda.is_available():
|
| 219 |
+
torch.cuda.empty_cache()
|
| 220 |
+
|
| 221 |
+
logging.info("="*60)
|
| 222 |
+
logging.info(f"✅ All {len(image_paths)} images processed successfully!")
|
| 223 |
+
logging.info(f"📂 Check the outputs in: {base_out_folder}")
|
cfd_workflow_20261012/_seiler_ref/physiopt_new_scripts/test_init_compliance.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|