Giter Site home page Giter Site logo

cgnsutilities's Introduction

cgnsUtilities

Build Status Documentation Status codecov

This repository contains many useful functions for working with CGNS grids and a CLI program called cgns_utils to call these functions.

License

Copyright 2020 MDO Lab. See the LICENSE file for details

cgnsutilities's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cgnsutilities's Issues

Update the information in the readme

Type of issue

What types of issue is it?

  • Documentation

Description

The information in the readme needs to reflect the current capabilities of the tool.

Include default values in help string

Description

We currently only include default values in a few places, but we should do it for all defaults. This can be done in one of two ways:

  • if there are only a few of these, we can just manually add them with placeholder text as I did in #36
  • if there are a lot more, we will want to do this programmatically. See this thread for some options. We also have to be careful since we probably don't want to print all the default: None stuff everywhere.

Rename modes to use camelCase

Description

Some modes use camelCase when others don't. To improve readability, we should change everything to camelCase. This will however break backwards compatibility, and if we want, we could cast everything to lower when comparing. But I am also fine with breaking backwards compatibility as long as we state it clearly in release notes.

Include `description` to subparser help text

Description

The add_subparsers function accepts both help and description. My understanding is that help is displayed at the main parser level, and description is a longer..description displayed at the subparser level. It would be good to have both shown, and we can do this by defining the help string as a variable, then appending to it some more detailed description and passing that to description=.

Note that this has certain implications if we plan to add sphinx documentation and use autoprogram or equivalent to document the CLI.

some bc routines fail to overwrite the existing data and just create a duplicate BC data

Description

Some of the internal methods that are supposed to overwrite existing BC information with the new BC information fails to "overwrite" and just end up creating duplicate BC data on these families. As a result, these meshes fail to run in adflow. I think this functionality definitely worked at some point, so I am guessing it will be a relatively minor fix on how we interact with the cgns library.

Steps to reproduce issue

Try to overwrite the BC information on any mesh via overwritebcs. I dont have an exact script ready now, but in the past, I had to first explicitly remove all BCs, and then set the updated ones one by one.

Current behavior

BC info is not overwritten and instead is duplicated.

Expected behavior

BC info should be overwritten so that there is a single BC definition for each face.

Add sphinx documentation

Description

Since this tool is actually somewhat complex, we may want to have a documentation site. This would include both auto-generated documentation (via autoprogram or equivalent), as well as some additional information for some file formats expected by the CLI tool (that don't fit into the help string). Some diagrams etc. may also be helpful.

Note that these Sphinx extensions that parse argparser are somewhat finicky, so #39 will be related to this effort.

Merge with pyHyp?

Type of issue

What types of issue is it?
Select the appropriate type(s) that describe this issue

  • Maintenance

Description

Should we merge this package with pyHyp? The two packages are typically used in conjunction, and this would help consolidate our repositories and make installation/maintenance easier.

combine gives error if file name is to long

Description

cgns_utils combine fails if the file name is to long. It only happens, when the name is longer than 31 chars. So I assume it has something to do with a length cap on a datatype.

Steps to reproduce issue

  1. rename a CGNS File to a_reaaaaaaaaaaly_long_name1.cgns
  2. rename a second CGNS File to a_reaaaaaaaaaaly_long_name2.cgns
  3. run cgns_utils combine a_reaaaaaaaaaaly_long_name1.cgns a_reaaaaaaaaaaly_long_name2.cgns test.cgns

Current behavior

This error gets thrown: Duplicate child name found: a_reaaaaaaaaaaly_long_name1.0000

Expected behavior

It should work regardless of the file name length.

Update package to properly install command line tool

Type of issue

What types of issue is it?
Select the appropriate type(s) that describe this issue

  • Maintenance

Description

Currently, the command line interface cgns_utils is not installed. Instead, we manually add the directory to the $PATH.

To do this properly, We would package the software using setup.py, such that during installation the script is placed in a directory which is on the $PATH. There are many helpful tutorials out there for this. The package folder structure would probably have to be updated too.

Review all options and make sure they work as intended

Type of issue

What types of issue is it?

  • New feature (non-breaking change which adds functionality)
  • Documentation update

Description

Review all command line options. The following should be performed for each option:

  • Run
  • Review/Update help documentation for option and all sub options
  • Provide example usage in help

Deprecation warning

Description

Running cgnsutilities with extract function will trigger the following:
ValueError: Non-string object detected for the array ordering. Please pass in 'C', 'F', 'A', or 'K' instead

This is probably introduced in new NumPy version from v1.4.0.

Someone may have interested in this link.

The timecombine option does not work

Type of issue

What types of issue is it?
Select the appropriate type(s) that describe this issue

  • Bugfix (non-breaking change which fixes an issue)

Description

The option timecombine does not work, as the Fortran subroutine is commented out (see here). I'm not sure why that is, but this is something we should probably fix at some point.

Improve test coverage

Description

There are not many tests. We should probably test the Python library rather than the command line program. Or both.

writeSubfaceFamily does not work when the BC is defined in patches

Description

writeSubfaceFamily call does not work if the target BC is already defined as a collection of patches. This check to find the target BC only picks up the first patch:

https://github.com/mdolab/cgnsutilities/blob/main/cgnsutilities/cgnsutilities.py#L391-L404

        # Locate the Boco we're replacing
        boco = None
        for i in range(len(self.blocks[blockID].bocos)):
            r = self.blocks[blockID].bocos[i].ptRange  # get the point range for existing boco
            if (
                (r[0][0] == r[0][1] == 1 and face == "ilow")
                or (r[0][0] == r[0][1] == self.blocks[blockID].dims[0] and face == "ihigh")
                or (r[1][0] == r[1][1] == 1 and face == "jlow")
                or (r[1][0] == r[1][1] == self.blocks[blockID].dims[1] and face == "jhigh")
                or (r[2][0] == r[2][1] == 1 and face == "klow")
                or (r[2][0] == r[2][1] == self.blocks[blockID].dims[2] and face == "khigh")
            ):
                boco = i
                break

If a grid comes from a parallel pyHyp run (most of our volume grids), then the BC is written in patches that are divided during the parallel load balancing. As a result, the writeSubfaceFamily only works if it is preceded by a complete overwrite of BCs.

Expected behavior

The writeSubFaceFamily should first find all patches on a BC, and overwrite all of it. This should be communicated in the documentation as well.

Code versions

  • Operating System:
  • Python:
  • OpenMPI:
  • CGNS:
  • PETSc:
  • Compiler:
  • This repository:

Issues with Python talking to libcgns_utils.so on Ubuntu 16.04 LTS

I end up with this error after executing the command:

$ cgns_utils autobc RAE2822wing_vol.cgns "z" 211.5
Traceback (most recent call last):
  File "/home/godot/repos/cgnsutilities/bin/cgns_utils", line 685, in <module>
    curGrid = readGrid(args.gridFile)
  File "/home/godot/repos/cgnsutilities/bin/cgns_utils.py", line 2620, in readGrid
    zoneName, dims, nBoco, nB2B = libcgns_utils.utils.getblockinfo(inFile, iBlock)
SystemError: bad format char passed to Py_BuildValue

The CGNS file is generated via pyHyp after following the ICEM surface meshing tutorial. Essentially, any functions that call cgns_utils through any of the other scripts are unusable because of this error. For example, here's the output that shows up after the mesh generation table when running run_pyhyp.py with autoConnect: True in options:

Traceback (most recent call last):
  File "/home/godot/repos/cgnsutilities/bin/cgns_utils", line 685, in <module>
    curGrid = readGrid(args.gridFile)
  File "/home/godot/repos/cgnsutilities/bin/cgns_utils.py", line 2620, in readGrid
    zoneName, dims, nBoco, nB2B = libcgns_utils.utils.getblockinfo(inFile, iBlock)
SystemError: bad format char passed to Py_BuildValue

+------------------------------------------------------------------------------+
| pyHyp Error: system command 'cgns_utils connect' failed, autoconnect was NOT |
| performed                                                                    |
+------------------------------------------------------------------------------+

Traceback (most recent call last):
  File "run_pyhyp.py", line 49, in <module>
    hyp.writeCGNS('RAE2822wing_vol.cgns')
  File "/home/godot/repos/pyhyp/python/pyHyp.py", line 747, in writeCGNS
    autoconnect was NOT performed")
pyhyp.python.pyHyp.Error

I should note that this error was popping up on an OS installation of Ubuntu 18.04 LTS while running ADFlow and pyHyp (without links to cgns_utils). So now I'm currently running a fresh install of Ubuntu 16.04 LTS (via Windows Subsystem for Linux), and all the required MDOLab modules I've cloned (ADflow, pyOptSparse, cgnsUtilities etc.) have compiled successfully (with successful imports and execution using the pre-generated meshes), and the only problems are occurring in the execution of cgns_utils, so I'm guessing this is some kind of version control issue, because cgns_utils works fine on 18.04 LTS. I've attached the differences between the packages installed on the two versions for reference.

Deprecation warning

Description

Running cgnsutilities will trigger the following:

/home/mdolabuser/repos/cgnsutilities/cgnsutilities/cgnsutilities.py:1309: DeprecationWarning: invalid escape sequence \d
  last_int = re.findall("\d+", blk.name)[-1]

This is probably introduced in Python 3.8.

Add proper documentation and tutorials

Type of issue

  • Documentation update

Description

Create proper tutorials page with examples and figured demonstrating the effect of all options as possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.