Skip to content

Bug: Output GCI with variable volume #1

Description

@sito115

Hi,
Thank you for developing this module!
I stumbled across your article at https://cfd.university/ and am trying to use this tool.

I discovered a bug when trying to create a CGS for variable volumes, as indicated in the README.md

from pyGCS import GCS

# create a grid convergence study object based on a constant domain volume
gcs = GCS(dimension=2, simulation_order=2, volume=76, cells=[18000, 8000, 4500], solution=[6.063, 5.972, 5.863])

# output information to Markdown-formated table
gcs.print_table(output_type='markdown', output_path='.')

This throws the following error:

  File "GCI.py", line 73, in __calculate_representative_grid_size
    h = pow(volume / self.__data['cells'][grid], 1.0 / self.__data['dimension'])
            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for /: 'tuple' and 'int'

Reason for this is, that the inputs given as a list get converted into a tuple when calling the __sort function, so when checking later whether volume is a list will return False because it is a tuple.

    def __sort(self, **kwargs):
        if 'volume' in kwargs:
            if type(kwargs['volume']) is list:
                assert len(kwargs['volume']) == len(kwargs['cells'])
                kwargs['cells'], kwargs['volume'], kwargs['solution'] = zip(*sorted(zip(kwargs['cells'],
                                                                                        kwargs['volume'],
                                                                                        kwargs['solution']),
                                                                                    reverse=True))

Best,
Thomas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions