COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-slice.py
Go to the documentation of this file.
1 import sys
2 import coolfluid as cf
3 from math import pi
4 
5 env = cf.Core.environment()
6 env.log_level = 1
7 #env.only_cpu0_writes = False
8 
9 root = cf.Core.root()
10 source_domain = root.create_component('SourceDomain', 'cf3.mesh.Domain')
11 target_domain = root.create_component('TargetDomain', 'cf3.mesh.Domain')
12 source_mesh = source_domain.create_component('sourcemesh','cf3.mesh.Mesh')
13 
14 h = 1.
15 
16 div = 2
17 
18 blocks = root.create_component('model', 'cf3.mesh.BlockMesh.BlockArrays')
19 grading = 20.
20 y_segs = 64/div
21 x_size = 4.*pi*h
22 z_size = 2.*pi*h
23 x_segs = 32/div
24 z_segs = 32/div
25 points = blocks.create_points(dimensions = 2, nb_points = 6)
26 points[0] = [0, 0.]
27 points[1] = [x_size, 0.]
28 points[2] = [0., h]
29 points[3] = [x_size, h]
30 points[4] = [0.,2.*h]
31 points[5] = [x_size, 2.*h]
32 block_nodes = blocks.create_blocks(2)
33 block_nodes[0] = [0, 1, 3, 2]
34 block_nodes[1] = [2, 3, 5, 4]
35 block_subdivs = blocks.create_block_subdivisions()
36 block_subdivs[0] = [x_segs, y_segs]
37 block_subdivs[1] = block_subdivs[0]
38 gradings = blocks.create_block_gradings()
39 gradings[0] = [1., 1., grading, grading]
40 gradings[1] = [1., 1., 1./grading, 1./grading]
41 left_patch = blocks.create_patch_nb_faces(name = 'left', nb_faces = 2)
42 left_patch[0] = [2, 0]
43 left_patch[1] = [4, 2]
44 bottom_patch = blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)
45 bottom_patch[0] = [0, 1]
46 top_patch = blocks.create_patch_nb_faces(name = 'top', nb_faces = 1)
47 top_patch[0] = [5, 4]
48 right_patch = blocks.create_patch_nb_faces(name = 'right', nb_faces = 2)
49 right_patch[0] = [1, 3]
50 right_patch[1] = [3, 5]
51 blocks.extrude_blocks(positions=[z_size], nb_segments=[z_segs], gradings=[1.])
52 blocks.partition_blocks(nb_partitions = 2, direction = 1)
53 blocks.partition_blocks(nb_partitions = 2, direction = 0)
54 blocks.partition_blocks(nb_partitions = 2, direction = 2)
55 blocks.create_mesh(source_mesh.uri())
56 
57 source_coords = source_mesh.geometry.coordinates
58 testfield = source_mesh.geometry.create_field(name = 'test', variables = 'testx,testy')
59 for i in range(len(source_coords)):
60  testfield[i][0] = 1.+2.*source_coords[i][0]
61  testfield[i][1] = 2.+3.*source_coords[i][1]
62 
63 target_mesh = target_domain.create_component('targetmesh','cf3.mesh.Mesh')
64 generator = target_domain.create_component('Generator', 'cf3.mesh.GeneratePlane3D')
65 generator.mesh = target_mesh.uri()
66 generator.origin = [0., h, 0.]
67 generator.normal = [0., 1., 0.]
68 generator.size = [x_size, z_size]
69 generator.segments = [x_segs, z_segs]
70 generator.execute()
71 
72 interpolator = root.create_component('Interpolator', 'cf3.mesh.actions.MeshInterpolator')
73 interpolator.source_mesh = source_mesh
74 interpolator.target_mesh = target_mesh
75 interpolator.execute()
76 
77 tgt_coords = target_mesh.geometry.coordinates
78 tgt_test = target_mesh.geometry.test
79 tgt_ranks = target_mesh.geometry.children.rank
80 my_rank = cf.Core.rank()
81 
82 for i in range(len(tgt_coords)):
83  if tgt_ranks[i] == my_rank:
84  print tgt_coords[i][0], tgt_coords[i][1], tgt_coords[i][2], tgt_test[i][0]
Send comments to:
COOLFluiD Web Admin