Example #1
0
def prepareCompositeIBMData(t, tb, DEPTH=2, loc='centers', frontType=1):
    dimPb = Internal.getNodeFromName(tb, 'EquationDimension')
    if dimPb is None:
        raise ValueError('EquationDimension is missing in input body tree.')
    dimPb = Internal.getValue(dimPb)
    tc = C.newPyTree()
    for nob in range(len(t[2])):
        if Internal.getType(t[2][nob]) == 'CGNSBase_t':
            basename = t[2][nob][0]
            C._addBase2PyTree(tc, basename)
    for nob in range(len(tb[2])):
        if tb[2][nob][3] == 'CGNSBase_t':
            basename = tb[2][nob][0]
            tloc = C.newPyTree([basename])
            tloc[2][1] = t[2][nob]
            tbloc = C.newPyTree([basename])
            tbloc[2][1] = tb[2][nob]
            # prepro IBM + interpolation entre blocs internes
            tloc, tcloc = prepareIBMData(tloc,
                                         tbloc,
                                         DEPTH=DEPTH,
                                         loc=loc,
                                         frontType=frontType,
                                         interp='composite')
            C._cpVars(tloc, 'centers:cellN', tcloc, 'cellN')
            tc[2][nob][2] += Internal.getZones(tcloc)
            Internal._rmNodesFromType(t[2][nob], "Zone_t")
            t[2][nob][2] += Internal.getZones(tloc)
    #
    offbodyZones = C.node2Center(t[2][-1][2])
    Internal._rmNodesByName(tc, "*TurbulentDistance*")
    Internal._rmNodesByName(tc, Internal.__FlowSolutionCenters__)
    tc[2][-1][2] += offbodyZones
    return t, tc
Example #2
0
def generateCompositeIBMMesh(tb,
                             vmin,
                             snears,
                             dfar,
                             dfarloc=0.,
                             DEPTH=2,
                             NP=0,
                             check=True,
                             merged=1,
                             sizeMax=4000000,
                             symmetry=0,
                             externalBCType='BCFarfield'):
    tbox = None
    snearsf = None
    dimPb = Internal.getNodeFromName(tb, 'EquationDimension')
    if dimPb is None:
        raise ValueError('EquationDimension is missing in input body tree.')
    dimPb = Internal.getValue(dimPb)
    model = Internal.getNodeFromName(tb, 'GoverningEquations')
    refstate = C.getState(tb)
    # list of near body meshes
    t = Internal.copyRef(tb)
    Internal._rmNodesFromType(t, "Zone_t")
    snearsExt = []
    tblank = Internal.copyRef(tb)

    DEPTHEXT = 3 * DEPTH + 1
    tov = Internal.rmNodesFromType(tb, 'Zone_t')
    for nob in range(len(tb[2])):
        base = tb[2][nob]
        if base[3] == 'CGNSBase_t':
            basename = base[0]
            res = generateIBMMesh(base,
                                  vmin,
                                  snears,
                                  dfarloc,
                                  DEPTH=DEPTH,
                                  NP=NP,
                                  tbox=None,
                                  snearsf=None,
                                  check=check,
                                  merged=merged,
                                  symmetry=symmetry,
                                  sizeMax=sizeMax,
                                  externalBCType='BCDummy',
                                  to=None,
                                  composite=1,
                                  mergeByParents=False)

            res = Internal.getZones(res)
            t[2][nob][2] = res
            # blanking box for off-body mesh
            extFacesL = C.extractBCOfType(res, "BCDummy")
            bbl = G.bbox(extFacesL)
            lMax = 0.
            for extf in extFacesL:
                if dimPb == 2: extf = T.subzone(extf, (1, 1, 1), (-1, 1, 1))
                extf = G.getVolumeMap(extf)
                dxloc = C.getValue(extf, 'centers:vol', 0)
                if dimPb == 3:
                    dxloc = dxloc**0.5
                lMax = max(lMax, dxloc)
                snearsExt.append(dxloc)
                tov[2][nob][2].append(extf)

            # ATTENTION : engendre une boite parallelepipedique - peut ne pas etre valide dans
            # les cas ou le maillage cartesien proche corps n est pas parallelepipedique
            # A ameliorer
            # IDEM pour les conditions aux limites dans octree2StructLoc et generateIBMMesh
            xminb = bbl[0] + DEPTHEXT * lMax
            xmaxb = bbl[3] - DEPTHEXT * lMax
            yminb = bbl[1] + DEPTHEXT * lMax
            ymaxb = bbl[4] - DEPTHEXT * lMax
            if dimPb == 3:
                zminb = bbl[2] + DEPTHEXT * lMax
                zmaxb = bbl[5] - DEPTHEXT * lMax
                blankingBoxL = G.cart(
                    (xminb, yminb, zminb),
                    (xmaxb - xminb, ymaxb - yminb, zmaxb - zminb), (2, 2, 2))
            else:
                blankingBoxL = G.cart((xminb, yminb, 0.),
                                      (xmaxb - xminb, ymaxb - yminb, 1.),
                                      (2, 2, 1))
            blankingBoxL = P.exteriorFaces(blankingBoxL)
            tblank[2][nob][2] = [blankingBoxL]

    tcart = generateIBMMesh(tov,
                            vmin,
                            snearsExt,
                            dfar,
                            DEPTH=DEPTH,
                            NP=NP,
                            tbox=tbox,
                            snearsf=snearsf,
                            check=check,
                            merged=1,
                            sizeMax=sizeMax,
                            symmetry=symmetry,
                            externalBCType='BCFarfield',
                            to=None,
                            mergeByParents=True)
    tcart[2][1][0] = 'OffBody'
    C._rmBCOfType(
        t, 'BCDummy')  # near body grids external borders must be BCOverlap
    t = C.fillEmptyBCWith(t, 'ov_ext', 'BCOverlap', dim=dimPb)
    t = C.mergeTrees(t, tcart)
    model = Internal.getValue(model)
    C._addState(t, 'GoverningEquations', model)
    C._addState(t, 'EquationDimension', dimPb)
    C._addState(t, state=refstate)
    return t, tblank