Menu

#229 pyFoamChangeBoundaryType fails with more than 20 patches

confirmed
None
normal
minor
Always
minor-fix
general
2023-09-15
2023-02-09
No

The application pyFoamChangeBoundaryType.py produces a wrong constant/polyMesh/boundary file, if the number of patches is greater than 20. For this cases the number of the list is written as floating point and not as integer to the file.

The floating point number is produced at this code line

theLen=len(lst)/2

in
https://sourceforge.net/p/openfoam-extend/PyFoam/ci/default/tree/src/PyFoam/Basics/FoamFileGenerator.py#l187

So, changing line https://sourceforge.net/p/openfoam-extend/PyFoam/ci/default/tree/src/PyFoam/Basics/FoamFileGenerator.py#l203 from

s+=(" "*indent)+str(theLen)+"\n"

to

s+=(" "*indent)+str(int(theLen))+"\n"

solves the problem.

Discussion

  • Jake Yun

    Jake Yun - 2023-09-14

    Yes. The problem is there.

    theLen=len(lst)/2
    

    And how about fixing it there like following?

    theLen=len(lst)//2
    
     
  • Bernhard Gschaider

    • status: new --> confirmed
    • assigned_to: Bernhard Gschaider
     
  • Bernhard Gschaider

    Thanks for the report

    The reason why it was a plain / is that this part was developed in Python2 and with Python3 it changed its semantics: before it was (if only integers were involved) an integer result. In Python3 the result became a float

    As far as I can tell // behaves the same in 2 and 3 and I will replace that (as long as there are clusters with RHEL7-derivatives - which has python2.7 as a default- around I will keep the Python2-support)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.