|
| 1 | +""" |
| 2 | +Mesh Morphing |
| 3 | +============= |
| 4 | +
|
| 5 | +This example shows a simple ICFD problem with mesh morphing. |
| 6 | +""" |
| 7 | + |
| 8 | +import os |
| 9 | +import sys |
| 10 | + |
| 11 | + |
| 12 | +from ansys.dyna.core.pre.dynasolution import DynaSolution |
| 13 | +from ansys.dyna.core.pre.dynaicfd import ( |
| 14 | + DynaICFD, |
| 15 | + MatICFD, |
| 16 | + ICFDPart, |
| 17 | + ICFDDOF, |
| 18 | + Curve, |
| 19 | + ICFDVolumePart, |
| 20 | + MeshedVolume, |
| 21 | + ICFDAnalysis |
| 22 | +) |
| 23 | +from ansys.dyna.core.pre import examples |
| 24 | + |
| 25 | + |
| 26 | +hostname = "localhost" |
| 27 | +if len(sys.argv) > 1: |
| 28 | + hostname = sys.argv[1] |
| 29 | + |
| 30 | +solution = DynaSolution(hostname) |
| 31 | +# Import the initial mesh data(nodes and elements) |
| 32 | +fns = [] |
| 33 | +path = examples.mesh_morphing + os.sep |
| 34 | +fns.append(path + "mesh_morphing.k") |
| 35 | +solution.open_files(fns) |
| 36 | +solution.set_termination(termination_time=40) |
| 37 | +icfd = DynaICFD() |
| 38 | +solution.add(icfd) |
| 39 | + |
| 40 | +icfdanalysis = ICFDAnalysis() |
| 41 | +icfdanalysis.set_timestep(0.05) |
| 42 | +icfd.add(icfdanalysis) |
| 43 | + |
| 44 | +# define model |
| 45 | +mat = MatICFD(flow_density=1.0, dynamic_viscosity=0.005) |
| 46 | + |
| 47 | +part_inflow = ICFDPart(1) |
| 48 | +part_inflow.set_material(mat) |
| 49 | +part_inflow.set_prescribed_velocity(dof=ICFDDOF.X, motion=Curve(x=[0, 5, 6, 10000], y=[0, 0, 1, 1])) |
| 50 | +part_inflow.set_prescribed_velocity(dof=ICFDDOF.Y, motion=Curve(x=[0, 10000], y=[0, 0])) |
| 51 | +icfd.parts.add(part_inflow) |
| 52 | + |
| 53 | +part_outflow = ICFDPart(2) |
| 54 | +part_outflow.set_material(mat) |
| 55 | +part_outflow.set_prescribed_pressure(pressure=Curve(x=[0, 10000], y=[0, 0])) |
| 56 | +icfd.parts.add(part_outflow) |
| 57 | + |
| 58 | +part_symmetric = ICFDPart(3) |
| 59 | +part_symmetric.set_material(mat) |
| 60 | +part_symmetric.set_free_slip() |
| 61 | +icfd.parts.add(part_symmetric) |
| 62 | + |
| 63 | +part_wall = ICFDPart(4) |
| 64 | +part_wall.set_material(mat) |
| 65 | +part_wall.set_non_slip() |
| 66 | +part_wall.compute_drag_force() |
| 67 | +part_wall.set_boundary_layer(number=2) |
| 68 | +part_wall.set_imposed_move(vy=Curve(func="2*3.14/10*sin(2*3.14/10*TIME+3.14/2)")) |
| 69 | +icfd.parts.add(part_wall) |
| 70 | + |
| 71 | +part_meshmorph = ICFDPart(5) |
| 72 | +part_meshmorph.set_material(mat) |
| 73 | +icfd.parts.add(part_meshmorph) |
| 74 | + |
| 75 | +partvol1 = ICFDVolumePart(surfaces=[1, 2, 3, 5]) |
| 76 | +partvol1.set_material(mat) |
| 77 | +icfd.parts.add(partvol1) |
| 78 | +partvol2 = ICFDVolumePart(surfaces=[5, 4]) |
| 79 | +partvol2.set_material(mat) |
| 80 | +partvol2.set_imposed_move(vy=Curve(func="2*3.14/10*sin(2*3.14/10*TIME+3.14/2)")) |
| 81 | +icfd.parts.add(partvol2) |
| 82 | +# define the volume space that will be meshed,The boundaries |
| 83 | +# of the volume are the surfaces "spids" |
| 84 | +meshvol = MeshedVolume(surfaces=[1, 2, 3, 4]) |
| 85 | +meshvol.set_fluid_interfaces([5]) |
| 86 | +icfd.add(meshvol) |
| 87 | + |
| 88 | +solution.create_database_binary(dt=0.5) |
| 89 | +solution.save_file() |
0 commit comments