#!/usr/bin/env python # coding: utf-8 r"""Generator : generation and adaptation of an unstructured octree mesh""" import math import Converter.PyTree as C import Generator.PyTree as G import Post.PyTree as P import Geom.PyTree as D import Converter.Internal as Internal # Creation of the octree mesh around a NACA0012 profile naca = D.naca(12) o = G.octree(stlArrays=[naca], snearList=[0.01], dfar=10., balancing=1) o = C.initVars(o, 'Density = {CoordinateX}') # Define a model sensor field 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'])
# test - enforceCurvature2 (pyTree) import Converter.PyTree as C import Geom.PyTree as D import Generator.PyTree as G import KCore.test as test # Cas 1 : courbure constante a = D.circle((0,0,0),0.1,N=51) ni = 101; db = G.cart((0,0,0),(1./(ni-1),1,1),(ni,1,1)) db = C.addBC2Zone(db, 'wall1', 'BCWall', 'jmin') db = C.addBC2Zone(db, 'match1', 'BCMatch', 'imin',db,'imax',[1,2]) db = C.addBC2Zone(db, 'match2', 'BCMatch', 'imax',db,'imin',[1,2]) db = C.addBC2Zone(db, 'wall2','BCWall','jmax') db = C.addVars(db,'Density'); db = C.addVars(db,'centers:cellN') db2 = G.enforceCurvature2(db, a) test.testT([db2],1) # Cas 2 : courbure variable a = D.naca(12.) ni = 101; db = G.cart((0,0,0),(1./(ni-1),1,1),(ni,1,1)) db = C.addBC2Zone(db, 'wall1','BCWall','jmin') db = C.addBC2Zone(db, 'match1','BCMatch','imin',db,'imax',[1,2]) db = C.addBC2Zone(db, 'match2','BCMatch','imax',db,'imin',[1,2]) db = C.addBC2Zone(db, 'wall2','BCWall','jmax') db = C.addVars(db,'Density'); db = C.addVars(db,'centers:cellN') db2 = G.enforceCurvature2(db, a) test.testT([db2],2)
# - splitCurvatureRadius (pyTree)- import Converter.PyTree as C import Geom.PyTree as D import Transform.PyTree as T a = D.naca(12.5000) zones = T.splitCurvatureRadius(a, 10.) C.convertPyTree2File(zones + [a], 'out.cgns')
# - getDistantIndex (PyTree)- import Geom.PyTree as D import KCore.test as test import Converter.PyTree as C a = D.naca(12., 5001) l = D.getLength(a) l2 = D.getDistantIndex(a, 1, l / 10.) test.testO(l2, 1)
# - hyper2D (pyTree) - import Geom.PyTree as D import Generator.PyTree as G import Converter.PyTree as C line = D.naca(12., 5001) # Distribution Ni = 300 Nj = 50 distrib = G.cart((0, 0, 0), (1. / (Ni - 1), 0.5 / (Nj - 1), 1), (Ni, Nj, 1)) a = G.hyper2D(line, distrib, "C") C.convertPyTree2File(a, 'out.cgns')
import KCore.test as test # Test 3D structure a = G.cylinder((0., 0., 0.), 0.5, 1., 360., 0., 10., (50, 50, 10)) a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin') a = C.addBC2Zone(a, 'wall2', 'BCWall', 'kmin') a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imin', a, 'imax', [1, 2, 3]) a = C.addBC2Zone(a, 'match2', 'BCMatch', 'imax', a, 'imin', [1, 2, 3]) a = C.fillEmptyBCWith(a, 'overlap', 'BCOverlap') a = C.initVars(a, 'Density', 1.) a = C.initVars(a, 'centers:cellN', 1.) t = G.getRegularityMap(a) test.testT(t, 1) # Test 2D structure msh = D.naca(12., 5001) # Distribution Ni = 300 Nj = 50 distrib = G.cart((0, 0, 0), (1. / (Ni - 1), 0.5 / (Nj - 1), 1), (Ni, Nj, 1)) a = G.hyper2D(msh, distrib, "C") a = T.reorder(a, (-3, 2, 1)) a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin') a = C.initVars(a, 'Density', 1.) a = C.initVars(a, 'centers:cellN', 1.) t = G.getRegularityMap(a) test.testT(t, 2) # Test 1D structure a = G.cart((0., 0., 0.), (0.1, 0.1, 0.2), (1, 10, 1)) a = C.initVars(a, 'Density', 1.)
# - getDistribution (PyTree) - import Geom.PyTree as D Foil = D.naca(12., N=49) print D.getDistribution(Foil)
# - hyper2D2 (pyTree) - import KCore.test as test import Geom.PyTree as D import Generator.PyTree as G msh = D.naca(12,5001) # Distribution Ni = 300; Nj = 50 distrib = G.cart((0,0,0), (1./(Ni-1), 0.5/(Nj-1),1), (Ni,Nj,1)) a = G.hyper2D2(msh, distrib, "C", 110.) test.testT(a,1)
# - splitCurvatureAngle (pyTree) - import Converter.PyTree as C import Geom.PyTree as D import Transform.PyTree as T a = D.naca(12,101) a2 = D.line((1,0,0), (2,0,0), 50) a = T.join(a, a2) a2 = D.line((2,0,0), (1,0,0), 50) a = T.join(a, a2) zones = T.splitCurvatureAngle(a, 20.) C.convertPyTree2File(zones+[a], 'out.cgns')
# - splitCurvatureAngle (pyTree)- import Converter.PyTree as C import Geom.PyTree as D import Transform.PyTree as T import KCore.test as test # i-array a = D.naca(12, 5001) a = C.initVars(a, 'Density', 2.) a = C.initVars(a, 'centers:cellN', 1.) zones = T.splitCurvatureAngle(a, 20.) test.testT(zones)
# - polyC1Mesher (pyTree)- import Converter.PyTree as C import Generator.PyTree as G import Geom.PyTree as D import KCore.test as test import Transform.PyTree as T # Definition de la geometrie a = D.naca(12., 101) a = T.reorder(a, (-1, 2, 3)) h = 0.1 hp = 0.001 density = 100. res = G.polyC1Mesher(a, h, hp, density) t = C.newPyTree(['Base']) t[2][1][2] += res[0] test.testT(t, 1) # # test sans split au bord d'attaque # res = G.polyC1Mesher(a, h, hp, density, splitCrit=0.01) t = C.newPyTree(['Base']) t[2][1][2] += res[0] test.testT(t, 2)