Example #1
0
for i in xrange(N):
    a = G.cart((pos, 0, 0), (1, 1, 1), (10 + i, 10, 10))
    pos += 10 + i - 1
    t[2][1][2].append(a)
t = X.connectMatch(t)
if Cmpi.rank == 0: C.convertPyTree2File(t, 'in.cgns')
Cmpi.barrier()

# lecture du squelette
a = Cmpi.convertFile2SkeletonTree('in.cgns')

# equilibrage 1
(a, dic) = D2.distribute(a, NProc=Cmpi.size, algorithm='fast', useCom=0)

# load des zones locales dans le squelette
a = Cmpi.readZones(a, 'in.cgns', rank=Cmpi.rank)

# equilibrage 2 (a partir d'un squelette charge)
(a, dic) = D2.distribute(a,
                         NProc=Cmpi.size,
                         algorithm='gradient1',
                         useCom='match')

a = D2mpi.redispatch(a)

# force toutes les zones sur 0
zones = Internal.getNodesFromType(a, 'Zone_t')
for z in zones:
    nodes = Internal.getNodesFromName(z, 'proc')
    Internal.setValue(nodes[0], 0)
import KCore.test as test

LOCAL = test.getLocal()

# Cree le fichier test HDF
if Cmpi.rank == 0:
    a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
    b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10))
    t = C.newPyTree(['Base', a, b])
    C.convertPyTree2File(t, LOCAL + '/test.hdf')
Cmpi.barrier()

# Relit des zones par procs
t = Cmpi.convertFile2SkeletonTree(LOCAL + '/test.hdf')
(t, dic) = Distributor2.distribute(t, NProc=2, algorithm='fast')
t = Cmpi.readZones(t, LOCAL + '/test.hdf', rank=Cmpi.rank)
if Cmpi.rank == 0: test.testT(t, 1)

# Cree le fichier test ADF
if Cmpi.rank == 0:
    a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
    b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10))
    t = C.newPyTree(['Base', a, b])
    C.convertPyTree2File(t, LOCAL + '/test.adf')
Cmpi.barrier()

# Relit des zones par procs
t = Cmpi.convertFile2SkeletonTree(LOCAL + '/test.adf')
(t, dic) = Distributor2.distribute(t, NProc=2, algorithm='fast')
t = Cmpi.readZones(t, LOCAL + '/test.adf', rank=Cmpi.rank)
if Cmpi.rank == 0:
Example #3
0
pos = 0
for i in xrange(N):
    a = G.cart((pos, 0, 0), (1, 1, 1), (10 + i, 10, 10))
    pos += 10 + i - 1
    t[2][1][2].append(a)
t = C.initVars(t, '{centers:Density} = {CoordinateX} + {CoordinateY}')
t = X.connectMatch(t)
if (Cmpi.rank == 0): C.convertPyTree2File(t, 'in.cgns')
Cmpi.barrier()

# lecture du squelette
sk = Cmpi.convertFile2SkeletonTree('in.cgns')

# equilibrage
(sk, dic) = Distributor2.distribute(sk,
                                    NProc=Cmpi.size,
                                    algorithm='gradient0',
                                    useCom='match')

# load des zones locales dans le squelette
a = Cmpi.readZones(sk, 'in.cgns', proc=Cmpi.rank)

# center2Node
a = Cmpi.center2Node(a, 'centers:Density')
# a est maintenant un arbre partiel
a = C.rmVars(a, 'centers:Density')

# Reconstruit l'arbre complet a l'ecriture
if (Cmpi.rank == 0):
    test.testT(a, 1)
Example #4
0
import Distributor2.PyTree as D2
import Converter.PyTree as C
import Connector.PyTree as X
import KCore.test as test
import Converter.Mpi as Cmpi

N = 11

# Cas test
t = C.newPyTree(['Base'])
off = 0
for i in range(N):
    a = G.cart( (off,0,0), (1,1,1), (10+i, 10, 10) )
    off += 9+i
    t[2][1][2].append(a)
t = X.connectMatch(t)
if Cmpi.rank == 0: C.convertPyTree2File(t, 'in.cgns')

# arbre complet 
t, stats = D2.distribute(t, NProc=5, algorithm='gradient', useCom='overlap')
print('full:', stats)
if Cmpi.rank == 0: test.testT(t, 1)

# arbre squelette charge (doit etre identique)
t = Cmpi.convertFile2SkeletonTree('in.cgns')
t, stats = D2.distribute(t, NProc=Cmpi.size, algorithm='fast', useCom=0)
t = Cmpi.readZones(t, 'in.cgns', rank=Cmpi.rank)
t, stats = D2.distribute(t, NProc=5, algorithm='gradient', useCom='overlap')
print('loaded skel:', stats)
if Cmpi.rank == 0: test.testT(t, 2)
# - convert2PartialTree (pyTree) -
import Converter.PyTree as C
import Converter.Mpi as Cmpi
import Distributor2.PyTree as Distributor2
import Generator.PyTree as G

# Cree le fichier test
if Cmpi.rank == 0:
    a = G.cart((0,0,0), (1,1,1), (10,10,10))
    b = G.cart((12,0,0), (1,1,1), (10,10,10))
    t = C.newPyTree(['Base',a,b])
    C.convertPyTree2File(t, 'test.cgns')
Cmpi.barrier()

# Relit des zones par procs
t = Cmpi.convertFile2SkeletonTree('test.cgns')
(t, dic) = Distributor2.distribute(t, NProc=Cmpi.size, algorithm='fast')
t = Cmpi.readZones(t, 'test.cgns', proc=Cmpi.rank)
# Arbre partiel (sans zones squelettes)
t = Cmpi.convert2PartialTree(t)
if Cmpi.rank == 0: C.convertPyTree2File(t, 'out.cgns')
# - readZones (pyTree) -
import Converter.PyTree as C
import Converter.Mpi as Cmpi
import Distributor2.PyTree as Distributor2
import Generator.PyTree as G

# Cree le fichier test
if Cmpi.rank == 0:
    a = G.cart((0,0,0), (1,1,1), (10,10,10))
    b = G.cart((12,0,0), (1,1,1), (10,10,10))
    t = C.newPyTree(['Base',a,b])
    C.convertPyTree2File(t, 'test.cgns')
Cmpi.barrier()

# Relit les zones par paths
t = Cmpi.convertFile2SkeletonTree('test.cgns')
Cmpi._readZones(t, 'test.cgns', zoneNames=['Base/cart'])

# Relit des zones par procs
t = Cmpi.convertFile2SkeletonTree('test.cgns')
(t, dic) = Distributor2.distribute(t, NProc=Cmpi.size, algorithm='fast')
t = Cmpi.readZones(t, 'test.cgns', rank=Cmpi.rank)
if Cmpi.rank == 0: C.convertPyTree2File(t, 'out.cgns')
if Cmpi.rank == 0:
    Ni = 50
    Nj = 50
    Nk = 2
    a = G.cart((0, 0, 0), (1. / (Ni - 1), 1. / (Nj - 1), 1), (Ni, Nj, Nk))
    b = G.cart((0, 0, 0), (2. / (Ni - 1), 2. / (Nj - 1), 1), (Ni, Nj, Nk))
    b[0] = 'cart2'
    a = T.rotate(a, (0, 0, 0), (0, 0, 1), 10.)
    a = T.translate(a, (0.5, 0.5, 0))
    t = C.newPyTree(['Base1', 'Base2'])
    t[2][1][2].append(a)
    t[2][2][2].append(b)
    t = C.fillEmptyBCWith(t, 'overlap', 'BCOverlap', dim=2)
    t = C.addVars(t, 'Density')
    t = C.addVars(t, 'centers:Pressure')
    C.convertPyTree2File(t, 'in.cgns')
Cmpi.barrier()

t = Cmpi.convertFile2SkeletonTree('in.cgns')
import sys
sys.exit()
(t, dic) = Distributor2.distribute(t, NProc=Cmpi.size, algorithm='fast')
t = Cmpi.readZones(t, 'in.cgns', proc=Cmpi.rank)

t2 = Xmpi.optimizeOverlap(t)
if Cmpi.rank == 0:
    test.testT(t2, 1)
    # priorite sur Base2
    #t2 = X.optimizeOverlap(t, priorities=['Base1',1,'Base2',0])
    #if Cmpi.rank == 0: test.testT(t2,2)
Example #8
0
# - Calcul d'isosurfaces a la paroi en distribue -
import Converter.PyTree as C
import Distributor2.PyTree as Distributor2
import Converter.Mpi as Cmpi
import Transform.PyTree as T
import Post.PyTree as P

rank = Cmpi.rank
size = Cmpi.size

# lecture du squelette
a = Cmpi.convertFile2SkeletonTree('cart.cgns')

# equilibrage
(a, dic) = Distributor2.distribute(a, NProc=size, algorithm='fast', useCom=0)

# load des zones locales dans le squelette
a = Cmpi.readZones(a, 'cart.cgns', proc=rank)

# Passage en arbre partiel
a = Cmpi.convert2PartialTree(a)

# Calcul de l'iso surface
isos = P.isoSurfMC(a, 'F', 0.3)
isos = Cmpi.setProc(isos, rank)  # affecte les isos au proc local
t = C.newPyTree(['Base'])
t[2][1][2] += isos

# Reconstruit l'arbre complet a l'ecriture
Cmpi.convertPyTree2File(t, 'out.cgns')
# - createBBoxTree (pyTree) -
import Converter.PyTree as C
import Converter.Mpi as Cmpi
import Distributor2.PyTree as Distributor2
import Generator.PyTree as G
import KCore.test as test

LOCAL = test.getLocal()

# Cree le fichier test
if Cmpi.rank == 0:
    a = G.cart((0,0,0), (1,1,1), (10,10,10))
    b = G.cart((12,0,0), (1,1,1), (10,10,10))
    t = C.newPyTree(['Base',a,b])
    C.convertPyTree2File(t, LOCAL+'/in.cgns')
Cmpi.barrier()

# Relit des zones par procs
t = Cmpi.convertFile2SkeletonTree(LOCAL+'/in.cgns')
(t, dic) = Distributor2.distribute(t, NProc=Cmpi.size, algorithm='fast')
t = Cmpi.readZones(t, LOCAL+'/in.cgns', rank=Cmpi.rank)

# Cree le bbox tree a partir du squelette charge
tb = Cmpi.createBBoxTree(t)
if Cmpi.rank == 0: test.testT(tb, 1)

# Cree le bbox a partir d'un arbre partiel
t = Cmpi.convert2PartialTree(t)
tb = Cmpi.createBBoxTree(t)
if Cmpi.rank == 0: test.testT(tb, 2)
# Create case
if Cmpi.rank == 0:
    ni = 100
    nj = 100
    nk = 100
    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)
    m = T.splitNParts(m, 4)
    C.convertPyTree2File(m, 'in.cgns')

    # Extraction mesh
    a = G.cart((0., 0., 0.5), (1., 0.1, 1.), (20, 20, 1))
    a[0] = 'extraction'
    a = T.splitNParts(a, 2)
    C.convertPyTree2File(a, 'in2.cgns')
Cmpi.barrier()

# Extract solution on extraction mesh
m = Cmpi.convertFile2SkeletonTree('in.cgns')
(m, dic) = Distributor2.distribute(m, NProc=Cmpi.size, algorithm='fast')
m = Cmpi.readZones(m, 'in.cgns', rank=Cmpi.rank)

a = Cmpi.convertFile2SkeletonTree('in2.cgns')
(a, dic) = Distributor2.distribute(a, NProc=Cmpi.size, algorithm='fast')
a = Cmpi.readZones(a, 'in2.cgns', rank=Cmpi.rank)

a = Pmpi.extractMesh(m, a)
if Cmpi.rank == 0:
    test.testT(a, 1)
import Generator.PyTree as G
import Converter.Mpi as Cmpi
import KCore.test as test

# Cree le fichier test HDF
if Cmpi.rank == 0:
    a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
    b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10))
    t = C.newPyTree(['Base', a, b])
    C.convertPyTree2File(t, 'test.hdf')
Cmpi.barrier()

# Relit des zones par procs
t = Cmpi.convertFile2SkeletonTree('test.hdf')
(t, dic) = Distributor2.distribute(t, NProc=2, algorithm='fast')
t = Cmpi.readZones(t, 'test.hdf', proc=Cmpi.rank)
if Cmpi.rank == 0: test.testT(t, 1)

# Cree le fichier test ADF
if Cmpi.rank == 0:
    a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
    b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10))
    t = C.newPyTree(['Base', a, b])
    C.convertPyTree2File(t, 'test.adf')
Cmpi.barrier()

# Relit des zones par procs
t = Cmpi.convertFile2SkeletonTree('test.adf')
(t, dic) = Distributor2.distribute(t, NProc=2, algorithm='fast')
t = Cmpi.readZones(t, 'test.adf', proc=Cmpi.rank)
if Cmpi.rank == 0:
Example #12
0
import Converter.Internal as Internal
import Converter.Mpi as Cmpi
import Distributor2.PyTree as Distributor2
import Generator.PyTree as G
import KCore.test as test

LOCAL = test.getLocal()

# Cree le fichier test
if Cmpi.rank == 0:
    a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
    b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10))
    t = C.newPyTree(['Base', a, b])
    C.convertPyTree2File(t, LOCAL + '/in.cgns')
Cmpi.barrier()

# Relit des zones par procs
t = Cmpi.convertFile2SkeletonTree(LOCAL + '/in.cgns')
(t, dic) = Distributor2.distribute(t, NProc=Cmpi.size, algorithm='fast')
t = Cmpi.readZones(t, LOCAL + '/in.cgns', proc=Cmpi.rank)

# Cree le bbox tree a partir du squelette charge
tb = Cmpi.createBBoxTree(t)
if Cmpi.rank == 0: test.testT(tb, 1)

# Cree le bbox a partir d'un arbre partiel
t = Cmpi.convert2PartialTree(t)
tb = Cmpi.createBBoxTree(t)
if Cmpi.rank == 0:
    test.testT(tb, 2)
Example #13
0
# - Calcul de distance a la paroi en distribue -
import Converter.PyTree as C
import Distributor2.PyTree as Distributor2
import Converter.Mpi as Cmpi
import Transform.PyTree as T
import Dist2Walls.PyTree as Dist2Walls

rank = Cmpi.rank
size = Cmpi.size

# lecture des parois
bodies = C.convertFile2PyTree('walls.cgns')

# lecture du squelette
a = Cmpi.convertFile2SkeletonTree('in.cgns')

# equilibrage
(a, dic) = Distributor2.distribute(a, NProc=size, algorithm='fast', useCom=0)

# load des zones locales dans le squelette
a = Cmpi.readZones(a, 'in.cgns', proc=rank)

# Passage en arbre partiel
a = Cmpi.convert2PartialTree(a)

# Calcul des distances a la paroi
a = Dist2Walls.distance2Walls(a, bodies, type='mininterf')

# Reconstruit l'arbre complet a l'ecriture
Cmpi.convertPyTree2File(a, 'out.cgns')
# - ExtractMesh distribue -

import Converter.PyTree as C
import Distributor2.PyTree as Distributor2
import Converter.Mpi as Cmpi
import Transform.PyTree as T
import Post.Mpi as Pmpi
import Converter.Internal as Internal

rank = Cmpi.rank
size = Cmpi.size

# Maillage d'extraction (distribue)
FILE = 'receiver.cgns'
e = Cmpi.convertFile2SkeletonTree(FILE)
(e, dic) = Distributor2.distribute(e, NProc=size, algorithm='fast', useCom=0)
e = Cmpi.readZones(e, FILE, rank=rank)

# Maillage source (distribue)
FILE = 'donor.cgns'
a = Cmpi.convertFile2SkeletonTree(FILE)
(a, dic) = Distributor2.distribute(a, NProc=size, algorithm='fast', useCom=0)
a = Cmpi.readZones(a, FILE, rank=rank)

# Extract mesh
e = Pmpi.extractMesh(a, e)

# Reconstruit l'arbre complet a l'ecriture
Cmpi.convertPyTree2File(e, 'out.cgns')