lsdo_genie.utils
Subpackages
Submodules
Package Contents
Classes
Computational System Design Language (CSDL) interface for using lsdo_genie in gradient-based |
|
Computational System Design Language (CSDL) interface for using lsdo_genie in gradient-based |
Functions
|
Calcuate an enlarged bounding box of a given point cloud |
|
Explicit level set function derived by Hicken and Kaur which interpolates |
|
Extract the point cloud data from a .stl file |
|
Approximate an arbitrary closed polygon by using the midpoints of the edges formed by an input set of vertices |
|
A quick way to approximate the normal vectors from an arbitrary closed polygon. |
|
Plots and shows a 2D point cloud with normal vectors |
|
Plots and shows a 3D point cloud with normal vectors |
- class lsdo_genie.utils.Genie2DCSDLModel
Bases:
csdl.CustomExplicitOperation
Computational System Design Language (CSDL) interface for using lsdo_genie in gradient-based optimization for 2D geometric shapes
- Parameters:
- num_ptsint
Number of points in the input
- x_namestr
CSDL variable name of the x-coordinate of the input points
- y_namestr
CSDL variable name of the y-coordinate of the input points
- out_namestr
CSDL variable name of the output phi
- genie_objectlsdo_genie.Genie2D
The genie object to be used in the model to compute phi
- compute(inputs, outputs)
compute
- compute_derivatives(inputs, derivatives)
compute_derivatives
- define()
define
- initialize()
initialize
- class lsdo_genie.utils.Genie3DCSDLModel
Bases:
csdl.CustomExplicitOperation
Computational System Design Language (CSDL) interface for using lsdo_genie in gradient-based optimization for 3D geometric shapes
- Parameters:
- num_ptsint
Number of points in the input
- x_namestr
CSDL variable name of the x-coordinate of the input points
- y_namestr
CSDL variable name of the y-coordinate of the input points
- z_namestr
CSDL variable name of the z-coordinate of the input points
- out_namestr
CSDL variable name of the output phi
- genie_objectlsdo_genie.Genie2D
The genie object to be used in the model to compute phi
- compute(inputs, outputs)
compute
- compute_derivatives(inputs, derivatives)
compute_derivatives
- define()
define
- initialize()
initialize
- lsdo_genie.utils.enlarged_bbox(surface_points: numpy.ndarray, percent: float = 10.0)
Calcuate an enlarged bounding box of a given point cloud
- Parameters:
- surface_pointsnp.ndarray(Ngamma,d)
The positions of points in a point cloud in ‘d’ dimensions
- percentfloat
The percentage to increase the bounding box from the minimum bounding box
- Returns:
- domainnp.ndarray(d,2)
The lower and upper bounds along each dimension
- lsdo_genie.utils.explicit_lsf(pts, data_points: scipy.spatial.KDTree, data_normals, k, rho)
Explicit level set function derived by Hicken and Kaur which interpolates data points via piecewise linear signed distance functions defined by local hyperplanes. The function is defined by these piecewise functions with KS-aggregation, but is non-differentiable if only using the k-nearest neighbors.
“An Explicit Level-Set Formula to Approximate Geometries” Jason E. Hicken and Sharanjeet Kaur doi:10.2514/6.2022-1862
- Parameters:
- pointsnp.ndarray(N,d)
Points to evaluate the level set funcion
- data_pointsscipy.spatial.KDTree
KDTree structure of the point cloud
- data_normalsnp.ndarray(Ngamma,d)
Normal vectors of the point cloud
- kint
Numer of nearest neighbors to include in the function
- rhofloat
Smoothing parameter
- Returns:
- phinp.ndarray(N,)
Approximate signed distance value of the points
- lsdo_genie.utils.extract_stl_data(filename: str, verbose: bool = False)
Extract the point cloud data from a .stl file
- Parameters:
- filenamestr
The location of your file relative to your working directory when running
- verbosebool
Prints the number of points loaded to the terminal
- Returns:
- centroidsnp.ndarray(N,3)
The centroids of the triangulation
- normalsnp.ndarray(N,3)
The normal vectors of the associated centroids
- lsdo_genie.utils.midpoint_normal_approx(vertices: numpy.ndarray)
Approximate an arbitrary closed polygon by using the midpoints of the edges formed by an input set of vertices Normal direction is determined by the direction of the points given in the input: Clockwise : normals point outwards Counter-Clockwise : normals point inwards
- Parameters:
- verticesnp.ndarray(num_pts,2)
The input points
- Returns:
- midpoints: np.ndarray(num_pts,2)
Midpoints between input points
- normalsnp.ndarray(num_pts,2)
Normal vectors at the midpoints
- lsdo_genie.utils.vertex_normal_approx(vertices: numpy.ndarray)
A quick way to approximate the normal vectors from an arbitrary closed polygon. Normals are an average between the 2 edge normals adjacent to a point and follow a covention: Clockwise : normals point outwards Counter-Clockwise : normals point inwards
- Parameters:
- verticesnp.ndarray(num_pts,2)
The input points
- Returns:
- normalsnp.ndarray(num_pts,2)
Approximate normal vectors at the input points
- lsdo_genie.utils.visualize_2Dptcloud(points: numpy.ndarray, normals: numpy.ndarray, show_normals: bool = True, title: str = '2D Point cloud with normals', perc_normal_length: float = 5.0)
Plots and shows a 2D point cloud with normal vectors
- Parameters:
- pointsnp.ndarray(N,2)
The points in the poind cloud
- normalsnp.ndarray(N,2)
The normal vectors of the point cloud
- show_normalsbool
Show the normal vectors with a blue arrow
- titlestr
Title of the plot
- lsdo_genie.utils.visualize_3Dptcloud(points: numpy.ndarray, normals: numpy.ndarray, show_normals: bool = True, title: str = '3D Point cloud with normals', perc_normal_length: float = 5.0)
Plots and shows a 3D point cloud with normal vectors
- Parameters:
- pointsnp.ndarray(N,3)
The points in the poind cloud
- normalsnp.ndarray(N,3)
The normal vectors of the point cloud
- show_normalsbool
Show the normal vectors with a blue arrow
- titlestr
Title of the plot