Components¶
TObj_Object¶
- class mstar.TObj_Object¶
Base class for all
MStarComponent
- IsAlive()¶
- Return type:
bool
- Returns:
True if object is alive in the model
- Detach()¶
Deletes object
- Return type:
bool
- Returns:
True if object was deleted
- ClearChildren()¶
Deletes children objects
- IterateChildren()¶
Used to iterate over child objects.
model = mstar.Load() # Iterate over all parent objects in model part = model.GetMainPartition() for obj in part.IterateChildren(): print (obj)
- Returns:
An iterator over the children objects
- Clone()¶
Create a copy of this object as a sibling to this object
- Returns:
created component
- GetName()¶
Get the object name
- Returns:
Object name
- Return type:
str
- AddComponent(typeDesc)¶
Add a component as child of this object. See the Type descriptors for AddComponent()
In general this should only be invoked for types that support non-geometry children. In most cases you will be adding geometry as a child object and should invoke one of the other methods.
- Parameters:
typeDesc (str) – Type descriptor
- Returns:
created component
- Return type:
MStarComponent¶
Tip
Use MStarModel.DumpHtmlFile()
to list out all the available properties in a model
- class mstar.MStarComponent(TObj_Object)¶
A component in the M-Star model tree that holds data and geometry. A MStarComponent is commonly created or retrieved using these methods:
Get a MStarComponent by name with
MStarModel.Get()
Add a new MStarComponent to the model
MStarModel.AddComponent()
Add a new MStarComponent under an existing object
TObj_Object.AddComponent()
Add a new geometry MStarComponent under an existing object
MStarComponent.AddGeometryFromFile()
import mstar model = mstar.Load() # Get an object by name simParams = model.Get("Simulation Parameters") # Add a new Static Body component staticBody = model.AddComponent("Static") # Add new geometry to a parent object geometryBody = staticBody.AddGeometryFromFile("MyGeometry.STEP")
Each component holds
mstar.IProperty
objectsimport mstar model = mstar.Load() simParams = model.Get("Simulation Parameters") # Get a property value runTimeValue = simParams.Get("Run Time").Value # Set a property value simParams.Get("Run Time").Value = 123.4
- MStarComponent.Get(*args)¶
Get a property by name or category and name. To see all properties in a model, use
MStarModel.DumpHtmlFile()
When 1 argument is provided – Get a property by name. If an exact name cannot be found, it will perform a fuzzy lookup using case and space insensitive searches. Note this will not be able to find certain properties in the model.
When 2 arguments are provided Recommended – Get a property by category and exact name. First argument is category, second argument is name.
Examples:
m = mstar.Load() sp = m.GetSimParams() # Get property using one argument sp.Get("Run Time").Value = 10.0 # Get property using category and name *recommended* sp.Get("Run Time", "Run Time").Value = 10.0
- Parameters:
args (str) – Arguments, must provide 1 or 2 arguments.
- Returns:
Property object
- Return type:
- Raises:
ValueError if property is not found or if wrong number of arguments provided
- MStarComponent.GetFuzzy(name)¶
Get a property by name. If an exact name cannot be found, it will perform a case and space insensitive searches. Note that this method cannot handle properties that have a ‘/’ character in either the category or name. Use
MStarModel.Get()
with 2 arguments to access properties by category and name. To see all properties in a model, useMStarModel.DumpHtmlFile()
m = mstar.Load() sp = m.GetSimParams() # get the property using a fuzzy search. sp.GetFuzzy("Run Time").Value = 10.0 sp.GetFuzzy("RunTime").Value = 10.0 sp.GetFuzzy("runTime").Value = 10.0
- Parameters:
name (str) – Name of the property
- Returns:
Property object
- Return type:
- Raises:
ValueError if property is not found
- MStarComponent.GetStrict(category, name)¶
Get a property by category and name. To see all properties in a model, use
MStarModel.DumpHtmlFile()
.Alternatively, use
MStarModel.Get()
with 2 arguments to access properties by category and name.model = mstar.Load() pr = model.AddComponent("Particles") prop = pr.GetStrict("Break-Up/Coalesce", "Breakup Enabled")
- Parameters:
category (str) – Category of the property
name (str) – Name of the property
- Returns:
Property object
- Return type:
- Raises:
ValueError if property is not found
- MStarComponent.__getattr__(name)¶
Get a property. Will perform a fuzzy lookup by exact name, display name and various case and space insensitive searches for the name
For example:
m = mstar.Load() sp = m.GetSimParams() # get the property via __getattr__ sp.RunTime.Value = 10.0
- Parameters:
name (str) – Name of the property
- Returns:
Property object
- Return type:
- MStarComponent.SetName(name)¶
Set the component name.
This operation can fail if the name is not unique or does not pass name constraint checks. For example some types, such as the ScalarField, require the name to be a valid C identifier, so this would prevent spaces and other characters from being in the name.
- Returns:
True if successful
- Return type:
bool
- MStarComponent.IsEnabled()¶
Check if object is enabled
- Returns:
True if object is enabled
- Return type:
bool
- MStarComponent.SetEnabled(val)¶
- Parameters:
val (bool)
- MStarComponent.AddGeometryFromCatalog(name)¶
Finds a geometry item in the catalog and adds it as a child object.
- Parameters:
name (str) – Name of geometry catalog item
- Returns:
created component
- Return type:
- MStarComponent.AddGeometryFromFile(filename)¶
Loads a geometry file and adds it as a child object. File types supported: .step, stp, .igs, .iges, .stl, .obj
- Parameters:
filename (str) – filename of geometry catalog item
- Returns:
created component
- Return type:
- MStarComponent.AddGeometry(name)¶
If the argument is a file that exists, calls
AddGeometryFromFile()
, otherwise callsAddGeometryFromCatalog()
- Parameters:
name (str) – filename or geometry catalog item name
- Returns:
created component
- Return type:
- MStarComponent.DynamicTypeName()¶
- Returns:
dynamic type name
- Return type:
str
- MStarComponent.ListAllProperties()¶
- Returns:
List of all property names
- Return type:
list[str]
- MStarComponent.ListActiveProperties()¶
- Returns:
List of active/relevant property names (show/hide filter logic applied)
- Return type:
list[str]
- MStarComponent.Translate(dx, dy, dz)¶
Transform the object by dx, dy, dz. Si units.
- Parameters:
dx (float) – Dx translation
dy (float) – Dy translation
dz (float) – Dz translation
- MStarComponent.Rotate(x, y, z, ax, ay, az, angle)¶
- Parameters:
x (float) – Rotation vector root point X
y (float) – Rotation vector root point Y
z (float) – Rotation vector root point Z
ax (float) – Rotation vector direction X
ay (float) – Rotation vector direction Y
az (float) – Rotation vector direction Z
angle (float) – Rotation angle in Radians
- MStarComponent.Scale(x, y, z, scaleFactor)¶
- Parameters:
x (float) – Scaling anchor point X
y (float) – Scaling anchor point Y
z (float) – Scaling anchor point Z
scaleFactor (float) – Scaling factor
IPlacedObject¶
- class mstar.IPlacedObject¶
A
MStarComponent
with additional methods to set placement location and axis. Common on objects with associated geometry, such as children geometry. Also available on some parent objects such as the moving body.
- IPlacedObject.GetLocation()¶
- Returns:
Get the location of placement system
- Return type:
list[float]
- IPlacedObject.SetLocation(x, y, z)¶
- Parameters:
x (float) – X location
y (float) – Y location
z (float) – Z location
Set the location of placement system and transform the object relative to its current position
- IPlacedObject.SetLocationAxis(x, y, z)¶
- Parameters:
x (float) – X location
y (float) – Y location
z (float) – Z location
Set the location of placement system. does not transform object like SetLocation
- IPlacedObject.GetAxisX()¶
- Returns:
Get the X-Axis vector of placement system
- Return type:
list[float]
- IPlacedObject.GetAxisY()¶
- Returns:
Get the Y-Axis vector of placement system
- Return type:
list[float]
- IPlacedObject.GetAxisZ()¶
- Returns:
Get the Z-Axis of placement system
- Return type:
list[float]
- IPlacedObject.SetAxisY(x, y, z)¶
Set the Y-Axis of placement system. X and Z axis automatically determined.
- IPlacedObject.SetAxisZ(x, y, z)¶
Set the Z-Axis of placement system. X and Y axis automatically determined.
- IPlacedObject.SetPlacement(loc, xaxis, zaxis)¶
- Parameters:
Set the placement canonically using the localtion, x axis and z axis.
Components¶
- class mstar.ImmersedBody¶
A Moving Body object which is derived from
IPlacedObject
.Use the
IPlacedObject.SetAxisY()
to change the moving body axis. Note that if using the SetPlacement method you must contruct the rotation axis as the Y-Direction.- property OutputTimeAvgStresses: BoolProperty¶
- property OutputVolumeFraction: BoolProperty¶
- property OutputWithSlices: BoolProperty¶
- property OutputVelocity: BoolProperty¶
- ComputeTraits()¶
Recompute the immersed boundary D and T values. Determined from the set axis.
- ComputeMomentsOfInertia(density)¶
Computes the second moments of inertia about the current body placed location and axis. Note this does not update the moment of inertia values on the object. This calculation uses the mesh representation of the object. Accuracy of results will depend on mesh resolution.
- Parameters:
density (float) – Density value
- Return type:
- SetMomentsOfInertia(props)¶
Sets the moment of inertia results on the object data.
- Parameters:
props (GProp_GProps) – Moment of inertia data
- UpdateMomentsOfInertia(density)¶
Computes the moments of inertia and updates the object data. Returns the moment of inertia results.
- Parameters:
density (float) – Density value
- Return type:
- class mstar.InletOutlet¶
Inlet/outlet object
- InletOutlet.SetFromPointDir(point, direction)¶
Set from a point and direction. Used for axis aligned boundary conditions
- InletOutlet.SetFromShape(shape, ax2)¶
Set using a shape
- InletOutlet.SetFromMesh(mesh, ax2)¶
Set using mesh
- class mstar.ImportedGeometry¶
Component to hold custom or imported geometry
- ImportedGeometry.SetShape(shape)¶
- ImportedGeometry.SetMesh(mesh)¶
- ImportedGeometry.GetShape()¶
- ImportedGeometry.GetMesh()¶
Fluid Model¶
- class mstar.FluidInterfaceOutputs¶
- property Area¶
- Type:
- property EDR¶
- Type:
- property StrainRate¶
- Type:
- property Velocity¶
- Type:
- GetCustomVars()¶
- Return type:
list[CustomVarLink]
- class mstar.CustomVarLink¶
- GetName()¶
Name of custom variable
- Return type:
str
- property Output: BoolProperty¶
- class mstar.FreeSurfaceFM¶
Free surface fluid model
- property InterfaceOutput: FluidInterfaceOutputs¶
- class mstar.Immiscible2FluidFM¶
Free surface fluid model
- property InterfaceOutput: FluidInterfaceOutputs¶
- class mstar.LookupTable¶
Lookup table object. Adds the lookup table as a UDF function. See Lookup Table
- GetTable()¶
Get the table columns and return them in a tuple
- Return type:
tuple[list[float], list[float]]
- SetTable(data)¶
Set the lookup table data.
Example:
m = mstar.Load() table = m.AddComponent("LookupTable") n = 100 xs = [ 2.0 * math.pi * (i / n) for i in range(n) ] ys = [ math.sin(x) for x in xs ] data0 = (xs, ys) table.SetTable(data0)
- Parameters:
data (tuple[list[float], list[float]]) – tuple of column data. Must have same length. Tuple must have length 2.
- class mstar.StoredPropertyCollection¶
Parameter sweep object
Example:
m = mstar.Load() movingbody = m.AddComponent("Moving") part = m.GetWorkFlowPartition() sweep = part.AddParameterSweep() sweepPropRunTime = sweep.AddProperty(m.GetSimParams().Get("Run Time")) sweepPropRotSpeed = sweep.AddProperty(movingbody.Get("Rotation Speed UDF")) values = [ "10", "20", "30" ] rpmvalues = [ "60", "80", "100"] names = [ "1", "2", "3" ] sweepPropRunTime.SetStringValues(values) sweepPropRotSpeed.SetStringValues(rpmvalues) sweep.SetCaseNames(names) # must save prior to Export m.Save("testsweep.msb") errs = sweep.Export("testSweep")
- GetCaseNames()¶
- Return type:
list[str]
- SetCaseNames(names)¶
- Parameters:
names (list[str]) – List of case names
- class mstar.SweepProperty¶
Property reference object used in parameter sweep StoredPropertyCollection object
- GetStringValues()¶
- Return type:
list[str]
- Returns:
List of string values to be applied in parameter sweep
- SetStringValues(values)¶
- Parameters:
values (list[str]) – String Values used in parameter sweep
- class mstar.TObj_Partition(TObj_Object)¶
Partition for models
- class mstar.WorkflowPartition(TObj_Partition)¶
Partition in the model that holds parameter sweep objects. Example of workflow usage here – Workflow Parameter Sweep
- AddParameterSweep()¶
- Return type:
- Returns:
New StoredPropertyCollection object
- Export(outputDir)¶
Export the parameter sweep cases to an output directory. Sub-directories in this directory are created for each case.
- Parameters:
outputDir (str) – Output directory to export parameter sweep
- Return type:
list[ComponentError]
- Returns:
List of errors (if any)
- class mstar.ComponentError¶
- Message¶
- Type:
str
- ObjectName¶
- Type:
str
- ObjectType¶
- Type:
str
- Level¶
- Type:
- class mstar.ComponentErrorLevel¶
Enum class for ComponentError Level
Info
Warning
Error
- class mstar.GlobalConstants¶
Global constants table. The “key” in the below methods is the variable name. Note that variable names must be valid C++ identifiers. Each global constant “value” can be an UDF expression. Note that no input variables are available for these expressions, so commonly available variables such as ‘t’ or ‘x’ are not available when these constants are created at runtime.
- GetKeys()¶
- Return type:
list[str]
- GetValue(key)¶
Get the expression associated with this variable
- Parameters:
key (str) – Name of the constant
- Return type:
str
- GetKeys()¶
Get the list of variable names
- Return type:
list[str]
- HaveKey(key)¶
Check if a variable name exists in the table
- Parameters:
key (str) – Name of the constant
- Return type:
bool
- SetValue(key, value)¶
Set the variable value
- Parameters:
key (str) – Name of the constant
key – Value of the constant. That this can be an UDF expression (no access to model variables)
- Return type:
bool
- RemoveKey(key)¶
Remove the variable from the table
- Parameters:
key (str) – Name of the constant
- Return type:
bool
- ClearTable()¶
Clear all table data