APREPRO Functions

CUBIT adds a number of APREPRO functions to aid in the meshing process. A description of each function is available in the categories below.

Table 1. Geometry Functions

Syntax Description
BBox_XMin("type", id) Returns the xmin value of the bounding box of the specified geometric entity. “type” can be “volume”, “surface”, “curve”, “vertex”, or “group”. If “volume”, “surface”, “curve”, or “vertex” it will calculate the bounding box for the entity with the given id. If “group” it will calculate the combined bounding box for the group. A group can have any of the geometry types (vol, surf, curve, vert) in it and can be of mixed types.
BBox_XMax("type", id) Returns the xmax value of the bounding box of the specified geometric entity. “type” can be “volume”, “surface”, “curve”, “vertex”, or “group”. If “volume”, “surface”, “curve”, or “vertex” it will calculate the bounding box for the entity with the given id. If “group” it will calculate the combined bounding box for the group. A group can have any of the geometry types (vol, surf, curve, vert) in it and can be of mixed types.
BBox_YMin("type", id) Returns the ymin value of the bounding box of the specified geometric entity. “type” can be “volume”, “surface”, “curve”, “vertex”, or “group”. If “volume”, “surface”, “curve”, or “vertex” it will calculate the bounding box for the entity with the given id. If “group” it will calculate the combined bounding box for the group. A group can have any of the geometry types (vol, surf, curve, vert) in it and can be of mixed types.
BBox_YMax("type", id) Returns the ymax value of the bounding box of the specified geometric entity. “type” can be “volume”, “surface”, “curve”, “vertex”, or “group”. If “volume”, “surface”, “curve”, or “vertex” it will calculate the bounding box for the entity with the given id. If “group” it will calculate the combined bounding box for the group. A group can have any of the geometry types (vol, surf, curve, vert) in it and can be of mixed types.
BBox_ZMin("type", id) Returns the zmin value of the bounding box of the specified geometric entity. “type” can be “volume”, “surface”, “curve”, “vertex”, or “group”. If “volume”, “surface”, “curve”, or “vertex” it will calculate the bounding box for the entity with the given id. If “group” it will calculate the combined bounding box for the group. A group can have any of the geometry types (vol, surf, curve, vert) in it and can be of mixed types.
BBox_ZMax("type", id) Returns the zmax value of the bounding box of the specified geometric entity. “type” can be “volume”, “surface”, “curve”, “vertex”, or “group”. If “volume”, “surface”, “curve”, or “vertex” it will calculate the bounding box for the entity with the given id. If “group” it will calculate the combined bounding box for the group. A group can have any of the geometry types (vol, surf, curve, vert) in it and can be of mixed types.
GeomCentroid_X("type", id) Returns the x coordinate of the centroid of the specified geometric entity. "type" can be "volume" or "group". If “volume” it calculates the centroid for the volume with the given id (single volume). If “group” it must be a group of volumes and it will calculate the combined centroid for the whole group with the given id.
GeomCentroid_Y("type", id) Returns the y coordinate of the centroid of the specified geometric entity. "type" can be "volume" or "group". If “volume” it calculates the centroid for the volume with the given id (single volume). If “group” it must be a group of volumes and it will calculate the combined centroid for the whole group with the given id.
GeomCentroid_Z("type", id) Returns the z coordinate of the centroid of the specified geometric entity. "type" can be "volume" or "group". If “volume” it calculates the centroid for the volume with the given id (single volume). If “group” it must be a group of volumes and it will calculate the combined centroid for the whole group with the given id.
Length(id) Returns the length of the curve with the given id.
Length(x, y, z, ord) Returns the length of the curve identified by the given center point coordinates and ordinal value.
NumCurves() Returns the number of curves in the model.
NumSurfaces() Returns the number of surfaces in the model.
NumVertices() Returns the number of vertices in the model.
NumVolumes() Returns the number of volumes in the model.
Radius(id) Returns the radius of the curve at its midpoint.
Radius(x, y, z, ord) Returns the radius of the curve identified by the given center point coordinates and ordinal value.
SurfaceArea(id) Returns the surface area of the surface with the given id.
SurfaceArea(x, y, z, ord) Returns the surface area of the surface  identified by the given center point coordinates and ordinal value.
Type("entity name") Returns the type of the specified entity name
Volume(id) Gets the geometric volume of the volume with the given id.
Volume(x, y, z, ord) Gets the geometric volume of the volume identified by the given center point coordinates and ordinal value.
Vx(id), Vy(id), Vz(id) Gets the x, y or z coordinate of vertex with the given id.
Vx(x, y, z, ord)
Vy(x, y, z, ord)
Vz(x, y, z, ord)
Gets the x, y or z coordinate of vertex identified by the given center point coordinates and ordinal value.
VertexAt(x, y, z, ordinal) Returns the id of the vertex with the idless reference, x,y,z,ordinal.
CurveAt(x, y, z, ordinal) Returns the id of the curve with the idless reference, x,y,z,ordinal.
SurfaceAt(x, y, z, ordinal) Returns the id of the surface with the idless reference, x,y,z,ordinal.
VolumeAt(x, y, z, ordinal) Returns the id of the volume with the idless reference, x,y,z,ordinal.

Table 2. Mesh Functions

Syntax Description
EdgeLength(id) Returns the length of the edge with the given id.
EdgeLength(x, y, z, ord) Returns the length of the edge identified by the given center point coordinates and ordinal value.
FaceArea(id) Returns the area of the face with the given id.
FaceArea(x, y, z, ord) Returns the area of the face identified by the given center point coordinates and ordinal value.
HexVolume(id) Returns the volume of the hex with the given id.
HexVolume(x, y, z, ord) Returns the volume of the hex identified by the given center point coordinates and ordinal value.
IntNum(id) Returns the number of intervals on a curve with the given id.
IntNum(x, y, z, ord) Returns the number of intervals on a curve identified by the given center point coordinates and ordinal value.
IntSize(id) Returns the interval size on a curve with the given id.
IntSize(x, y, z, ord) Returns the interval size on a curve identified by the given center point coordinates and ordinal value.
MeshCentroid_X("type", id) Returns the x coordinate of the centroid of the specified mesh entity. “type” can be “volume”, “block”, or “group”. If “volume” it calculates the centroid of the 3D elements in the volume with the given id. If “block” it calculates the centroid of the elements in the block with the given id. If “group” it must be a group of volumes and it calculates the centroid of the group with the given id.
MeshCentroid_Y("type", id) Returns the y coordinate of the centroid of the specified mesh entity. “type” can be “volume”, “block”, or “group”. If “volume” it calculates the centroid of the 3D elements in the volume with the given id. If “block” it calculates the centroid of the elements in the block with the given id. If “group” it must be a group of volumes and it calculates the centroid of the group with the given id.
MeshCentroid_Z("type", id) Returns the z coordinate of the centroid of the specified mesh entity. “type” can be “volume”, “block”, or “group”. If “volume” it calculates the centroid of the 3D elements in the volume with the given id. If “block” it calculates the centroid of the elements in the block with the given id. If “group” it must be a group of volumes and it calculates the centroid of the group with the given id.
MeshLength(id) Gets the length of the meshed curve with the given id.
MeshLength(x, y, z, ord) Gets the length of the meshed curve identified by the given center point coordinates and ordinal value.
MeshSurfaceArea(id) Returns the total area of all triangle or quadrilateral elements on the surface with the given id. This will vary from the geometric surface area since the mesh approximates the boundary with linear mesh edges.
MeshSurfaceArea(x, y, z, ord) Returns the total area of all triangle or quadrilateral elements on the surface  identified by the given center point coordinates and ordinal value. This will vary from the geometric surface area since the mesh approximates the boundary with linear mesh edges.
MeshVolume(id) Returns the total volume of all mesh elements in the volume with the given id. This will vary from the actual geometric volume since the mesh approximates curved boundaries with linear mesh edges.
MeshVolume(x, y, z, ord) Returns the total volume of all mesh elements in the volume identified by the given center point coordinates and ordinal value. This will vary from the actual geometric volume since the mesh approximates curved boundaries with linear mesh edges.
MinSurfaceMeshQuality(id, "metric") Returns the worst value of the specified element quality metric of all elements on the given surface.

Acceptable metrics include:
shape
aspect ratio
condition no
distortion
element area
jacobian
maximum angle
minimum angle
relative size
scaled jacobian
shape and size
shear and size
shear
skew
stretch
taper
warpage

MinSurfaceMeshQuality(x, y, z, ord, "metric") Returns the worst value of the specified element quality metric of all elements on the surface identified by the given center point coordinates and ordinal value.

Acceptable metrics include:
shape
aspect ratio
condition no
distortion
element area
jacobian
maximum angle
minimum angle
relative size
scaled jacobian
shape and size
shear and size
shear
skew
stretch
taper
warpage

MinVolumeMeshQuality(id, "metric") Returns the worst value of the specified element quality metric of all elements in the volume with the given id.

Acceptable metrics include:
shape
aspect ration bet
aspect ratio gam
aspect ratio
condition no
diagonal ratio
dimension
distortion
element volume
jacobian
mass increase ratio
mean ratio
inradius
node distance
normalized inradius
relative size
scaled jacobian
shape and size
shear and size
shear
skew
stretch
taper
timestep

MinVolumeMeshQuality(x, y, z, ord, "metric") Returns the worst value of the specified element quality metric of all elements in the volume identified by the given center point coordinates and ordinal value.
  
Acceptable metrics include:
shape
aspect ration bet
aspect ratio gam
aspect ratio
condition no
diagonal ratio
dimension
distortion
element volume
jacobian
mass increase ratio
mean ratio
inradius
node distance
normalized inradius
relative size
scaled jacobian
shape and size
shear and size
shear
skew
stretch
taper
timestep
NumEdgesOnCurve(id) Returns the number of edges on the curve with the given id.
NumEdgesOnCurve(x, y, z, ord) Returns the number of edges on the curve identified by the given center point coordinates and ordinal value.
NumElemsOnSurface(id) Returns the number of elements on the surface with the given id.
NumElemsOnSurface(x, y, z, ord) Returns the number of elements on the surface identified by the given center point coordinates and ordinal value.
NumElemsInVolume(id) Returns the number of elements in the volume with the given id.
NumElemsInVolume(x, y, z, ord) Returns the number of elements in the volume identified by the given center point coordinates and ordinal value.
Nx(id), Ny(id), Nz(id) Gets the x, y or z coordinate of node with the given id.
Nx(x, y, z, ord)
Ny(x, y, z, ord)
Nz(x, y, z, ord)
Gets the x, y or z coordinate of node identified by the given center point coordinates and ordinal value.
TetVolume(id) Returns the volume of the tet with the given id.
TetVolume(x, y, z, ord) Returns the volume of the tet identified by the given center point coordinates and ordinal value.
TriArea(id) Returns the area of the tri with the given id.
TriArea(x, y, z, ord) Returns the area of the tri identified by the given center point coordinates and ordinal value. .

Table 3. Group, Block, and Assemblyl Metadata Functions

Syntax Description
BlockAttributeName(id, index)

Returns the name for the specified attribute index in the block within the given id

BlockAttributeValue(id, index)

Returns the value for the specified attribute index in the block within the given id

NumBlocks()

Returns the number of blocks in the model.

NumSidesets()

Returns the number of sidesets in the model.

NumNodesets()

Returns the number of nodesets in the model.

NumInGrp("groupname") Returns the number of entities in the given group.
NumTypeInGroup("group_name",
"entity_type")
Returns the number of "entity_type" in group "group_name".
NumVolsInPart("part_name") Returns the number of volumes assigned to the part with the specified name.
PartInVol(id) Returns the name and instance number of the part that the volume has been assigned to.

Table 4. ID Functions

Syntax Description
CurveAt(x, y, z, ordinal) Returns the id of the curve with the idless reference, x,y,z,ordinal.
EdgeAt(x, y, z, ordinal) Returns the id of the edge with the idless reference, x,y,z,ordinal.
FaceAt(x, y, z, ordinal) Returns the id of the quad face with the idless reference, x,y,z,ordinal.
GroupMemberId("group_name",
"entity_type", index)
Returns the ID of "entity_type" in group "group_name" at the specified index. If the group contains multiple entity types the index will only be relevant for the entity type specified and will behave as if the group only contained that entity type.
HexAt(x, y, z, ordinal) Returns the id of the hexahedra element with the idless reference, x,y,z,ordinal.
Id("type") Returns the ID of the entity most recently created with the specified type. Acceptable types include: "body", "volume", "surface", "curve", "vertex", "group", "node", "edge", "quad", "face", "tri", "hex", "tet", or "pyramid".
NodeAt(x, y, z) Returns the id of the node closest to the xyz location.
NodeAt(x, y, z, ordinal) Returns the id of the Node with the idless reference, x,y,z,ordinal.
PyramidAt(x, y, z, ordinal) Returns the id of the pyramid element with the idless reference, x,y,z,ordinal.
SurfaceAt(x, y, z, ordinal) Returns the id of the surface with the idless reference, x,y,z,ordinal.
TetAt(x, y, z, ordinal) Returns the id of the tetraheral element with the idless reference, x,y,z,ordinal.
TriAt(x, y, z, ordinal) Returns the id of the triangle with the idless reference, x,y,z,ordinal.
VertexAt(x, y, z, ordinal) Returns the id of the vertex with the idless reference, x,y,z,ordinal.
VolumeAt(x, y, z, ordinal) Returns the id of the volume with the idless reference, x,y,z,ordinal.
WedgeAt(x, y, z, ordinal) Returns the id of the wedge element with the idless reference, x,y,z,ordinal.

Table 5. Miscellaneous Functions

Syntax

Description

FileExists("file name") Checks if the given file exists. Returns non-zero if true.
GeometryEngineVersion("engine name") Get the version for the specified geometry engine.
get_error_count() Returns the current error count in CUBIT
get_warning_count() Returns the current warning count in CUBIT
HasFeature("feature name") Checks if the specified feature is available. Returns non-zero if the feature is enabled.
Print(msg) Prints msg
PrintError(svar) Outputs the string svar to stderr.
Quote(svar) Returns the string svar, enclosed in single quotes.
SessionId() Returns the unique id for the current CUBIT session.
GetMachineType() Returns the string name of the platform Cubit is running on ("Linux", "Darwin", "Microsoft Windows", etc.).
set_error_count(val) Sets the error count in CUBIT to val
set_warning_count(val) Sets the warning count in CUBIT to val
TimerStart() Starts the CPU timer
TimerStop() Stops the CPU timer

Table 6. Pre-defined Variables

The following APREPRO variables are predefined in CUBIT.

Variable

Description

CUBIT Variable to indicate that CUBIT is defined
CUBIT_VERSION Current version of CUBIT (not to be confused with VERSION, which stores the current version of APREPRO)