Skip to content

Commit 7e7cbc9

Browse files
committed
add icfd model:mesh morphing
1 parent 25eea7c commit 7e7cbc9

File tree

7 files changed

+3031
-0
lines changed

7 files changed

+3031
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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()

src/ansys/dyna/core/pre/dynaicfd.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,15 +619,37 @@ def __init__(self, surfaces):
619619
self.secid = 1
620620
self.mid = 0
621621
self.surfaces = surfaces
622+
self.defined_imposed_move = False
622623

623624
def set_material(self, mat):
624625
"""Set material."""
625626
self.mid = mat.material_id
626627

628+
def set_imposed_move(self, vx=None, vy=None, vz=None):
629+
"""Impose a velocity on specific ICFD part."""
630+
self.defined_imposed_move = True
631+
self.vx = vx
632+
self.vy = vy
633+
self.vz = vz
634+
627635
def create(self):
628636
"""Create ICFD volume part."""
629637
ret = self.stub.ICFDCreatePartVol(ICFDPartVolRequest(secid=1, mid=self.mid, spids=self.surfaces))
630638
self.id = ret.id
639+
if self.defined_imposed_move:
640+
lcvx, lcvy, lcvz = 0, 0, 0
641+
if self.vx != None:
642+
self.vx.create(self.stub)
643+
lcvx = self.vx.id
644+
if self.vy != None:
645+
self.vy.create(self.stub)
646+
lcvy = self.vy.id
647+
if self.vz != None:
648+
self.vz.create(self.stub)
649+
lcvz = self.vz.id
650+
ret = self.stub.ICFDCreateControlImposedMove(
651+
ICFDControlImposedMoveRequest(pid=self.id, lcvx=lcvx, lcvy=lcvy, lcvz=lcvz)
652+
)
631653
logging.info(f"ICFD part volume {self.id} Created...")
632654
return ret
633655

src/ansys/dyna/core/pre/examples/examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
strong_fsi = os.path.join(_module_path, "icfd", "strong_fsi")
2828
imposed_move = os.path.join(_module_path, "icfd", "imposed_move")
2929
mesh_adaptivity = os.path.join(_module_path, "icfd", "mesh_adaptivity")
30+
mesh_morphing = os.path.join(_module_path, "icfd", "mesh_morphing")
3031
dem_coupling = os.path.join(_module_path, "icfd", "dem_coupling")
3132

3233
iga_sample = os.path.join(_module_path, "iga", "iga_sample")

0 commit comments

Comments
 (0)