Geometry

Geometry object definitions.

Geometry from CAD

class onscale.CadFile(path: str, unit: Optional[str] = None, characteristic_length: Optional[float] = None, contraction_area_ratio: Optional[float] = 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")
...
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")
...     force = on.loads.Force(10, [0, 0, -1])
...     force >> geom.parts[0].faces[1].edges[0]
...
ApplyLoad(left=Force#0x..., right=Selection#0x...) ...
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]
...
ApplyLoad(left=Force#0x..., right=Selection#0x...) ...
static from_dict(data: Dict[str, Any], sim: Optional[onscale.tree.Simulation] = None) onscale.tree.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]
...
ApplyLoad(left=HeatFlux#0x..., right=Selection#0x...) ...
to_json() str

Convert this node into JSON representation

class onscale.ParametricCad(paths: List[str], unit: Optional[str] = None, characteristic_lengths: Optional[List[float]] = None, contraction_area_ratios: Optional[List[float]] = 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"])
...
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")
...     force = on.loads.Force(10, [0, 0, -1])
...     force >> geom.parts[0].faces[1].edges[0]
...
ApplyLoad(left=Force#0x..., right=Selection#0x...) ...
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]
...
ApplyLoad(left=Force#0x..., right=Selection#0x...) ...
static from_dict(data: Dict[str, Any], sim: Optional[onscale.tree.Simulation] = None) onscale.tree.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]
...
ApplyLoad(left=HeatFlux#0x..., right=Selection#0x...) ...
to_json() str

Convert this node into JSON representation

Geometry Primitives

class onscale.Point(x: float, y: float, z: Optional[float] = None, *, mode: str = 'xyz', alias: Optional[str] = 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: Optional[onscale.tree.Simulation] = None) onscale.tree.Node

Construct this node from serialized dictionary data

to_json() str

Convert this node into JSON representation

class onscale.Plane(point: Collection[float], normal: Collection[float], alias: Optional[str] = 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: Optional[str] = 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: Optional[onscale.tree.Simulation] = None) onscale.tree.Node

Construct this node from serialized dictionary data

to_json() str

Convert this node into JSON representation

class onscale.BoundPlane(point: Collection[float], normal: Collection[float], box_min: Collection[float], box_max: Collection[float], alias: Optional[str] = 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: Optional[onscale.tree.Simulation] = None) onscale.tree.Node

Construct this node from serialized dictionary data

to_json() str

Convert this node into JSON representation

Rigid Body

class onscale.RigidBody(ref_point: Optional[Collection[float]] = None)

A group of geometries that are defined as rigid in the solver.

A RigidBody has limited degrees of freedom and can be acted upon in different ways from normal geometry. You can apply Force, Moment, Displacement and Rotation loads on a RigidBody.

Examples: >>> import onscale as on >>> >>> with on.Simulation(“Static Solve”) as sim: … geom = on.CadFile(‘file.step’, ‘m’) … rigid_body = on.RigidBody(ref_point=[0.0, 1.0, 2.0]) … geometry.parts[0].faces[19] >> rigid_body … geometry.parts[0].faces[29] >> rigid_body … moment = on.loads.Moment(10, [0, 0, -1]) … moment >> rigid_body … rotation = on.loads.Rotation(x=0.1, z=0) … rotation >> rigid_body # doctest: +ELLIPSIS …

Parameters

ref_point – Optional point of reference for rigid body. Defaults to center of mass for dynamic simulation. Defaults to geometric center for static simulation.

static from_dict(data: Dict[str, Any], sim: Optional[onscale.tree.Simulation] = None) onscale.tree.Node

Construct this node from serialized dictionary data

to_json() str

Convert this node into JSON representation

Deformable Body

class onscale.DeformableBody(ref_point: Optional[Collection[float]] = None, x: bool = True, y: bool = True, z: bool = True)

A group of geometries that are defined as a deformable body in the solver.

You can apply Force and Moment loads on a DeformableBody. The force/moment is tranferred to nodes that belong to geometery applied to DeformableBody using AddToDeformableBody

Examples: >>> import onscale as on >>> >>> with on.Simulation(“Static Solve”) as sim: … geom = on.CadFile(‘file.step’, ‘m’) … deformable_body = on.DeformableBody(x=False) … geom.parts[0].faces[158] >> deformable_body … moment = on.loads.Moment(10, [1, 0, 0], alias=’Moment 1’) … moment >> deformable_body # doctest: +ELLIPSIS …

Parameters
  • ref_point – Optional reference point for deformable body where moment and forces are applied. Defaults to geometric center.

  • x – If true activates x degree of freedom for the nodes on geometry applied to DeformableBody

  • y – If true activates y degree of freedom for the nodes on geometry applied to DeformableBody

  • z – If true activates z degree of freedom for the nodes on geometry applied to DeformableBody

static from_dict(data: Dict[str, Any], sim: Optional[onscale.tree.Simulation] = None) onscale.tree.Node

Construct this node from serialized dictionary data

to_json() str

Convert this node into JSON representation