Пример #1
0
# - extractMesh (pyTree) -
import Converter.PyTree as C
import Post.PyTree as P
import Generator.PyTree as G
import KCore.test as test

# Maillage en noeuds
ni = 30
nj = 40
nk = 10
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
m = C.initVars(m, 'Density', 1)
m = C.initVars(m, 'MomentumX', 1)
m = C.initVars(m, 'centers:cellN', 1)

a = G.cart((0., 0., 0.), (0.01, 0.01, 0.1), (40, 40, 1))
for i in [2]:
    a2 = P.extractMesh(m, a, order=i)
    test.testT(a2, i)
Пример #2
0
K = 1./math.sqrt(0.001*2*math.pi)
K2 = 1./(2*0.001)


def F(x, y):
    if 0.05 < abs(y) < 0.7:
        return K*math.exp(-(x-0.5)**2*K2)
    else:
        return 0.

o = C.initVars(o, 'F', F, ['CoordinateX', 'CoordinateY'])

# Computation of the indicator onto the octree mesh
npts = Internal.getZoneDim(o)[1]
o2, valInf, valSup = P.computeIndicatorField(o, 'F', nbTargetPts=1.2*npts,
                                             refineFinestLevel=0, bodies=[naca])

# Adaptation of the octree wrt the indicator
o2 = G.adaptOctree(o2)

# Interpolate solution on adapted octree
o = C.rmVars(o, ['centers:indicator', 'F'])
o2 = P.extractMesh([o], o2)

# Save file
t = C.newPyTree(['Octree', 'Octree2'])
t[2][1][2] += [o]
t[2][2][2] = [o2]
C.convertPyTree2File(t, 'out.cgns')
Пример #3
0
# - extractMesh (PyTree) -
# Tests pour mode=accurate
import Converter.PyTree as C
import Post.PyTree as P
import Generator.PyTree as G
import KCore.test as test

# extraction
b = G.cart((0.5,0.5,0.5),(1,1,1),(9,9,9))

# STRUCT
a = G.cart((0,0,0),(1,1,1),(10,10,10))
a = C.initVars(a, '{centers:Density}={centers:CoordinateX}')
b = P.extractMesh(a, b, mode='accurate')
test.testT(b, 1)

# TETRA
a = G.cartTetra((0,0,0),(1,1,1),(10,10,10))
a = C.initVars(a, '{centers:Density}={centers:CoordinateX}')
b = P.extractMesh(a, b, mode='accurate')
test.testT(b, 2)

# HEXA
a = G.cartHexa((0,0,0),(1,1,1),(10,10,10))
a = C.initVars(a, '{centers:Density}={centers:CoordinateX}')
b = P.extractMesh(a, b, mode='accurate')
test.testT(b, 2)

# NGON
a = G.cartNGon((0,0,0),(1,1,1),(10,10,10))
a = C.initVars(a, '{centers:Density}={centers:CoordinateX}')
Пример #4
0
# Project the sensor field F on the unstructured octree:
o2 = P.computeIndicatorValue(o, res0, 'F')

# Computation of the indicator onto the unstructured octree mesh
npts = Internal.getZoneDim(o)[1]
o2, valInf, valSup = P.computeIndicatorField(o2,
                                             'F',
                                             nbTargetPts=1.1 * npts,
                                             refineFinestLevel=0,
                                             bodies=[naca])

# Adaptation of the octree wrt the indicator
o2 = G.adaptOctree(o2)

# Creation of the adapted structured Cartesian grids
res = G.octree2Struct(o2, vmin=5, ext=0)

# Undefined BC: external borders are defined by farfield BCs
res = C.fillEmptyBCWith(res, 'nref', 'BCFarfield', dim=2)

# Interpolate solution on adapted set of Cartesian grids
res0 = C.rmVars(res0, ['centers:indicator', 'F'])
res = P.extractMesh(res0, res)

# Save file
t = C.newPyTree(['CARTESIAN0', 'CARTESIAN'])
t[2][1][2] += res0
t[2][2][2] += res
C.convertPyTree2File(t, 'out.cgns')
    z = u
    return (x, y, z)


# Create an init function
def FI(x, y, z):
    return x * x + y * y + z * z


# Creation de la surface portant la solution
a = D.surface(FS, 50)
a = C.initVars(a, 'sol', FI, ['CoordinateX', 'CoordinateY', 'CoordinateZ'])

# Creation de la surface d'extraction
e = D.surface(FS, 100)
e = P.extractMesh([a], e, order=2, tol=1.e-3)
test.testT(e, 1)

# unstructured surface
a = C.convertArray2Tetra(a)
a = C.initVars(a, 'sol', FI, ['CoordinateX', 'CoordinateY', 'CoordinateZ'])
e = C.convertArray2Tetra(e)
e = P.extractMesh([a], e, order=2, tol=1.e-3)
test.testT(e, 2)

# arbre
t = C.newPyTree(['Base', 2])
t[2][1][2] += [a]
a = C.initVars(a, 'sol', FI, ['CoordinateX', 'CoordinateY', 'CoordinateZ'])
e = P.extractMesh(t, e, order=2, tol=1.e-3)
test.testT(e, 3)
# - extractMesh (pyTree) -
import Converter.PyTree as C
import Post.PyTree as P
import Generator.PyTree as G

ni = 30
nj = 40
nk = 10
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
m = C.initVars(m, 'Density', 2.)
m = C.initVars(m, 'centers:cellN', 1)

# Extraction mesh
a = G.cart((0., 0., 0.5), (1., 0.1, 1.), (20, 20, 1))
a[0] = 'extraction'

# Extract solution on extraction mesh
a = P.extractMesh(m, a)
t = C.newPyTree(['Solution', 3, 'Extraction', 2])
t[2][1][2].append(m)
t[2][2][2] += [a]
C.convertPyTree2File(a, 'out.cgns')
# - extractMesh (pyTree) -
import Converter.PyTree as C
import Post.PyTree as P
import Generator.PyTree as G
import KCore.test as test

# test arbre
# Maillage en noeuds
ni = 30
nj = 40
nk = 10
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
m = C.initVars(m, 'Density', 1)
m = C.initVars(m, 'MomentumX', 1)
m = C.initVars(m, 'centers:cellN', 1)
m = C.addBC2Zone(m, 'overlap', 'BCOverlap', 'imin')
m = C.fillEmptyBCWith(m, 'nref', 'BCFarfield')
t = C.newPyTree(['Base'])
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
t[2][1][2].append(m)
a = G.cart((0., 0., 0.), (0.01, 0.01, 0.1), (40, 40, 1))
surf = P.extractMesh(t, a)
test.testT(surf, 1)

a = G.cart((0., 0., 0.), (0.01, 0.01, 0.1), (40, 40, 2))
a = C.addBC2Zone(a, 'wall', 'BCWall', 'kmin')
a = C.fillEmptyBCWith(a, 'ov', 'BCOverlap')
surf = P.extractMesh(t, a)
test.testT(surf, 2)