mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
TUT: verificationAndValidation for weightedFlux scheme (#1388)
This commit is contained in:
committed by
Mark Olesen
parent
d04de0d481
commit
3b6ba059c3
@ -0,0 +1,30 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class volScalarField;
|
||||
object DT;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dimensions [0 2 -1 0 0 0 0];
|
||||
|
||||
internalField uniform 0;
|
||||
|
||||
boundaryField
|
||||
{
|
||||
"(top|bottom|sideWalls)"
|
||||
{
|
||||
type fixedGradient;
|
||||
gradient uniform 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,39 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class volScalarField;
|
||||
object T;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dimensions [0 0 0 1 0 0 0];
|
||||
|
||||
internalField uniform 273;
|
||||
|
||||
boundaryField
|
||||
{
|
||||
top
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform 1;
|
||||
}
|
||||
bottom
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform 0;
|
||||
}
|
||||
sideWalls
|
||||
{
|
||||
type zeroGradient;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
12
tutorials/verificationAndValidation/schemes/weightedFluxExample/Allclean
Executable file
12
tutorials/verificationAndValidation/schemes/weightedFluxExample/Allclean
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
cleanCase0
|
||||
|
||||
rm -f *.png
|
||||
|
||||
rm -f system/controlDict system/fvSchemes
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
42
tutorials/verificationAndValidation/schemes/weightedFluxExample/Allrun
Executable file
42
tutorials/verificationAndValidation/schemes/weightedFluxExample/Allrun
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
restore0Dir
|
||||
|
||||
cp -f system/controlDict.template system/controlDict
|
||||
cp -f system/fvSchemes.template system/fvSchemes
|
||||
|
||||
runApplication blockMesh
|
||||
runApplication setFields
|
||||
|
||||
# ----
|
||||
echo "Run base-line (1)"
|
||||
foamDictionary -entry endTime -set 1 system/controlDict >/dev/null
|
||||
sed -i '/^ *laplacian/s/Gauss.*;/Gauss linear corrected;/' system/fvSchemes
|
||||
|
||||
runApplication -s 1 $(getApplication)
|
||||
|
||||
# ----
|
||||
echo "Run harmonic corrected (2)"
|
||||
|
||||
foamDictionary -entry endTime -set 2 system/controlDict >/dev/null
|
||||
sed -i '/^ *laplacian/s/Gauss.*;/Gauss harmonic corrected;/' system/fvSchemes
|
||||
|
||||
runApplication -s 2 $(getApplication)
|
||||
|
||||
# ----
|
||||
echo "Run weightedFlux (3)"
|
||||
foamDictionary -entry endTime -set 3 system/controlDict >/dev/null
|
||||
sed -i '/^ *grad/s/Gauss.*;/Gauss weightedFlux "DT";/' system/fvSchemes
|
||||
|
||||
runApplication -s 3 $(getApplication)
|
||||
|
||||
# ----
|
||||
|
||||
runApplication -s singleGraph postProcess -func singleGraph
|
||||
|
||||
./plot $@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -0,0 +1,20 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "constant";
|
||||
object transportProperties;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
DT 0; //Not used
|
||||
|
||||
// ************************************************************************* //
|
||||
88
tutorials/verificationAndValidation/schemes/weightedFluxExample/plot
Executable file
88
tutorials/verificationAndValidation/schemes/weightedFluxExample/plot
Executable file
@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Plot temperature, heat flux vs analytical
|
||||
|
||||
graphDir="postProcessing/singleGraph"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
plotTemperature() {
|
||||
graphName="Tprofile.png"
|
||||
echo "Creating temperature profile graph to $graphName"
|
||||
gnuplot<<GNUPLOT
|
||||
set terminal pngcairo font "Helvetica,12" size 800,600
|
||||
set title "Temperature profile" font "Helvetica,12"
|
||||
|
||||
set key bottom right
|
||||
set xlabel "z" font "Helvetica,12"
|
||||
set ylabel "Temperature" font "Helvetica,16"
|
||||
set output "$graphName"
|
||||
|
||||
set logscale y
|
||||
set format y "10^{%L}"
|
||||
set key font ",12"
|
||||
|
||||
set lmargin 10
|
||||
set rmargin 1.5
|
||||
set bmargin 3.2
|
||||
|
||||
s1=1
|
||||
s2=1e6
|
||||
|
||||
fo(x)=s1/(s1+s2)+s2*x/(s1+s2)
|
||||
fu(x)=s1/(s1+s2)+s1*x/(s1+s2)
|
||||
|
||||
plot \
|
||||
(x<=0)?fu(x):fo(x) w l lc 0 t 'analytical solution', \
|
||||
"$graphDir/1/line_T.xy" u 1:2 w p pt 2 ps 2 lt rgb "red" t 'linear interpolation', \
|
||||
"$graphDir/2/line_T.xy" u 1:2 w p pt 6 ps 2 lt rgb "green" t 'harmonic interpolation'
|
||||
|
||||
GNUPLOT
|
||||
}
|
||||
|
||||
|
||||
plotHeatFlux() {
|
||||
graphName="heatFlux.png"
|
||||
echo "Creating heat-flux graph to $graphName"
|
||||
gnuplot<<GNUPLOT
|
||||
set terminal pngcairo font "Helvetica,12" size 800,600
|
||||
set title "Heat Flux" font "Helvetica,16"
|
||||
|
||||
set key top right
|
||||
set xlabel "z" font "Helvetica,12"
|
||||
set output "$graphName"
|
||||
|
||||
set logscale y
|
||||
set format y "10^{%L}"
|
||||
set key font ",12"
|
||||
|
||||
set lmargin 10
|
||||
set rmargin 1.5
|
||||
set bmargin 3.2
|
||||
|
||||
plot \
|
||||
"$graphDir/1/line_flux.xy" u 1:4 w p pt 6 ps 2 lt rgb "red" t 'laplacian: linear, grad: linear', \
|
||||
"$graphDir/2/line_flux.xy" u 1:4 w p pt 2 ps 2 lt rgb "blue" t 'laplacian: harmonic, grad: linear', \
|
||||
"$graphDir/3/line_flux.xy" u 1:4 w l lt rgb "green" t 'laplacian: harmonic, grad: weightedFlux'
|
||||
GNUPLOT
|
||||
}
|
||||
|
||||
|
||||
if notTest $@
|
||||
then
|
||||
# Create validation plots
|
||||
|
||||
# Require gnuplot
|
||||
command -v gnuplot >/dev/null || {
|
||||
echo "gnuplot not found - skipping graph creation" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
plotTemperature
|
||||
plotHeatFlux
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
@ -0,0 +1,68 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object blockMeshDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
a 0.5;
|
||||
b -0.5;
|
||||
h1 -1;
|
||||
h2 1;
|
||||
|
||||
vertices
|
||||
(
|
||||
($a $a $h1)
|
||||
($b $a $h1)
|
||||
($b $b $h1)
|
||||
($a $b $h1)
|
||||
|
||||
($a $a $h2)
|
||||
($b $a $h2)
|
||||
($b $b $h2)
|
||||
($a $b $h2)
|
||||
);
|
||||
|
||||
blocks
|
||||
(
|
||||
hex (0 1 2 3 4 5 6 7) (1 1 100) simpleGrading (1 1 1)
|
||||
);
|
||||
|
||||
edges
|
||||
(
|
||||
);
|
||||
|
||||
boundary
|
||||
(
|
||||
bottom
|
||||
{
|
||||
type wall;
|
||||
faces
|
||||
(
|
||||
(0 1 2 3)
|
||||
);
|
||||
}
|
||||
top
|
||||
{
|
||||
type wall;
|
||||
faces
|
||||
(
|
||||
(4 5 6 7)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
mergePatchPairs
|
||||
(
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object controlDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
application laplacianFoam;
|
||||
|
||||
startFrom latestTime;
|
||||
|
||||
startTime 0;
|
||||
|
||||
stopAt endTime;
|
||||
|
||||
endTime 1;
|
||||
|
||||
deltaT 0.005;
|
||||
|
||||
writeControl runTime;
|
||||
|
||||
writeInterval 1;
|
||||
|
||||
purgeWrite 0;
|
||||
|
||||
writeFormat ascii;
|
||||
|
||||
writePrecision 6;
|
||||
|
||||
writeCompression off;
|
||||
|
||||
timeFormat general;
|
||||
|
||||
timePrecision 6;
|
||||
|
||||
runTimeModifiable true;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object fvSchemes;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
ddtSchemes
|
||||
{
|
||||
default steadyState;
|
||||
}
|
||||
|
||||
gradSchemes
|
||||
{
|
||||
grad(T) Gauss linear;
|
||||
}
|
||||
|
||||
divSchemes
|
||||
{
|
||||
default none;
|
||||
}
|
||||
|
||||
laplacianSchemes
|
||||
{
|
||||
laplacian(DT,T) Gauss linear corrected;
|
||||
}
|
||||
|
||||
interpolationSchemes
|
||||
{
|
||||
default linear;
|
||||
}
|
||||
|
||||
snGradSchemes
|
||||
{
|
||||
default corrected;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,35 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object fvSolution;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
solvers
|
||||
{
|
||||
T
|
||||
{
|
||||
solver PCG;
|
||||
preconditioner DIC;
|
||||
tolerance 1e-15;
|
||||
relTol 0;
|
||||
}
|
||||
}
|
||||
|
||||
SIMPLE
|
||||
{
|
||||
nNonOrthogonalCorrectors 2;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,38 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object setFieldsDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
defaultFieldValues
|
||||
(
|
||||
volScalarFieldValue DT 1
|
||||
);
|
||||
|
||||
regions
|
||||
(
|
||||
cylinderToCell
|
||||
{
|
||||
p1 (0 0 -5);
|
||||
p2 (0 0 .000);
|
||||
radius 1;
|
||||
fieldValues
|
||||
(
|
||||
volScalarFieldValue DT 1e6
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,26 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1912 |
|
||||
| \\ / A nd | Website: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
singleGraph
|
||||
{
|
||||
start (0 0 -1);
|
||||
end (0 0 1);
|
||||
fields (T flux);
|
||||
|
||||
#includeEtc "caseDicts/postProcessing/graphs/sampleDict.cfg"
|
||||
|
||||
setConfig
|
||||
{
|
||||
axis z;
|
||||
}
|
||||
|
||||
// Must be last entry
|
||||
#includeEtc "caseDicts/postProcessing/graphs/graph.cfg"
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user