Skip to content
Snippets Groups Projects
Commit b99bd662 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

TUT: copy/reuse existing OpenFOAM tutorials

- setup without hypre as the safer choice.
  PETSc may not have been configured with hypre.

Add test for petscFoam loading to top-level tutorials/Allrun
parent df6aaa12
No related merge requests found
Showing
with 157 additions and 16499 deletions
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
. ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions # Tutorial logfile functions
#------------------------------------------------------------------------------
echo "--------"
removeLogs
echo "Cleaning tutorials"
foamCleanTutorials -self
echo "--------"
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions # Tutorial log-file functions
#------------------------------------------------------------------------------
# Collect log files as 'testLoopReport'
collectLogs
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
## . ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions # Tutorial logfile functions
#------------------------------------------------------------------------------
# Test for petscFoam
if command -v foamHasLibrary >/dev/null \
&& ! foamHasLibrary -verbose petscFoam
then
/bin/cat<<INFORMATION 1>&2
==> petsc not found?
Define manually, enable in OpenFOAM etc/bashrc, or try the following [POSIX]:
eval \$(foamEtcFile -sh -config petsc -- -force)
==
INFORMATION
echo "Skip petscFoam tutorials"
exit 1
fi
foamRunTutorials -skipFirst $* # Run tutorials recursively
## collectLogs
#------------------------------------------------------------------------------
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: 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
{
patch1
{
type zeroGradient;
}
patch2
{
type fixedValue;
value uniform 273;
}
patch3
{
type zeroGradient;
}
patch4
{
type fixedValue;
value uniform 573;
}
}
// ************************************************************************* //
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
cleanCase
rm -rf run
cleanCase0
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication ansysToFoam flange.ans -scale 0.001
runApplication $(getApplication)
# runApplication foamToEnsight -noZero
# runApplication foamToVTK
./Allrun.init
dst=run
if [ -d "$dst" ]
then
(cd "$dst" && foamRunTutorials)
# Copy back log files
cp -f "$dst"/log.* .
fi
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication ansysToFoam flange.ans -scale 0.001
runApplication decomposePar
runParallel $(getApplication)
./Allrun.init
dst=run
if [ -f "$dst/Allrun-parallel" ]
then
"$dst"/Allrun-parallel
# Copy back log files
cp -f "$dst"/log.* .
fi
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
tutorial="basic/laplacianFoam/flange"
src="$FOAM_TUTORIALS/$tutorial"
dst=run
if [ -d "$dst" ]
then
echo "Already initialized $tutorial -> $dst/"
elif [ -d "$src" ]
then
echo "Copying $tutorial -> $dst/"
mkdir "$dst"
cp -r "$src"/constant "$dst"
cp -r "$src"/system "$dst"
# Copy zero directory (0.orig/, or 0/)
for i in 0.orig 0
do
if [ -d "$src/$i" ]
then
cp -r "$src/$i" "$dst"
break
fi
done
# Allclean, Allrun etc may not exist
for i in "$src"/All*
do
if [ -f "$i" ]
then
cp "$i" "$dst"
fi
done
else
echo "No OpenFOAM tutorial: $tutorial"
exit 2
fi
#------------------------------------------------------------------------------
# Adjust controlDict - needs refinement if controlDict has other libs
if [ -f "$dst"/system/controlDict ] \
&& ! grep -q petscFoam "$dst"/system/controlDict
then
echo "Add libs (petscFoam) to controlDict"
echo "libs (petscFoam);" >> "$dst"/system/controlDict
fi
# Use fvSolution-petsc
if [ -f "$dst"/system/fvSolution ] \
&& [ ! -f "$dst"/system/fvSolution-petsc ]
then
echo "Rename fvSolution and relink to fvSolution-petsc"
mv "$dst"/system/fvSolution "$dst"/system/fvSolution-foam
(cd "$dst"/system && ln -sf ../../fvSolution-petsc fvSolution)
fi
#------------------------------------------------------------------------------
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
view
{
type petscViewMatrix;
libs ("libpetscFoam.so");
active on;
timeStart 0.1;
duration 10;
selectionMode all;
fields (T);
sleep 3;
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
DT 4e-05;
// ************************************************************************* //
This diff is collapsed.
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\ / O peration | Version: v2006 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
......@@ -37,6 +37,7 @@ solvers
// ksp_norm_type natural;
mat_type mpiaij;
}
// use petsc default convergence testing instead of OpenFOAM's L1 based criterion
// default is false
use_petsc_residual_norm false;
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / 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 0.005;
deltaT 0.005;
writeControl runTime;
writeInterval 0.1;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
#include "<system>/controlDict-petsc"
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / A nd | Website www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Load petsc solver library interface
libs ("petscFoam");
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4;
method scotch;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(T) Gauss linear;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
laplacian(DT,T) Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
// ************************************************************************* //
fvSolution-petsc
\ No newline at end of file
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\ / O peration | Version: v2006 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\ / O peration | Version: v2006 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\ / O peration | Version: v2006 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment