pymead.core.geometry_collection.GeometryCollection#
- class GeometryCollection(gui_obj=None)[source]#
Bases:
DualRep- __init__(gui_obj=None)[source]#
The geometry collection is the primary class in pymead for housing all the available fundamental geometry types. Geometry, parameters, and constraints can be added using the nomenclature
add_<object-name>(). For example, points can be added usinggeo_col.add_point(x=<x-value>, y=<y-value>).
Methods
add_airfoil(leading_edge, trailing_edge[, ...])add_bezier(point_sequence[, default_nt, ...])add_bspline(point_sequence, knot_sequence[, ...])add_constraint(constraint_type, *constraint_args)add_desvar(value, name[, lower, upper, ...])Directly adds a design variable value to the geometry collection.
add_ferguson(point_sequence[, default_nt, ...])add_line(point_sequence[, name, ...])add_mea(airfoils[, name, assign_unique_name])add_param(value[, name, lower, upper, ...])Adds a parameter to the geometry collection sub-container
"params", and modifies the name to make it unique if necessary.add_point(x, y[, name, ...])Adds a point by value to the geometry collection
add_polyline(source[, coords, start, end, ...])add_pymead_obj_by_ref(pymead_obj[, ...])This method adds a pymead object by passing it directly to the geometry collection.
add_reference_polyline([points, source, ...])add_to_subcontainer(pymead_obj[, ...])Adds an object to a sub-container within the geometry collection's
container().This method sorts a sub-container with the following rules:
assign_design_variable_values(dv_values[, ...])Assigns a list or array of design variable values, possibly normalized by the bounds, to the design variables in the geometry collection 'desvar' container.
Clears all the entities in the geometry container.
clear_selected_objects()Retrieves the geometry container.
cover_point_xy(point)demote_desvar_to_param(desvar)Demotes a design variable to a parameter by removing the bounds.
deselect_object(pymead_obj)equate_constraints(constraint1, constraint2)expose_point_xy(point)Extracts the values of the design variables in the geometry collection 'desvar' container.
get_dict_rep()get_metadata()get_name_list(sub_container)Gets a list of all the parameter or geometry names in a specified sub-container.
hover_enter_obj(pymead_obj)hover_leave_obj(pymead_obj)Gets a list of available example file names that can be used to create a new
GeometryCollectionobject using theGeometryCollection.load_examplemethod.load_example(example_name, **kwargs)Class method that creates a
GeometryCollectionobject directly from a.jmeafile.load_file(jmea_file, **kwargs)Class method that creates a
GeometryCollectionobject directly from a.jmeafile.promote_param_to_desvar(param[, lower, upper])Promotes a parameter to a design variable by adding bounds.
remove_from_subcontainer(pymead_obj)Removes an object from the specified sub-container.
remove_pymead_obj(pymead_obj[, ...])Removes a pymead object from the geometry collection.
remove_selected_objects()replace_geo_objs(tool, target)This static method is used to make sure that in param/desvar promotion/demotion, any references to geometric objects get replaced.
save_to_file(jmea_file)Saves the
GeometryCollectionto a.jmeafile.select_object(pymead_obj)set_from_dict_rep(d[, canvas, tree, gui_obj])split_polyline(polyline, split)switch_units(unit_type, old_unit, new_unit)unique_namer(specified_name, name_list)This static method creates unique names for parameters or geometry by incrementing the appended index, which is attached with a hyphen.
verify_all()verify_constraints()verify_desvar()verify_params()verify_point_movement()write_to_iges(base_dir, file_name[, ...])Writes all the Bézier curves in the geometry collection to an IGES file.
Attributes
- add_desvar(value: float, name: str, lower: float | None = None, upper: float | None = None, unit_type: str | None = None, assign_unique_name: bool = True, point: Point | None = None, root: Point | None = None, rotation_handle: Point | None = None, enabled: bool = True, equation_str: str | None = None)[source]#
Directly adds a design variable value to the geometry collection.
- Parameters:
value (float) – Value of the design variable
name (str) – Name of the design variable (might be overridden when adding to the ‘desvar’ sub-container).
lower (float or None) – Lower bound for the design variable. If
None, a reasonable value will be chosen automatically. Default:None.upper (float or None.) – Upper bound for the design variable. If
None, a reasonable value will be chosen automatically. Default:None.unit_type (str or None:) – The unit type of design variable to create. Default:
None.
- Returns:
The generated design variable
- Return type:
- add_param(value: float, name: str | None = None, lower: float | None = None, upper: float | None = None, unit_type: str | None = None, assign_unique_name: bool = True, point: Point | None = None, root: Point | None = None, rotation_handle: Point | None = None, enabled: bool = True, equation_str: str | None = None)[source]#
Adds a parameter to the geometry collection sub-container
"params", and modifies the name to make it unique if necessary.- Parameters:
value (float) – Parameter value
name (str or None) – Parameter name
lower (float or None) – Lower bound. If
None, no bound will be set. Default:None.upper (float or None) – Upper bound. If
None, no bound will be set. Default:None.unit_type (str or None:) – The unit type of design variable to create. Default:
None.
- Returns:
The generated parameter
- Return type:
- add_point(x: float, y: float, name: str | None = None, relative_airfoil_name: str | None = None, assign_unique_name: bool = True)[source]#
Adds a point by value to the geometry collection
- add_pymead_obj_by_ref(pymead_obj: PymeadObj, assign_unique_name: bool = True) PymeadObj[source]#
This method adds a pymead object by passing it directly to the geometry collection. If the object is already associated with a geometry collection, a
ValueErroris raised.- Parameters:
pymead_obj (PymeadObj) – The pymead object to add to the collection
assign_unique_name (bool) – Whether to assign a unique name to the pymead object (by appending
"-1"to the end of the name of the object if there are no objects with the same name,"-2"if there is one object with the same name, etc.). Default:True
- Returns:
The modified pymead object
- Return type:
- add_to_subcontainer(pymead_obj: PymeadObj, assign_unique_name: bool = True)[source]#
Adds an object to a sub-container within the geometry collection’s
container(). Also performs the task of assigning a unique name to the object before insertion into the sub-container, if necessary.
- alphabetical_sub_container_key_list(sub_container: str)[source]#
This method sorts a sub-container with the following rules:
Text case does not matter
Any consecutive numerical strings should appear in descending order
For parameters with an associated index, the parameter with an implied index of 1 should appear first, provided it exists. For example,
"Point-2.x"should come after"Point.x", and"myParam-5"should come after"myParam".
- assign_design_variable_values(dv_values: list, bounds_normalized: bool = False)[source]#
Assigns a list or array of design variable values, possibly normalized by the bounds, to the design variables in the geometry collection ‘desvar’ container.
- Parameters:
dv_values (Union[Iterable, Sized]) – List or array of design variable values. Must be equal in length to the number of design variables in the ‘desvar’ container. Note that the value assignment will not necessarily take place in the same order as the order of the design variables in the GUI, but rather in the order they are present in the underlying dictionary.
bounds_normalized (bool) – Whether the specified
dv_valuesare normalized by the design variable bounds. Default:False.
- container()[source]#
Retrieves the geometry container. Note that there is no “setter” method because geometry items should be added only be their respective methods. For example, a
Paramshould be added using.add_param(). This allows for name validation, which ensures that every geometry item in the container has a unique name.- Returns:
Dictionary of geometry items
- Return type:
- demote_desvar_to_param(desvar: DesVar)[source]#
Demotes a design variable to a parameter by removing the bounds. The
DesVarwill be removed from the ‘desvar’ sub-container, and the correspondingParamwill be added to the ‘params’ sub-container.
- extract_design_variable_values(bounds_normalized: bool = False)[source]#
Extracts the values of the design variables in the geometry collection ‘desvar’ container.
- get_name_list(sub_container: str)[source]#
Gets a list of all the parameter or geometry names in a specified sub-container.
- static list_examples() List[str][source]#
Gets a list of available example file names that can be used to create a new
GeometryCollectionobject using theGeometryCollection.load_examplemethod.
- classmethod load_example(example_name: str, **kwargs)[source]#
Class method that creates a
GeometryCollectionobject directly from a.jmeafile.- Parameters:
example_name (str) – Name of an example file (with or without the
.jmeaextension). SeeGeometryCollection.list_examplesfor a complete list of example nameskwargs – Additional keyword arguments to pass to
GeometryCollection.set_from_dict_rep. Should only be specified if this method is called from the GUI
- Returns:
A new geometry collection object with the data loaded from the example file
- Return type:
- classmethod load_file(jmea_file: str, **kwargs)[source]#
Class method that creates a
GeometryCollectionobject directly from a.jmeafile.- Parameters:
jmea_file (str) – Absolute path to a
.jmeafilekwargs – Additional keyword arguments to pass to
GeometryCollection.set_from_dict_rep. Should only be specified if this method is called from the GUI
- Returns:
A new geometry collection object with the data loaded from the
.jmeafile- Return type:
- promote_param_to_desvar(param: Param, lower: float | None = None, upper: float | None = None)[source]#
Promotes a parameter to a design variable by adding bounds. The
Paramwill be removed from the ‘params’ sub-container, and the correspondingDesVarwill be added to the ‘desvar’ sub-container.- Parameters:
param (Param or str) – Parameter to promote. If
str, theParamwill be identified by looking in the ‘params’ sub-container.lower (float or None) – Lower bound for the design variable. If
None, a reasonable value will be chosen automatically. Default:None.upper (float or none.) – Upper bound for the design variable. If
None, a reasonable value will be chosen automatically. Default:None.
- Returns:
The generated design variable.
- Return type:
- remove_from_subcontainer(pymead_obj: PymeadObj)[source]#
Removes an object from the specified sub-container.
- Parameters:
pymead_obj (PymeadObj) – Object to remove.
- remove_pymead_obj(pymead_obj: PymeadObj, promotion_demotion: bool = False, constraint_removal: bool = False, equating_constraints: bool = False)[source]#
Removes a pymead object from the geometry collection.
- Parameters:
pymead_obj (PymeadObj) – Pymead object to remove
promotion_demotion (bool) – When this flag is set to
True, theValueErrornormally raised when directly deleting aParamassociated with aGeoConis ignored. Default:Falseconstraint_removal (bool) – When this flag is set to
True, theValueErrornormally raise when directly deleting aParamassociated with a constraint cluster rotation is ignored. Default:Falseequating_constraints (bool) – When this flag is set to
Trueand thepymead_objis aParam, the associated constraints are not deleted
- static replace_geo_objs(tool: Param, target: Param)[source]#
This static method is used to make sure that in param/desvar promotion/demotion, any references to geometric objects get replaced.
- save_to_file(jmea_file: str)[source]#
Saves the
GeometryCollectionto a.jmeafile.- Parameters:
jmea_file (str) – Name of the file including the
.jmeaextension
- static unique_namer(specified_name: str, name_list: List[str])[source]#
This static method creates unique names for parameters or geometry by incrementing the appended index, which is attached with a hyphen. A dot separator is used to distinguish between levels within the geometry collection hierarchy. For example, the \(x\)-location of the second point added is given by
"Point-2.x". Note that, for parameters and design variables, the first parameter added with a given name will not have an index by default. For example, if aParamwithname=="my_param"is added three times, the resulting names, in order, will be"my_param","my_param-2", and"my_param-3".If a parameter is removed, and another parameter with the same name added, the index assigned will be the maximum index plus one. In the previous example, if
"my_param-2"is removed from the geometry collection and the addition of"my_param"requested, the actual name assigned will be"my_param-4". This is to prevent confusion between removed and added parameters, as well as to give an indication of the order in which the parameter was added.- Parameters:
- Returns:
The (possibly modified)
specified_name- Return type:
- write_to_iges(base_dir: str, file_name: str, translation: List[float] | None = None, scaling: List[float] | None = None, rotation: List[float] | None = None, transformation_order: str | None = None)[source]#
Writes all the Bézier curves in the geometry collection to an IGES file.
- Parameters:
base_dir (str) – Directory where the IGES file will be stored
file_name (str) – Name of the IGES file (should include the .igs extension)
translation (List[float]) – How to translate the curves from the X-Z plane (in the form [tx, ty, tz])
scaling (List[float]) – How to scale the curves from the X-Z plane (in the form [sx, sy, sz])
rotation (List[float]) – How to rotate the curves from the X-Z plane (in the form [rx, ry, rz])
transformation_order (str) – Order in which the transformation takes place
- Returns:
The full file path to the created IGES file
- Return type: