tutorials: Examples of mapFieldsPar usage

Two pitzDaily variants have been added; pitzDailySteadyMappedToPart, and
pitzDailySteadyMappedToRefined. These demonstrate usage of workflows
which involve mapping between cases with mapFieldsPar.

The pitzDailySteadyMappedToPart case demonstrates mapping onto a small
section of the mesh; in this case in the vicinity of the the corner of
the backstep. This mesh is not consistent with the source data, so
fields are required in the zero directory and cutting patches are used
to specify the properties at the inlets.

The pitzDailySteadyMappedToRefined case demonstrates mapping onto a
geometrically similar case with a different mesh density. This mesh is
consistent with the source, so no fields are needed and no cutting
patches are used. This case does, however, perturb the geometry of the
block mesh a bit, so that some of the refined case is not overlapping
the original case. This provides a test of the stabilisation
procedures within the mesh-to-mesh mapping functions.
This commit is contained in:
Will Bainbridge
2023-02-09 15:31:07 +00:00
parent 9175fb13fd
commit 2cf966de89
47 changed files with 568 additions and 0 deletions

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
cutIn
{
type fixedValue;
value $internalField;
}
cutOut
{
type pressureInletOutletVelocity;
value $internalField;
}
lowerWall
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 14.855;
boundaryField
{
cutIn
{
type fixedValue;
value $internalField;
}
cutOut
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
lowerWall
{
type epsilonWallFunction;
value $internalField;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0.375;
boundaryField
{
cutIn
{
type fixedValue;
value $internalField;
}
cutOut
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
lowerWall
{
type kqRWallFunction;
value $internalField;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
cutIn
{
type calculated;
value $internalField;
}
cutOut
{
type calculated;
value $internalField;
}
lowerWall
{
type nutkWallFunction;
value $internalField;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
cutIn
{
type zeroGradient;
}
cutOut
{
type entrainmentPressure;
p0 $internalField;
value $internalField;
}
lowerWall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,9 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase && rm -rf pitzDailySteady constant system/controlDict system/fv*
#------------------------------------------------------------------------------

View File

@ -0,0 +1 @@
Allrun-parallel

View File

@ -0,0 +1,46 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run and clean functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
# Copy the source case
isTest "$@" && path=.. || path=$FOAM_TUTORIALS/modules/incompressibleFluid
cp -r $path/pitzDailySteady/constant .
cp -r $path/pitzDailySteady/system/controlDict system
cp -r $path/pitzDailySteady/system/fv* system
cp -r $path/pitzDailySteady .
# Run the source case in parallel
(
cd pitzDailySteady
isTest "$@" && cleanCase
cp ../system/decomposeParDict system
runApplication blockMesh -dict $FOAM_TUTORIALS/resources/blockMesh/pitzDaily
runApplication decomposePar
runParallel foamRun
)
# Mesh
runApplication blockMesh
runApplication decomposePar
# Map from the source case into this case and run in parallel
#
# !!! Smooth interpolative mapping from a coarse to a fine case is not
# available within mapFieldsPar. All current options create fields with step
# changes at the boundaries between coarse source cells. This poor
# initialisation results in a large transient at the start of the part
# simulation. We need a lot of under-relaxation to overcome this. In future, it
# is desired to introduce smooth interpolative mapping, which should resolve
# this issue and the need for additional under-relaxation.
#
runParallel mapFieldsPar pitzDailySteady -sourceTime latestTime -fields "(epsilon k nut p U)"
runApplication foamDictionary system/fvSolution -entry relaxationFactors/equations -set '{ ".*" 0.1; }'
runParallel foamRun
# Reconstruct, including the values mapped to the zero directory
runApplication reconstructPar -withZero
#------------------------------------------------------------------------------

View File

@ -0,0 +1,39 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run and clean functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
# Copy the source case
isTest "$@" && path=.. || path=$FOAM_TUTORIALS/modules/incompressibleFluid
cp -r $path/pitzDailySteady/constant .
cp -r $path/pitzDailySteady/system/controlDict system
cp -r $path/pitzDailySteady/system/fv* system
cp -r $path/pitzDailySteady .
# Run the source case
(
cd pitzDailySteady
isTest "$@" && cleanCase
./Allrun
)
# Mesh
runApplication blockMesh
# Map from the source case into this case and run
#
# !!! Smooth interpolative mapping from a coarse to a fine case is not
# available within mapFieldsPar. All current options create fields with step
# changes at the boundaries between coarse source cells. This poor
# initialisation results in a large transient at the start of the part
# simulation. We need a lot of under-relaxation to overcome this. In future, it
# is desired to introduce smooth interpolative mapping, which should resolve
# this issue and the need for additional under-relaxation.
#
runApplication mapFieldsPar pitzDailySteady -sourceTime latestTime -fields "(epsilon k nut p U)"
runApplication foamDictionary system/fvSolution -entry relaxationFactors/equations -set '{ ".*" 0.1; }'
runApplication foamRun
#------------------------------------------------------------------------------

View File

@ -0,0 +1,85 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(-2 0 -0.5)
(-2 1 -0.5)
(0 -1 -0.5)
(0 0 -0.5)
(0 1 -0.5)
(2 -1 -0.5)
(2 0 -0.5)
(2 1 -0.5)
(-2 0 0.5)
(-2 1 0.5)
(0 -1 0.5)
(0 0 0.5)
(0 1 0.5)
(2 -1 0.5)
(2 0 0.5)
(2 1 0.5)
);
blocks
(
hex (0 3 4 1 8 11 12 9) (30 40 1) simpleGrading (0.2 5 1)
hex (2 5 6 3 10 13 14 11) (30 40 1) simpleGrading (5 0.2 1)
hex (3 6 7 4 11 14 15 12) (30 40 1) simpleGrading (5 5 1)
);
defaultPatch
{
name frontAndBack;
type empty;
}
boundary
(
lowerWall
{
type wall;
faces
(
(0 3 11 8)
(3 2 10 11)
);
}
cutIn
{
type patch;
faces
(
(0 1 9 8)
(2 5 13 10)
);
}
cutOut
{
type patch;
faces
(
(1 4 12 9)
(4 7 15 12)
(5 6 14 13)
(6 7 15 14)
);
}
);
// ************************************************************************* //

View File

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

View File

@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object mapFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
patchMap (lowerWall lowerWall);
cuttingPatches (cutIn);
// ************************************************************************* //

View File

@ -0,0 +1,11 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase && rm -rf pitzDailySteady 0 constant
find system -type f -not -name decomposeParDict -delete
#------------------------------------------------------------------------------

View File

@ -0,0 +1,30 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
# Get the standard mesh dictionary
cp -f $FOAM_TUTORIALS/resources/blockMesh/pitzDaily system
# Decrease the mesh spacings by a factor
factor=5/4
for nX in 18 180 25
do
for nY in 27 30
do
nXYZ0="($nX $nY 1)"
nXYZ1="($(echo $nX*$factor | bc) $(echo $nY*$factor | bc) 1)"
sed -i "s/$nXYZ0/$nXYZ1/g" system/blockMeshDict
done
done
# Create a slightly inconsistent geometry, with some cells and patch faces
# falling outside the source case. This tests the stabilisation of the
# mesh-to-mesh interpolations.
sed -i 's/(0 0 \(.*\))/(-1.2 0 \1)/g' system/blockMeshDict
# Mesh
runApplication blockMesh
#------------------------------------------------------------------------------

View File

@ -0,0 +1 @@
Allrun-parallel

View File

@ -0,0 +1,35 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run and clean functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
# Copy the source case
isTest "$@" && path=.. || path=$FOAM_TUTORIALS/modules/incompressibleFluid
cp -r $path/pitzDailySteady/constant .
cp -r $path/pitzDailySteady/system/* system
cp -r $path/pitzDailySteady .
# Run the source case in parallel
(
cd pitzDailySteady
isTest "$@" && cleanCase
cp ../system/decomposeParDict system
runApplication blockMesh -dict $FOAM_TUTORIALS/resources/blockMesh/pitzDaily
runApplication decomposePar
runParallel foamRun
)
# Mesh
./Allmesh
runApplication decomposePar
# Map from the source case into this case and run
runParallel mapFieldsPar pitzDailySteady -consistent -sourceTime latestTime
runParallel foamRun
# Reconstruct, including the values mapped to the zero directory
runApplication reconstructPar -withZero
#------------------------------------------------------------------------------

View File

@ -0,0 +1,28 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run and clean functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
# Copy the source case
isTest "$@" && path=.. || path=$FOAM_TUTORIALS/modules/incompressibleFluid
cp -r $path/pitzDailySteady/constant .
cp -r $path/pitzDailySteady/system/* system
cp -r $path/pitzDailySteady .
# Run the source case
(
cd pitzDailySteady
isTest "$@" && cleanCase
./Allrun
)
# Mesh
./Allmesh
# Map from the source case into this case and run
runApplication mapFieldsPar pitzDailySteady -consistent -sourceTime latestTime
runApplication foamRun
#------------------------------------------------------------------------------

View File

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