ddg.optimize.ifs.utils module

ddg.optimize.ifs.utils.log_history(f)[source]

Creates a log for the input of a given function.

Parameters:
fCallable

Function to use

Returns:
Callable

Wrapped function

ddg.optimize.ifs.utils.attribute_helper(ifs, cell_type, name, boundary=[])[source]

Helper function for flatten wrappers extracting needed information about IndexedFaceSet attributes.

Parameters:
ifsIndexedFaceSet
cell_typestr

Cell type of the attribute

namestr

Name of the indexed faceset attribute to use

boundaryIterable

Indices of cells to ignore

Returns:
arraynumpy.ndarray

Array of the attribute

masknumpy.ndarray

Mask for non-boundary cells

shape_igntuple of ints

Shape of attribute array used for flatten wrappers, when boundary values get ignored

shape_remtuple of ints

Shape of attribute array used for flatten wrappers, when boundary values get removed

ddg.optimize.ifs.utils.nflat_index(idx, n)[source]

Return indices for flattened (m,n)-dimensional arrays. The returned indices correspond to the indices of the entries of the rows given by idx after flattening the array.

Parameters:
idxIterable

Indices to convert to flattened indices

nint

Dimension of target (m,n) array

Returns:
numpy.ndarray

Flat indices corresponding to idx

ddg.optimize.ifs.utils.zero_columns(f, columns)[source]

Wraps sparse matrix valued function to zero columns.

Parameters:
f: Callable

Function to wrap

columns: Iterable

Columns to zero

Returns:
Callable

wrapped function

ddg.optimize.ifs.utils.remove_columns(f, columns)[source]

Wraps sparse matrix valued function to remove columns.

Parameters:
f: Callable

Function to wrap

columns: Iterable

Columns to remove

Returns:
Callable

wrapped function

ddg.optimize.ifs.utils.initial_guess(ifs, cell_type, name, boundary=[])[source]

Extracts attribute values for non-boundary cells.

Parameters:
ifsIndexedFaceSet
cell_typestr

Cell type of the attribute

namestr

Name of the indexed faceset attribute to use

boundaryIterable

Indices of cells to ignore

Returns:
numpy.ndarray of shape (m,)

Values of attribute [name] on non-boundary cells in a flattened array