Skip to main content

Create & Convert Cubed-sphere Grids (CSGrid) to Unstructured Meshes

https://img.shields.io/pypi/v/csgrid2unstr.svg https://img.shields.io/pypi/l/csgrid2unstr.svg

Introduction

The grid generator is from here, and I/O is handled by meshio.

This package was created for education/research purpose. Personally, I use this to study the grid convergence for data transferring between CSGrid and spherical centroidal Voronoi tessellations (SCVT).

demo.png

Installation

You can easily install this package through pip, i.e.

$ pip install csgrid2unstr --user

You can, of course, install it directly from the repository:

$ git clone https://github.com/chiao45/csgrid2unstr.git
$ cd csgrid2unstr && python setup.py install --user

Notice that this package depends on:

  1. numpy

  2. setuptools

  3. meshio

Usage

As Executable Binary

Once you have installed the package, open the terminal and type:

$ csgrid2unstr -h
usage: csgrid2unstr [-h] [-n SIZE] [-o OUTPUT] [-r REFINE]
                [-f {vtk,vtu,gmsh,off,exodus,xdmf,dolfin-xml,stl}] [-b]
                [-V] [-v]

write CSGrid to unstr

optional arguments:
  -h, --help            show this help message and exit
  -n SIZE, --size SIZE  Number of intervals of a square face
  -o OUTPUT, --output OUTPUT
                        Output file name, w/o extension
  -r REFINE, --refine REFINE
                        Level of refinements, default is 1
  -f {vtk,vtu,gmsh,off,exodus,xdmf,dolfin-xml,stl}, --format {vtk,vtu,gmsh,off,exodus,xdmf,dolfin-xml,stl}
                        Output file format, default is VTK
  -b, --binary          Use BINARY. Notice that this flag is ignored for
                        some formats
  -V, --verbose         Verbose output
  -v, --version         Check version

If you got command not found: csgrid2unstr, make sure csgrid2unstr is in your $PATH.

There are two must-provided parameters, i.e. -n (--size) and -o (--output). The former is to define the number of intervals of a square face, i.e. the number of quadrilaterals of a face is n*n, and the latter is to provide the output filename (without extension). For instance:

$ csgrid2unstr -n 20 -o demo

will construct a CSGrid of 400 quadrilaterals per face, convert the grid into an unstructured mesh and store it in demo.vtk.

You can create a serial of uniform refined grids by adding -r (--refine) switch, e.g.:

$ csgrid2unstr -n 10 -r 3 -o demo -f xdmf

will construct three CSGrids with 100, 400, and 1600 quadrilaterals per face, convert them into three unstructured meshes and store them in demo0.xdmf, demo1.xdmf, and demo2.xdfm, resp.

As Module

Using csgrid2unstr as a Python module is also simple.

from __future__ import print_function
from csgrid2unstr.cubed_sphere import CSGrid
from csgrid2unstr.unstr import Unstr

# create a CSGrid of 25 quads per face
cs = CSGrid(5)

# convert it into an unstructured mesh
mesh = Unstr(cs)

# two attributes, points and cells, of np.ndarray

print('Nodes {}-by-3'.format(len(mesh.points)))
print(mesh.points)

print('Cells {}-by-4'.format(len(mesh.cells)))
print(mesh.cells)

License

MIT License

Copyright (c) 2018 Qiao Chen

Metadata

Release files for csgrid2unstr 0.0.1

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

Source distribution (sdist)

Source distribution for csgrid2unstr 0.0.1
File Size Uploaded
csgrid2unstr-0.0.1.tar.gz 9.1 kB Details

Release files / csgrid2unstr-0.0.1.tar.gz

Download URL csgrid2unstr-0.0.1.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0a839d73c2c9b744edc4c5ebe3b155af5ab0e91881a52bb86d66195aa388ab02
BLAKE2b-256 checksum
How to use checksums
b2850c0cc1df1d63f42723bff9e1b095721d54b1596f60a0a6e148d483d56998
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

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