Skip to main content

Process and visualize numerical-analysis-geometries.

Project description

gustaf

gustaf is a Python library to process and visualize numerical-analysis-geometries; gustaf currently supports the following elements:

  • points,
  • lines,
  • triangle,
  • quadrilateral,
  • tetrahedron, and
  • hexahedron.

Installation

gustaf only has numpy for its strict dependency. The minimal version can be installed using pip.

pip install gustaf

To install all the optional dependencies at the same time, you can use:

pip install gustaf[all]

For the latest develop version of gustaf:

pip install git+https://github.com/tataratat/gustaf.git@main

Quick Start

This example shows how to visualize and extract properties of tetrahedrons and NURBS using gustaf. For visualization, gustaf uses vedo as main backend.

To begin we need to import the needed libraries:

import gustaf as gus
import numpy as np

Create a tetrahedron

Now we create our first volume. It will be just a basic cube. Even here we can already choose between using a tetrahedron and a hexahedron-based mesh. The Volume class will use tetrahedrons if the volumes keyword is made up of a list of 4 elements (defining the corners of the tetrahedron), if 8 elements are in each list hexahedrons are used (defining the corners of the hexahedron in the correct order).

# create tetrahedron mesh using Volumes
# it requires vertices and connectivity info, volumes
tet = gus.Volumes(
    vertices=[
        [0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0],
        [0.0, 1.0, 0.0],
        [1.0, 1.0, 0.0],
        [0.0, 0.0, 1.0],
        [1.0, 0.0, 1.0],
        [0.0, 1.0, 1.0],
        [1.0, 1.0, 1.0],
    ],
    volumes=[
        [0, 2, 7, 3],
        [0, 2, 6, 7],
        [0, 6, 4, 7],
        [5, 0, 4, 7],
        [5, 0, 7, 1],
        [7, 0, 3, 1],
    ],
)

# set line color and width
tet.show_options["lc"] = "black"
tet.show_options["lw"] = 4

tet.show()

Tetrahedron based volume

hexa = gus.Volumes(
    vertices=[
        [0.0, 0.0, 0.0], #0
        [1.0, 0.0, 0.0], #1
        [0.0, 1.0, 0.0],
        [1.0, 1.0, 0.0], #3
        [0.0, 0.0, 1.0],
        [1.0, 0.0, 1.0],
        [0.0, 1.0, 1.0], #6
        [1.0, 1.0, 1.0],
    ],
    volumes=[
        [0, 1, 3, 2, 4, 5, 7, 6],
    ],
)

hexa.show_options["lc"] = "black"
hexa.show_options["lw"] = 4

hexa.show()

Hexahedron based volume

Basic visualization

As just shown, it is really easy to show the objects by just calling the show() function on the object. But that is just the beginning of the possibilities in vedo. You can plot multiple objects next to each other:

# show multiple items in one plot
# each list will be put into a separate subplot.
gus.show(
    ["Tetrahedron", tet],
    ["Hexahedron", hexa]
)

Compare hexahedron and tetrahedron-based volumes

Now let's add a color map to the object for the norm of the coordinate, and let us also add at each vertex an arrow with random direction and length.

# let's visualize some scalar data and vector data defined on vertices
tet.vertex_data["arange"] = np.arange(len(tet.vertices))  # scalar
tet.show_options["data_name"] = "arange"
tet.vertex_data["random"] = np.random.random((len(tet.vertices), 3))  # vector
tet.show_options["arrow_data"] = "random"
tet.show()

Add additional data to the object

Are you interested in splines? Please checkout splinepy!

Optional Dependencies

Package Description
numpy Fast array data operations.
vedo Default renderer / visualization core of gustaf.
scipy Create k-d trees and simple rotation matrices.
napf Fast k-d tree build / query based on nanoflann. Supersedes scipy if it is importable.
funi A different method to find unique float array rows. But faster than k-d trees!
meshio Supports loading/exporting numerous mesh formats.

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

gustaf-0.0.12.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

gustaf-0.0.12-py3-none-any.whl (57.4 kB view details)

Uploaded Python 3

File details

Details for the file gustaf-0.0.12.tar.gz.

File metadata

  • Download URL: gustaf-0.0.12.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for gustaf-0.0.12.tar.gz
Algorithm Hash digest
SHA256 1167d858bd08b9ff8519b209924f7a7d8af2902030aa131065b71753634d28f7
MD5 43158b2284e5ba1cc147387bbc12b0a6
BLAKE2b-256 6b7a8b7bb6033987fcf4e0075c404ba91ba10d4b38bdcc2e2486dc1481279393

See more details on using hashes here.

File details

Details for the file gustaf-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: gustaf-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 57.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for gustaf-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 33fe6245c94cb38877cecb7b208829891e4d4fc517d9e1ed5c6e9b1bd66d6e1b
MD5 8538bda8293469cf43ab056803c634ac
BLAKE2b-256 f80afc1ba865b63e6120bf3140a43b54cde9d4f7baf20f473e8de4aa92aeed4d

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