esys.pycad.design Package¶
Classes¶
- 
class esys.pycad.design.AbstractDesign(dim=3, element_size=1.0, order=1, keep_files=False)¶
- Bases: - object- Template for a design which defines the input for a mesh generator. - Note: - class variable GMSH - gmsh file format - Note: - class variable IDEAS - I_DEAS universal file format - Note: - class variable VRML - VRML file format - Note: - class variable STL - STL file format - Note: - class variable NASTRAN - Nastran bulk data format - Note: - class variable MEDIT - Medit file format - Note: - class variable CGNS - CGNS file format - Note: - class variable PLOT3D - Plot3D file format - Note: - class variable DIFFPACK- Diffpack file format - 
__init__(dim=3, element_size=1.0, order=1, keep_files=False)¶
- Initializes a design. - Parameters: - dim – spatial dimension
- element_size – global element size
- order – element order
- keep_files – flag to keep work files
 
 - 
CGNS= 'cgns'¶
 - 
DIFFPACK= 'diff'¶
 - 
GMSH= 'msh'¶
 - 
IDEAS= 'unv'¶
 - 
MEDIT= 'mesh'¶
 - 
NASTRAN= 'bdf'¶
 - 
PLOT3D= 'p3d'¶
 - 
STL= 'stl'¶
 - 
VRML= 'vrml'¶
 - 
addItems(*items)¶
- Adds items to the design. 
 - 
clearItems()¶
- Removes all items from the design. 
 - 
generate()¶
- generate output file - Note: - this method may be overwritten by a particular design implementation. 
 - 
getAllPrimitives()¶
- Returns a list of all primitives used to create the design. Each primitive appears once. The primitives are ordered by their order of generation. 
 - 
getDim(dim=3)¶
- Returns the spatial dimension. 
 - 
getElementOrder()¶
- Returns the element order. 
 - 
getElementSize()¶
- Returns the global element size. 
 - 
getFileFormat()¶
- Returns the file format 
 - 
getItems()¶
- Returns a list of the items used in the design. 
 - 
getMeshFileName()¶
- Returns the name of the mesh file. 
 - 
getMeshHandler()¶
- Returns a handle to a mesh meshing the design. - Note: - this method has to be overwritten by a particular design implementation. 
 - 
getTagMap()¶
- Returns a - TagMapto map the names of- PropertySets to tags.
 - 
keepFiles()¶
- Returns True if work files are kept, False otherwise. 
 - 
setDim(dim=3)¶
- Sets the spatial dimension. 
 - 
setElementOrder(order=1)¶
- Sets the element order. 
 - 
setElementSize(element_size=1.0)¶
- Sets the global element size. 
 - 
setFileFormat(format='msh')¶
- Sets the file format to be used. - Parameters: - format – format to be used. needs to be one of 
 - 
setKeepFilesOff()¶
- Work files are deleted at the end of the generation 
 - 
setKeepFilesOn()¶
- Work files are kept at the end of the generation. 
 - 
setMeshFileName(name=None)¶
- Sets the name for the mesh file. If no name is given a name is generated. 
 - 
setOptions(**kwargs)¶
- Sets options of the mesh generator. - Note: - this method is typically overwritten by a particular design implementation. 
 
- 
- 
class esys.pycad.design.Manifold1D¶
- Bases: - esys.pycad.primitives.PrimitiveBase- General one-dimensional manifold in 1D defined by a start and end point. - 
__init__()¶
- Initializes the one-dimensional manifold. 
 - 
apply(transformation)¶
- Returns a new object by applying the transformation. 
 - 
copy()¶
- Returns a deep copy of the object. 
 - 
getBoundary()¶
- Returns a list of the zero-dimensional manifolds forming the boundary of the curve. 
 - 
getConstructionPoints()¶
- Returns the points used to construct the primitive. 
 - 
getElementDistribution()¶
- Returns the element distribution. - Returns: - the tuple of the number of elements, the progression factor and the bump flag. If no element distribution is set - Noneis returned- Return type: - tuple
 - 
getEndPoint()¶
- Returns the end point. 
 - 
getPrimitives()¶
- Returns a list of primitives used to construct the primitive with no double entries. 
 - 
getStartPoint()¶
- Returns the start point. 
 - 
modifyBy(transformation)¶
- Modifies the coordinates by applying a transformation. 
 - 
resetElementDistribution()¶
- removes the a previously set element distribution from the line. 
 - 
setElementDistribution(n, progression=1, createBump=False)¶
- Defines the number of elements on the line. If set it overwrites the local length setting which would be applied. The progression factor - progressiondefines the change of element size between neighboured elements. If- createBumpis set progression is applied towards the center of the line.- Parameters: - n (int) – number of elements on the line
- progression (positive float) – a positive progression factor
- createBump (bool) – of elements on the line
 
- n (
 - 
setLocalScale(factor=1.0)¶
- Sets the local refinement factor. 
 
- 
- 
class esys.pycad.design.Manifold2D¶
- Bases: - esys.pycad.primitives.PrimitiveBase- General two-dimensional manifold. - Note: - Instance variable LEFT - left element orientation when meshing with transfinite meshing - Note: - Instance variable RIGHT - right element orientation when meshing with transfinite meshing - Note: - Instance variable ALTERNATE - alternate element orientation when meshing with transfinite meshing - 
__init__()¶
- Creates a two-dimensional manifold. 
 - 
ALTERNATE= 'Alternate'¶
 - 
LEFT= 'Left'¶
 - 
RIGHT= 'Right'¶
 - 
apply(transformation)¶
- Returns a new object by applying the transformation. 
 - 
copy()¶
- Returns a deep copy of the object. 
 - 
getBoundary()¶
- Returns a list of the one-dimensional manifolds forming the boundary of the surface (including holes). 
 - 
getConstructionPoints()¶
- Returns the points used to construct the primitive. 
 - 
getPoints()¶
- returns a list of points used to define the boundary - Returns: - list of points used to define the boundary - Return type: - listof- Points
 - 
getPrimitives()¶
- Returns a list of primitives used to construct the primitive with no double entries. 
 - 
getRecombination()¶
- returns max deviation from right angle in the recombination algorithm - Returns: - max deviation from right angle in the recombination algorithm. If recombination is switched off, - Noneis returned.- Return type: - floator- None
 - 
getTransfiniteMeshing()¶
- returns the transfinite meshing settings. If transfinite meshing is not set, - Noneis returned.- Returns: - a tuple of the tuple of points used to define the transfinite meshing and the orientation. If no points are set the points tuple is returned as - None. If no transfinite meshing is not set,- Noneis returned.- Return type: - tupleof a- tupleof- Points (or- None) and the orientation which is one of the values- Manifold2D.LEFT,- Manifold2D.RIGHT,- Manifold2D.ALTERNATE
 - 
hasHole()¶
- Returns True if a hole is present. 
 - 
modifyBy(transformation)¶
- Modifies the coordinates by applying a transformation. 
 - 
resetTransfiniteMeshing()¶
- removes the transfinite meshing from the surface 
 - 
setElementDistribution(n, progression=1, createBump=False)¶
- Defines the number of elements on the lines - Parameters: - n (int) – number of elements on the line
- progression (positive float) – a positive progression factor
- createBump (bool) – of elements on the line
 
- n (
 - 
setLocalScale(factor=1.0)¶
- Sets the local refinement factor. 
 - 
setRecombination(max_deviation=0.7853981633974483)¶
- Recombines triangular meshes on the surface into mixed triangular/quadrangular meshes. - max_deviationspecifies the maximum derivation of the largest angle in the quadrangle from the right angle. Use- max_deviation``==``Noneto switch off recombination.- Parameters: - max_deviation ( - floator- None.) – maximum derivation of the largest angle in the quadrangle from the right angle.
 - 
setTransfiniteMeshing(orientation='Left')¶
- applies 2D transfinite meshing to the surface. - Parameters: - orientation ( - Manifold2D.LEFT,- Manifold2D.RIGHT,- Manifold2D.ALTERNATE) – sets the orientation of the triangles. It is only relevant if recombination is not used.- Note: - Transfinite meshing can not be applied if holes are present. 
 
- 
- 
class esys.pycad.design.Manifold3D¶
- Bases: - esys.pycad.primitives.PrimitiveBase- General three-dimensional manifold. - 
__init__()¶
- Creates a three-dimensional manifold. 
 - 
apply(transformation)¶
- Returns a new object by applying the transformation. 
 - 
copy()¶
- Returns a deep copy of the object. 
 - 
getBoundary()¶
- Returns a list of the 2-dimensional manifolds forming the boundary of the volume (including holes). 
 - 
getConstructionPoints()¶
- Returns the points used to construct the primitive. 
 - 
getPrimitives()¶
- Returns a list of primitives used to construct the primitive with no double entries. 
 - 
getTransfiniteMeshing()¶
- returns the transfinite meshing settings. If transfinite meshing is not set, - Noneis returned.- Returns: - a tuple of the tuple of points used to define the transfinite meshing and the orientation. If no points are set the points tuple is returned as - None. If no transfinite meshing is not set,- Noneis returned.- Return type: - tupleof a- tupleof- Points (or- None) and the orientation which is one of the values- Manifold2D.LEFT,- Manifold2D.RIGHT,- Manifold2D.ALTERNATE
 - 
modifyBy(transformation)¶
- Modifies the coordinates by applying a transformation. 
 - 
resetTransfiniteMeshing()¶
- removes the transfinite meshing from the volume but not from the surfaces 
 - 
setElementDistribution(n, progression=1, createBump=False)¶
- Defines the number of elements on the lines and surfaces - Parameters: - n (int) – number of elements on the line
- progression (positive float) – a positive progression factor
- createBump (bool) – of elements on the line
 
- n (
 - 
setLocalScale(factor=1.0)¶
- Sets the local refinement factor. 
 - 
setRecombination(max_deviation=0.7853981633974483)¶
- Recombines triangular meshes on all surface into mixed triangular/quadrangular meshes. These meshes are then used to generate the volume mesh if possible. Recombination requires 3D transfinite meshing. - max_deviationspecifies the maximum derivation of the largest angle in the quadrangle from the right angle. Use- max_deviation``==``Noneto switch off recombination.- Parameters: - max_deviation ( - floator- None.) – maximum derivation of the largest angle in the quadrangle from the right angle.
 - 
setTransfiniteMeshing(orientation='Left')¶
- applies 3D transfinite meshing to the volume and all surface. It requires transfinite meshing on all faces which will be enforced (except if - orientationis equal to- None). :param orientation: sets the orientation of the triangles on the surfaces. It is only relevant if recombination is not used. If orientation is equal to- None, the transfinite meshing is not applied to the surfaces but must be set by the user. :type orientation:- Manifold2D.LEFT,- Manifold2D.RIGHT,- Manifold2D.ALTERNATE:note: Transfinite meshing can not be applied if holes are present. :note: only five or six surfaces may be used. :warning: The functionality of transfinite meshing without recombination is not entirely clear in- gmsh. So please apply this method with care.
 
- 
- 
class esys.pycad.design.Point(x=0.0, y=0.0, z=0.0, local_scale=1.0)¶
- Bases: - esys.pycad.primitives.Primitive,- esys.pycad.primitives.PrimitiveBase- A three-dimensional point. - 
__init__(x=0.0, y=0.0, z=0.0, local_scale=1.0)¶
- Creates a point with coordinates - x,- y,- zwith the local refinement factor- local_scale. If- xis a list or similar it needs to have length less or equal 3. In this case- yand- zare overwritten by- x[1]and- x[2].
 - 
apply(transformation)¶
- Returns a new object by applying the transformation. 
 - 
collectPrimitiveBases()¶
- Returns primitives used to construct the primitive. 
 - 
copy()¶
- Returns a deep copy of the object. 
 - 
getConstructionPoints()¶
- Returns the points used to construct the primitive. 
 - 
getCoordinates()¶
- Returns the coordinates of the point as a - numpy.ndarrayobject.
 - 
getCoordinatesAsList()¶
- Returns the coordinates of the point as a - listobject.
 - 
getDirectedID()¶
- Returns the primitive ID where a negative sign means that reversed ordering is used. 
 - 
getID()¶
- Returns the primitive ID. 
 - 
getLocalScale()¶
- Returns the local refinement factor. 
 - 
getPrimitives()¶
- Returns a list of primitives used to construct the primitive with no double entries. 
 - 
getUnderlyingPrimitive()¶
- Returns the underlying primitive. 
 - 
hasSameOrientation(other)¶
- Returns True if - otheris the same primitive and has the same orientation, False otherwise.
 - 
isColocated(primitive)¶
- Returns True if the - Point- primitiveis collocated (has the same coordinates) with self. That is, if |self - primitive| <= tol * max(|self|,|primitive|).
 - 
isReversed()¶
- returns True is the primitive is a reversed primitive. 
 - 
modifyBy(transformation)¶
- Modifies the coordinates by applying the given transformation. 
 - 
setCoordinates(x)¶
- Sets the coordinates of the point from a - numpy.ndarrayobject- x.
 - 
setLocalScale(factor=1.0)¶
- Sets the local refinement factor. 
 - 
substitute(sub_dict)¶
- Returns a copy of self with substitutes for the primitives used to construct it given by the dictionary - sub_dict. If a substitute for the object is given by- sub_dictthe value is returned, otherwise a new instance with substituted arguments is returned.
 
- 
- 
class esys.pycad.design.Primitive¶
- Bases: - object- Class that represents a general primitive. - 
__init__()¶
- Initializes the Primitive instance object with a unique ID. 
 - 
collectPrimitiveBases()¶
- Returns a list of primitives used to construct the primitive. It may contain primitives twice. - Note: - This method is overwritten by subclasses. 
 - 
getDirectedID()¶
- Returns the primitive ID where a negative sign means that reversed ordering is used. 
 - 
getID()¶
- Returns the primitive ID. 
 - 
getUnderlyingPrimitive()¶
- Returns the underlying primitive. 
 - 
hasSameOrientation(other)¶
- Returns True if - otheris the same primitive and has the same orientation, False otherwise.
 - 
isColocated(primitive)¶
- Returns True if the two primitives are located at the same position. - Note: - This method is overwritten by subclasses. 
 - 
isReversed()¶
- returns True is the primitive is a reversed primitive. 
 - 
substitute(sub_dict)¶
- Returns a copy of self with substitutes for the primitives used to construct it given by the dictionary - sub_dict. If a substitute for the object is given by- sub_dictthe value is returned, otherwise a new instance with substituted arguments is returned.- Note: - This method is overwritten by subclasses. 
 
- 
- 
class esys.pycad.design.PropertySet(name, *items)¶
- Bases: - esys.pycad.primitives.Primitive,- esys.pycad.primitives.PrimitiveBase- Defines a group of - Primitives which can be accessed through a name.- 
__init__(name, *items)¶
- Initializes the Primitive instance object with a unique ID. 
 - 
addItem(*items)¶
- Adds items. An item my be any - Primitivebut no- PropertySet.
 - 
addItems(*items)¶
- Adds items. An item my be any - Primitivebut no- PropertySet.
 - 
apply(transformation)¶
- Returns a new object by applying the transformation. 
 - 
clearItems()¶
- Clears the list of items. 
 - 
collectPrimitiveBases()¶
- Returns primitives used to construct the PropertySet. 
 - 
copy()¶
- Returns a deep copy of the object. 
 - 
getConstructionPoints()¶
- Returns the points used to construct the primitive. 
 - 
getDim()¶
- Returns the dimensionality of the items. 
 - 
getDirectedID()¶
- Returns the primitive ID where a negative sign means that reversed ordering is used. 
 - 
getID()¶
- Returns the primitive ID. 
 - 
getItems()¶
- Returns the list of items. 
 - 
getManifoldClass()¶
- Returns the manifold class expected from items. 
 - 
getName()¶
- Returns the name of the set. 
 - 
getNumItems()¶
- Returns the number of items in the property set. 
 - 
getPrimitives()¶
- Returns a list of primitives used to construct the primitive with no double entries. 
 - 
getTag()¶
- Returns the tag used for this property set. 
 - 
getUnderlyingPrimitive()¶
- Returns the underlying primitive. 
 - 
hasSameOrientation(other)¶
- Returns True if - otheris the same primitive and has the same orientation, False otherwise.
 - 
isColocated(primitive)¶
- Returns True if the two primitives are located at the same position. - Note: - This method is overwritten by subclasses. 
 - 
isReversed()¶
- returns True is the primitive is a reversed primitive. 
 - 
modifyBy(transformation)¶
- Modifies the coordinates by applying a transformation. 
 - 
setLocalScale(factor=1.0)¶
- Sets the local refinement factor. 
 - 
setName(name)¶
- Sets the name. 
 - 
substitute(sub_dict)¶
- Returns a copy of self with substitutes for the primitives used to construct it given by the dictionary - sub_dict. If a substitute for the object is given by- sub_dictthe value is returned, otherwise a new instance with substituted arguments is returned.- Note: - This method is overwritten by subclasses. 
 
- 
- 
class esys.pycad.design.ReversePrimitive(primitive)¶
- Bases: - object- A view onto a primitive creating a reverse orientation. - 
__init__(primitive)¶
- Instantiates a view onto - primitive.
 - 
collectPrimitiveBases()¶
- Returns a list of primitives used to construct the primitive. It may contain primitives twice. 
 - 
getDirectedID()¶
- Returns the primitive ID where a negative signs means that reversed ordering is used. 
 - 
getID()¶
- Returns the primitive ID. 
 - 
getUnderlyingPrimitive()¶
- Returns the underlying primitive. 
 - 
hasSameOrientation(other)¶
- Returns True if - otheris the same primitive and has the same orientation as self.
 - 
isColocated(primitive)¶
- Returns True if the two primitives are located at the same position. - Note: - This method is overwritten by subclasses. 
 - 
isReversed()¶
- returns True is the primitive is a reversed primitive. 
 - 
substitute(sub_dict)¶
- Returns a copy of self with substitutes for the primitives used to construct it given by the dictionary - sub_dict. If a substitute for the object is given by- sub_dictthe value is returned, otherwise a new instance with substituted arguments is returned.
 
- 
- 
class esys.pycad.design.TagMap(mapping={})¶
- Bases: - object- A class that allows to map tags to names. - Example: - tm=TagMap({5 : x }) tm.setMap(a=1,x=4) assert tm.getTags("a") == [ 1 ] assert tm.getTags("x") == [ 5, 4 ] assert tm.map(x=10., a=20.) == { 5 : 10, 4: 10, 1 : 20 } - 
__init__(mapping={})¶
- Initializes the mapping. - mappingdefines an initial mapping from tag to a name.
 - 
fillFromXML(iostream)¶
- Uses the XML file or string to set the mapping. 
 - 
fromDom(node)¶
- Fills names and tags from dom - node.
 - 
getMapping()¶
- Returns a dictionary where the tags define the keys and the values the corresponding names. 
 - 
getName(tag=None)¶
- Returns the name of a tag. If - tagis not present a list of all names is returned.
 - 
getTags(name=None)¶
- Returns a list of the tags assigned to - name. If name is not present a list of all tags is returned.
 - 
insert(data, default=0, **kwargs)¶
- Inserts values into the - esys.escript.Dataobject according to the given values assigned to the keywords. The default is used for tags which map onto name with unspecified values.
 - 
map(default=0, **kwargs)¶
- Returns a dictionary where the tags define the keys and the values give the values assigned to the tag via name and kwargs: - tm=TagMap(x=5) tm.setMap(a=1,x=4) print tm.map(x=10., a=20.) { 5 : 10, 4: 10, 1 : 20 } - The default is used for tags which map onto name with unspecified values. 
 - 
passToDomain(domain)¶
- Passes the tag map to the - esys.escript.Domain- domain.
 - 
setMap(**kwargs)¶
- Sets a new map where <name>=<tag> assigns the tag <tag> to name <name>. <tag> has to be an integer. If <tag> has been assigned to a name before the mapping will be overwritten. Otherwise a new mapping <tag> -> <name> is set. Notice that a single name can be assigned to different tags. 
 - 
toDOM(dom)¶
- Adds object to - dom.
 - 
writeXML(iostream=None)¶
- Serializes self as XML into - iostreamor if not present returns the XML as string.
 
-