Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise Error if a Mesh Cell is skewed above threshold #235

Merged
merged 27 commits into from
Oct 10, 2023

Conversation

DavidAnderegg
Copy link
Collaborator

@DavidAnderegg DavidAnderegg commented Oct 5, 2022

Purpose

I am optimising a two element-airfoil. Because of the proximity of those elements, the mesh quality deteriorates fast. To fix this, i check if the variable adflow.killsignals.fatalfail is set to true. When this is the case, I regenerate a mesh.
Unfortunately, this method is to slow as the variable is only set when the mesh has negative volumes.

This PR should addresses this in the following way:
Calculate the skewness as described here. If it goes above a certain threshold defined in the regular python-wrapper (e.g. meshMaxSkewness: 0.4), ADflow errors out by means of setting adflow.killsignals.fatalfail to true.

I introduced three new options:

  • useSkewnessCheck activates the the code in this PR when set to True
  • meshMaxSkewness ADflow throws an error if one's cell skewness is above this value
  • printBadlySkewedCells prints the indices of the cells whose skewness is above meshMaxSkewness (equivalent to printNegativeVolumes)

Expected time until merged

Probably a couple of weeks.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

Testing

I copied the cube_4x4x4.cgns file and coarsed it to a 1x1x1 cube. I also set the wallBC on all faces. This is necesairy to prohibit idwarp from warping everything. You find it here: cube_1x1x1.zip

The idea is to warp each face of each axis two times. Once by slightly less than 1 and the other time slightly more than 1.
Warping by 1 gives a skewness of 0.5. So i set the meshMaxSkewness to 0.5 and test if adflow.killsignals.fatalfail is False in the first case and True in the seccond.

Checklist

  • I have run flake8 and black to make sure the Python code adheres to PEP-8 and is consistently formatted
  • I have formatted the Fortran code with fprettify or C/C++ code with clang-format as applicable
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@DavidAnderegg DavidAnderegg marked this pull request as ready for review October 5, 2022 17:31
@DavidAnderegg DavidAnderegg requested a review from a team as a code owner October 5, 2022 17:31
@eirikurj eirikurj marked this pull request as draft October 6, 2022 13:29
@eirikurj
Copy link
Contributor

eirikurj commented Oct 6, 2022

Changing to draft as author suggest that the PR is not ready and content needs discussion.

@codecov
Copy link

codecov bot commented Mar 16, 2023

Codecov Report

Merging #235 (07ccd31) into main (559a1de) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #235   +/-   ##
=======================================
  Coverage   41.94%   41.94%           
=======================================
  Files          13       13           
  Lines        4005     4005           
=======================================
  Hits         1680     1680           
  Misses       2325     2325           
Files Coverage Δ
adflow/pyADflow.py 68.94% <ø> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@DavidAnderegg DavidAnderegg marked this pull request as ready for review September 26, 2023 17:21
@joanibal joanibal removed their request for review September 26, 2023 21:38
Copy link
Contributor

@anilyil anilyil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a very minor change in the .pyf file, otherwise, this is good to go

src/f2py/adflow.pyf Show resolved Hide resolved
@anilyil anilyil self-requested a review October 10, 2023 13:39
@anilyil anilyil merged commit 5e18826 into mdolab:main Oct 10, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants