Coder Social home page Coder Social logo

damogranlabs / classy_blocks Goto Github PK

View Code? Open in Web Editor NEW
121.0 13.0 37.0 13.51 MB

Python classes for easier creation of OpenFOAM's blockMesh dictionaries.

License: MIT License

Python 100.00%
mesh openfoam cfd geometry modeling parametric parametric-modelling parametric-design blockmesh blockmeshdict

classy_blocks's Introduction

classy_blocks

Flywheel

Python classes for easier creation of OpenFOAM's blockMesh dictionaries.

About

blockMesh is a very powerful mesher but the amount of manual labour it requires to make even the simplest meshes makes it mostly useless. Even attempts to simplify or parametrize blockMeshDicts with #calc or even the dreadful m4 quickly become unmanageable and cryptic.

classy_blocks' aim is to minimize the amount of meticulous work by providing a more intuitive workflow, off-the-shelf parts and some automatic helpers for building and optimization of block-structured hexahedral meshes. Still it is not an automatic mesher and therefore some kinds of geometry are more suited than others.

Tutorial

Check out the classy_blocks tutorial on damogranlabs.com!

Useful For

Fields

  • Turbomachinery (impellers, propellers)
  • Microfluidics
  • Flow around buildings
  • Heat transfer (PCB models, heatsinks)
  • Airfoils (2D)
  • Solids (heat transfer, mechanical stresses)

Cases

  • Simpler rotational geometry (immersed rotors, mixers, cyclones)
  • Pipes/channels
  • Tanks/plenums/containers
  • External aerodynamics of blunt bodies
  • Modeling thin geometry (seals, labyrinths)
  • Parametric studies
  • Background meshes for snappy (cylindrical, custom)
  • 2D and axisymmetric cases
  • Overset meshes

Not Good For

  • External aerodynamics of vehicles (too complex to mesh manually, without refinement generates too many cells)
  • Complex geometry in general
  • One-off simulations (use automatic meshers)

How To Use It

  • To install the current stable version from pypi, use pip install classy_blocks
  • To download the cutting-edge development version, install the development branch from github: pip install git+https://github.com/damogranlabs/classy_blocks.git@development
  • If you want to run examples, follow instructions in Examples
  • If you want to contribute, follow instructions in CONTRIBUTING.rst

Features

Workflow

As opposed to blockMesh, where the user is expected to manually enter pre-calculated vertices, edges, blocks and whatnot, classy_blocks tries to mimic procedural modeling of modern 3D CAD programs. Here, a Python script contains steps that describe geometry of blocks, their cell count, grading, patches and so on. At the end, the procedure is translated directly to blockMeshDict and no manual editing of the latter should be required.

Building Elements

Unchecked items are not implemented yet but are on a TODO list

  • Manual definition of a Block with Vertices, Edges and Faces
  • Operations (Loft, Extrude, Revolve)
    • Loft
    • Extrude
    • Revolve
    • Wedge (a shortcut to Revolve for 2D axisymmetric cases)
    • Connector (A Loft between two existing Operations)
  • Sketches of common cross-sections
    • Quarter and Semi circle
    • Circle
    • Boxed circle
    • Oval with straight sides
    • Ellipse (and ovals in various configurations)
    • Cartesian grid
  • Simple way of creating custom Sketches
  • Easy shape creation from Sketches
  • Predefined Shapes
    • Box (shortcut to Block aligned with coordinate system)
    • Elbow (bent pipe of various diameters/cross-sections)
    • Cone Frustum (truncated cone)
    • Cylinder
    • Ring (annulus)
    • Hemisphere
  • Stacks (collections of similar Shapes stacked on top of each other)
  • Predefined parametric Objects
    • T-joint (round pipes)
    • X-joint
    • N-joint (multiple pipes)
    • Collector (a barrel with multiple radial outlets)
  • Other building tools
    • Use existing Operation's Face to generate a new Operation
    • Chain Shape's start/end surface to generate a new Shape
    • Expand Shape's outer surface to generate a new Shape (Cylinder/Annulus > Annulus)
    • Contract Shape's inner surface into a new Shape (Annulus > Cylinder/Annulus)
    • Join two Operations by extending their Edges
    • Offset Operation's faces to form new operations

Modifiers

After blocks have been placed, it is possible to create new geometry based on placed blocks or to modify them.

  • Move Vertex/Edge/Face
  • Delete a Block created by a Shape or Object
  • Project Vertex/Edge/Face
  • Optimize point position of a Sketch or mesh vertices

Meshing Specification

  • Simple definition of all supported kinds of edges with a dedicated class (Arc/Origin/Angle/Spline/PolyLine/Project)
  • Automatic sorting/reorienting of block vertices based on specified front and top points
  • Automatic calculation of cell count and grading by specifying any of a number of parameters (cell-to-cell expansion ratio, start cell width, end cell width, total expansion ratio)
  • Edge grading (separate specification for each edge)
  • Automatic propagation of grading and cell count from a single block to all connected blocks as required by blockMesh
  • Projections of vertices, edges and block faces to geometry (triangulated and searchable surfaces)
  • Face merging as described by blockMesh user guide. Breaks the pure-hexahedral-mesh rule but can often save the day for trickier geometries. Automatic duplication of points on merged block faces
  • Auto grading for Low-Re meshes: boundary layer with specified cell-to-cell expansion, transition with 2:1 expansion, and specified 'bulk' cell size

Examples

How to run:

  • Install classy_blocks as described above
  • cd to directory of the chosen example
  • Run python <example.py>; that will write blockMeshDict to examples/case
  • Run blockMesh on the case
  • Open examples/case/case.foam in ParaView to view the result

For instance:

cd examples/chaining
python tank.py
blockMesh -case ../case

Operations

Analogous to a sketch in 3D CAD software, a Face is a set of 4 vertices and 4 edges. An Operation is a 3D shape obtained by swiping a Face into 3rd dimension by a specified rule. Here is a Revolve as an example:

# a quadrangle with one curved side
base = cb.Face(
    [ # quad vertices
        [0, 0, 0],
        [1, 0, 0],
        [1, 1, 0],
        [0, 1, 0]
    ],
    [ # edges: None specifies a straight edge
        cb.Arc([0.5, -0.2, 0]),
        None,
        None,
        None
  ]
)

revolve = cb.Revolve(
    base, # face to revolve
    f.deg2rad(45), # revolve angle
    [0, -1, 0], # axis
    [-2, 0, 0]  # origin
)

revolve.chop(0, count=15) # first edge
revolve.chop(1, count=15) # second edge
revolve.chop(2, start_size=0.05) # revolve direction
mesh.add(revolve)

Ducts

See examples/operations for an example of each operation.

Shapes

Some basic shapes are ready-made so that there's no need for workout with Operations.

A simple Cylinder:

inlet = cb.Cylinder([x_start, 0, 0], [x_end, 0, 0], [0, 0, radius])
inlet.chop_radial(count=n_cells_radial, end_size=boundary_layer_thickness)
inlet.chop_axial(start_size=axial_cell_size, end_size=2*axial_cell_size)
inlet.chop_tangential(count=n_cells_tangential)

inlet.set_start_patch('inlet')
inlet.set_outer_patch('wall')
inlet.set_end_patch('outlet')
mesh.add(inlet)

See examples/shape for use of each shape

3D pipes with twists and turns (chained Elbow and Cylinder Shapes) Piping

Chaining and Expanding/Contracting

Useful for Shapes, mostly for piping and rotational geometry; An existing Shape's start or end sketch can be reused as a starting sketch for a new Shape, as long as they are compatible. For instance, an Elbow can be chained to a Cylinder just like joining pipes in plumbing.

Moreover, most shapes* can be expanded to form a wall version of the same shape. For instance, expanding a Cylinder creates an ExtrudedRing or an ExtrudedRing can be filled to obtain a Cylinder that fills it.

A simple tank with rounded edges Tank

A flywheel in a case. Construction starts with a Cylinder which is then expanded and chained from left towards right. VTK Blocking output for debug is shown in the middle Flywheel

Venturi tube Venturi tube

See examples/chaining for an example of each operation.

Custom Sketches and Shapes

A Sketch is a collection of faces - essentially a 2D geometric object, split into quadrangles. Each Face in a Sketch is transformed into 3D space, creating a Shape.

A number of predefined Sketches is available to choose from but it's easy to create a custom one.

disk_in_square = cb.WrappedDisk(start_point, corner_point, disk_diameter/2, normal)
shape = cb.ExtrudedShape(disk_in_square, length)

Sketch Smoothing and Optimization

Points that define a custom sketch can only be placed approximately. Their positions can then be defined by Laplacian smoothing or optimization to obtain best face quality.

See examples/shape/custom for an example with a custom sketch.

Stacks

A collection of similar Shapes; a Stack is created by starting with a Sketch, then transforming it a number of times, obtaining Shapes, stacked on top of each other.

An Oval sketch, translated and rotated to obtain a Shape from which a Stack is made. Stack

A Grid sketch, consisting of 3x3 faces is Extruded 2 times to obtain a Stack. The bottom-middle box is removed from the mesh so that flow around a cube can be studied:

base = Grid(point_1, point_2, 3, 3)

stack = ExtrudedStack(base, side * 2, 2)

# ...
mesh.delete(stack.grid[0][1][1])

Cube

See examples/stack/cube.py for the full script.

An electric heater in water, a mesh with two cellZones. The heater zone with surrounding fuild of square cross-section is an extruded WrappedDisk followed by a RevolvedStack of the same cross-sections. The center is then filled with a SemiCylinder. Heater

See examples/complex/heater for the full script.

Assemblies

A collection of pre-assembled parametric Shapes, ready to be used for further construction.

Three pipes, joined in a single point. N-Joint

Projection To Geometry

Any geometry that snappyHexMesh understands is also supported by blockMesh. That includes searchable surfaces such as spheres and cylinders and triangulated surfaces.

Projecting a block side to a geometry is straightforward; edges, however, can be projected to a single geometry (will 'snap' to the closest point) or to an intersection of two surfaces, which will define it exactly.

Geometry is specified as a simple dictionary of strings and is thrown in blockMeshDict exactly as provided by the user.

geometry = {
    'terrain': [
        'type triSurfaceMesh',
        'name terrain',
        'file "terrain.stl"',
    ],
    'left_wall': [
        'type       searchablePlane',
        'planeType  pointAndNormal',
        'point      (-1 0 0)',
        'normal     (1  0  0)',
    ]
}

box = cb.Box([-1., -1., -1.], [1., 1., 1.])
box.project_side('bottom', 'terrain')
box.project_edge(0, 1, 'terrain')
box.project_edge(3, 0, ['terrain', 'left_wall'])

Edges and faces, projected to an STL surface Projected

Mesh for studying flow around a sphere. Edges and faces of inner ('wall') and outer ('prismatic layers') cells are projected to a searchableSphere, adding no additional requirements for STL geometry. Sphere

Face Merging

Simply provide names of patches to be merged and call mesh.merge_patches(<master>, <slave>). classy_blocks will take care of point duplication and whatnot.

box = cb.Box([-0.5, -0.5, 0], [0.5, 0.5, 1])
for i in range(3):
    box.chop(i, count=25)
box.set_patch('top', 'box_top')
mesh.add(box)

cylinder = cb.Cylinder(
    [0, 0, 1],
    [0, 0, 2],
    [0.25, 0, 1]
)
cylinder.chop_axial(count=10)
cylinder.chop_radial(count=10)
cylinder.chop_tangential(count=20)

cylinder.set_bottom_patch('cylinder_bottom')
mesh.add(cylinder)

mesh.merge_patches('box_top', 'cylinder_bottom')

Offsetting Faces

It is possible to create new blocks by offsetting existing blocks' faces. As an example, a sphere can be created by offsetting all six faces of a simple box, then projected to a searchableSphere.

See examples/shapes/shell.py for the sphere tutorial.

Automatic Blocking Optimization

Once an approximate blocking is established, one can fetch specific vertices and specifies certain degrees of freedom along which those vertices will be moved to get blocks of better quality.

Block is treated as a single cell for which OpenFOAM's cell quality criteria are calculated and optimized per user's instructions.

Points can move freely (3 degrees of freedom), along a specified line/curve (1 DoF) or surface (2 DoF).

# [...] A simple setup with two cylinders of different radii,
# connected by a short conical frustum that has bad cells
# [...]

mesh.assemble()

# Find inside vertices at connecting frustum
finder = cb.RoundSolidFinder(mesh, frustum)
inner_vertices = finder.find_core(True).union(finder.find_core(False))

optimizer = cb.Optimizer(mesh)

# Move chosen vertices along a line, parallel to x-axis
for vertex in inner_vertices:
    clamp = cb.LineClamp(vertex, vertex.position, vertex.position + f.vector(1, 0, 0))
    optimizer.add_clamp(clamp)

optimizer.optimize()

mesh.write(os.path.join("..", "case", "system", "blockMeshDict"), debug_path="debug.vtk")

The result (basic blocking > optimized): Diffuser

See examples/optimization for the diffuser example.

Airfoil core with blunt trailing edge (imported points from NACA generator) and adjustable angle of attack. Exact blocking is determined by in-situ optimization (see examples/complex/airfoil.py). A simulation-ready mesh needs additional blocks to expand domain further away from the airfoil. Airfoil

Debugging

By default, a debug.vtk file is created where each block represents a hexahedral cell. By showing block_ids with a proper color scale the blocking can be visualized. This is useful when blockMesh fails with errors reporting invalid/inside-out blocks but VTK will happily show anything.

Also!

2D mesh for studying Karman Vortex Street Karman Vortex Street

A parametric, Low-Re mesh of a real-life impeller (not included in examples) Impeller - Low Re

A gear, made from a curve of a single tooth, calculated by py_gear_gen Gear

A complex example: parametric, Low-Re mesh of a cyclone Cyclone

See examples/complex/cyclone for a full example of a complex building workflow.

Prerequisites

Package (python) dependencies can be found in pyproject.toml file. Other dependencies that must be installed:

  • python3.8 and higher
  • OpenFoam: .org or .com version is supported, foam-extend's blockMesh doesn't support multigrading but is otherwise also compatible. BlockMesh is not required to run Python scripts. There is an ongoing effort to create VTK meshes from within classy_blocks. See the wip_mesher branch for the latest updates.

Technical Information

There's no official documentation yet so here are some tips for easier navigation through source.

The Process, Roughly

  1. User writes a script that defines operations/shapes/objects, their edges, projections, cell counts, whatever is needed.
  2. All the stuff is added to mesh.
  3. Mesh converts user entered data into vertices, blocks, edges and whatnot.
  4. The mesh can be written at that point; or,
  5. Modification of placed geometry, either by manually moving vertices or by utilizing some sort of optimization algorithm.
  6. Output of optimized/modified mesh.

Support?

If you are stuck, try reading the classy_blocks tutorial on damogranlabs.com.

You are free to join the OpenFOAM Discord channel where classy_blocks users and developers hang out.

If you have collosal plans for meshing but no resources, write an email to Nejc Jurkovic and we'll discuss your options.

classy_blocks's People

Contributors

darrengarvey avatar franzbangar avatar lasseholch avatar schperplata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

classy_blocks's Issues

Elbow from multiple blocks

An option to specify how many axial blocks to create an elbow from to keep consistent circular cross-section

Point vs point confusion

'Point' is an classy object that has a position, projections and some useful methods; a 'point', mathematically, can be a list of integers/floats or a numpy array. This causes massive confusion in code and tests.

The bug fixed in feature/offset is the result of this confusion, there are probably more.

TODO:

  1. Change names of 'point' variables (not objects) to 'position' or similar
  2. Refactor test_vertex_list and test_edge_list with better shortcuts
  3. Tests of the new Vertex.from_point() functionality

Include examples in tests

The plan:

  1. Generate blockMeshDicts from examples using the already-written tool (tests/helpers/collect_outputs)
  2. Run meshes and check them visually by hand to make sure they work
  3. Repeat the above for other two OF versions
  4. Save valid example files
  5. Run No. 1 and compare output to saved dicts for each test

Cylinder with multiple inlet and outlet pipes

Hi,

I attempted to create a cylinder with four holes that will eventually be connected to inlet and outlet pipes. I have attached a rough script that does this traditionally by combining multiple blocks, but I'm having trouble closing the cylinder at the bottom. It may have been better to start with a custom sketch and then extrude it. I would not have ended up with a dirty script.

Could you please advise on the best approach to achieve this classier, more reusable way?

Thank you!
Screenshot 2024-07-01 092054

Install fails on WSL2

  • classy_blocks version: commit 993b272
  • Python version: 3.10.6
  • Operating System: Ubuntu 22.04.2 LTS *(Running on WSL2)

Description

Package name in unrecognizable through pip thus cannot import classy_blocks through python script

What I Did

Following "How To Use It" section in README.md

input
pip install git+https://github.com/damogranlabs/classy_blocks.git

output

Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/damogranlabs/classy_blocks.git
  Cloning https://github.com/damogranlabs/classy_blocks.git to /tmp/pip-req-build-6bivehnb
  Running command git clone --filter=blob:none --quiet https://github.com/damogranlabs/classy_blocks.git /tmp/pip-req-build-6bivehnb
  Resolved https://github.com/damogranlabs/classy_blocks.git to commit 993b272418618d34264752a9b4014ba9542830e3
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: UNKNOWN
  Building wheel for UNKNOWN (pyproject.toml) ... done
  Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=1795 sha256=eb42ec936b192297fb6c5aa2a6443e4c2dcb47efa0da358840a97441116e2b06
  Stored in directory: /tmp/pip-ephem-wheel-cache-4g9qqxj0/wheels/9f/5a/bc/716b0a81067ee88b8363d0652c0f9cbd785a48a34a5cf47168
Successfully built UNKNOWN
Installing collected packages: UNKNOWN
Successfully installed UNKNOWN-0.0.0

After install, when I try to import classy_blocks as cb in .py file:
ModuleNotFoundError: No module named 'classy_blocks'

Debug mode

  • print more verbose information about blocks with no cell counts/gradings
  • export block vertices/edges to .obj file

Use `pytest` instead of `unittest`

It seems like VS Code test explorer does not know how to handle @parameterized.* tests:
image

By switching to pytest framework, you can still write tests in unittest format as currently, but VSC will show you also these parametrized sub-tests:
image
image

Let me know if you are interested, I have a branch with these settings are configured, could do PR.

On the problem that overlapping faces cannot be merged

Hello, I found a small bug.Take a simple example.
As shown in the figure,a face is made up of three blue rectangles that lie horizontally,at the same time, the face is also composed of two vertical yellow cuboids.
It can be understood this way,The respective sides of three horizontal cuboids and two vertical cuboids completely coincide on this surface,
Under normal circumstances, this face should be recognized and merged by openfoam as an internal face, but it is not used in practice, and the five faces with the outermost vertices completely coincident cannot be merged by using the merge command.
image
I think this may be a small bug that needs to be dealt with

Shell.chop() only on a single face

Chop only the first block of a shell, other blocks should copy from it.

When Shell will be made from disconnected faces, a warning should be issued (a matter of discussion?).

HexMesh extension [Points_list or Corner_list Class Request ]

  • classy_blocks version:
  • Python version:
  • Operating System:

Description

I cant find where a corner projection is stored in a class list
face projections are stored in face_list
edge projections are stored in edge_list

why are corner projections not stored in a corner_list ?

can you create this list please

PS
i have just written an extension to classy blocks in python that creates the hexmesh
(removing the need for blockmesh) -
I know its not what this project was intended for -
but would you be interested in adding this extension to your project ?

Regards
Malcolm

Multigrading option

Is there the option to use multigrading feature of block_mesh utility by classy_blocks? ? I cannot find any info about it in source code and examples

mesh check failed

The mesh check failed for a few examples as I tried just now. airfoil_2d, elbow and pump_volute are failed at checkMesh.
elbow: ***Number of edges not aligned with or perpendicular to non-empty directions: 40110

enhancement: operations on sketches

Hi,

Currently, the operations work only on a single face (or two faces in the loft case). It would be easier to create a blocking structure when these operations work on a sketch, just like in a CAD program. I know it is already possible to do so by using the translation/rotation functions for instance in the elbow shape. However, for an end-user it would be intuitive if the operation classes could by used for this. I understand that this will introduce some work, since a single operation is now converted to a single block.

Would you be willing to take a look at this idea?

enhancement: structured block array

Hi,

I have an idea for an additional functionality in classy blocks: a multiHex object. This is a structured 3d array of blocks. I’ve attached a proof of concept in python. This is not yet linked to classy blocks. It creates the points and blocks and shows how one can interact with these.

The advantage of creating a separate class over having multiple lofts is the ease of selecting and editing the location of the vertices. In this class one can select vertices and blocks based on their location in the blocking structure; i.e. (1,2,3) means the second vertex in x direction, the third vertex in y direction and the fourth vertex in z direction. When selecting this vertex it can be translated or rotated afterwards. Since the hexblocks have an index to the vertices in the multiHex class, all the hexBlocks are updated automatically when the vertex is moved. For a Cartesian mesh this procedure is far easier than the current method in classy blocks of selecting vertices in the mesh by looking at their location within a sphere or box.

The idea is based on blockmeshbuilder: https://github.com/NauticalMile64/blockmeshbuilder/blob/master/blockmeshbuilder/blockstructures/cartesian.py . However, I’ve built the code from scratch and added more features. In the attached file, you can see what the code is currently capable of and what I still would like to add.

My question is: would this be interesting for you to add? If so, I could integrate this code to classy blocks. However, I suppose it would need some final editing by you since you know all the ins and outs of the class blocks framework.
What would be your idea to integrate this code to classy blocks. Should this code create multiple loft operations which can be added to the mesh, or should this code be directly added to the mesh class?
multiHex.zip

Boolean operations

A question has popped up whether there are boolean operations possible with classy_blocks. The answer:

Within classy_blocks there are no boolean operations. Using them one very quickly gets a shape that can't be created using structured meshes so it makes no sense trying to achieve the impossible. However, there are two options:

  1. create blocks for both sides of boolean operation and assign them to separate cellZones. Then, using subsetMesh, remove one cellZone from another. Here's a tutorial: https://www.youtube.com/watch?v=VdZAkO0XbcY
    You can put a block in a cellzone just by setting the cell_zone property: block1.cell_zone = "removal" and it will be named in the block definition in blockMeshDict. For operations and shapes there is no such feature yet but I'll add them ASAP. Still you can access the block object: Operation.block. For shapes there are Shape.core.block and Shape.Shell[4].block (a list of 4 operations)
  2. Where you can't make a clean boolean cut on a structured mesh, you have no choice but to use a non-structured mesher. In this case classy_blocks still might be helpful for creating parametric geometry. See this blog post: https://damogranlabs.com/2020/10/a-parametric-cfd-model-wind-turbine-from-pipes/

A new issue will be opened for cell zone assignment on operations and shapes.

T-joint implementation

Hi, I noticed that the T-joints still need to be implemented. Do you have any rough implementations of T-joints? Or can you guide me through how to implement it myself?

Thank you

Face merging

Merge patches using face merging
with something like mesh.merge_patches(master_patch, slave_patch) and no additional wrestling with duplicated points, patches and so on

Package info and settings cleanup

This file can be removed. ATM, Travis is not used and CI is configured in GitHub Actions.

Also, new standards are simplifying and unifying some package info. I think setup.py and requirements-dev.txt can be merged to pyproject.toml, similar to example here.

Should I look into it?

Patch type

set_patch() should include patch type.

help needed to convert PIV data to OpenFoam mesh

Hi,
thanks for this great piece of software that apparently saves tons of hours for OpenFoam users. I'm here to ask for your advice on a slightly different topic. We work with the particle image velocimetry (open source software, called openpiv-python) and we're interested to convert the measurement results (columns of x,y and 2 components of velocity, u,v) into OpenFOAM boundary conditions or initial conditions over the user - prescribed mesh.

Seems that your from_points does something very close to what we think is needed. I have no idea about OpenFoam, btw.

Thanks
Alex @alexlib

Error installing

  • classy_blocks version:
  • Python version: 3.8
  • Operating System: Ubuntu 18.04 LTS

Description

I'm getting the following error while installing:
File "setup.py", line 6
def read_file(rel_path: str) -> str:
^
SyntaxError: invalid syntax

What I Did

sudo python setup.py install

Sweep on a negative angle

Hey, you'd better put the absolute value of an angle when you calculate elbow_arc_length in sweep_block function so you could sweep in other sense too.

classy_blocks installable

Summary

the repository is not "user friendly" and it lacks a continious integration. that would help with the efficiency and effectivity of the development.

tools that will be used in this feature branch

Specifications

  • installabe
  • usage of requirements.txt
  • implementation of pytest
  • OpenSource MIT Licence
  • sphynx documentation (you probably want to delete this. we will have to look into this)
  • no terminal cli
  • np pypi deployment (installable via pip install classy_blocks) ... (i would need user credentials)
  • runs with python 3.9 (the version i am currently using as VTK is not yet compatible with python 3.10)

development plan

  • open a feature branch
  • move codebase of classy_blocks to temporary directory in the feature branch
  • use cookiecutter with audrey template
  • fill requirements.txt for automated dependency installation
  • insert requirements.txt in setup.py
  • move codebase of classy_blocks to project source
  • merge classy_examples into classy_installable
  • delete unwanted files after merge. they will stay in classy_examples
  • add tests to project
  • add continious integration to project
  • merge into master if tests are passing

What should the package usage look like?

when i implement a cookiecutter project, i will orientate myself on your given examples in this repository or in the example-repository. i think there should be some kind of documentation on how to use this project. i will try not to spend hours on understanding your algorithms, so it would help me if somebody guides me through an application of this repository.

# here we could document a usage of the installable package

from classy_blocks import bla

bla(**args)

Uneven cell count on equal blocks

This fails when cell_size = 1.5 but works with other cell sizes:

#!/usr/bin/env python
import os
from classy_blocks.classes.mesh import Mesh
from classy_blocks.classes.shapes import ExtrudedRing

d_shaft = 12e-3
d_2 = 63e-3
d_3 = 80e-3
h = 20e-3
b_3 = 15e-3

cell_size = 1.5e-3

mesh = Mesh()

inner_ring = ExtrudedRing(
    [0, 0, 0],
    [0, 0, h],
    [d_shaft/2, 0, 0],
    d_2/2
)
inner_ring.chop_axial(start_size=cell_size)
inner_ring.chop_radial(start_size=cell_size)
inner_ring.chop_tangential(start_size=cell_size)

mesh.add(inner_ring)

Looks like same blocks with different orientation get a different calculated size;
two things to check:

  1. Size calculation
  2. Only set one block of ring (and other shapes)
  3. why the above doesn't work (something with grading propagation)
  4. fix all of the above

Revolve Operation with negative angle

Revolve with a negative angle will create a block that spans 360deg - |angle|. It should create a Revolve with given angle instead.
A workaround is to flip the axis and use a positive angle value.

To investigate: Angle EdgeData (or use the previous Revolve calculation with Arc edges).

feature: more edge types

I've been interested in blockmesh creation codes for a while and I've used and adapted the ofblockmeshdicthelper (https://github.com/takaakiaoki/ofblockmeshdicthelper)

Now, I've been browsing around in your code, and from what I've seen this looks like the best blockmesh creator available! I think you have created a nice framework where extensions are possible. However, the edge type creation is not very flexible. I did miss the feature to use more edge types such as

The new arc methods allow for a far better readable blockmesh file.

Since you are overhauling the code in the branch: feature/optimization, would this be the right time to add the possibility to use different types of edges?

Setting Cell Zone

  • classy_blocks version: 1.4.0
  • Python version: 3.10.12
  • Operating System: Ubuntu 22.04.4 LTS

Hello! First, I wanted to say that this is an excellent and impressive tool. Thank you for making it. I think I have found a small deficiency, but perhaps I have overlooked the functionality. I am editing the rhoPorousSimpleFoam tutorial using classy_blocks and it wants cell zones to be defined. From what I've seen, it appears that in order to have blockMesh select a cell zone, the entry in blocks needs to read "hex (points) zoneName ... " and could be included in a similar fashion to set_patch. Does this functionality currently exist and I simply overlooked it? If not, I'd be happy to play around with the source if you could point out which file actually generates this section of the output.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.