Geometry
Geometry object definitions.
Geometry from CAD
CadFile
- class onscale.CadFile(path: str, unit: str | None = None, characteristic_length: float | None = None, contraction_area_ratio: float | None = None)
An object representing geometry loaded from a CAD file.
Examples
>>> import onscale as on >>> >>> with on.Simulation("Static Solve") as sim: ... on.CadFile("I_Beam.step")
- Parameters:
path – The name of the CAD file.
unit – Optionally override the units for this CAD geometry. Use a unit string such as “m”, “mm”, “ft”, etc.
characteristic_length – Optional parameter for CAD model used within Lattice Boltzmann fluid solvers.
contraction_area_ratio – Optional parameter for CAD model used within Lattice Boltzmann fluid solvers.
- property edges
Edges must be selected from a face.
Examples
>>> import onscale as on >>> >>> with on.Simulation("Static Solve") as sim: ... geom = on.CadFile("I_Beam.step") ... displacement = on.loads.Displacement(x=10, y=3, z=0) ... displacement >> geom.parts[0].faces[0].edges[0]
- property faces
Faces must be selected from a part.
Examples
>>> import onscale as on >>> >>> with on.Simulation("Static Solve") as sim: ... geom = on.CadFile("I_Beam.step") ... force = on.loads.Force(10, [0, 0, -1]) ... force >> geom.parts[0].faces[1]
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- property parts
Make a selection of part(s) from this geometry.
- Returns:
A selection of type PART.
Examples
>>> import onscale as on >>> >>> with on.Simulation("Static Solve") as sim: ... geom = on.CadFile("I_Beam.step") ... flux = on.loads.HeatFlux(100) ... flux >> geom.parts[0].faces[1]
- set(property_name: str, value: Any)
Modify a geometry version property of this geometry. :param property_name: version property name to override. :param value: The new value to update.
- Returns:
self
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.
ParametricCad
- class onscale.ParametricCad(paths: List[str], unit: str | None = None, characteristic_lengths: List[float] | None = None, contraction_area_ratios: List[float] | None = None)
An object for multiple CAD files generated from parameterized CAD
The result will be multiple simulations, each sweeping over a separate CAD file instance in this list.
Examples
>>> import onscale as on >>> >>> with on.Simulation("Static Solve") as sim: ... on.ParametricCad(["I_Beam_1.step", "I_Beam_2.step"])
- Parameters:
paths – A list of CAD file names. Each is a different realized instance of parameterized CAD geometry. There can be no duplicate items across all paths attributes of all ParametricCad objects in a simulation.
unit – Optionally override the units for this CAD geometry. Use a unit string such as “m”, “mm”, “ft”, etc.
characteristic_lengths – A list of values representing the characteristic_length value for each of the cad_files in the corresponding position in the paths list. If the list is not None, there must be one value for each cad file within the paths list.
contraction_area_ratios – A list of values representing the contraction_area_ratio value for each of the cad_files in the corresponding position in the paths list. If the list is not None, there must be one value for each cad file within the paths list.
- property edges
Edges must be selected from a face.
Examples
>>> import onscale as on >>> >>> with on.Simulation("Static Solve") as sim: ... geom = on.CadFile("I_Beam.step") ... displacement = on.loads.Displacement(x=10, y=3, z=0) ... displacement >> geom.parts[0].faces[0].edges[0]
- property faces
Faces must be selected from a part.
Examples
>>> import onscale as on >>> >>> with on.Simulation("Static Solve") as sim: ... geom = on.CadFile("I_Beam.step") ... force = on.loads.Force(10, [0, 0, -1]) ... force >> geom.parts[0].faces[1]
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- property parts
Make a selection of part(s) from this geometry.
- Returns:
A selection of type PART.
Examples
>>> import onscale as on >>> >>> with on.Simulation("Static Solve") as sim: ... geom = on.CadFile("I_Beam.step") ... flux = on.loads.HeatFlux(100) ... flux >> geom.parts[0].faces[1]
- set(property_name: str, value: Any)
Modify a geometry version property of this geometry. :param property_name: version property name to override. :param value: The new value to update.
- Returns:
self
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.
Geometry Primitives
Point
- class onscale.Point(x: float, y: float, z: float | None = None, *, mode: str = 'xyz', alias: str | None = None)
A point in 3D space
- Parameters:
x – X-coordinate position
y – Y-coordinate position
z – Z-coordinate position
mode – Coordinate mode, ‘xyz’ or ‘ijk’
alias – Optional alias for this node.
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.
Plane
- class onscale.Plane(point: Collection[float], normal: Collection[float], alias: str | None = None)
A plane in 3D space
- Parameters:
point – R^3 origin of the plane.
normal – R^3 normal vector of the plane.
alias – Optional alias for this node.
- bound(box_min: Collection[float], box_max: Collection[float], alias: str | None = None)
Convert a plane to a BoundPlane by supplying a bounding box.
- Parameters:
box_min – R^3 minimum point for the bounding box.
box_max – R^3 maximum point for the bounding box.
alias – Optional alias for the resulting BoundPlane
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.
BoundPlane
- class onscale.BoundPlane(point: Collection[float], normal: Collection[float], box_min: Collection[float], box_max: Collection[float], alias: str | None = None)
A plane that is bounded to within a fix bounding box.
- Parameters:
point – R^3 origin of the plane.
normal – R^3 normal vector of the plane.
box_min – R^3 minimum point for the bounding box.
box_max – R^3 maximum point for the bounding box.
alias – Optional alias for this node.
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.
Geometry Groups
Body
- class onscale.Body(body_type: None | BodyType | str = BodyType.COLLECTION, ref_point: Collection[float] | None = None, additional_mass: float | None = None, additional_inertia_xx: float | None = None, additional_inertia_yy: float | None = None, additional_inertia_zz: float | None = None, additional_inertia_xy: float | None = None, additional_inertia_yz: float | None = None, additional_inertia_zx: float | None = None, alias: str | None = None)
A group of geometries that are defined as a Body in the solver.
A body can be of type ‘Collection’, ‘Rigid’, or ‘Deformable’. Collection is the default.
A body of type Collection is essentially a collection of geometries without additional properties of its own, whereas bodies of type Rigid and Deformable have additional properties such as a reference point.
A body of type Rigid has limited degrees of freedom and can be acted upon in different ways from normal geometry.
Force, Torque, Displacement and Rotation loads can be applied to a Rigid or Deformable body. The force/torque is tranferred to nodes that belong to geometery that constitutes the Body. Several types of loads can be applied to a Collection body, depending on the type of geometry contained within it.
Materials and meshes can be applied to Rigid, Deformable, and Collection bodies; internally they will be applid to the geometries constituting the body.
Examples
>>> import onscale as on >>> >>> with on.Simulation("Static Solve") as sim: ... geometry = on.CadFile('file.step', 'm') ... body = on.Body(body_type="rigid", ref_point=[0.0, 1.0, 2.0]) ... geometry.parts[0].faces[19] >> body ... geometry.parts[0].faces[29] >> body ... torque = on.loads.Torque(10, [0, 0, -1]) ... torque >> body ... rotation = on.loads.Rotation(x=0.1, z=0) ... rotation >> body
- Parameters:
body_type – Optional body type. It can be either “collection”, “rigid”, or “deformable” Defaults to “collection”
ref_point – Optional point of reference for “deformable” or “rigid” body. Defaults to center of mass for dynamic simulation. Defaults to geometric center for static simulation.
alias – Optional alias for this node.
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.