quad_refinement module¶
Quad refinement scheme for the inner trabecular region Author: Simone Poncioni, MSB Date: 04.2023
https://stackoverflow.com/questions/31527755/extract-blocks-or-patches-from-numpy-array https://blender.stackexchange.com/questions/230534/fastest-way-to-skin-a-grid https://gitlab.onelab.info/gmsh/gmsh/-/issues/1710 https://gitlab.onelab.info/gmsh/gmsh/-/issues/2439
- class quad_refinement.QuadRefinement(nb_layers: int, DIM: int = 2, SQUARE_SIZE_0_MM: int = 1, MAX_SUBDIVISIONS: int = 3, ELMS_THICKNESS: int = 2)[source]¶
Bases:
object
- add_curve_loop(curve_loop_tags)[source]¶
Add a curve loop to the Gmsh model.
This function adds a curve loop to the Gmsh model based on the provided curve loop tags.
- Parameters:
curve_loop_tags (List[int]) – List of curve loop tags.
- Returns:
The tag of the created curve loop.
- Return type:
int
- add_surface_loop(surface_loop_tags)[source]¶
Add a surface loop to the Gmsh model.
This function adds a surface loop to the Gmsh model based on the provided surface loop tags.
- Parameters:
surface_loop_tags (List[int]) – List of surface loop tags.
- Returns:
The tag of the created surface loop.
- Return type:
int
- center_of_mass(vertices_coords)[source]¶
Calculate the center of mass of the given vertices.
This function computes the center of mass for the provided vertices coordinates.
- Parameters:
vertices_coords (ndarray) – Array of vertices coordinates.
- Returns:
The center of mass coordinates.
- Return type:
ndarray
- check_closed_surface_loop(lines_lower_dict: dict, lines_upper_dict: dict, lines_intersurf_dict: dict) dict [source]¶
Check for closed surface loops.
This function checks for closed surface loops by matching lines from the lower surface, upper surface, and intersurface dictionaries.
- Parameters:
lines_lower_dict (Dict[int, List[int]]) – Dictionary of lower surface lines and their points.
lines_upper_dict (Dict[int, List[int]]) – Dictionary of upper surface lines and their points.
lines_intersurf_dict (Dict[int, List[int]]) – Dictionary of intersurface lines and their points.
- Returns:
Dictionary of closed surface loops.
- Return type:
Dict[int, List[int]]
- close_outer_loop(line_tags, outer_square_lines)[source]¶
Close the outer loop with surfaces.
This function closes the outer loop by creating surfaces from the provided line tags and outer square lines.
- Parameters:
line_tags (List[int]) – List of line tags.
outer_square_lines (List[int]) – List of outer square line tags.
- Returns:
List of surface tags.
- Return type:
List[int]
- common(arr)[source]¶
Find common elements in an array.
This function finds the common elements in the provided array.
- Parameters:
arr (ndarray) – The input array.
- Returns:
Array of common elements.
- Return type:
ndarray
- create_connecting_surfaces(curve_loops_line_tags)[source]¶
Create connecting surfaces between curve loops.
This function creates connecting surfaces between the provided curve loops.
- Parameters:
curve_loops_line_tags (List[int]) – List of curve loop line tags.
- Returns:
List of surface loops.
- Return type:
List[ndarray]
- create_intersurface_connection(point_tags)[source]¶
Create intersurface connections.
This function creates intersurface connections based on the provided point tags.
- Parameters:
point_tags (List[List[int]]) – List of point tags for each surface.
- Returns:
List of line tags for intersurface connections.
- Return type:
List[List[int]]
- create_line_dict(lines_lower_surf, lines_upper_surf, lines_intersurf)[source]¶
Create dictionaries of lines and their corresponding points.
This function creates dictionaries for the lower surface lines, upper surface lines, and intersurface lines, mapping each line to its corresponding points.
- Parameters:
lines_lower_surf (List[List[int]]) – List of line tags for the lower surface.
lines_upper_surf (List[List[int]]) – List of line tags for the upper surface.
lines_intersurf (List[int]) – List of line tags for the intersurface.
- Returns:
Dictionary of lower surface lines and their points.
Dictionary of upper surface lines and their points.
Dictionary of intersurface lines and their points.
- Return type:
Tuple[Dict[int, List[int]], Dict[int, List[int]], Dict[int, List[int]]]
- create_square_grid(big_square_size, squares_per_side, origin)[source]¶
Create a grid of squares.
This function generates a grid of squares based on the specified size and number of squares per side.
- Parameters:
big_square_size (float) – The size of the big square.
squares_per_side (int) – The number of squares per side.
origin (List[float]) – The origin coordinates.
- Returns:
List of vertices coordinates for the grid.
- Return type:
List[ndarray]
- create_subvertices(center_of_mass, hierarchy, square_size_0)[source]¶
Create subvertices for the grid.
This function generates subvertices for the grid based on the specified hierarchy and square size.
- Parameters:
center_of_mass (ndarray) – The center of mass coordinates.
hierarchy (int) – The hierarchy level.
square_size_0 (float) – The initial square size.
- Returns:
List of subvertices coordinates.
- Return type:
List[ndarray]
- create_surf_dict(surf_lower, surf_upper, surf_inter)[source]¶
Create dictionaries of surfaces and their corresponding lines.
This function creates dictionaries for the lower surfaces, upper surfaces, and intersurfaces, mapping each surface to its corresponding lines.
- Parameters:
surf_lower (List[int]) – List of surface tags for the lower surface.
surf_upper (List[int]) – List of surface tags for the upper surface.
surf_inter (List[int]) – List of surface tags for the intersurface.
- Returns:
Dictionary of lower surfaces and their lines.
Dictionary of upper surfaces and their lines.
Dictionary of intersurfaces and their lines.
- Return type:
Tuple[Dict[int, List[int]], Dict[int, List[int]], Dict[int, List[int]]]
- exec_quad_refinement(outer_point_tags)[source]¶
Execute quadrilateral refinement on the given outer point tags.
This function performs quadrilateral refinement on the provided outer point tags, creating points, lines, surfaces, and volumes in the Gmsh model.
- Parameters:
outer_point_tags (List[List[int]]) – List of lists of point tags, each representing a corner of the structure.
- Returns:
List of line tags for intersurface connections.
List of surface tags.
List of volume tags.
- Return type:
Tuple[List[List[int]], List[List[int]], List[List[int]]]
- flatten(arr)[source]¶
Flatten a nested list.
This function flattens a nested list into a single list.
- Parameters:
arr (List[List[Any]]) – The nested list.
- Returns:
The flattened list.
- Return type:
List[Any]
- get_adjacent_points(surf_tag: str) list [source]¶
Get adjacent points for a given surface tag.
This function retrieves the adjacent points for the specified surface tag.
- Parameters:
surf_tag (str) – The surface tag.
- Returns:
List of adjacent point tags.
- Return type:
List[int]
- get_affine_transformation_matrix(verts_1, point_coords)[source]¶
Get the affine transformation matrix.
This function calculates the affine transformation matrix to map the provided vertices to the point coordinates.
- Parameters:
verts_1 (ndarray) – Array of vertices coordinates.
point_coords (ndarray) – Array of point coordinates.
- Returns:
The affine transformation matrix.
- Return type:
ndarray
- get_common_lines(arr)[source]¶
Get common lines from an array of points.
This function retrieves the common lines from the provided array of points.
- Parameters:
arr (List[int]) – List of point tags.
- Returns:
Array of common line tags.
- Return type:
ndarray
- get_vertices_coords(vertices_tags)[source]¶
Get the coordinates of vertices.
This function retrieves the coordinates of the specified vertices.
- Parameters:
vertices_tags (List[int]) – List of vertex tags.
- Returns:
Array of vertex coordinates.
- Return type:
ndarray
- get_vertices_minmax(point_coords)[source]¶
Get the minimum and maximum vertices.
This function retrieves the minimum and maximum vertices from the provided point coordinates.
- Parameters:
point_coords (ndarray) – Array of point coordinates.
- Returns:
Array of the four outermost vertices.
- Return type:
ndarray
- gmsh_add_custom_lines(point_tags)[source]¶
Add lines to the Gmsh model of the internal refined structure.
This function adds custom lines to the Gmsh model based on the provided point tags. It includes center squares, diagonal lines, border squares, center trapezoids, diagonal trapezoids, and outer squares.
- Parameters:
point_tags (List[int]) – List of point tags.
- Returns:
Tuple containing the line tags and outer square line tags.
- Return type:
Tuple[List[int], List[int]]
- gmsh_add_line(point_skins)[source]¶
Add lines to the Gmsh model.
This function adds lines to the Gmsh model based on the provided point skins.
- Parameters:
point_skins (List[ndarray]) – List of point skins.
- Returns:
List of line tags.
- Return type:
List[Tuple[int, int, int, int]]
- gmsh_add_outer_connectivity(line_tags, initial_point_tags, point_tags)[source]¶
Add outer connectivity to the Gmsh model.
This function adds outer connectivity lines and surfaces to the Gmsh model based on the provided line tags and point tags.
- Parameters:
line_tags (List[int]) – List of line tags.
initial_point_tags (List[int]) – List of initial point tags.
point_tags (List[int]) – List of point tags.
- Returns:
Updated line tags.
List of external surface tags.
List of curve loop line tags.
List of corner points for transfinite surfaces.
- Return type:
Tuple[List[int], List[int], List[int], List[Tuple[int, int, int, int]]]
- gmsh_add_plane_surface(line_tags)[source]¶
Add a plane surface to the Gmsh model.
This function creates a plane surface from the provided line tags and adds it to the Gmsh model.
- Parameters:
line_tags (List[int]) – List of line tags.
- Returns:
The tag of the created plane surface.
- Return type:
int
- gmsh_add_points(vertices)[source]¶
Add points to the Gmsh model.
This function adds the provided vertices as points to the Gmsh model.
- Parameters:
vertices (List[ndarray]) – List of vertices coordinates.
- Returns:
List of point tags.
- Return type:
List[int]
- gmsh_add_surface(curve_loop)[source]¶
Add a surface to the Gmsh model.
This function adds a surface to the Gmsh model based on the provided curve loop.
- Parameters:
curve_loop (int) – The curve loop tag.
- Returns:
The tag of the created surface.
- Return type:
int
- gmsh_add_surfaces(line_tags)[source]¶
Add surfaces to the Gmsh model.
This function adds surfaces to the Gmsh model based on the provided line tags.
- Parameters:
line_tags (List[int]) – List of line tags.
- Returns:
List of surface tags.
- Return type:
List[int]
- gmsh_add_surfs(l_tags)[source]¶
Add surfaces to the Gmsh model.
This function adds surfaces to the Gmsh model based on the provided line tags. It includes center surfaces, border squares, center trapezoids, and additional surfaces.
- Parameters:
l_tags (List[int]) – List of line tags.
- Returns:
List of surface tags.
- Return type:
List[int]
- gmsh_add_volume(surface_loop)[source]¶
Add a volume to the Gmsh model.
This function adds a volume to the Gmsh model based on the provided surface loop.
- Parameters:
surface_loop (int) – The surface loop tag.
- Returns:
The tag of the created volume.
- Return type:
int
- gmsh_get_unique_surfaces(curve_loop)[source]¶
Get unique surfaces from curve loops.
This function retrieves unique surfaces from the provided curve loops.
- Parameters:
curve_loop (List[int]) – List of curve loop tags.
- Returns:
Array of unique surface tags.
- Return type:
ndarray
- gmsh_make_transfinite(line_tags, surf_tags, n_trans)[source]¶
Set transfinite meshing for lines and surfaces.
This function sets transfinite meshing for the provided lines and surfaces.
- Parameters:
line_tags (List[int]) – List of line tags.
surf_tags (List[int]) – List of surface tags.
n_trans (int) – Number of transfinite divisions.
- Returns:
None
- gmsh_skin_points(point_tags)[source]¶
Generate a grid of point skins.
This function generates a grid of point skins from the provided point tags.
- Parameters:
point_tags (List[int]) – List of point tags.
- Returns:
Array of point skins.
- Return type:
ndarray
- plot_vertices(vertices)[source]¶
Plot the vertices.
This function plots the provided vertices and annotates their indices.
- Parameters:
vertices (List[ndarray]) – List of vertices coordinates.
- Returns:
None
- quad_refinement(initial_point_tags)[source]¶
Perform quadrilateral refinement on the given initial point tags.
This function refines the quadrilateral mesh based on the initial point tags. It creates subvertices, sorts them, applies an affine transformation, and adds points, lines, and surfaces to the Gmsh model.
- Parameters:
initial_point_tags (List[int]) – List of initial point tags.
- Returns:
Tuple containing the point tags, line tags, and surface tags.
- Return type:
Tuple[List[int], List[int], List[int]]
- set_transformation_matrix(M, point_coords)[source]¶
Apply the affine transformation matrix.
This function applies the affine transformation matrix to the provided point coordinates.
- Parameters:
M (ndarray) – The affine transformation matrix.
point_coords (ndarray) – Array of point coordinates.
- Returns:
Array of transformed coordinates.
- Return type:
ndarray