Skip to main content

This is a collection of Python subroutines and examples that illustrate how to build a 1D Mesh with custom mesh spacing. The meshes created in the package can be used for variety of applications, including physical simulation.

Installation

pip install mesh-generator

Dependencies

python >= 3.5.0 
numpy >= 1.15.2 
matplotlib >= 3.0.0 
scipy >= 1.1.0
h5py >= 2.8.0 
tk >= 8.6.0 
pyhdf >= 0.9.10

Usage

This an example for creating a 1D theta mesh. Read the comments inside the python scripts for more details.

  • Step 1 : Input mesh requirements. Make sure to specify:

    Mesh:

    • Set lower_bnd and upper_bnd limits of mesh.

    • Set periodic.

    • Set DEFAULT_BG_REGION_RATIO - Ratio in areas without ds constraint. (Optional)

    • Set DEFAULT_FG_REGION_RATIO - Ratio in areas with ds constraint. (Optional)

    Mesh segment:

    • Set s0 and s1 for segment domain limits.

    • Set ds to the resolution you want.

    • Set var_ds_ratio as segment maximum cell to cell mesh expansion ratio. (Optional)

from mesh_generator import Mesh
from mesh_generator import MeshSegment
from mesh_generator.bin.call_psi_mesh_tool import create_psi_mesh
import numpy 

# ratio in regions you do not care about. (Default is 1.06)
MeshSegment.DEFAULT_BG_REGION_RATIO = 1.06 

# ratio in regions you do care about. (Default is 1.03) 
MeshSegment.DEFAULT_FG_REGION_RATIO = 1.03  

# mesh boundaries and if periodic. 
mesh = Mesh(lower_bnd=0.00, upper_bnd=numpy.pi, periodic=False) 

# Mesh segment requirements:
# s0 - segment begin, s1- segment end, ds- mesh spacing
# (Optional) var_ds_ratio- the maximum ratio between each point in the mesh segment. 
mesh.insert_mesh_segment(MeshSegment(s0=1.10, s1=1.40, ds=0.01, var_ds_ratio=1.05))
mesh.insert_mesh_segment(MeshSegment(s0=1.30, s1=1.90, ds=0.02))
mesh.insert_mesh_segment(MeshSegment(s0=0.40, s1=2.80, ds=0.04, var_ds_ratio=1.02))
  • Step 2: Get final mesh and write results.
input_mesh = mesh.json_dict()
adjusted_mesh = mesh.resolve_mesh_segments().json_dict()
legacy_mesh = mesh.build_legacy_mesh().json_dict()
create_psi_mesh(adjusted_mesh, legacy_mesh, mesh_type="t", dir_name=os.getcwd(),
     output_file_name="tmp_mesh_t.dat", mesh_res_file_name="mesh_res_t.dat",
     save_plot=True, show_plot=True, save_plot_path=os.getcwd(), plot_file_name="t_mesh_spacing.png", 
     input_mesh=input_mesh)

Mesh Generator User Interface

from mesh_generator import MeshGeneratorUI
MeshGeneratorUI()

License

Apache

Authors

Predictive Science Inc.

Release files for mesh-generator 1.1.12

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

Source distribution (sdist)

Source distribution for mesh-generator 1.1.12
File Size Uploaded
mesh_generator-1.1.12.tar.gz 75.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mesh-generator 1.1.12
File Interpreter ABI Platform
mesh_generator-1.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 143.9 kB

Release files / mesh_generator-1.1.12.tar.gz

Download URL mesh_generator-1.1.12.tar.gz
Size 75.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e20a48e2a256190f1c1c573037c2d5c9b6da13113980c86bf960768bb2b4913f
BLAKE2b-256 checksum
How to use checksums
98c8bfa5f01909d58b4375e8830cc4f7023deb3d5b9b391ba4ccf5ae280deaff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / mesh_generator-1.1.12-py3-none-any.whl

Download URL mesh_generator-1.1.12-py3-none-any.whl
Size 67.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41ae4eb019c81c599487c8fd7988bbef9cf40e9fbabe70adadac534a46662c0b
BLAKE2b-256 checksum
How to use checksums
9c460346071ac482bb3472f0da3fbb21c5d1945d94da6a1b6e45993ad8b727a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.1.12 This release

2 release files

1.1.11

2 release files

1.1.10

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

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