adflow icon indicating copy to clipboard operation
adflow copied to clipboard

raise Error if a Mesh Cell is skewed above threshold

Open DavidAnderegg opened this issue 3 years ago • 1 comments

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 do not consider this PR ready yet. But I want to get feeback from you guys as soon as possible. I am especially interested in these points:

  1. I only calculate the skewness when we are actually interested in it (meshMaxSkewness < 1). Does this make sense?
  2. Is highjacking the subroutine WriteNegVolumes fine as I did?
  3. I need to release my new flowdom variable skew. Where is the best place to do this?

Expected time until merged

Probably a couple of weeks.

Type of change

  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [x] 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

  • [x] 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
  • [x] I have added new tests that prove my fix is effective or that my feature works
  • [x] I have added necessary documentation

DavidAnderegg avatar Oct 05 '22 15:10 DavidAnderegg

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

eirikurj avatar Oct 06 '22 13:10 eirikurj

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% <ø> (ø)

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

codecov[bot] avatar Mar 16 '23 14:03 codecov[bot]