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

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.6.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

mesh_generator-1.0.6-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mesh_generator-1.0.6.tar.gz
  • Upload date:
  • Size: 33.5 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.6.tar.gz
Algorithm Hash digest
SHA256 abbec1fededb51c7dff9ea2b3554024e3e705b033626d5c6790c079751ea8c83
MD5 24aa46f11d9c9010b6c016cfd7459db3
BLAKE2b-256 38ddb82d08742921c22e14f917e33535eaacaddda1364e72fa9055fd55ae8bfb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mesh_generator-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 34.2 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 42b58059e282edf91f1bd0457029cfb7e0f2dcc47f22dd7b188cf537cc05fcff
MD5 9c029846e32d93ec13d1d212e7c4784c
BLAKE2b-256 f69fbeaa75e8ac9d72b4fb75cd153e38f868bc8330796f1261ea58567288972f

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