Mesher
Geometry Operations
Transformation
- class TwinAPI.SimulationTools.Mesher.transformer(myFun, x_trans, y_trans, z_trans)
Transformer is a class to translate the created body by given coordinate vector
Rotation
- class TwinAPI.SimulationTools.Mesher.RotateBody(myFun, angle, axis)
This class lets you rotate a defined body by given angle around given axis Angle is in degrees and axis can be ‘X’, ‘Y’ or ‘Z’
Revolver
- class TwinAPI.SimulationTools.Mesher.revolver(myFun, angle, axis, n_rad, typer, dirr)
This class lets you revolve a 2D geometric shape. myFun is the 2D geometric shape to be revolved. angle is the angle of resulting revolved geometry. axis is the axis of revolution. It can take values: ‘X’, ‘Y’ or ‘Z’. n_rad is the number of nodes along angle of revolution. typer is the node distribution type along angle of revolution. dirr is the node distribution direction along angle of revolution.
1from TwinAPI.SimulationTools import Mesher
2quad1=Mesher.transformer(Mesher.Quad2D(1,5,"linear",">",1,5,"parabolic","<>"),0,diskRad,0)
3rev1=Mesher.revolver(quad1, 300, "X", 50, "uniform", "")

2D Shapes
Circle
- class TwinAPI.SimulationTools.Mesher.Circle2D(radius, nodeAlongRadius, distTypeAlongRadius, distDirectionAlongRadius, angle, nodeAlongTheta, distTypeAlongTheta, distDirectionAlongTheta)
This class lets you define a circular geometry on XY plane. radius is the Radius of Circle nodeAlongRadius is the number of nodes along the circle’s radius distTypeAlongRadius is the bias type of nodes’ distribution along radius line distDirectionAlongRadius is the bias direction of nodes’ distribution along radius line angle is the Angle of Circle with respect to X axis. nodeAlongTheta is the number of nodes along the circle’s hoop distTypeAlongTheta is the bias type of nodes’ distribution along circle hoops distDirectionAlongTheta is the bias direction of nodes’ distribution along circle hoops
You can easily call the boundaries of a circle with angle less than 360 using bottom, slope and outer attributes. If the angle is given as 360 only outer attribute will be available
1from TwinAPI.SimulationTools import Mesher
2circ=Mesher.Circle2D(5, 3, "exp:2", "><", 60, 50, "uniform", "<")

CircleQuad
- class TwinAPI.SimulationTools.Mesher.CircleQuad2D(radius, nodeX, nodeY, nodeCurve, angle, area_ratio)
This class lets you define a circular geometry on XY plane made out of quad elements. radius is the Radius of Circle
nodeX is the number of nodes of the square within the geometry along X axis nodeY is the number of nodes of the square within the geometry along Y axis nodeCurve is the number of curves between circle curve and square boundaries angle is the Angle of Circle with respect to X axis in degrees (Since an inner square is defined to form this geometry, angle should be less than 180) area_ratio is the area ratio of square to circle.
This is an experimantal class. There is still work to do to perfect it. TODO: take an input as a multiplier of this geometry to form a full circle
1from TwinAPI.SimulationTools import Mesher
2circquad=Mesher.CircleQuad2D(radius=5, n1=20, n2=20, n_hoop=7, alpha=90, area_ratio=5)

Ellipse
- class TwinAPI.SimulationTools.Mesher.Ellipse2D(radiusX, radiusY, nodeAlongRadius, distTypeAlongRadius, distDirectionAlongRadius, angle, nodeAlongTheta, distTypeAlongTheta, distDirectionAlongTheta)
This class lets you define an elliptic geometry on XY plane. radiusX is the Radius of Circle along X axis radiusY is the Radius of Circle along Y axis nodeAlongRadius is the number of nodes along the circle’s radius distTypeAlongRadius is the bias type of nodes’ distribution along radius line distDirectionAlongRadius is the bias direction of nodes’ distribution along radius line angle is the Angle of Circle with respect to X axis. nodeAlongTheta is the number of nodes along the circle’s hoop distTypeAlongTheta is the bias type of nodes’ distribution along circle hoops distDirectionAlongTheta is the bias direction of nodes’ distribution along circle hoops
You can easily call the boundaries of a circle with angle less than 360 using bottom, slope and outer attributes. If the angle is given as 360 only outer attribute will be available
1from TwinAPI.SimulationTools import Mesher
2ell=Mesher.Ellipse2D(rx=5,y=3,rNode=5,rType="exp:e",rDir="<>",angle=250,rTheta=20,rType="uniform",rDir="")

Frame
- class TwinAPI.SimulationTools.Mesher.Frame(height, n_height, biastype_height, biasdir_height, thickness, n_thickness, biastype_thickness, biasdir_thickness)
This class lets you define a frame crossection on XY plane This class only takes inputs for a quarter of a frame section. height is the distance between upper and lower part of the section n_height is the node number between upper and lower part of the section biastype_height is the node distribution type between upper and lower part of the section biasdir_height is the node distribution direction between upper and lower part of the section thickness is the thickness of one side of a frame section n_thickness is the number of nodes along thickness of one side of a frame section biastype_thickness is the distribution type of nodes along thickness of one side of a frame section biasdir_thickness is the distribution direction of nodes along thickness of one side of a frame section
You can call the inner and outer boundaries of this seciton easily by typing them as attributes.
1from TwinAPI.SimulationTools import Mesher
2frame=Mesher.Frame(5,3,"uniform","",1,3,"parabolic","<>")

I Beam Section
- class TwinAPI.SimulationTools.Mesher.I_Beam(height, n_height, biastype_height, biasdir_height, thickness, n_thickness, biastype_thickness, biasdir_thickness, hLeg, n_hLeg, biastype_hLeg, biasdir_hLeg, web, n_web, biastype_web, biasdir_web)
This class lets you define an I Beam section. height is the length of central piece along Y axis n_height is the node number of central piece along Y axis biastype_height is the node distribution type of central piece along Y axis biasdir_height is the node distribution direction of central piece along Y axis thickness is the length of upper and lower piece along Y axis n_thickness is the node number of upper and lower piece along Y axis biastype_thickness is the node distribution type of upper and lower piece along Y axis biasdir_thickness is the node distribution direction of upper and lower piece along Y axis hLeg is the length of one side of upper and lower piece along X axis n_hLeg is the node number of one side of upper and lower piece along X axis biastype_hLeg is the node distribution type of one side of upper and lower piece along X axis biasdir_hLeg is the node distribution direction of one side of upper and lower piece along X axis web is the length of central piece along X axis n_web is the node number of central piece along X axis biastype_web is the node distribution type of central piece along X axis biasdir_web is the node distribution direction of central piece along X axis
1from TwinAPI.SimulationTools import Mesher
2IBeam=Mesher.I_Beam(5,3,"uniform","",5,3,"uniform","",5,3,"uniform","",5,3,"uniform","")

Pipe
- class TwinAPI.SimulationTools.Mesher.Pipe2D(r_in, r_out, n_hoop, typeHoop, dirHoop, angle, n_rad, typeRad, dirRad)
This class lets you define a Pipe2D geometry on XY plane. r_in is the inner radius of pipe. r_out is the outer radius of pipe. n_hoop is the number of nodes along radius. typeHoop is the node distribution type along radius dirHoop is the node distribution direction along radius angle is the angle of pipe geometry. 0 angle is the X axis. n_rad is number of nodes along angle. typeRad is the node distribution type along angle dirRad is the node distribution direction along angle
1from TwinAPI.SimulationTools import Mesher
2pipe=Mesher.Pipe2D(r_in=3, r_out=5, n_hoop=5, typeHoop="uniform", dirHoop="", angle=180, n_rad=36, typeRad="uniform", dirRad="")

Rectangular
- class TwinAPI.SimulationTools.Mesher.Quad2D(lengthX, nodeAlongX, distTypeAlongX, distDirectionAlongX, lengthY, nodeAlongY, distTypeAlongY, distDirectionAlongY)
This class lets you define a rectangular geometry. lengthX is the length of edge of rectangular along X axis nodeAlongX is the node number on edge of rectangular along X axis distTypeAlongX is the node distribution of edge of rectangular along X axis distDirectionAlongX is the direction of distribution of edge of rectangular along X axis lengthY is the length of edge of rectangular along Y axis nodeAlongY is the node number on edge of rectangular along Y axis distTypeAlongY is the node distribution of edge of rectangular along Y axis distDirectionAlongY is the direction of distribution of edge of rectangular along Y axis
You can call the boundaries of this geometry easily by typing bottom, top, left or right as an attribute.
1from TwinAPI.SimulationTools import Mesher
2quad=Mesher.Quad2D(1,5,"uniform",">",.4,5,"uniform","<>")

Triangle
- class TwinAPI.SimulationTools.Mesher.Tri2D(l1, n1, type1, dir1, l2, n2, type2, dir2)
This class lets you define Tri2D section. l1 is the length along X axis. n1 is the number of nodes along X axis. type1 is the node distribution type along X axis. dir1 is the node distribution direction along X axis. l2 is the length along Y axis. n2 is the number of nodes along Y axis. type2 is the node distribution type along Y axis. dir2 is the node distribution direction along Y axis.
1from TwinAPI.SimulationTools import Mesher
2tri=Mesher.Tri2D(4,21,"uniform","<",5,20,"uniform","")

U Beam Section
- class TwinAPI.SimulationTools.Mesher.U_Beam(height, n_height, biastype_height, biasdir_height, thickness, n_thickness, biastype_thickness, biasdir_thickness, width, n_width, biastype_width, biasdir_width, web, n_web, biastype_web, biasdir_web)
This class lets you define an U_Beam section. height is the length of central piece along Y axis n_height is the node number of central piece along Y axis biastype_height is the node distribution type of central piece along Y axis biasdir_height is the node distribution direction of central piece along Y axis thickness is the length of upper and lower piece along Y axis n_thickness is the node number of upper and lower piece along Y axis biastype_thickness is the node distribution type of upper and lower piece along Y axis biasdir_thickness is the node distribution direction of upper and lower piece along Y axis hLeg is the length of one side of upper and lower piece along X axis n_hLeg is the node number of one side of upper and lower piece along X axis biastype_hLeg is the node distribution type of one side of upper and lower piece along X axis biasdir_hLeg is the node distribution direction of one side of upper and lower piece along X axis web is the length of central piece along X axis n_web is the node number of central piece along X axis biastype_web is the node distribution type of central piece along X axis biasdir_web is the node distribution direction of central piece along X axis
1from TwinAPI.SimulationTools import Mesher
2IBeam=Mesher.U_Beam(9,6,"uniform","",1,6,"uniform","",1,6,"uniform","",2,6,"uniform","")

3D Shapes
Box
- class TwinAPI.SimulationTools.Mesher.box(lx, nx, typeX, dirX, ly, ny, typeY, dirY, lz, nz, typeZ, dirZ, x_trans, y_trans, z_trans)
This class lets you define an box geometry. lx is the length along X axis. nx is the number of nodes along X axis. typeX is the node distribution type along X axis. dirX is the node distribution direction along X axis. lx is the length along X axis. nx is the number of nodes along X axis. typeX is the node distribution type along X axis. dirX is the node distribution direction along X axis. lx is the length along X axis. nx is the number of nodes along X axis. typeX is the node distribution type along X axis. dirX is the node distribution direction along X axis. x_trans is the transformation vector’s X axis component. y_trans is the transformation vector’s Y axis component. z_trans is the transformation vector’s Z axis component.
1from TwinAPI.SimulationTools import Mesher
2box=Mesher.box(1,5,"uniform",">",.4,5,"uniform","<>", .4,5,"uniform","<>", 0,0,0)

Cylinder
- class TwinAPI.SimulationTools.Mesher.cylinder(radius, nodeAlongRadius, distTypeAlongRadius, distDirectionAlongRadius, angle, nodeAlongTheta, distTypeAlongTheta, distDirectionAlongTheta, lz, nz, typeZ, dirZ, x_trans, y_trans, z_trans)
This class lets you define a cylinder geometry radius is the Radius of Circle nodeAlongRadius is the number of nodes along the circle’s radius distTypeAlongRadius is the bias type of nodes’ distribution along radius line distDirectionAlongRadius is the bias direction of nodes’ distribution along radius line angle is the Angle of Circle with respect to X axis. nodeAlongTheta is the number of nodes along the circle’s hoop distTypeAlongTheta is the bias type of nodes’ distribution along circle hoops distDirectionAlongTheta is the bias direction of nodes’ distribution along circle hoops lz is the length along Z axis. nz is the number of nodes along Z axis. typeZ is the node distribution type along Z axis. dirZ is the node distribution direction along Z axis. x_trans is the transformation vector’s X axis component. y_trans is the transformation vector’s Y axis component. z_trans is the transformation vector’s Z axis component.
You can easily call the boundaries of a circle with angle less than 360 using bottom, slope and outer attributes. If the angle is given as 360 only outer attribute will be available.
1from TwinAPI.SimulationTools import Mesher
2circ=Mesher.cylinder(5, 3, "exp:2", "><", 60, 50, "uniform", "<",.4,5,"uniform","<>", 0,0,0)

Extrusion Path
- class TwinAPI.SimulationTools.Mesher.extrusionPath(myFun, nodePath)
This class lets you define an extruded path section. myFun is the 2D geometric shape to be extruded. nodePath is the set of nodes which follows the required path.
1from TwinAPI.SimulationTools import Mesher
2quad=Mesher.Quad2D(1,5,"uniform",">",.4,5,"uniform","<>")
3Path=Mesher.node2Nurbs([[1,0,0],[0,1,0],[-1,0,0],[0,-1,0],[2,-1,0]],3,4,200)
4extrPath=Mesher.extrusionPath(quad, Path)

Heater Surface
- class TwinAPI.SimulationTools.Mesher.heaterSurf(lx, ly, z_trans, csvFile, **kwargs)
This class lets you define a conventional heater surface. lx is the length of heater along X axis. ly is the length of heater along Y axis. z_trans is the distance of heater from origin. csvFile is the temperature configuration of heater. An optional argument can be defined here: ‘Fitting’ If the csv file consists of the cell percentage of the conventional heater the fitting function can be given here. Hence, the correct temperature value in K will be calculated according to the given fitting function.
1from TwinAPI.SimulationTools import Mesher
2heater=Mesher.heaterSurf(1, 1, 0.2, "upper.csv")

Import STL and STEP Files
- class TwinAPI.SimulationTools.Mesher.MeshFromCad(cadFile, meshSize, elemOrder, scale, **OptCad)
This class allows you to convert CAD File to Mesh File. cadFile is the representative 3D Body Cad Geometry. meshSize is the max length of an element. elemOrder is the order of polynomial of elements used to construct the mesh. scale is the scaling factor to shrink or expand the imported geometry.
1from TwinAPI.SimulationTools import Mesher
2CadGeom=Mesher.MeshFromCad(1, 1, 0.2, "upper.csv")

Indices and tables