Exemplo n.º 1
0
def mesh(entities, *args, **kwargs):
    """ Meshes a body using Cubits internal meshing function, that behaves differently

    :param entities: list or single entity to mesh
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    idList = _functions.listIdString(entities)
    if idList[0] == _common.BodyTypes.body:
        idList = _functions.listIdString(_functions.getEntitiesFromObject(entities, _common.BodyTypes.volume))
    _system.cubitCmd('mesh {0[0]} {0[1]} {1} {2}'.format(idList,
                                                         _functions.listStr(args),
                                                         _functions.listKeywordString(kwargs)))
Exemplo n.º 2
0
def imprintCurve(surface, curve, *args, **kwargs):
    """ Imprint a curve onto a surface

    :param surface: Surface to imprint on
    :param curve: Curve to imprint
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('imprint surface {0} curve {1[1]} {2} {3}'
                     .format(_functions.listIdString(surface, _common.BodyTypes.surface),
                             _functions.listIdString(curve, _common.BodyTypes.curve),
                             _functions.listStr(args),
                             _functions.listKeywordString(kwargs)))
Exemplo n.º 3
0
def createBlockFromElements(blockId, elementType, objects=None):
    """ Create a block with elements, limiting it to a specific entity
    :param blockId: the block id
    :param elementType: the element type, eg. hex
    :param objects: list or single element id or entity ids
    :return: None
    """
    try:
        idList = _functions.listIdString(objects)
        if idList[0] == _common.BodyTypes.body:
            idList = _functions.listIdString(_functions.getEntitiesFromObject(objects, _common.BodyTypes.volume))
        cmdStr = 'block {0} {1} in {2[0]} {2[1]}'.format(blockId, elementType, idList)
    except _system.AdvCubitException:
        cmdStr = 'block {0} {1} {2}'.format(blockId, elementType, _functions.listStr(objects))
    _system.cubitCmd(cmdStr)
Exemplo n.º 4
0
def setMeshScheme(entities, meshScheme, *args, **kwargs):
    """ Assign a meshing scheme to a body

    :param entities: list or single entity
    :param meshScheme: the scheme
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    idList = _functions.listIdString(entities)
    if idList[0] == _common.BodyTypes.body:
        idList = _functions.listIdString(_functions.getEntitiesFromObject(entities, _common.BodyTypes.volume))
    _system.cubitCmd('{0[0]} {0[1]} scheme {1} {2} {3}'.format(idList, meshScheme,
                                                               _functions.listStr(args),
                                                               _functions.listKeywordString(kwargs)))
Exemplo n.º 5
0
def delete(entities):
    """ Delete a list or single entity

    :param entities: the entity or list of entities to be deleted
    :return: None
    """
    _system.cubitCmd('delete {0[0]} {0[1]}'.format(_functions.listIdString(entities)))
Exemplo n.º 6
0
def createSideset(entities, sidesetId):
    """ Create a side set

    :param entities: list of entities to assign to side set
    :param sidesetId: the id number of the sideset
    :return: None
    """
    _system.cubitCmd('sideset {0} {1[0]} {1[1]}'.format(sidesetId, _functions.listIdString(entities)))
Exemplo n.º 7
0
def createBlock(entities, blockId):
    """ Assign a entity to a block

    :param entities: the entity or list of entities to be assigned
    :param blockId: the block id
    :return: None
    """
    _system.cubitCmd('block {0} {1[0]} {1[1]}'.format(blockId, _functions.listIdString(entities)))
Exemplo n.º 8
0
def createNodeset(entities, nodesetId):
    """ Adds entities to or creates node set

    :param entities: list of entities
    :param bodyType: type of entities
    :return: None
    """
    _system.cubitCmd('nodeset {0} {1[0]} {1[1]}'.format(nodesetId, _functions.listIdString(entities)))
Exemplo n.º 9
0
def setName(entities, name):
    """ Set a name for a single entity or a list of entities

    :param entities: single or list of entities
    :param name: name to be set
    :return: None
    """
    _system.cubitCmd('{0[0]} {0[1]} rename "{1}"'.format(
        _functions.listIdString(entities), name))
Exemplo n.º 10
0
def createBlock(entities, blockId):
    """ Assign a entity to a block

    :param entities: the entity or list of entities to be assigned
    :param blockId: the block id
    :return: None
    """
    _system.cubitCmd('block {0} add {1[0]} {1[1]}'.format(
        blockId, _functions.listIdString(entities)))
Exemplo n.º 11
0
def createBlockFromElements(blockId, elementType, objects=None):
    """ Create a block with elements, limiting it to a specific entity
    :param blockId: the block id
    :param elementType: the element type, eg. hex
    :param objects: list or single element id or entity ids
    :return: None
    """
    try:
        idList = _functions.listIdString(objects)
        if idList[0] == _common.BodyTypes.body:
            idList = _functions.listIdString(
                _functions.getEntitiesFromObject(objects,
                                                 _common.BodyTypes.volume))
        cmdStr = 'block {0} {1} in {2[0]} {2[1]}'.format(
            blockId, elementType, idList)
    except _system.AdvCubitException:
        cmdStr = 'block {0} {1} {2}'.format(blockId, elementType,
                                            _functions.listStr(objects))
    _system.cubitCmd(cmdStr)
Exemplo n.º 12
0
def sweepMesh(body, sources, targets, *args, **kwargs):
    """ set the meshing scheme of a volume to sweep

    :param body: the body
    :param sources: list/single source surface
    :param targets: list/single target surface
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    if not isinstance(body, _system.cubitWrapper.Body) and not isinstance(body, _system.cubitWrapper.Volume):
        raise _system.AdvCubitException('Object is not a valid cubit entity "{0}"'.format(body))
    _system.cubitCmd('volume {0} scheme sweep source {1[1]} target {2[1]} {3} {4}'
                     .format(body.volumes()[0].id(),
                             _functions.listIdString(sources, _common.BodyTypes.surface),
                             _functions.listIdString(targets, _common.BodyTypes.surface),
                             _functions.listStr(args),
                             _functions.listKeywordString(kwargs)))
    mesh(body.volumes()[0])
Exemplo n.º 13
0
def sectionCut(entities, plane='x', *args, **kwargs):
    """ Section cut a entity or list of entities
    :param entities: the entity or a list of entities
    :param plane: plane to cut at: x, y, z
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('section {0[0]} {0[1]} {1}plane {2} {3}'.format(_functions.listIdString(entities), plane,
                                                                     _functions.listStr(args),
                                                                     _functions.listKeywordString(kwargs)))
Exemplo n.º 14
0
def intersect(bodies, *args, **kwargs):
    """ Create the logical AND of bodies

    :param bodies: list of bodies
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: intersected body
    """
    _system.cubitCmd('intersect {0[0]} {0[1]} {1} {2}'.format(_functions.listIdString(bodies),
                                                              _functions.listStr(args),
                                                              _functions.listKeywordString(kwargs)))
    return _transform.getLastBody()
Exemplo n.º 15
0
def rotate(entities, angle, axis='z', *args, **kwargs):
    """ Rotate a entity
    :param entities: the entity or list of entities
    :param angle: angle in degrees
    :param axis: coordinate system axis x, y, z
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('rotate {0[0]} {0[1]} angle {1} about {2} {3} {4}'.format(
        _functions.listIdString(entities), angle, axis,
        _functions.listStr(args), _functions.listKeywordString(kwargs)))
Exemplo n.º 16
0
def intersect(bodies, *args, **kwargs):
    """ Create the logical AND of bodies

    :param bodies: list of bodies
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: intersected body
    """
    _system.cubitCmd('intersect {0[0]} {0[1]} {1} {2}'.format(
        _functions.listIdString(bodies), _functions.listStr(args),
        _functions.listKeywordString(kwargs)))
    return _transform.getLastBody()
Exemplo n.º 17
0
def meshQuality(entities, elementType='', *args, **kwargs):
    """ Function to check the quality of the mesh
    :param entities: list of entities or single body, None gives all
    :param elementType: mesh element type
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('quality {0[0]} {0[1]} {1} {2} {3}'.format(_functions.listIdString(entities),
                                                                elementType,
                                                                _functions.listStr(args),
                                                                _functions.listKeywordString(kwargs)))
Exemplo n.º 18
0
def setInterval(entities, interval, *args, **kwargs):
    """ Set the number of intervals for a curve

    :param entities: the base curve
    :param interval: number of intervals
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('{0[0]} {0[1]} interval {1} {2} {3}'.format(_functions.listIdString(entities), interval,
                                                                 _functions.listStr(args),
                                                                 _functions.listKeywordString(kwargs)))
Exemplo n.º 19
0
def rotate(entities, angle, axis='z', *args, **kwargs):
    """ Rotate a entity
    :param entities: the entity or list of entities
    :param angle: angle in degrees
    :param axis: coordinate system axis x, y, z
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('rotate {0[0]} {0[1]} angle {1} about {2} {3} {4}'.format(_functions.listIdString(entities),
                                                                               angle, axis,
                                                                               _functions.listStr(args),
                                                                               _functions.listKeywordString(kwargs)))
Exemplo n.º 20
0
def webcut(entities, plane='x', offset=0, *args, **kwargs):
    """
    :param entities: entities or single one to cut
    :param plane: plane: x, y, z
    :param offset: offset from origin
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd(
        'webcut {0[0]} {0[1]} with plane {1}plane offset {2} {3} {4}'.format(
            _functions.listIdString(entities), plane, offset,
            _functions.listStr(args), _functions.listKeywordString(kwargs)))
Exemplo n.º 21
0
def setAutoSize(entities, factor, *args, **kwargs):
    """ Set auto size on a surface or curve

    :param entities: list or single entity
    :param factor: the auto size factor
    :param propagate: flag for propagation
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('{0[0]} {0[1]} size auto factor {1} {2} {3}'.format(_functions.listIdString(entities), factor,
                                                                         _functions.listStr(args),
                                                                         _functions.listKeywordString(kwargs)))
Exemplo n.º 22
0
 def test_list_id_str(self):
     v = _system.cubitWrapper.brick(1, 1, 1)
     self.assertEqual(_functions.listIdString(v), (_common.BodyTypes.body, ' 1'))
     self.assertEqual(_functions.listIdString(v.bodies()), (_common.BodyTypes.body, ' 1'))
     self.assertEqual(_functions.listIdString(v.volumes()), (_common.BodyTypes.volume, ' 1'))
     self.assertEqual(_functions.listIdString(v.surfaces()), (_common.BodyTypes.surface, ' 1 2 3 4 5 6'))
     self.assertEqual(_functions.listIdString(v.curves()), (_common.BodyTypes.curve, ' 1 2 3 4 5 6 7 8 9 10 11 12'))
     self.assertEqual(_functions.listIdString(v.vertices()), (_common.BodyTypes.vertex, ' 1 2 3 4 5 6 7 8'))
Exemplo n.º 23
0
def copyReflect(entities, plane='x', *args, **kwargs):
    """ Reflect and copy a list of entities

    :param entities: list or single base entity
    :param plane: reflection plane x, y, z
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: created entity
    """
    # TODO get list of entities back
    _system.cubitCmd('{0[0]} {0[1]} copy reflect {1} {2} {3}'.format(_functions.listIdString(entities), plane,
                                                                     _functions.listStr(args),
                                                                     _functions.listKeywordString(kwargs)))
    return getLastBody()
Exemplo n.º 24
0
def webcut(entities, plane='x', offset=0, *args, **kwargs):
    """
    :param entities: entities or single one to cut
    :param plane: plane: x, y, z
    :param offset: offset from origin
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd(
        'webcut {0[0]} {0[1]} with plane {1}plane offset {2} {3} {4}'.format(_functions.listIdString(entities),
                                                                             plane, offset,
                                                                             _functions.listStr(args),
                                                                             _functions.listKeywordString(kwargs)))
Exemplo n.º 25
0
def merge(entities=None, *args, **kwargs):
    """ Merge a list of bodies

    :param entities: list of bodies or None
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    if entities is None:
        mergeAll(*args, **kwargs)
    else:
        _system.cubitCmd('merge {0[0]} {0[1]} {1} {2}'.format(_functions.listIdString(entities),
                                                              _functions.listStr(args),
                                                              _functions.listKeywordString(kwargs)))
Exemplo n.º 26
0
 def test_list_id_str(self):
     v = _system.cubitWrapper.brick(1, 1, 1)
     self.assertEqual(_functions.listIdString(v),
                      (_common.BodyTypes.body, ' 1'))
     self.assertEqual(_functions.listIdString(v.bodies()),
                      (_common.BodyTypes.body, ' 1'))
     self.assertEqual(_functions.listIdString(v.volumes()),
                      (_common.BodyTypes.volume, ' 1'))
     self.assertEqual(_functions.listIdString(v.surfaces()),
                      (_common.BodyTypes.surface, ' 1 2 3 4 5 6'))
     self.assertEqual(
         _functions.listIdString(v.curves()),
         (_common.BodyTypes.curve, ' 1 2 3 4 5 6 7 8 9 10 11 12'))
     self.assertEqual(_functions.listIdString(v.vertices()),
                      (_common.BodyTypes.vertex, ' 1 2 3 4 5 6 7 8'))
Exemplo n.º 27
0
def setColor(entities, color):
    """ Set the color for a single entity or a list of entities

    Colors available are:
    red green yellow magenta khaki cyan white skyblue gold lightblue lightgreen salmon coral pink purple paleturquoise
    lightsalmon springgreen lightcyan orange seagreen pink turquoise greenyellow powderblue mediumturquoise, grey
    tomato lightcyan dodgerblue aquamarine lightgoldenrodyellow darkgreen lightcoral mediumslateblue lightseagreen
    goldenrod indianred mediumspringgreen darkturquoise yellowgreen chocolate steelblue burlywood hotpink saddlebrown
    violet tan mediumseagreen thistle palegoldenrod firebrick palegreen lightyellow darksalmon orangered palevioletred
    limegreen mediumblue blueviolet deeppink beige royalblue darkkhaki lawngreen lightgoldenrod plum sandybrown
    lightslateblue orchid cadetblue peru olivedrab mediumpurple maroon lightpink darkslateblue rosybrown
    mediumvioletred lightsteelblue mediumaquamarine proe_background win2kgray proe_2001_top proe_2001_bottom
    wildfire_top wildfire_bottom

    :param entities: single or list of entities
    :param color: color, choose from available colors
    :return: None
    """

    _system.cubitCmd('color {0[0]} {0[1]} {1}'.format(
        _functions.listIdString(entities), color))