Esempio n. 1
0
def fillEmptyBCWith():
    if CTK.t == []: return
    typeBC = VARS[4].get()
    if typeBC not in Internal.KNOWNBCS:
        nameBC = typeBC
        typeBC = 'FamilySpecified:' + typeBC
    else:
        nameBC = typeBC

    node = Internal.getNodeFromName(CTK.t, 'EquationDimension')
    if node is not None: ndim = Internal.getValue(node)
    else:
        CTK.TXT.insert('START',
                       'EquationDimension not found (tkState). Using 3D.\n')
        CTK.TXT.insert('START', 'Warning: ', 'Warning')
        ndim = 3

    CTK.saveTree()
    nzs = CPlot.getSelectedZones()
    if CTK.__MAINTREE__ <= 0 or nzs == []:
        C._fillEmptyBCWith(CTK.t, nameBC + 'Fill', typeBC, dim=ndim)
    else:
        for nz in nzs:
            nob = CTK.Nb[nz] + 1
            noz = CTK.Nz[nz]
            C._fillEmptyBCWith(CTK.t[2][nob][2][noz],
                               nameBC + 'Fill',
                               typeBC,
                               dim=ndim)
    CTK.TXT.insert('START', 'Empty BCs filled.\n')
    CTK.TKTREE.updateApp()
    check()
Esempio n. 2
0
# - importVariables (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Post.PyTree as P
import Converter.Internal as Internal
import KCore.test as test

# z2 sans solutions
z1 = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (3, 3, 3))
C._addBC2Zone(z1, 'overlap', 'BCOverlap', 'imin')
C._fillEmptyBCWith(z1, 'nref', 'BCFarfield')
t1 = C.newPyTree(['Base', z1])
t2 = Internal.copyRef(t1)
C._initVars(t1, 'centers:cellN', 1.)
C._initVars(t1, 'Pressure', 10.)
C._initVars(t1, 'Density', 1.)
C._addState(t1[2][1], 'Mach', 0.6)
C._addState(t2[2][1], 'Mach', 0.6)
t2 = P.importVariables(t1, t2)
test.testT(t2, 1)

# z2 avec cellN = 0
C._initVars(t2, 'centers:cellN', 0.)
t2 = P.importVariables(t1, t2)
test.testT(t2, 2)

# z1 en centres avec z2 sans solution
Internal._rmNodesByType(t2, 'FlowSolution_t')
t1 = C.node2Center(t1)
t2 = P.importVariables(t1, t2)
test.testT(t2, 3)
# - blanCells (pyTree) -
# - cas 2D -
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import Geom.PyTree as D
import KCore.test as test

surf = D.circle((0,0,0), 0.5, 20)

a = G.cart((-1.,-1.,0.),(0.1,0.1,1), (20,20,1))
C._addBC2Zone(a, 'ov', 'BCOverlap', 'jmin')
t = C.newPyTree(['Cart',2,a])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
C._fillEmptyBCWith(t, 'wall', 'BCWall')
C._addVars(t, 'Density')
C._initVars(t, 'centers:cellN', 1.)
bodies = [[surf]]
criterions = ['cell_intersect', 'cell_intersect_opt', 'center_in']
# Matrice de masquage (arbre d'assemblage)
import numpy
BM = numpy.array([[1]])
c = 1
for delta in [0.,0.1]:
    for type in criterions:
        if (type == 'cell_intersect_opt' and delta > 0): c += 1
        else:
            t2 = X.blankCells(t, bodies, BM,
                              blankingType=type, delta=delta,
                              dim=2)
            test.testT(t2,c)
Esempio n. 4
0
# - prefixDnrInSubRegions (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Connector.PyTree as X
import Converter.elsAProfile as elsAProfile

a = G.cylinder((0, 0, 0), 1., 3., 360, 0, 1, (200, 30, 2))
a[0] = 'cylindre1'
C._addBC2Zone(a, 'wall1', 'BCWall', 'jmin')
C._addBC2Zone(a, 'ov1', 'BCOverlap', 'jmax')
b = G.cylinder((4, 0, 0), 1., 3., 360, 0, 1, (200, 30, 2))
b[0] = 'cylindre2'
C._addBC2Zone(b, 'wall1', 'BCWall', 'jmin')
C._addBC2Zone(b, 'ov1', 'BCOverlap', 'jmax')
c = G.cart((-5., -7.5, 0), (15. / 200, 15. / 200, 1), (200, 200, 2))
t = C.newPyTree(['Corps1', 'Corps2', 'Bgrd'])
t[2][1][2].append(a)
t[2][2][2].append(b)
t[2][3][2].append(c)
t = X.connectMatch(t, dim=2)
C._fillEmptyBCWith(t, 'nref', 'BCFarfield', dim=2)
t = X.applyBCOverlaps(t, depth=1)
t = X.setInterpolations(t, loc='cell')
elsAProfile._prefixDnrInSubRegions(t)
C.convertPyTree2File(t, "out.cgns")
import Converter.Internal as Internal
import Transform.PyTree as T
import KCore.test as test

LOCAL = test.getLocal()

NK = 2
DIM = 3
if NK == 2: DIM = 2
a = G.cylinder((0, 0, 0), 1, 2, 10, 130, 1, (60, 20, NK))
a[0] = 'cyl1'
b = G.cylinder((0, 0, 0), 1, 1.5, 0, 30, 1, (30, 20, NK))
b[0] = 'cyl2'
C._addBC2Zone(a, 'wall', 'BCWall', 'jmin')
C._addBC2Zone(b, 'wall', 'BCWall', 'jmin')
C._fillEmptyBCWith(b, 'overlap', 'BCOverlap', dim=DIM)
t = C.newPyTree(['Base', 'Base2'])
t[2][1][2] = [a]
t[2][2][2] = [b]
C._initVars(t, 'Density', 1.)
C._initVars(t, 'centers:cellN', 1)
t = X.connectMatchPeriodic(t,
                           rotationCenter=[0., 0., 0.],
                           rotationAngle=[0., 0., 120.],
                           dim=DIM)
C._fillEmptyBCWith(t, 'nref', 'BCFarfield', dim=DIM)
C._addState(t[2][1], 'EquationDimension', DIM)
t = X.applyBCOverlaps(t, depth=1)
t = X.setInterpolations(t,
                        double_wall=1,
                        storage='direct',
Esempio n. 6
0
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import KCore.test as test
import Transform.PyTree as T
import Converter.Internal as Internal

NK = 51
a = G.cylinder((0, 0, 0), 1, 2, 10, 130, 4., (60, 20, NK))
a[0] = 'cyl1'
b = G.cart((0.4, 1.2, -0.3), (0.04, 0.04, 0.1), (11, 11, 21))
a = X.connectMatchPeriodic(a,
                           rotationCenter=[0., 0., 0.],
                           rotationAngle=[0., 0., 120.])
C._fillEmptyBCWith(a, "wall", "BCWall")
C._addBC2Zone(a,
              'overlapdd',
              'BCOverlap',
              'kmin',
              zoneDonor=[b],
              rangeDonor='doubly_defined')  #dd
#
C._addBC2Zone(b, 'overlap', 'BCOverlap', 'kmax')
C._fillEmptyBCWith(b, "wall", "BCWall")
for rangel in ['imin', 'imax', 'jmin', 'jmax']:
    C._addBC2Zone(b,
                  'overlapdd',
                  'BCOverlap',
                  rangel,
                  zoneDonor=[a],
                  rangeDonor='doubly_defined')
InterDict = X.getIntersectingDomains(t, method='hybrid')
t2 = X.optimizeOverlap(t, intersectionsDict=interDict)
test.testT(t2, 5)
# Second test:
t = X.optimizeOverlap(t)
test.testT(t, 2)

# cas double wall
a = G.cylinder((0, 0, 0), 1, 2, 0, 360, 1, (60, 20, 2))
b = G.cylinder((0, 0, 0), 1, 2, 3, 160, 1, (30, 20, 2))
C._addBC2Zone(a, 'wall', 'BCWall', 'jmin')
C._addBC2Zone(a, 'match', 'BCMatch', 'imin', a, 'imax', trirac=[1, 2, 3])
C._addBC2Zone(a, 'match', 'BCMatch', 'imax', a, 'imin', trirac=[1, 2, 3])
C._addBC2Zone(a, 'nref', 'BCFarfield', 'jmax')
C._addBC2Zone(b, 'wall', 'BCWall', 'jmin')
C._fillEmptyBCWith(b, 'overlap', 'BCOverlap', dim=2)
t = C.newPyTree(['Base', a, 'Base2', b])
C._initVars(t, 'Density', 1.)
C._initVars(t, 'centers:cellN', 1)
C._addState(t[2][1], 'EquationDimension', 2)
t = X.connectMatchPeriodic(t, translation=(0, 0, 1))
# Same as third test, but now using an Intersection Dictionnary
InterDict = X.getIntersectingDomains(t, method='hybrid')
t3 = X.optimizeOverlap(t,
                       double_wall=1,
                       priorities=['Base2', 0, 'Base', 1],
                       intersectionsDict=interDict)
test.testT(t3, 6)
# Third test:
t = X.optimizeOverlap(t, double_wall=1, priorities=['Base2', 0, 'Base', 1])
test.testT(t, 3)
Esempio n. 8
0
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import KCore.test as test

a = G.cylinder((0, 0, 0), 1, 2, 0, 360, 1, (60, 20, 3))
b = G.cylinder((0, 0, 0), 1, 2, 3, 160, 1, (30, 10, 3))
C._addBC2Zone(a, 'wall', 'BCWall', 'jmin')
C._addBC2Zone(a, 'match', 'BCMatch', 'imin', a, 'imax', trirac=[1, 2, 3])
C._addBC2Zone(a, 'match', 'BCMatch', 'imax', a, 'imin', trirac=[1, 2, 3])
C._addBC2Zone(b, 'wall', 'BCWall', 'jmin')
C._addBC2Zone(b, 'overlap', 'BCOverlap', 'imin')
C._addBC2Zone(b, 'overlap', 'BCOverlap', 'imax')
tD = C.newPyTree(['Base', a])
tR = C.newPyTree(['Base', b])
C._fillEmptyBCWith(tD, 'nref', 'BCFarfield')
C._fillEmptyBCWith(tR, 'nref', 'BCFarfield')

C._initVars(tD, 'Density', 1.)
C._initVars(tD, 'cellN', 1.)
C._initVars(tD, 'MomentumX', -0.1)
C._initVars(tD, 'MomentumY', -0.2)
tR = X.applyBCOverlaps(tR, depth=1)
tD = X.setInterpData(tR,
                     tD,
                     double_wall=1,
                     loc='centers',
                     storage='inverse',
                     order=3)
info = X.setInterpTransfersD(tD, variables=['MomentumX'])
test.testO(info, 1)