COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-cf3mesh.py
Go to the documentation of this file.
1 import sys
2 import coolfluid as cf
3 
4 env = cf.Core.environment()
5 env.log_level = 4
6 env.only_cpu0_writes = True
7 
8 root = cf.Core.root()
9 domain = root.create_component('Domain', 'cf3.mesh.Domain')
10 mesh = domain.create_component('OriginalMesh','cf3.mesh.Mesh')
11 
12 blocks = root.create_component('model', 'cf3.mesh.BlockMesh.BlockArrays')
13 points = blocks.create_points(dimensions = 2, nb_points = 4)
14 points[0] = [0., 0.]
15 points[1] = [1., 0.]
16 points[2] = [1., 1.]
17 points[3] = [0., 1.]
18 block_nodes = blocks.create_blocks(1)
19 block_nodes[0] = [0, 1, 2, 3]
20 block_subdivs = blocks.create_block_subdivisions()
21 block_subdivs[0] = [40,20]
22 gradings = blocks.create_block_gradings()
23 gradings[0] = [1., 1., 1., 1.]
24 blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)[0] = [0, 1]
25 blocks.create_patch_nb_faces(name = 'right', nb_faces = 1)[0] = [1, 2]
26 blocks.create_patch_nb_faces(name = 'top', nb_faces = 1)[0] = [2, 3]
27 blocks.create_patch_nb_faces(name = 'left', nb_faces = 1)[0] = [3, 0]
28 blocks.partition_blocks(nb_partitions = cf.Core.nb_procs(), direction = 1)
29 blocks.create_mesh(mesh.uri())
30 
31 link_horizontal = domain.create_component('LinkHorizontal', 'cf3.mesh.actions.LinkPeriodicNodes')
32 link_horizontal.mesh = mesh
33 link_horizontal.source_region = mesh.topology.right
34 link_horizontal.destination_region = mesh.topology.left
35 link_horizontal.translation_vector = [-1., 0.]
36 link_horizontal.execute()
37 
38 make_par_data = root.create_component('MakeParData', 'cf3.solver.actions.ParallelDataToFields')
39 make_par_data.mesh = mesh
40 make_par_data.execute()
41 
42 p2space = mesh.create_continuous_space(name = 'TestP2Space', shape_function = 'cf3.mesh.LagrangeP2')
43 
44 mesh.print_tree()
45 
46 outfile = cf.URI('cf3test.cf3mesh')
47 domain.write_mesh(outfile)
48 
49 reader = domain.create_component('CF3MeshReader', 'cf3.mesh.cf3mesh.Reader')
50 reader.mesh = domain.create_component('ReadBackMesh','cf3.mesh.Mesh')
51 reader.file = outfile
52 reader.execute()
53 
54 reader.mesh.print_tree()
55 
56 meshdiff = domain.create_component('MeshDiff', 'cf3.mesh.actions.MeshDiff')
57 meshdiff.left = mesh
58 meshdiff.right = reader.mesh
59 meshdiff.execute()
60 
61 if not meshdiff.properties()['mesh_equal']:
62  raise Exception('Read mesh differs from original!')
Send comments to:
COOLFluiD Web Admin