Skip to main content

Utilities to generate blockMeshDicts for OpenFOAM.

Project description

nemoblock

Code style: black

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

nemoblock is not listed on the python package index yet. To use it, you have to clone the repository and install it manually with pip:

git clone https://github.com/nemocrys/nemoblock.git
cd nemoblock
pip install -e ./

Usage

nemoblock follows the naming conventions in the OpenFOAM user guide:

block naming, source: https://www.openfoam.com/documentation/user-guide/4-mesh-generation-and-conversion/4.3-mesh-generation-with-the-blockmesh-utility

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_cell(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_cell(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:

example mesh

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:

example mesh

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nemoblock-1.0.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nemoblock-1.0-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file nemoblock-1.0.tar.gz.

File metadata

  • Download URL: nemoblock-1.0.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for nemoblock-1.0.tar.gz
Algorithm Hash digest
SHA256 ea3b5568f3b4f7aecec9d707e40f4d85602f7d152c55ba41e4a6237efb4ac5f8
MD5 0843da7b996fcbbed44628c2c324ecf5
BLAKE2b-256 3d188c191c51aea716ac3819e73d0234cec0e652014c4570b269a706f0d86cb8

See more details on using hashes here.

File details

Details for the file nemoblock-1.0-py3-none-any.whl.

File metadata

  • Download URL: nemoblock-1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for nemoblock-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 228d0cfc3285ba419397c8791607f102b9e50d2a11c91fd2be7cebbcdd2a83bc
MD5 edc27a5f68d690faa17b577901070108
BLAKE2b-256 157b8fe48e240ca211a1f65369a86262b8b8304b92f598ac970066569babf7fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page