Skip to main content

Python subroutines to create a 1D mesh in Python.

Project description

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

numpy>=1.15.2 # Minimum version 1.18.1
matplotlib>=3.0.0 # Minimum version 3.1.3
python>=3.5.0 # Minimum version 3.5

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
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 save it as a dictionary.
mesh.resolve_mesh_segments()
mesh.build_legacy_mesh()
mesh.json_dict() #returns the final discretized mesh.

License

Apache

Authors

Predictive Science Inc.

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

mesh_generator-1.0.8.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

mesh_generator-1.0.8-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

Details for the file mesh_generator-1.0.8.tar.gz.

File metadata

  • Download URL: mesh_generator-1.0.8.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6

File hashes

Hashes for mesh_generator-1.0.8.tar.gz
Algorithm Hash digest
SHA256 58ba82d7eeda13256f0ff13b4e7e742f77518971c4196ca905e01c2d2df4a069
MD5 7a6a393d56cc26d3c529fa6ddebfda9f
BLAKE2b-256 46737ba3b8608b66dfcca94549b74b94d65815dd6fdefa0d83cc66ee09d91e77

See more details on using hashes here.

File details

Details for the file mesh_generator-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: mesh_generator-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 34.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6

File hashes

Hashes for mesh_generator-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 74c8577e0bcb5c3e26d8997e0a21e644aa09a4bd2ad6115e0a640df65b637713
MD5 0af07986452d0c3d3d60ee54062342ae
BLAKE2b-256 6dbfee1558e8bd8d3eaed11e7fbe79b4e9081c37493488b236cbe47f6122b190

See more details on using hashes here.

Supported by

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