pygeon.grids.levelset_remesh module

pygeon.grids.levelset_remesh.levelset_remesh(sd, levelset)[source]

Remeshes a polygonal grid such that it conforms to a level-set function

Parameters:
  • sd (pg.Grid) – The grid to remesh.

  • levelset (Callable) – A function that returns the level-set value for each x.

Returns:

A new grid conforming to the level set.

Return type:

pg.Grid

pygeon.grids.levelset_remesh.merge_connectivities(old_con, new_con)[source]

Concatenates two connectivity matrices without reordering their indices.

Parameters:
  • old_con (sps.csc_array) – The old connectivity matrix.

  • new_con (sps.csc_array) – The additional connectivities using global numbering.

Returns:

The merged connectivity matrix.

Return type:

sps.csc_array

pygeon.grids.levelset_remesh.create_new_entity_map(cut_entities, offset=0)[source]

Creates a mapping matrix of size n_new x n_old in which (i_new, i_old) = 1 if i_new is a new entity placed on i_old.

Parameters:
  • cut_entities (np.ndarray) – Boolean array indicating which entities are cut.

  • offset (int, optional) – Offset value for the mapping matrix. Defaults to 0.

Returns:

Mapping matrix of size n_new x n_old

Return type:

sps.csc_array

pygeon.grids.levelset_remesh.create_splitting_map(cut_entities, offset=0)[source]

Creates a mapping matrix of size n_new x n_old in which (i_new, i_old) = 1 if i_new is a new entity from a splitting of i_old.

Parameters:
  • cut_entities (np.ndarray) – Boolean array indicating which entities are cut.

  • offset (int, optional) – Offset value for the rows of the mapping matrix.

  • 0. (Defaults to)

Returns:

Mapping matrix of size n_new x n_old

Return type:

sps.csc_array

pygeon.grids.levelset_remesh.intersect_faces(sd, levelset, root_finder=<function brentq>)[source]

Marks the cells and faces cut by the level set and finds the new nodes at the intersection points.

Parameters:
  • sd (pg.Grid) – The grid object.

  • levelset (Callable) – The level set function.

  • root_finder (brentq) – The root finder function. Default is brentq.

Returns:

A tuple containing the cut_faces array and the new_nodes array.

Return type:

Tuple[np.ndarray[Any, bool], np.ndarray]

pygeon.grids.levelset_remesh.intersect_cells(sd, cut_faces)[source]

Marks the cells that are cut and checks if each cut cell is only cut once.

Parameters:
  • sd (pg.Grid) – The grid object representing the spatial domain.

  • cut_faces (np.ndarray[Any, bool]) – An array indicating which faces are cut.

Returns:

An array indicating which cells are cut.

Return type:

np.ndarray[Any, bool]

pygeon.grids.levelset_remesh.create_new_face_nodes(sd, cut_cells, cut_faces, entity_maps)[source]

Creates new faces through the cut cells and on top of cut faces and generates the corresponding face-node connectivity matrix.

Parameters:
  • sd (pg.Grid) – The grid object.

  • cut_cells (np.ndarray[Any, bool]) – Boolean array indicating the cut cells.

  • cut_faces (np.ndarray[Any, bool]) – Boolean array indicating the cut faces.

  • entity_maps (Dict) – Dictionary containing entity maps.

Returns:

The face-node connectivity matrix.

Return type:

sps.csc_array

pygeon.grids.levelset_remesh.create_new_cell_faces(sd, cut_cells, cut_faces, entity_maps, face_nodes)[source]

Creates two new cells on top of each cut cell and generates the corresponding cell-face connectivity matrix.

Parameters:
  • sd (pg.Grid) – The grid object.

  • cut_cells (np.ndarray[Any, bool]) – Boolean array indicating which cells are cut.

  • cut_faces (np.ndarray[Any, bool]) – Boolean array indicating which faces are cut.

  • entity_maps (Dict) – Dictionary containing entity maps.

  • face_nodes (sps.csc_array) – Sparse matrix representing the face nodes.

Returns:

The cell-face connectivity matrix.

Return type:

sps.csc_array

pygeon.grids.levelset_remesh.create_oriented_node_loop(I_node, J_face, V_orient)[source]

Creates a node loop for the cell according to a positive orientation.

Parameters:
  • I_node (np.ndarray[Any, int]) – Array of node indices.

  • J_face (np.ndarray[Any, int]) – Array of face indices.

  • V_orient (np.ndarray[Any, float]) – Array of orientation values.

Returns:

Array of node indices representing the node loop.

Return type:

np.ndarray[Any, int]

Notes

The input corresponds to (node, face, orient) triplets such that orient = plus/minus 1 means that the node is at the end/start of the face according to the ccw orientation of the cell.