예제 #1
0
def set_btypes(obj, bt, segm=None):
    icheck(0, AObject())
    icheck(1, ZType())
    icheck(2, NoneOr(List(UInt())))
    if segm is None:
        generalfun.set_boundary_type(obj, bt)
    else:
        generalfun.set_boundary_type(obj, bdict={bt: segm})
예제 #2
0
def remove_geom(objs):
    """ Completely removes object or list of objects

    :param objs: identifier or list of identifiers of removing objects

    :returns: None
    """
    icheck(0, UListOr1(AObject()))
    ob = objs if isinstance(objs, list) else [objs]
    c = com.objcom.RemoveGeom({"names": ob})
    flow.exec_command(c)
예제 #3
0
def raw_data(obj, what):
    icheck(0, AObject())
    t = flow.receiver.whatis(obj)
    if t == 'c2':
        return o2info.tab_cont2(obj, what)
    elif t == 'g2':
        return o2info.tab_grid2(obj, what)
    elif t == 's3':
        return o3info.tab_surf3(obj, what)
    elif t == 'g3':
        return o3info.tab_grid3(obj, what)
예제 #4
0
def copy_geom(objs):
    """ Creates deep copies of geometry objects

    :param objs: identifier or list of identifiers of objects to copy

    :returns: list of identifiers of copied objects in oder prescribed by
       input list
    """
    icheck(0, ListOr1(AObject()))
    if not isinstance(objs, list):
        objs = [objs]

    c = com.objcom.CopyGeom({"names": objs})
    flow.exec_command(c)
    return c.odered_output()
예제 #5
0
def remove_all_but(objs):
    """ Removes all geometry objects except for listed ones

    :param objs: identifier or list of identifiers of objects
       which should NOT be removed

    :returns: None
    """
    icheck(0, UListOr1(AObject()))

    if not isinstance(objs, list):
        objs = [objs]

    all_obj = flow.receiver.get_names()
    all_obj = [x for x in all_obj if x not in objs]
    remove_geom(all_obj)
예제 #6
0
def scale_geom(objs, xpc=100., ypc=100., zpc=100., refp=[0.0, 0.0, 0.0]):
    """ Scales objects

    :param objs: identifier or list of identifiers of scaling objects

    :param float xpc:

    :param float ypc:

    :param float zpc: percentages of scaling in x, y and z directions

    :param list-of-float refp: reference point as ``[x, y, z]`` which stays
       fixed after transformation

    :returns: None

    if **objs** contains only 2d objects **zpc** is ignored and could be
    ommitted, **refp** could by given as ``[x, y]``.
    """
    icheck(0, UListOr1(AObject()))
    icheck(1, Float(grthan=0.))
    icheck(2, Float(grthan=0.))
    icheck(3, Float(grthan=0.))
    icheck(4, APoint())
    # for backward compatibility check if zpc was omitted
    if isinstance(zpc, list):
        refp = zpc
        zpc = 100.
    if len(refp) == 2:
        refp = [refp[0], refp[1], 0.]

    ob = objs if isinstance(objs, list) else [objs]
    c = com.objcom.ScaleGeom({
        "names": ob,
        "xpc": xpc,
        "ypc": ypc,
        "zpc": zpc,
        "p0": refp
    })
    flow.exec_command(c)
예제 #7
0
def move_geom(objs, dx, dy, dz=0.):
    """ Moves a list of objects

    :param objs: identifier or list of identifiers of moving objects

    :param float dx:

    :param float dy:

    :param float dz: shifts in x, y and z direction. Z moves take place only
       for 3d objects

    :returns: None
    """
    icheck(0, UListOr1(AObject()))
    icheck(1, Float())
    icheck(2, Float())
    icheck(3, Float())

    ob = objs if isinstance(objs, list) else [objs]
    c = com.objcom.MoveGeom({"names": ob, "dx": dx, "dy": dy, "dz": dz})
    flow.exec_command(c)
예제 #8
0
def set_boundary_type(obj, btps=None, bfun=None, bdict=None):
    """ Mark geometrical object with boundary types.

    :param obj: geometric object identifier

    :param btps: single identifier for the whole object or list
       of identifiers for each boundary segment.

    :param  bfun: function which returns boundary type taking segment
       coordinates and old boundary type as arguments.

    :param bdict: {btype: [list-of-segment indicies]} dictionary
       which maps boundary type with object segments indicies

    Only one of **btps**, **bfun**, **bdict** arguments should be defined.

    **bfun** signature is:

       * ``(x0, y0, x1, y1, bt) -> btype`` for 2D objects, where
         *x0, y0, x1, y1* are edge end point coordinates,
         bt - old boundary type
       * ``(xc, yc, zc, bt) -> btype`` for 3D objects, where
         *xc, yc, zc* - approximate face center coordinates,
         bt - old boundary type

    If **obj** is a grid then only boundary segments will be passed
    to **bfun** function and **btps** list entries will
    be associated with boundary segments only.
    However **bdict** entries should contain global edge or face indicies.

    Example:

      .. literalinclude:: ../../testing/py/fromdoc/ex_setbtype.py
          :start-after: START OF EXAMPLE
          :end-before: END OF EXAMPLE

    """
    icheck(0, AObject())
    icheck(1, NoneOr(ListOr1(ZType())))
    icheck(3, NoneOr(Dict(ZType(), List(UInt()))))
    t = flow.receiver.whatis(obj)
    if t in ['g2', 'c2']:
        icheck(2, NoneOr(Func(narg=5)))
    else:
        icheck(2, NoneOr(Func(narg=4)))
    if [btps, bfun, bdict].count(None) != 2:
        raise InvalidArgument("One of [btps, bfun, bdict] should be not None")

    args = {'name': obj, 'whole': None, 'btypes': {}}

    if isinstance(btps, int):
        args['whole'] = btps
    elif bdict is not None:
        args['btypes'] = bdict
    else:
        g = flow.receiver.get_object(obj)
        if t == 'g2':
            if btps is not None:
                _setbt_args_g2g3btps(g, btps, args['btypes'])
            if bfun is not None:
                _setbt_args_g2bfun(g, bfun, args['btypes'])
        if t == 'g3':
            if btps is not None:
                _setbt_args_g2g3btps(g, btps, args['btypes'])
            if bfun is not None:
                _setbt_args_g3bfun(g, bfun, args['btypes'])
        if t == 'c2':
            if btps is not None:
                _setbt_args_c2s3btps(g, btps, args['btypes'])
            if bfun is not None:
                _setbt_args_c2bfun(g, bfun, args['btypes'])
        if t == 's3':
            if btps is not None:
                _setbt_args_c2s3btps(g, btps, args['btypes'])
            if bfun is not None:
                _setbt_args_s3bfun(g, bfun, args['btypes'])
    c = com.objcom.SetBType(args)
    flow.exec_command(c)
예제 #9
0
def dims(gid):
    icheck(0, AObject())
    ob = flow.receiver.get_object(gid)
    return ob.dims()