Stage Module¶
- class ammorph.stage.CompositeStage(callback=None, callbackargs=(), name=None)¶
CompositeStage describes a stage that is composed of substages.
The difference between a normal stage that is added to a study and a CompositeStage is that the children stages of the CompositeStage do not use the current deformation as reference coordinates for interpolation. Instead each substage uses the deformation at the beginning of the stage.
- Parameters
callback (function, optional) – Callback function with signature callback(x, d, delta_d, *args) This function is called after the stage has been finished. x are the reference coordinates d is the displacement vector at beginning of the stage delta_d is the difference to the displacement vector after processing the stage.
callbackargs (tuple, optional) – arguments that are passed as *args in the callback function
name (str, optional) – A name can be passed that is used in logging features to identify the stage that produces certain loggin messages.
- add_child(stage, partitioned=False)¶
Adds a stage to the CompositeStage
- Parameters
stage ({ ammorph.stage.Stage, ammorph.stage.CompositeStage }) – Stage object that is added to the composite.
partitioned (bool) – Flag if child should be performed in partitioned mode or not.
- morph(p_args, p_vals, x0, d0, delta_d, partition=None, no_of_partitions=0)¶
Computes delta_d for the stage.
- Parameters
p_args (tuple) – tuple of sympy sympols or ammorph.parameters.Parameter objects that determines the meaning of the coordinates in the p_vals vector.
p_vals (array_like) – Array of dtype float64 that describes the values of the paramters with which the delta_d is computed.
x0 (array_like) – Array of dtype float64 describing the node coordinates of the nodes in reference configuration
d0 (array_like) – Array of dtype float64 describing the displacement vector that has been computed in previous stages such that the current configuration before this stage is x0 + d0
delta_d (array_like) – Array of dtype float64 used to write the result of the stage deformation into
partition (array_like, optional) – Array of dtype int32 describing a partitioning of the deformation process. The value of each coordinate describes which partition is assigned to the corresponding node. If such an array is passed, the stage is performed in partitioned mode. Otherwise, no partitioning is done. Example: np.array([0, 3, 0, 5], dtype=np.int32) means that node indices 0 and 2 are assigned to partition 0 node index 1 is assigned to partition 3 and node index 3 is assigned to partition 5.
no_of_partitions (int, optional) – If the number of partitions is known a priori, this information can be passed to avoid this computation within the function
- class ammorph.stage.Stage(active_nodes, fixed_nodes, rbf_func, polynomial_order=None, callback=None, callbackargs=(), name=None)¶
Class to define a so called stage of a mesh deformation.
A Stage can be seen as a deformation step. A full mesh morphing study consists of several stages that are applied in seqence to the mesh.
- Parameters
active_nodes (array_like) – numpy array of dtype int32 containing the indices of all active nodes of this stage. Active nodes are those nodes that will have an updated deformation vector after the stage has been finished.
fixed_nodes (array_like) – numpy array of dtype int32 containing the indices of all fixed nodes of this stage. Fixed nodes are nodes that are considered to be fixed during the deformation. Typically these nodes are at boundaries or nodes of special geometries like bore holes mounting geometries etc. which may not be deformed.
rbf_func (str) – A string describing the Radial basis function that is used for the interpolation in this stage. The string must contain the character r as variable for the radial basis function phi(r). Valid strings can be obtained by using the static methods of the class
ammorph.rbf_string.RBFpolynomial_order ({int, 0, 1}, optional) – Default: None Determines if the system of equations to determine the weights is augmented by polynomial terms. None adds no terms, 0 adds a constant term and 1 adds constant term and linear terms in x, y, z.
callback (function, optional) – Callback function with signature callback(x, d, delta_d, *args) This function is called after the stage has been finished. x are the reference coordinates d is the displacement vector at beginning of the stage delta_d is the difference to the displacement vector after processing the stage.
callbackargs (tuple, optional) – arguments that are passed as *args in the callback function
name (str, optional) – A name can be passed that is used in logging features to identify the stage that produces certain loggin messages.
- add_deformation_handler(handler, parameters)¶
Adds a deformation handler object to the stage.
- Parameters
handler (ammorph.handler.DeformationHandler) – Deformation handler object that is added to the stage.
parameters ({tuple, list}) – Tuple or list containing sympy expressions to describe the parameters of the deformation handler. The number and meaning of required expressions is described in the documentation for the DeformationHandler object that is wanted to be added.
Examples
>>> import numpy as np >>> from ammorph import Stage, RBF >>> from ammorph.handler import ShiftDeformationHandler >>> rbf_func = RBF.thin_plate_spline(0.3) >>> active_nodes = np.array([0, 1, 2, 3], dtype=np.int32) >>> fixed_nodes = np.array([0], dtype=np.int32) >>> stage = Stage(active_nodes, fixed_nodes, rbf_func) >>> p = ammorph.Parameter('p') >>> expr = 3*p >>> csys = stage.csys >>> handler = ShiftDeformationHandler(handle_nodes, csys, csys) >>> stage.add_deformation_handler(handler, (expr, ))
- morph(p_args, p_vals, x0, d0, delta_d, partition=None, no_of_partitions=0)¶
Computes delta_d for the stage.
- Parameters
p_args (tuple) – tuple of sympy sympols or ammorph.parameters.Parameter objects that determines the meaning of the coordinates in the p_vals vector.
p_vals (array_like) – Array of dtype float64 that describes the values of the paramters with which the delta_d is computed.
x0 (array_like) – Array of dtype float64 describing the node coordinates of the nodes in reference configuration
d0 (array_like) – Array of dtype float64 describing the displacement vector that has been computed in previous stages such that the current configuration before this stage is x0 + d0
delta_d (array_like) – Array of dtype float64 used to write the result of the stage deformation into
partition (array_like, optional) – Array of dtype int32 describing a partitioning of the deformation process. The value of each coordinate describes which partition is assigned to the corresponding node. If such an array is passed, the stage is performed in partitioned mode. Otherwise, no partitioning is done. Example: np.array([0, 3, 0, 5], dtype=np.int32) means that node indices 0 and 2 are assigned to partition 0 node index 1 is assigned to partition 3 and node index 3 is assigned to partition 5.
no_of_partitions (int, optional) – If the number of partitions is known a priori, this information can be passed to avoid this computation within the function