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
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
andupper_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
ands1
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 write results.
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")
Mesh Generator User Interface
from mesh_generator import MeshGeneratorUI
MeshGeneratorUI()
License
Authors
- Opal Issan (oissan@predsci.com)
- Cooper Downs (cdowns@predsci.com)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mesh_generator-1.1.6.tar.gz
.
File metadata
- Download URL: mesh_generator-1.1.6.tar.gz
- Upload date:
- Size: 58.0 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.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f28f951f96c0070ce714d3229666e0d1d77ae65e5e68765ab7fc2b3e249d4194 |
|
MD5 | b5910edd55d65ed927165e2bd6440ddc |
|
BLAKE2b-256 | 977e31acf394e1fd099bd49e2d92e600a125fb8856912e3f498a675e9868750c |
File details
Details for the file mesh_generator-1.1.6-py3-none-any.whl
.
File metadata
- Download URL: mesh_generator-1.1.6-py3-none-any.whl
- Upload date:
- Size: 66.8 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.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45e44ead9d050cf82ce7a2dba55ad978f635e53715b76825dbe71723d55b5f4d |
|
MD5 | abcf9e8a41c0f06900c48be3ef647752 |
|
BLAKE2b-256 | 15cb91b2656114074fb697084ccfc71f066c3a8c27a3367c32936802ed288f40 |