TUT: added a topology optimisation tutorial using ISQP

to update the design variables
This commit is contained in:
Vaggelis Papoutsis
2023-12-08 14:11:38 +02:00
committed by Andrew Heather
parent 0af46becdd
commit 7868d9251a
36 changed files with 1880 additions and 0 deletions

View File

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
"wall|fixedWalls"
{
type fixedValue;
value uniform (0 0 0);
}
inlet
{
type surfaceNormalFixedValue;
refValue uniform -10;
value uniform (0 0 0);
}
"outlet.*"
{
type zeroGradient;
}
symmetry
{
type symmetry;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
"wall|fixedWalls"
{
type fixedValue;
value uniform (0 0 0);
}
inlet
{
type adjointInletVelocity;
value uniform (0 0 0);
}
"outlet.*"
{
type adjointOutletVelocityFlux;
value uniform (0 0 0);
}
symmetry
{
type symmetry;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,42 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
"wall|fixedWalls"
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
"outlet.*"
{
type fixedValue;
value uniform 0;
}
symmetry
{
type symmetry;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,42 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
"wall|fixedWalls"
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
"outlet.*"
{
type adjointOutletPressure;
value uniform 0;
}
symmetry
{
type symmetry;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,15 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
cleanCase0
if [ -d reEval ]
then
cd reEval
./Allclean
cd ..
fi
#------------------------------------------------------------------------------

View File

@ -0,0 +1,23 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication blockMesh
runApplication -s 'refinementZones' topoSet
runApplication refineHexMesh -overwrite allIO
runApplication -s 'allZones' topoSet
runApplication setsToZones -noFlipMap
runApplication createPatch -overwrite
restore0Dir
runApplication decomposePar
runParallel $(getApplication)
if [ -d reEval ]
then
cd reEval
./AllrunReEval > log.AllrunReEval 2>&1 && echo "End" >> log.AllrunReEval
cd ..
fi
#------------------------------------------------------------------------------

View File

@ -0,0 +1,23 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object adjointRASProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
adjointRASModel adjointLaminar;
adjointTurbulence on;
printCoeffs off;
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 1e-03;
// ************************************************************************* //

View File

@ -0,0 +1,28 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
RAS
{
RASModel laminar;
turbulence on;
printCoeffs on;
}
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
"wall|fixedWalls|topOPatch"
{
type fixedValue;
value uniform (0 0 0);
}
inlet
{
type surfaceNormalFixedValue;
refValue uniform -10;
value uniform (0 0 0);
}
"outlet.*"
{
type zeroGradient;
}
symmetry
{
type symmetry;
}
#includeEtc "caseDicts/setConstraintTypes"
}
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
"wall|fixedWalls|topOPatch"
{
type fixedValue;
value uniform (0 0 0);
}
inlet
{
type adjointInletVelocity;
value uniform (0 0 0);
}
"outlet.*"
{
type adjointOutletVelocityFlux;
value uniform (0 0 0);
}
symmetry
{
type symmetry;
}
#includeEtc "caseDicts/setConstraintTypes"
}
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
"wall|fixedWalls|topOPatch"
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
"outlet.*"
{
type fixedValue;
value uniform 0;
}
symmetry
{
type symmetry;
}
#includeEtc "caseDicts/setConstraintTypes"
}
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
"wall|fixedWalls|topOPatch"
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
"outlet.*"
{
type adjointOutletPressure;
value uniform 0;
}
symmetry
{
type symmetry;
}
#includeEtc "caseDicts/setConstraintTypes"
}
// ************************************************************************* //

View File

@ -0,0 +1,22 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
cleanCase0
# Remove surface and features
rm -rf constant/extendedFeatureEdgeMesh
rm -rf constant/triSurface/*
# Restore default entries in snappyHexMeshDict and surfaceFeatureExtractDict
foamDictionary system/snappyHexMeshDict -entry castellatedMeshControls.locationInMesh -remove
foamDictionary system/snappyHexMeshDict -entry castellatedMeshControls.locationInMesh -add "myLocationInMesh"
topOEndTime=$(foamDictionary ../system/controlDict -entry 'endTime' -value)
fileName=topOIsoSurface$topOEndTime
sed -i "s|$fileName|stlName|g" system/snappyHexMeshDict
sed -i "s|$fileName|stlName|g" system/surfaceFeatureExtractDict
#------------------------------------------------------------------------------

View File

@ -0,0 +1,31 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
topOEndTime=$(foamDictionary ../system/controlDict -entry 'endTime' -value)
fileName=topOIsoSurface$topOEndTime
# A bit ugly but expanding a stored variable of the form "(a b c)" seems tricky
locationInMesh="\(0.058 0.15 0.094\)"
sed -i "s|myLocationInMesh|$locationInMesh|g" system/snappyHexMeshDict
sed -i "s|stlName|$fileName|g" system/snappyHexMeshDict
sed -i "s|stlName|$fileName|g" system/surfaceFeatureExtractDict
mkdir -p constant/triSurface
cp ../optimisation/topOIsoSurfaces/$fileName.stl constant/triSurface/.
runApplication blockMesh
runApplication surfaceFeatureExtract
runApplication decomposePar
runParallel snappyHexMesh -overwrite
restore0Dir -processor
runParallel $(getApplication)
#------------------------------------------------------------------------------

View File

@ -0,0 +1,23 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object adjointRASProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
adjointRASModel adjointLaminar;
adjointTurbulence on;
printCoeffs off;
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicRefineFvMesh;
dynamicRefineFvMeshCoeffs
{
// How often to refine
refineInterval 1;
// Field to be refinement on
field mmagfi;
// Refine field inbetween lower..upper
lowerRefineLevel -0.003;
upperRefineLevel 0;
// If value < unrefineLevel unrefine
unrefineLevel -0.003;
// Have slower than 2:1 refinement
nBufferLayers 1;
// Refine cells only up to maxRefinement levels
maxRefinement 1;
// Stop refinement if maxCells reached
maxCells 500000;
// Flux field and corresponding velocity field. Fluxes on changed
// faces get recalculated by interpolating the velocity. Use 'none'
// on surfaceScalarFields that do not need to be reinterpolated.
correctFluxes
(
// (phi U)
// (phia Ua)
);
// Write the refinement level as a volScalarField
dumpLevel true;
}
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 1e-03;
// ************************************************************************* //

View File

@ -0,0 +1,28 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
RAS
{
RASModel laminar;
turbulence on;
printCoeffs on;
}
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
(0 0 0) //0
(0.3 0 0) //1
(0.3 0.3 0) //2
(0 0.3 0) //3
(0 0 0.3) //4
(0.3 0 0.3) //5
(0.3 0.3 0.3) //6
(0 0.3 0.3) //7
);
blocks
(
hex (0 1 2 3 4 5 6 7) (75 75 75) simpleGrading (1 1 1)
);
edges
(
);
patches
(
);
mergePatchPairs
(
);
// ************************************************************************* //

View File

@ -0,0 +1,47 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application adjointOptimisationFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 100;
deltaT 1;
writeControl timeStep;
writeInterval 3000;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression false;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
// ************************************************************************* //

View File

@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4;
method scotch;
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default steadyState;
}
gradSchemes
{
default Gauss linear;
gradUATC cellLimited Gauss linear 1;
grad(U) cellLimited Gauss linear 1;
gradUConv cellLimited Gauss linear 1;
gradUaConv cellLimited Gauss linear 1;
}
divSchemes
{
default Gauss linear;
div(phi,U) bounded Gauss linearUpwindV gradUConv;
div(-phi,Ua) bounded Gauss linearUpwindV gradUaConv;
}
interpolationSchemes
{
default linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
snGradSchemes
{
default corrected;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,54 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
SIMPLE
{
nNonOrthogonalCorrectors 0;
}
solvers
{
"p|pa.*|bTilda"
{
solver PCG;
preconditioner DIC;
tolerance 1e-09;
relTol 0.1;
}
"U|Ua.*" smoothSolver
{
smoother GaussSeidel;
tolerance 1e-9;
relTol 0.1;
};
}
relaxationFactors
{
fields
{
p 0.6;
"pa.*" 0.7;
}
equations
{
U 0.8;
"Ua.*" 0.7;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,104 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object optimisationDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
optimisationManager singleRun;
primalSolvers
{
op1
{
active true;
type incompressible;
solver simple;
solutionControls
{
nIters 3000;
residualControl
{
"p.*" 5.e-7;
"U.*" 5.e-7;
}
}
}
}
adjointManagers
{
adjManager1
{
primalSolver op1;
adjointSolvers
{
as1
{
// choose adjoint solver
//----------------------
active false;
type incompressible;
solver adjointSimple;
computeSensitivities false;
// manage objectives
//------------------
objectives
{
type incompressible;
objectiveNames
{
losses
{
weight 1.;
type PtLosses;
patches ("inlet.*" "outlet.*");
}
uniformity
{
weight 1.;
type uniformityPatch;
patches (outlet1 outlet2);
}
mass
{
weight 1.;
type flowRatePartition;
inletPatches (inlet);
outletPatches (outlet1 outlet2);
targetFractions (0.5 0.5);
}
}
}
// ATC treatment
//--------------
ATCModel
{
ATCModel standard;
}
// solution control
//------------------
solutionControls
{
nIters 300;
residualControl
{
"pa.*" 5.e-7;
"Ua.*" 5.e-7;
}
}
}
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,170 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
FoamFile
{
version 2;
format ascii;
class dictionary;
object snappyHexMeshDict;
}
castellatedMesh true;
snap true;
addLayers true;
singleRegionName true;
geometry
{
stlName.stl
{
type triSurfaceMesh;
name duct;
regions
{
fixedWalls
{
name fixedWalls;
}
symmetry
{
name symmetry;
}
outlet1
{
name outlet1;
}
outlet2
{
name outlet2;
}
inlet
{
name inlet;
}
topOPatch
{
name topOPatch;
}
}
}
}
castellatedMeshControls
{
maxLocalCells 100000;
maxGlobalCells 2000000;
minRefinementCells 100;
maxLoadUnbalance 0.2;
nCellsBetweenLevels 2;
features ( { file stlName.eMesh ; level 2 ; } );
refinementSurfaces
{
duct
{
level ( 2 2 );
patchInfo
{
type patch;
}
regions
{
"topOPatch|fixedWalls"
{
level ( 2 2 );
patchInfo
{
type wall;
inGroups ( ductWalls );
}
}
symmetry
{
level ( 1 1 );
patchInfo
{
type symmetry;
}
}
}
}
}
resolveFeatureAngle 30;
refinementRegions
{
}
allowFreeStandingZoneFaces true;
locationInMesh myLocationInMesh;
}
snapControls
{
nSmoothPatch 3;
tolerance 2;
nSolveIter 30;
nRelaxIter 5;
nFeatureSnapIter 10;
implicitFeatureSnap false;
explicitFeatureSnap true;
multiRegionFeatureSnap false;
}
addLayersControls
{
relativeSizes true;
layers
{
"topOPatch|fixedWalls"
{
nSurfaceLayers 2;
}
}
expansionRatio 1;
finalLayerThickness 0.3;
minThickness 0.1;
nGrow 0;
featureAngle 60;
slipFeatureAngle 30;
nRelaxIter 3;
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
maxFaceThicknessRatio 0.5;
maxThicknessToMedialRatio 0.3;
minMedialAxisAngle 90;
nBufferCellsNoExtrude 0;
nLayerIter 50;
}
meshQualityControls
{
maxNonOrtho 65;
maxBoundarySkewness 20;
maxInternalSkewness 4;
maxConcave 80;
minVol 1e-13;
minTetQuality 1e-15;
minArea -1;
minTwist 0.02;
minDeterminant 0.001;
minFaceWeight 0.02;
minVolRatio 0.01;
minTriangleTwist -1;
nSmoothScale 4;
errorReduction 0.75;
}
writeFlags ( scalarLevels layerSets layerFields );
mergeTolerance 1e-06;
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object surfaceFeatureExtractDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
stlName.stl
{
// How to obtain raw features (extractFromFile || extractFromSurface)
extractionMethod extractFromSurface;
// Mark edges whose adjacent surface normals are at an angle less
// than includedAngle as features
// - 0 : selects no edges
// - 180: selects all edges
includedAngle 120;
subsetFeatures
{
// Keep nonManifold edges (edges with >2 connected faces)
nonManifoldEdges no;
// Keep open edges (edges with 1 connected face)
openEdges yes;
}
// Write options
// Write features to obj format for postprocessing
writeObj yes;
}
// ************************************************************************* //

View File

@ -0,0 +1,69 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
(0 0 0) //0
(0.2 0 0) //1
(0.2 0.1 0) //2
(0.2 0.2 0) //3
(0.1 0.2 0) //4
(0 0.1 0) //5
(0 0 0.1) //6
(0.2 0 0.1) //7
(0.2 0.1 0.1) //8
(0.2 0.2 0.1) //9
(0.1 0.2 0.1) //10
(0 0.1 0.1) //11
);
blocks
(
hex (0 1 2 5 6 7 8 11) (76 38 38) simpleGrading (1 1 1)
hex (5 2 3 4 11 8 9 10) (76 38 38) simpleGrading (1 1 1)
);
edges
(
);
patches
(
wall fixedWalls
(
(0 1 2 5)
(7 1 2 8)
(6 0 5 11)
(0 1 7 6)
(5 2 3 4)
(8 2 3 9)
(11 5 4 10)
(4 3 9 10)
)
symmetry symmetry
(
(6 7 8 11)
(11 8 9 10)
)
);
mergePatchPairs
(
);
// ************************************************************************* //

View File

@ -0,0 +1,47 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application adjointOptimisationFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 70;
deltaT 1;
writeControl timeStep;
writeInterval 70;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression false;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
// ************************************************************************* //

View File

@ -0,0 +1,91 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// This application/dictionary controls:
// - optional: create new patches from boundary faces (either given as
// a set of patches or as a faceSet)
// - always: order faces on coupled patches such that they are opposite. This
// is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches.
// - always: remove zero-sized (non-coupled) patches (that were not added)
// 1. Create cyclic:
// - specify where the faces should come from
// - specify the type of cyclic. If a rotational specify the rotationAxis
// and centre to make matching easier
// - always create both halves in one invocation with correct 'neighbourPatch'
// setting.
// - optionally pointSync true to guarantee points to line up.
// 2. Correct incorrect cyclic:
// This will usually fail upon loading:
// "face 0 area does not match neighbour 2 by 0.0100005%"
// " -- possible face ordering problem."
// - in polyMesh/boundary file:
// - loosen matchTolerance of all cyclics to get case to load
// - or change patch type from 'cyclic' to 'patch'
// and regenerate cyclic as above
// Do a synchronisation of coupled points after creation of any patches.
// Note: this does not work with points that are on multiple coupled patches
// with transformations (i.e. cyclics).
pointSync false;
// Patches to create.
patches
(
{
name inlet;
patchInfo
{
type patch;
}
constructFrom set;
set inlet;
}
{
// Name of new patch
name outlet1;
// Dictionary to construct new patch from
patchInfo
{
type patch;
}
constructFrom set;
set outlet1;
}
{
// Name of new patch
name outlet2;
// Dictionary to construct new patch from
patchInfo
{
type patch;
}
constructFrom set;
set outlet2;
}
);
// ************************************************************************* //

View File

@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 60;
method scotch;
// ************************************************************************* //

View File

@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvOptions;
}
momSource
{
type topOSource;
names (U Uaas1 Uauniformity Uamass);
function BorrvallPetersson;
b 100;
interpolationField beta;
}

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default steadyState;
}
gradSchemes
{
default Gauss linear;
gradUATC cellLimited Gauss linear 1;
grad(U) cellLimited Gauss linear 1;
gradUConv cellLimited Gauss linear 1;
gradUaConv cellLimited Gauss linear 1;
}
divSchemes
{
default Gauss linear;
div(phi,U) bounded Gauss linearUpwindV gradUConv;
"div\(-phi,Ua.*\)" bounded Gauss linearUpwindV gradUaConv;
}
interpolationSchemes
{
default linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
snGradSchemes
{
default corrected;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,54 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
SIMPLE
{
nNonOrthogonalCorrectors 0;
}
solvers
{
"p|pa.*|bTilda"
{
solver PCG;
preconditioner DIC;
tolerance 1e-12;
relTol 0.01;
}
"U|Ua.*" smoothSolver
{
smoother GaussSeidel;
tolerance 1e-12;
relTol 0.1;
};
}
relaxationFactors
{
fields
{
p 0.6;
"pa.*" 0.6;
}
equations
{
U 0.8;
"Ua.*" 0.6;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,236 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object optimisationDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
optimisationManager steadyOptimisation;
primalSolvers
{
op1
{
active true;
type incompressible;
solver simple;
solutionControls
{
nIters 300;
consistent true;
residualControl
{
"p.*" 1.e-6;
"U.*" 1.e-6;
}
}
}
}
adjointManagers
{
adjManager1
{
primalSolver op1;
adjointSolvers
{
as1
{
// choose adjoint solver
//----------------------
active true;
type incompressible;
solver adjointSimple;
isConstraint true;
// manage objectives
//------------------
objectives
{
type incompressible;
objectiveNames
{
losses
{
weight 1.;
type PtLosses;
patches ("inlet.*" "outlet.*");
normalize true;
target 0.778;
normFactor 0.778;
}
}
}
// ATC treatment
//--------------
ATCModel
{
ATCModel standard;
}
// solution control
//------------------
solutionControls
{
nIters 300;
consistent true;
residualControl
{
"pa.*" 1.e-6;
"Ua.*" 1.e-6;
}
}
}
uniformity
{
// choose adjoint solver
//----------------------
active true;
type incompressible;
solver adjointSimple;
// manage objectives
//------------------
objectives
{
type incompressible;
objectiveNames
{
uniformity
{
weight 1.;
type uniformityPatch;
patches (outlet1 outlet2);
normalize true;
}
}
}
// ATC treatment
//--------------
ATCModel
{
ATCModel standard;
}
// solution control
//------------------
solutionControls
{
nIters 300;
consistent true;
residualControl
{
"pa.*" 1.e-6;
"Ua.*" 1.e-6;
}
}
}
vol
{
// choose adjoint solver
//----------------------
active true;
type null;
isConstraint true;
// manage objectives
//------------------
objectives
{
type geometric;
objectiveNames
{
vol
{
weight 1.;
type topOVolume;
percentage 0.1;
}
}
}
}
mass
{
// choose adjoint solver
//----------------------
active true;
type incompressible;
solver adjointSimple;
isConstraint true;
// manage objectives
//------------------
objectives
{
type incompressible;
objectiveNames
{
mass
{
weight 1.;
type flowRatePartition;
inletPatches (inlet);
outletPatches (outlet1 outlet2);
targetFractions (0.5 0.5);
normalize true;
target 1.e-5;
}
}
}
// ATC treatment
//--------------
ATCModel
{
ATCModel standard;
}
// solution control
//------------------
solutionControls
{
nIters 300;
consistent true;
residualControl
{
"pa.*" 1.e-6;
"Ua.*" 1.e-6;
}
}
}
}
}
}
optimisation
{
designVariables
{
type topO;
sensitivityType topO;
regularisation
{
regularise true;
growFromWalls true;
//meanRadiusMult 10;
radius 0.0380789;
function tanh;
b 20;
}
betaMaxType Darcy;
DarcyCoeffs
{
inletPatches (inlet);
}
maxInitChange 0.2;
}
updateMethod
{
method ISQP;
targetConstraintReduction 0.2;
preconditioner ShermanMorrison;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,118 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name fixedWalls;
type faceSet;
action new;
source patchToFace;
patch fixedWalls;
}
{
name inlet;
type faceSet;
action new;
source faceToFace;
set fixedWalls;
}
{
name inlet;
type faceSet;
action subset;
source boxToFace;
sourceInfo
{
box (0.030 0.130 0.080) (0.070 0.170 0.120);
}
}
{
name inletZone;
type cellSet;
action new;
source faceToCell;
set inlet;
option any;
}
{
name outlet1;
type faceSet;
action new;
source faceToFace;
set fixedWalls;
}
{
name outlet1;
type faceSet;
action subset;
source boxToFace;
sourceInfo
{
box (0.199 0.088 0.02) (0.201 0.112 0.044);
}
}
{
name outlet1Zone;
type cellSet;
action new;
source faceToCell;
set outlet1;
option any;
}
{
name outlet2;
type faceSet;
action new;
source faceToFace;
set fixedWalls;
}
{
name outlet2;
type faceSet;
action subset;
source boxToFace;
sourceInfo
{
box (0.199 0.088 0.064) (0.201 0.112 0.088);
}
}
{
name outlet2Zone;
type cellSet;
action new;
source faceToCell;
set outlet2;
option any;
}
{
name allIO;
type cellSet;
action new;
source cellToCell;
sets (inletZone outlet1Zone outlet2Zone);
}
);
// ************************************************************************* //