View Issue Details

IDProjectCategoryView StatusLast Update
0002175OpenFOAMPatchpublic2016-08-03 12:22
ReporterwyldckatAssigned Tohenry 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.x 
Fixed in Version 
Summary0002175: Bug in script "lagrangian/reactingParcelFilmFoam/hotBoxes/patchifyObstacles"
DescriptionIn commit ecee2d275e9c2935, 20th of July 2015, there was an accidental introduction of a bug in the script "tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/patchifyObstacles": https://github.com/OpenFOAM/OpenFOAM-dev/blame/master/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/patchifyObstacles#L74

The change made in that commit changed this:

  if [ $n -lt 10 ]; then

to this:

  if [ $n -lt 10]; then

Attached is the fixed script.


I've marked this report with Severity "major", given that it essentially makes the tutorial not be properly set-up... although I'm not familiar with it and I'm not sure if there are any other bugs in this tutorial.
TagsNo tags attached.

Activities

wyldckat

2016-08-02 18:36

updater  

patchifyObstacles (5,170 bytes)
#!/bin/sh
#--------------------------------*- C++ -*------------------------------------#
# =========                 |                                                 #
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           #
#  \\    /   O peration     | Version:  4.x                                   #
#   \\  /    A nd           | Web:      www.OpenFOAM.org                      #
#    \\/     M anipulation  |                                                 #
#-----------------------------------------------------------------------------#
cd ${0%/*} || exit 1    # Run from this directory

x0=0.4
y0=0.1
z0=0.1
l=0.2
offset=0.3
tol=0.001

nx=1
ny=2
nz=2


tmpSetSet='patchify.setSet'
rm -f patchify.setSet >/dev/null 2>&1


initialiseFaceSet()
{
    echo "faceSet cubeFaceSet clear" >> $tmpSetSet;
}

addToFaceSet()
{
    name=$1
    x1=$2
    x2=$3
    y1=$4
    y2=$5
    z1=$6
    z2=$7

    echo "faceSet cubeFaceSet add boxToFace ($x1 $y1 $z1) ($x2 $y2 $z2)" >> $tmpSetSet
    echo "   $name: (x1=$x1 y1=$y1 z1=$z1) (x2=$x2 y2=$y2 z2=$z2)"
}

createSetsAndZone()
{
    name=$1
    x1=$2
    x2=$3
    y1=$4
    y2=$5
    z1=$6
    z2=$7

    echo "faceSet ${name}Faces new boxToFace ($x1 $y1 $z1) ($x2 $y2 $z2)" >> $tmpSetSet
    echo "   $name: (x1=$x1 y1=$y1 z1=$z1) (x2=$x2 y2=$y2 z2=$z2)"
}

initialiseFaceSet


# loop over cubes
n=1
x=$x0
for xi in $(seq 1 1 $nx); do
   y=$y0
   for yi in $(seq 1 1 $ny); do
       z=$z0
       for zi in $(seq 1 1 $nz); do
           echo "processing cube $n"

           pad=""
           if [ $n -lt 10 ]; then
               pad="0"
           fi

           # side 1
           side=1
           x1=`echo $x $tol | awk '{print $1 - $2}'`
           x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'`
           y1=`echo $y $tol | awk '{print $1 - $2}'`
           y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'`
           z1=`echo $z $l $tol | awk '{print $1 + $2 - $3}'`
           z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'`
           addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2

           #  side 2
           side=2
           x1=`echo $x $l $tol | awk '{print $1 + $2 - $3}'`
           x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'`
           y1=`echo $y $tol | awk '{print $1 - $2}'`
           y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'`
           z1=`echo $z $tol  | awk '{print $1 - $2}'`
           z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'`
           addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2

           # side 3
           side=3
           x1=`echo $x $tol | awk '{print $1 - $2}'`
           x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'`
           y1=`echo $y $tol | awk '{print $1 - $2}'`
           y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'`
           z1=`echo $z $tol | awk '{print $1 - $2}'`
           z2=`echo $z $tol | awk '{print $1 + $2}'`
           addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2

           # side 4
           side=4
           x1=`echo $x $tol | awk '{print $1 - $2}'`
           x2=`echo $x $tol | awk '{print $1 + $2}'`
           y1=`echo $y $tol | awk '{print $1 - $2}'`
           y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'`
           z1=`echo $z $tol | awk '{print $1 - $2}'`
           z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'`
           addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2

           # side 5
           side=5
           x1=`echo $x $tol | awk '{print $1 - $2}'`
           x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'`
           y1=`echo $y $l $tol | awk '{print $1 + $2 - $3}'`
           y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'`
           z1=`echo $z $tol | awk '{print $1 - $2}'`
           z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'`
           addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2

           # side 6
           side=6
           x1=`echo $x $tol | awk '{print $1 - $2}'`
           x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'`
           y1=`echo $y $tol | awk '{print $1 - $2}'`
           y2=`echo $y $tol | awk '{print $1 + $2}'`
           z1=`echo $z $tol | awk '{print $1 - $2}'`
           z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'`
           addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2

           n=$((n+1))

           z=`echo $z $offset | awk '{print $1 + $2}'`
       done

       y=`echo $y $offset | awk '{print $1 + $2}'`
   done

   x=`echo $x $offset | awk '{print $1 + $2}'`
done

echo "cellSet cubeFacesCells new faceToCell cubeFaceSet owner" >> $tmpSetSet
echo "faceZoneSet cubeFaces new setsToFaceZone cubeFaceSet cubeFacesCells" >> $tmpSetSet

echo "processing floor"
floorMax=`echo 1 $tol | awk '{print $1 + $2}'`
createSetsAndZone Floor -$tol $floorMax -$tol $floorMax -$tol $tol
echo "cellSet floorCells new faceToCell FloorFaces owner" >> $tmpSetSet
echo "faceZoneSet floorFaces new setsToFaceZone FloorFaces floorCells" >> $tmpSetSet

setSet -batch $tmpSetSet > log.setSet.patchifyObstacles 2>&1

# *************************************************************************
patchifyObstacles (5,170 bytes)

wyldckat

2016-08-02 18:39

updater  

sampleCone (1,028 bytes)
#!/bin/sh
cd ${0%/*} || exit 1    # Run from this directory

#
# FUNCTIONS
#
usage()
{
    while [ "$#" -ge 1 ]; do echo "$1"; shift; done

    cat<<USAGE
Usage: ${0##*/} [OPTION]

options:
  -l         -latestTime option for sample
  -h         help

Runs a set of samples across the cone face and concatenates output files
USAGE
    exit 1
}

#------------------------------------------------------------------------------

unset timeOpt

# parse options
while [ "$#" -gt 0 ]
do
    case "$1" in
    -h | -help)
        usage
        ;;
    -l | -latestTime)
        timeOpt="-latestTime"
        shift
        ;;
    *)
        usage "unknown option/argument: '$*'"
        ;;
    esac
done


sample $timeOpt
SDIR=sets
LSDIR=`ls $SDIR | head -1`
EXAMPLE_FILE=`ls -1 $SDIR/${LSDIR}/* | head -1`
FS=`basename $EXAMPLE_FILE | cut -d_ -f2-`

for d in $SDIR/*
do
    cat ${d}/cone25_${FS} ${d}/cone55_${FS} ${d}/base_${FS} > ${d}/biconic_${FS}
done

#------------------------------------------------------------------------------
sampleCone (1,028 bytes)

wyldckat

2016-08-02 18:39

updater   ~0006616

Similar happened to "tutorials/compressible/rhoCentralFoam/biconic25-55Run35/sampleCone", attached is the updated file.

wyldckat

2016-08-02 18:45

updater   ~0006617

Fortunately there aren't any other tutorials affected by that commit, at least not that I can see in the commit changes.

There was one other file "tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/externalSolver", but that was fixed back then the very next day.

henry

2016-08-02 19:16

manager   ~0006618

Thanks for finding and fixing this issue Bruno

Resolved in OpenFOAM-4.x by commit 1bad0a52f1af075e01018b173d69c2d0dfb0333a
Resolved in OpenFOAM-dev by commit e301f74c93b10391f320ff1dfff0475eec2b6d4c

wyldckat

2016-08-03 12:12

updater   ~0006626

Hi Henry,

I didn't notice this was an issue on 3.0.x, but could you please also apply these files to the OpenFOAM-3.0.x repository?

Because I'm currently diagnosing an issue with the reactingParcelFilmFoam tutorial cases on 4.x and the results from 3.0.x are fairly different, which I'll report once I've got more details (preliminary symptoms are that the hf equation is taking a lot of time to solve on 4.x).
But since unfortunately "patchifyObstables" is also damaged on 3.0.x, it's best to have this file also fixed on 3.0.x for ensuring that the results are consistent.

I haven't checked yet if the "compressible/rhoCentralFoam/biconic25-55Run35" tutorial is also affected somehow, but it's probably best to also apply the attached fix for it too.

henry

2016-08-03 12:21

manager   ~0006627

Resolved by commit 4b5e129783d9bea7ea00a617b6ee3b73b0f308e4

Issue History

Date Modified Username Field Change
2016-08-02 18:36 wyldckat New Issue
2016-08-02 18:36 wyldckat Status new => assigned
2016-08-02 18:36 wyldckat Assigned To => henry
2016-08-02 18:36 wyldckat File Added: patchifyObstacles
2016-08-02 18:39 wyldckat File Added: sampleCone
2016-08-02 18:39 wyldckat Note Added: 0006616
2016-08-02 18:45 wyldckat Note Added: 0006617
2016-08-02 19:16 henry Note Added: 0006618
2016-08-02 19:16 henry Status assigned => resolved
2016-08-02 19:16 henry Fixed in Version => 4.x
2016-08-02 19:16 henry Resolution open => fixed
2016-08-03 12:12 wyldckat Note Added: 0006626
2016-08-03 12:12 wyldckat Status resolved => feedback
2016-08-03 12:12 wyldckat Resolution fixed => reopened
2016-08-03 12:21 henry Note Added: 0006627
2016-08-03 12:21 henry Status feedback => resolved
2016-08-03 12:21 henry Fixed in Version 4.x => 3.0.x
2016-08-03 12:21 henry Resolution reopened => fixed