Skip to main content

nemoblock

Code style: black DOI

Project description

nemoblock provides utilities to generate blockMeshDicts for structured mesh generation in OpenFOAM. It manages the numbering of the points, the orientation of the surfaces and the connections between the blocks. In this way it helps the user to focus on the most important point: generating high quality meshes.

The project is developed and maintained by the Model experiments group at the Leibniz Institute for Crystal Growth (IKZ).

Referencing

If you use this code in your research, please cite our article:

TODO

Prerequisites

nemoblock requires Python >= 3.7. The following dependencies are installed automatically: matplotlib, numpy, scipy.

If you encounter any problems with these packages try:

pip install --upgrade matplotlib
pip install --upgrade numpy
pip install --upgrade scipy

Installation

The latest release can be installed using pip:

pip install nemoblock

Usage

nemoblock follows the naming conventions in the OpenFOAM user guide:

To initialize nemoblock you have to create a mesh object:

import nemoblock as nb
mesh = nb.Mesh()

You can then create a block object with the mesh and points p0 to p7 :

b1 = b1 = nb.Block(
    mesh,
    [0, 0, 0],
    [1, 0, 0],
    [1, 1, 0],
    [0, 1, 0],
    [0, 0, 1],
    [1, 0, 1],
    [1, 1, 1],
    [0, 1, 1],
)

Then, you can set the number of cells in x1, x2 and x3 direction and modify the grading:

b1.set_number_of_cells(10, 10, 10)
b1.grading = "simpleGrading (1 1 1)"  # this is the default

When all the points are defined you have to "create" the block:

b1.create()

This creates the edges e0 to e11 that can then be modified, e.g. to form an arc:

b1.e0.type = "arc"
b1.e0.points.append([0.5, 0.3, 0])

If you add additional blocks you have to set the relations:

b2 = nb.Block(mesh)  # raw block
b2.set_connection(b1, "bottom")  # on top of b1
# define missing points
b2.p4 = [0, 0, 2]
b2.p5 = [1, 0, 2]
b2.p6 = [1, 1, 2]
b2.p7 = [0, 1, 2]
# set number of cells
b2.cells_x3 = 5  # the others were derived from b1
b2.create()

However, this does only work if the coordinate systems of the blocks have the same orientation. In more complex cases you can use:

b2.face_top = b1.face_bottom
# define missing points
...
# set number of cells
b2.set_number_of_cells(10, 10, 5) 
# In this case you have to provide the number of cells for all directions.
# Make sure that this is conforming with b1!

Only use this if your mesh topology requires it, because it is prone to errors.

Eventually, you can create a patch, e.g. an inlet and export your blockMeshDict:

inlet = nb.Patch(mesh, "inlet inlet")
inlet.add_face(b1.face_bottom)

mesh.write()

The resulting mesh looks like this:

Examples

Examples, e.g. with grading for boundary layers or much more complex meshes generated using pre-defined cylinders and rings, can be found in the examples directory. This includes the setup for a mesh with the following structure:

License

nemoblock is published under the GPLv3 license.

Acknowledgements

This project has received funding from the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme (grant agreement No 851768).

Contribution

Any help to improve this package is very welcome!

Metadata

Release files for nemoblock 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nemoblock 1.0.4
File Size Uploaded Provenance Actions
nemoblock-1.0.4.tar.gz 26.6 kB Without provenance Details for nemoblock-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nemoblock 1.0.4
File Interpreter ABI Platform Actions
nemoblock-1.0.4-py3-none-any.whl Python 3 none any Details for nemoblock-1.0.4-py3-none-any.whl

Total release size: 52.7 kB

Release files / nemoblock-1.0.4.tar.gz

Download URL nemoblock-1.0.4.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ec9ffaa4d109a141bc5e9f06f2f84ce1f463a1de58239860586ea93fb0ecf7d2
BLAKE2b-256 checksum
How to use checksums
696b1425cb167c81aff1b503e582275b407c920e405cbbcdb8d1dde55475582e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / nemoblock-1.0.4-py3-none-any.whl

Download URL nemoblock-1.0.4-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a510e1104c495b8d58c06519ac68835afb0eea1ac308d85076b90540a95c5c0
BLAKE2b-256 checksum
How to use checksums
0fe6a3af8cfa68ea66b8ea5143e9446ecb62f121425556cdf48df2f051dbedf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for nemoblock 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page