Skip to content
Snippets Groups Projects
Commit 8c5d9ca9 authored by Malte Nyhuis's avatar Malte Nyhuis
Browse files

Gmshcascade

parent 5060743d
Branches
Tags
1 merge request!43Gmshcascade
Showing
with 200 additions and 47 deletions
......@@ -8,20 +8,16 @@ variables:
SREGISTRY_URL : "https://cloud.sylabs.io/"
SREGISTRY_USERNAME : nyhuma
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/topics/caching/
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/
.before_script_template: &build_test
.before_script_template: &environment
before_script:
- apt-get update -y && apt-get install libgl1-mesa-glx xvfb -y
- apt-get update -y
# graphics
- apt-get install libgl1-mesa-glx xvfb -y
# gmsh
- apt-get install libglu1-mesa libxcursor1 libxinerama1 -y
# repository
- python -m pip install --upgrade pip
- python --version # For debugging
- pip install virtualenv
......@@ -35,43 +31,55 @@ stages: # List of stages for jobs, and their order of execution
- docs
- deploy
cache:
paths:
- .cache/pip
- venv/
- /var/cache/apt/archives/
build:
stage: build
<<: *build_test
<<: *environment
script:
- pip install .
test: # This job runs in the build stage, which runs first.
stage: test
<<: *build_test
<<: *environment
script:
- pip install .
- pip install -r requirements_dev.txt
- pytest tests/.
dependencies:
- build
lint_test: # This job also runs in the test stage.
stage: quality
<<: *build_test # It can run at the same time as unit-test-job (in parallel).
<<: *environment # It can run at the same time as unit-test-job (in parallel).
script:
- pip install flake8
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude='venv/'
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude='venv/'
dependencies:
- build
jupyter_test:
stage: quality
<<: *build_test
<<: *environment
script:
- apt-get install pandoc -y
- apt-get install texlive-xetex texlive-fonts-recommended texlive-plain-generic -y
- pip install nbconvert
- pip install nbconvert ipykernel
- pip install . #todo: this should not be necessary
- cd examples
# Loop through .ipynb files in the examples directory
- for file in *.ipynb; do echo "Converting $file to PDF..."; jupyter nbconvert --execute "$file" --to pdf; done
dependencies:
- build
coverage_test:
stage: quality
<<: *build_test
<<: *environment
script:
- pip install .
- pip install -r requirements_dev.txt
......@@ -81,11 +89,13 @@ coverage_test:
artifacts:
paths:
- coverage.xml
when: always
dependencies:
- build
pages:
stage: docs
<<: *build_test
<<: *environment
script:
- pip install sphinx sphinx-rtd-theme
- cd docs
......@@ -95,7 +105,11 @@ pages:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- exists:
- $CI_COMMIT_TAG
- exists:
- $CI_COMMIT_BRANCH
- $CI_DEFAULT_BRANCH
build-singularity:
image:
......@@ -111,7 +125,7 @@ build-singularity:
publish:
stage: deploy
<<: *build_test
<<: *environment
script:
- pip install twine
- python setup.py sdist bdist_wheel
......
......@@ -13,7 +13,7 @@ Types of Contributions
Report Bugs
~~~~~~~~~~~
Report bugs at https://github.com/MaNyh/ntrfc/issues
Report bugs at https://gitlab.uni-hannover.de/tfd_public/tools/NTRfC/-/issues
If you are reporting a bug, please include:
......@@ -24,7 +24,7 @@ If you are reporting a bug, please include:
Fix Bugs
~~~~~~~~
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
Look through the issues for bugs. Anything tagged with "bug" and "help
wanted" is open to whoever wants to implement it.
Implement Features
......@@ -43,7 +43,7 @@ NTRfC could always use more documentation, whether as part of the official NTRfC
Submit Feedback
~~~~~~~~~~~~~~~
The best way to send feedback is to file an issue at https://github.com/MaNyh/ntrfc/issues.
The best way to send feedback is to file an issue at https://gitlab.uni-hannover.de/tfd_public/tools/NTRfC/-/issues .
If you are proposing a feature:
......@@ -83,13 +83,13 @@ Ready to contribute? Here's how to set up `ntrfc` for local development.
To get flake8 and tox, just pip install them into your virtualenv.
6. Commit your changes and push your branch to GitHub::
6. Commit your changes and push your branch to GitLab::
$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature
7. Submit a pull request through the GitHub website.
7. Submit a pull request through the GitLab website.
Pull Request Guidelines
-----------------------
......
......@@ -2,6 +2,13 @@
History
=======
0.1.5 (2023-07-04)
------------------
- bugfixes alphashape
- initial gmsh intigration
- jupyternotebook testing
- improved codecov
0.1.4 (2023-06-25)
------------------
- cleaner structure, more reliability
......
......@@ -2,7 +2,7 @@
NTRfC README
============
Numerical Test Rig for Cascades.
**Numerical Test Rig for Cascades.**
* Free software: MIT license
......@@ -11,14 +11,20 @@ Numerical Test Rig for Cascades.
Features
**Features**
Easy geometry and post-processing visualization and manipulation with pyvista.
Tested methods and functions for math, time-series, and mesh quality analysis.
Dependencies
**Dependencies**
NTRfC v0.1.0 and any following version is based on Python 3.10. Only older versions can be used with older versions of Python. Library requirements will be installed with the package itself.
- libgl1-mesa-glx (graphics driver)
- xvfb (virtual Display)
- libglu1-mesa (gmsh dependency)
- libxcursor1 (gmsh dependency)
- libxinerama1 (gmsh dependency)
Current NTRfC versions are based on Python 3.10. Only versions <v0.1.0 can be used with older versions of Python. Library requirements will be installed with the package itself.
Installation
NTRfC is utilizing powerful and complex dependencies like pyvista and gmsh. We strongly recommend using virtual or conda environments for installation.
......@@ -31,14 +37,21 @@ For more information, see:
mamba: https://mamba.readthedocs.io/en/latest/installation.html
**Installation**
Installation from pypi
```
pip install ntrfc
```
### Installation from gitlab with pip
Installation from gitlab with pip
```
pip install git+https://gitlab.uni-hannover.de/tfd_public/tools/NTRfC.git
```
### Installation from source
Installation from source
After cloning the repository, go to the project root dir and type
......@@ -46,8 +59,7 @@ After cloning the repository, go to the project root dir and type
python setup.py install
```
### Editable installation from source with pip
Editable installation from source with pip
After cloning the repository, go to the project root dir and type
......@@ -59,12 +71,12 @@ This way you have NTRfC installed but the code is not installed, but linked to t
You don't have to reinstall the package after your edits.
This speeds up testing and will lead to less debugging time.
### Singularity releases
**Singularity releases**
use a singularity container from ntrfc singularity releases: https://cloud.sylabs.io/library/nyhuma/ntrflows/ntr.sif].
Use a singularity container from ntrfc singularity releases: https://cloud.sylabs.io/library/nyhuma/ntrflows/ntr.sif].
The containers will come with a virtual graphics card and a xvfb display-server, enabling you to render on hpc-systems and any other unprepared system with limited graphics capability.
## Credits
**Credits**
This package was created with Cookiecutter and the `audreyr/cookiecutter-pypackage` project template. It uses the following libraries:
......
......@@ -26,19 +26,19 @@ you through the process.
From sources
------------
The sources for NTRfC can be downloaded from the `Github repo`_.
The sources for NTRfC can be downloaded from the `https://gitlab.uni-hannover.de/tfd_public/tools/NTRfC repo`_.
You can either clone the public repository:
.. code-block:: console
$ git clone git://github.com/MaNyh/ntrfc
$ git clone https://gitlab.uni-hannover.de/tfd_public/tools/NTRfC.git
Or download the `tarball`_:
.. code-block:: console
$ curl -OJL https://github.com/MaNyh/ntrfc/tarball/master
$ curl -OJL https://gitlab.uni-hannover.de/tfd_public/tools/NTRfC/tarball/master
Once you have a copy of the source, you can install it with:
......@@ -47,5 +47,5 @@ Once you have a copy of the source, you can install it with:
$ python setup.py install
.. _Github repo: https://github.com/MaNyh/ntrfc
.. _tarball: https://github.com/MaNyh/ntrfc/tarball/master
.. _Github repo: https://gitlab.uni-hannover.de/tfd_public/tools/NTRfC.git
.. _tarball: https://gitlab.uni-hannover.de/tfd_public/tools/NTRfC.git/tarball/master
......@@ -15,14 +15,20 @@ class CascadeDomain2D:
casemeta: CaseMeta = CaseMeta(tempfile.mkdtemp())
pressureside: pv.PolyData = None
suctionside: pv.PolyData = None
profilepoints: pv.PolyData = None
le_index: int = None
te_index: int = None
yperiodic_low: pv.PolyData = None
yperiodic_high: pv.PolyData = None
inlet: pv.PolyData = None
outlet: pv.PolyData = None
def generate_from_cascade_parameters(self, domainparams: DomainParameters):
# Use params attributes to generate attributes of CascadeDomain2D
self.profilepoints = domainparams.profile_points
self.le_index = domainparams.leading_edge_index
self.te_index = domainparams.trailing_edge_index
x_mids = domainparams.midspoly.points[::, 0]
y_mids = domainparams.midspoly.points[::, 1]
beta_leading = domainparams.beta_in
......
import tempfile
from dataclasses import dataclass
import os
import pyvista as pv
from ntrfc.turbo.pointcloud_methods import extract_geo_paras
......@@ -50,6 +50,8 @@ class DomainParameters:
Returns:
pv.Plotter: The PyVista plotter object used for plotting.
"""
if os.getenv('DISPLAY') is None:
pv.start_xvfb() # Start X virtual framebuffer (Xvfb)
pv.set_plot_theme('document')
plotter = pv.Plotter(off_screen=True)
plotter.window_size = 1600, 1600
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
# Import modules:
import gmsh
# Initialize gmsh:
import numpy as np
import pyvista as pv
from ntrfc.geometry.line import lines_from_points
from ntrfc.math.vectorcalc import vecAbs_list
def generate_turbocascade(sortedpoly, idx_le, idx_te, per_y_upper, per_y_lower, inletPoly, outletPoly, filename,
verbose=False):
###CONFIGURATION
min_lc = 0.000002
max_lc = 0.02
lc = 5e-2 # Characteristic length for blade region
# Initialize gmsh:
gmsh.initialize()
points = {}
splines = {}
lines = {}
curveloops = {}
surfaceloops = {}
surfaces = {}
sortedpoly_spline = lines_from_points(sortedpoly.points)
inlet_spline = lines_from_points(inletPoly.points)
per_y_upper_spline = lines_from_points(per_y_upper.points)
outlet_spline = lines_from_points(outletPoly.points[::-1])
per_y_lower_spline = lines_from_points(per_y_lower.points[::-1])
sortedpoly_spline["ids"] = np.arange(sortedpoly_spline.number_of_points)
inlet_spline["ids"] = np.arange(inlet_spline.number_of_points)
per_y_upper_spline["ids"] = np.arange(per_y_upper_spline.number_of_points)
outlet_spline["ids"] = np.arange(outlet_spline.number_of_points)
per_y_lower_spline["ids"] = np.arange(per_y_lower_spline.number_of_points)
if verbose:
p = pv.Plotter()
p.add_mesh(sortedpoly_spline, label="sortedpoly_spline")
p.add_mesh(sortedpoly_spline.points[idx_le], label="idx_le", color="green", point_size=20)
p.add_mesh(sortedpoly_spline.points[idx_te], label="idx_te", color="red", point_size=20)
p.add_mesh(inlet_spline, label="inlet_spline")
p.add_mesh(per_y_upper_spline, label="per_y_upper_spline")
p.add_mesh(outlet_spline, label="outlet_spline")
p.add_mesh(per_y_lower_spline, label="per_y_lower_spline")
p.add_legend()
p.show()
distance_leading_edge = vecAbs_list(sortedpoly_spline.points[idx_le] - sortedpoly_spline.points)
distance_trailing_edge = vecAbs_list(sortedpoly_spline.points[idx_te] - sortedpoly_spline.points)
lc_blade_new = np.min(np.stack([distance_leading_edge, distance_trailing_edge]).T,axis=1)
lc_blade_new_normalized = (lc_blade_new - min(lc_blade_new)) * (max_lc - min_lc) / (max(lc_blade_new) - min(lc_blade_new)) + min_lc
points["blade"] = [gmsh.model.occ.add_point(*pt, lcb) for pt,lcb in zip(sortedpoly_spline.points,lc_blade_new_normalized)]
points["per_y_upper"] = [gmsh.model.occ.add_point(*pt, lc) for pt in per_y_upper.points]
points["per_y_lower"] = [gmsh.model.occ.add_point(*pt, lc) for pt in per_y_lower.points[::-1]]
points["inlet"] = [points["per_y_lower"][-1], points["per_y_upper"][0]]
points["outlet"] = [points["per_y_upper"][-1], points["per_y_lower"][0]]
splines["blade"] = gmsh.model.occ.add_spline([*points["blade"], points["blade"][0]])
splines["inlet"] = gmsh.model.occ.add_spline(points["inlet"])
splines["per_y_upper"] = gmsh.model.occ.add_spline(points["per_y_upper"])
splines["outlet"] = gmsh.model.occ.add_spline(points["outlet"])
splines["per_y_lower"] = gmsh.model.occ.add_spline(points["per_y_lower"])
curveloops["blade"] = gmsh.model.occ.add_curve_loop([splines["blade"]])
curveloops["domain"] = gmsh.model.occ.add_curve_loop(
[splines["inlet"], splines["per_y_upper"], splines["outlet"], splines["per_y_lower"]])
#surfaces["blade"] = gmsh.model.occ.add_plane_surface([curveloops["blade"]])
surfaces["domain"] = gmsh.model.occ.add_plane_surface([curveloops["domain"], curveloops["blade"]])
f = gmsh.model.mesh.field.add('BoundaryLayer')
gmsh.model.mesh.field.setNumbers(f, 'CurvesList', [curveloops["blade"]])
gmsh.model.mesh.field.setNumber(f, 'Size', 1.7e-5)
gmsh.model.mesh.field.setNumber(f, 'Ratio', 1.2)
gmsh.model.mesh.field.setNumber(f, 'Quads', 1)
gmsh.model.mesh.field.setNumber(f, 'Thickness', 0.05)
gmsh.model.mesh.field.setAsBoundaryLayer(f)
# Extrude the domain surface in the z-direction
volume = gmsh.model.occ.extrude([(2, surfaces["domain"])], 0, 0, 0.6,numElements=[10],recombine=True)
gmsh.model.occ.synchronize()
gmsh.model.addPhysicalGroup(2, [1], 1, "The 1")
gmsh.model.addPhysicalGroup(2, [2], 2, "The 2")
gmsh.model.addPhysicalGroup(2, [3], 3, "The 3")
gmsh.model.addPhysicalGroup(2, [4], 4, "The 4")
gmsh.model.addPhysicalGroup(2, [5], 5, "The 5")
gmsh.model.addPhysicalGroup(2, [6], 6, "The 6")
gmsh.model.addPhysicalGroup(2, [7], 7, "The 7")
gmsh.model.addPhysicalGroup(3, [1], 1, "The volume")
gmsh.model.occ.synchronize()
# Generate mesh:
gmsh.model.mesh.generate(3)
# Write mesh data:
gmsh.write(filename)
return 0
......@@ -14,3 +14,4 @@ trame==2.5.0
scikit-learn
jupyter
sphinx
gmsh==4.11.1
[bumpversion]
current_version = 0.1.4
current_version = 0.1.5
commit = True
tag = True
......
......@@ -46,6 +46,6 @@ setup(
test_suite='tests',
tests_require=test_requirements,
url='https://gitlab.uni-hannover.de/tfd_public/tools/NTRfC',
version='0.1.4',
version='0.1.5',
zip_safe=False,
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment