PyT3D project documentation

Python preprocessor for T3D, a three-dimensional sequential mesh generator

T3D is a powerfull mesh generator capable to discretize complex 3D domains into triangular and tetrahedral meshes of high quality. However, it uses text input files, which might be tedious and difficult to create manually, especially for complex geometries. PyT3D is a Python module to simplify the process:

For better orientation, see T3D documentation first

Inheritance diagram of T3DObject, Vertex, Polygon, Curve, Entity2d, Patch, Surface, Region

T3DObject

class pyt3d.T3DObject(id=-1, size=None, sizeMul=None, factor=None, property=None, virtual=None, hidden=None, output=None, coincide=None, slave=None, master=None, noslave=None, nomaster=None, **kw)

Bases: object

Base class for all other objects, implementing common interface and attributes

Parameters:
  • id (int) – id
  • size – size
  • sizeMul (float) – size multiplier
coincide = None

coincide attribute

factor = None

factor attribute

hidden = None

hidden attribute

id = None

id attribute

isWritten = None

whether receiver is already written or not

master = None

master attribute

nomaster = None

nomaster attribute

noslave = None

noslave attribute

output = None

output attribute

property = None

property attribute

size = None

size attribute

sizeMul = None

size multiplier

slave = None

slave attribute

toFile(f, deps=[])

Writes receiver to given file / file name

Parameters:
  • f (file|str) – opened file for writing of file name
  • deps ([T3DObject]) – dependencies to be write prior to receiver
virtual = None

virtual attribute

Vertex

class pyt3d.Vertex(xyz=None, fixed=None, weight=None, **kw)

Bases: pyt3d.T3DObject

Class representing T3D Vertex

Parameters:
  • xyz (Vector3) – position
  • fixed (Vector3) – fixed parameter
  • weight (Vector3) – weight
  • **kw – keywords for T3DObject
curves = None

list of curves sharing the Vertex

findCurveTo(anotherVertex)

Returns Curve connecting receiver and given vertex. Returns None if no such Curve exists

Parameters:anotherVertex (Vertex) – given vertex
Return type:Curve
fixed = None

fixed parameter

giveNeighbors()

Returns list of neighbors (Vectices which are connected with receiver by Curves)

Return type:[Vertex]
isNeighborOf(anotherVertex)

Checks if receiver and given vertex are neighbors (if they are connected with Curve)

Parameters:anotherVertex (Vertex) – given Vertex
Return type:bool
toFile(f)

Write receiver to given file

Parameters:f (file|str) – opened file for writing or file name
weight = None

weight

xyz = None

position

Polygon

class pyt3d.Polygon(xyz=None, poly=None, size=None, weight=1.0)

Bases: object

Class representing T3D Curve control point

Parameters:
  • xyz (Vector3) – position
  • poly (Polygon) – already specified Polygon
  • size – size
  • weight (float) – control point weight
id = None

id

poly = None

Already defined polygon

size = None

size parameter

weight = None

weight parameter

xyz = None

Position

Curve

class pyt3d.Curve(v1, v2, polygons=, []**kw)

Bases: pyt3d.T3DObject

class representing T3D Curve object connecting two Vertices

Parameters:
findCommonVertexWith(anotherCurve)

Returns common vectex with given Curve (None if there is no common Vertex)

Parameters:anotherCurve (Curve) – given Curve
Return type:Vertex
giveSecondVertex(v)

Returns secong Vertex of receiver (None if given Vertex does not belong to receiver)

Parameters:v (Vertex) – given Vertex
Return type:Vertex
giveVertices()

Returns list of receiver’s Vertices

Return type:[Vertex]
hasCommonVertexWith(anotherCurve)

Returns if receiver and given Curve has common Vertex or not

Parameters:anotherCurve (Curve) – given Curve
Return type:bool
patches = None

list od Patches

polygons = None

list of Polygons

surfaces = None

list od Surfaces

toFile(f)

Write receiver to file (its Vertices first)

Parameters:f (file|str) – opened file for writing or file name
v1 = None

1st Vertex

v2 = None

2nd Vertex

Entity2d

class pyt3d.Entity2d(curves, reorder=True, **kw)

Bases: pyt3d.T3DObject

Base class for 2D objects (Patches and Surfaces)

Parameters:
  • curves ([Curve]) – bounding curves
  • **kw – keywords for T3DObject
checkCurves(reorder=True)

Checks if order of curves is correct and reorder them (if reorder=True) accordingly

Parameters:reorder (bool) – passing this argument as False means not to reorder the curves, only checks if it is possible to connect them and raise error if not
curves = None

list of Curves

findCommonCurveWith(e)

Returns common Curve with given 2d object (None if there is non such Curve)

Parameters:e (Entity2d) – given 2d object
Return type:Curve
giveNeighbors()

Returns list of neighbors (2d objects with common boundary Curves)

Return type:[Entity2d]
giveSignOf(c)

Returns sign of given bounding Curve

Parameters:b (Curve) – given bounding Curve
toFile(f)

Write receiver to file (its Curves first)

Parameters:f (file|str) – opened file for writing or file name

Patch

class pyt3d.Patch(curves, normal=None, ref=None, **kw)

Bases: pyt3d.Entity2d

class representing T3D Patch object

Parameters:
  • curves ([Curve]) – bounding curves
  • normal (Vector3) – patch normal
  • ref (Vector3) – patch ref parameter (only used if parameter normal is not specified)
  • **kw – keywords for Entity2d
checkCurves(reorder=True)

Checks if order of curves is correct and reorder them (if reorder=True) accordingly

Parameters:reorder (bool) – passing this argument as False means not to reorder the curves, only checks if it is possible to connect them and raise error if not
findCommonCurveWith(e)

Returns common Curve with given 2d object (None if there is non such Curve)

Parameters:e (Entity2d) – given 2d object
Return type:Curve
giveNeighbors()

Returns list of neighbors (2d objects with common boundary Curves)

Return type:[Entity2d]
giveSignOf(c)

Returns sign of given bounding Curve

Parameters:b (Curve) – given bounding Curve
normal = None

normal vector

ref = None

ref parameter

toFile(f)

Write receiver to file (its Curves first)

Parameters:f (file|str) – opened file for writing or file name

Surface

class pyt3d.Surface(curves, order=(1, 1), polygons=, []**kw)

Bases: pyt3d.Entity2d

class representing T3D Surface object

Parameters:
  • curves ([Curve]) – bounding curves
  • order ((int,int)) – order in u and v direction
  • polygons ([Polygon]) – list of control points
  • **kw – keywords for Entity2d
checkCurves(reorder=True)

Checks if order of curves is correct and reorder them (if reorder=True) accordingly

Parameters:reorder (bool) – passing this argument as False means not to reorder the curves, only checks if it is possible to connect them and raise error if not
findCommonCurveWith(e)

Returns common Curve with given 2d object (None if there is non such Curve)

Parameters:e (Entity2d) – given 2d object
Return type:Curve
giveNeighbors()

Returns list of neighbors (2d objects with common boundary Curves)

Return type:[Entity2d]
giveSignOf(c)

Returns sign of given bounding Curve

Parameters:b (Curve) – given bounding Curve
order = None

order in u and v direction

polygons = None

list of Polygons

toFile(f)

Write receiver to file (its Curves first)

Parameters:f (file|str) – opened file for writing or file name

Region

class pyt3d.Region(surfaces=, []patches=, []**kw)

Bases: pyt3d.T3DObject

Class representing T3D Region

Parameters:
checkBoundaries(nSteps=10)

Checks and reorder receiver’s 2d entities

Parameters:nSteps (int) – maximum number of tries + number of boundaries
checkOrientationOf(b1, b2)

Checks orientation of two receiver’s bounding Entities2d. Changes sign of b2 or raise error in case of problem. Returns if the second boundary was changed or not

Parameters:
Return type:

bool

giveSignOf(b)

Returns sign of given bounding Entity2d

Parameters:b (Entity2d) – given bounding Entity2d
patches = None

list of Patches

reverse()

Reverse receiver (sign of its bounding Entities2d

subregions = None

list of Regions

surfaces = None

list of Surfaces

toFile(f)

Write receiver to file (its surfaces, patches and subregions first)

Parameters:f (file|str) – opened file for writing or file name

Exceptions

exception pyt3d.PyT3DError(msg)

Module exception

Functions

pyt3d.run(iName, oName='', graphics=False, exe='t3d', defaultSize=1.0, extra='', phaseByPhase=False)

Runs T3D

Parameters:
  • iName (str) – input file name
  • oName (str) – output file name
  • graphics (bool) – if run T3D with graphics or not
  • exe (str) – T3D executable name
  • defaultSize (float) – default size
  • extra (str) – extra command lines arguments for T3D
  • phaseByPhase (bool) – run T3D phase by phase or not
pyt3d.axisAlignedBox(lower, upper)

Construct axis aligned box

Parameters:
  • lower (Vector3) – lower corner
  • upper (Vector3) – upper corner
Return type:

([Vertex],[Curve],[Surface],Region)

pyt3d.box(vertices)

Returns box

Parameters:vertices ([Vertex]) – given vertices
Return type:([Vertex],[Curve],[Surface],Region)
pyt3d.sphere(center, radius)

Returns sphere

Parameters:
  • center (Vector3) – center
  • radius (float) – radius
Return type:

([Vertex],[Curve],[Surface],Region)

pyt3d.polyhedron(points, connectivity, returnOnlyRegion=False)

Returns polygon

Parameters:
  • points ([Vector3]) – polyhedron vertices
  • connectivity ([[int]]) – connectivity table of polyhedron
  • returnOnlyRegion (bool) – if True, returns only the resulting region
Return type:

([Vertex],[Curve],[Patch],Region)|Region

Table Of Contents

This Page