optimus.utils.mesh

Get mesh statistics and scale mesh elements.

Module Contents

Functions

_get_mesh_stats(grid[, verbose])

Compute the minimum, maximum, median, mean and standard deviation of

get_geometries_stats(geometries[, verbose])

Compute the minimum, maximum, median, mean and standard deviation of

scale_mesh(geometry, scaling_factor)

Scale the entire geometry with a multiplicative factor.

translate_mesh(geometry, translation_vector)

Translate the entire geometry with an additive vector.

msh_from_string(geo_string)

Create a mesh from a string.

generate_grid_from_geo_string(geo_string)

Helper routine that implements the grid generation

plane_grid(x_axis_lims, y_axis_lims, rotation_axis, ...)

Return a 2D square shaped plane.

create_grid_points(resolution, plane_axes, ...)

Create a grid on a plane, either with Numpy or Gmsh.

optimus.utils.mesh._get_mesh_stats(grid, verbose=False)

Compute the minimum, maximum, median, mean and standard deviation of mesh elements for a grid object.

Parameters
gridbempp.api.Grid

The surface grid.

verbose: boolean

Print the results.

Returns
statsdict

The mesh statistics.

optimus.utils.mesh.get_geometries_stats(geometries, verbose=False)

Compute the minimum, maximum, median, mean and standard deviation of mesh elements for optimus Geometries.

Parameters
geometriesoptimus.geometry.common.Geometry, tuple[optimus.geometry.common.Geometry]

The Optimus geometry object(s).

verbose: boolean

Print the results.

Returns
statsdict

The mesh statistics.

optimus.utils.mesh.scale_mesh(geometry, scaling_factor)

Scale the entire geometry with a multiplicative factor.

The connectivity of the mesh remains intact and the scaling is with respect to the global origin as defined in the mesh.

Parameters
geometry: optimus.geometry.common.Geometry

The geometry to scale.

scaling_factorfloat

Scaling factor for the grid.

Returns
geometry: optimus.geometry.common.Geometry

A new, scaled geometry.

optimus.utils.mesh.translate_mesh(geometry, translation_vector)

Translate the entire geometry with an additive vector.

The connectivity of the mesh remains intact.

Parameters
geometry: optimus.geometry.common.Geometry

The geometry to translate.

translation_vectornumpy.ndarray

A 3D vector to translate the grid.

Returns
geometry: optimus.geometry.common.Geometry

A new, translated geometry.

optimus.utils.mesh.msh_from_string(geo_string)

Create a mesh from a string.

optimus.utils.mesh.generate_grid_from_geo_string(geo_string)

Helper routine that implements the grid generation

optimus.utils.mesh.plane_grid(x_axis_lims, y_axis_lims, rotation_axis, rotation_angle, element_size)

Return a 2D square shaped plane.

Parameters
x_axis_limstuple[float], list[float]

A list of length two for the bounding values along the x-axis of plane.

y_axis_limstuple[float], list[float]

A list of length two for the bounding values along the y-axis of plane.

rotation_axistuple[int], list[int]

A list of length three populated with 0 or 1. It defines the axis of rotation so to construct the desired plane from an x-y plane.

rotation_anglestr

The angle of rotation.

element_sizefloat

Element size.

Returns
gridbempp.api.Grid

The triangular mesh on the plane.

optimus.utils.mesh.create_grid_points(resolution, plane_axes, plane_offset, bounding_box, mode)

Create a grid on a plane, either with Numpy or Gmsh.

Parameters
resolutionlist[int], tuple[int]

The number of visualisation points along the plane axes.

plane_axeslist[int], tuple[int]

The labels of the plane axes (0,1,2).

plane_offsetfloat

The offset of the plane in perpendicular direction.

bounding_boxlist[float], tuple[float]

Restricting the plane to the bounding box.

modestr

The algorithm to create a visualisation plane. Options: “numpy”, “gmsh”.

Returns
pointsnumpy.ndarray

The visualisation points.

planeAny

The grid, with format depending on the algorithm.