Skip to content

Commit b274153

Browse files
committed
add icfd model:weak fsi
1 parent 781252a commit b274153

File tree

13 files changed

+3276
-811
lines changed

13 files changed

+3276
-811
lines changed

examples/ICFD/icfd_weak_fsi.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
"""
2+
Weak FSI
3+
========
4+
5+
This example shows a simple FSI coupling problem using weak/loose/explicit FSI.
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+
ShellPart,
23+
ShellFormulation,
24+
PartSet,
25+
Curve,
26+
DOF,
27+
Motion
28+
)
29+
from ansys.dyna.core.pre.dynamaterial import MatRigid
30+
from ansys.dyna.core.pre import examples
31+
32+
33+
hostname = "localhost"
34+
if len(sys.argv) > 1:
35+
hostname = sys.argv[1]
36+
37+
solution = DynaSolution(hostname)
38+
# Import the initial mesh data(nodes and elements)
39+
fns = []
40+
path = examples.weak_fsi + os.sep
41+
fns.append(path + "weak_fsi.k")
42+
solution.open_files(fns)
43+
solution.set_termination(termination_time=40)
44+
icfd = DynaICFD()
45+
solution.add(icfd)
46+
47+
icfd.set_timestep(tssfac=0.9)
48+
49+
icfdanalysis = ICFDAnalysis()
50+
icfdanalysis.set_timestep(0.05)
51+
icfd.add(icfdanalysis)
52+
53+
# define model
54+
mat = MatICFD(flow_density=1.0, dynamic_viscosity=0.005)
55+
56+
part_inflow = ICFDPart(1)
57+
part_inflow.set_material(mat)
58+
part_inflow.set_prescribed_velocity(dof=ICFDDOF.X, motion=Curve(x=[0, 5, 6, 10000], y=[0, 0, 1, 1]))
59+
part_inflow.set_prescribed_velocity(dof=ICFDDOF.Y, motion=Curve(x=[0, 10000], y=[0, 0]))
60+
icfd.parts.add(part_inflow)
61+
62+
part_outflow = ICFDPart(2)
63+
part_outflow.set_material(mat)
64+
part_outflow.set_prescribed_pressure(pressure=Curve(x=[0, 10000], y=[0, 0]))
65+
icfd.parts.add(part_outflow)
66+
67+
part_symmetric = ICFDPart(3)
68+
part_symmetric.set_material(mat)
69+
part_symmetric.set_free_slip()
70+
icfd.parts.add(part_symmetric)
71+
72+
part_wall = ICFDPart(4)
73+
part_wall.set_material(mat)
74+
part_wall.set_non_slip()
75+
part_wall.set_fsi()
76+
part_wall.compute_drag_force()
77+
part_wall.set_boundary_layer(number=3)
78+
icfd.parts.add(part_wall)
79+
80+
partvol = ICFDVolumePart(surfaces=[1, 2, 3, 4])
81+
partvol.set_material(mat)
82+
icfd.parts.add(partvol)
83+
# define the volume space that will be meshed,The boundaries
84+
# of the volume are the surfaces "spids"
85+
meshvol = MeshedVolume(surfaces=[1, 2, 3, 4])
86+
icfd.add(meshvol)
87+
88+
#define rigid cylinder
89+
matrigid = MatRigid(mass_density=1000,young_modulus=2e11,poisson_ratio=0.3)
90+
cylinder = ShellPart(1)
91+
cylinder.set_material(matrigid)
92+
cylinder.set_element_formulation(ShellFormulation.PLANE_STRESS)
93+
icfd.parts.add(cylinder)
94+
# Define boundary conddition
95+
icfd.boundaryconditions.create_imposed_motion(PartSet([1]),Curve(func="2*3.14/10*sin(2*3.14/10*TIME+3.14/2)"),dof=DOF.Y_TRANSLATIONAL,motion=Motion.VELOCITY)
96+
97+
solution.create_database_binary(dt=0.2)
98+
solution.save_file()

src/ansys/dyna/core/pre/Server/kwprocess_pb2.py

Lines changed: 419 additions & 399 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ansys/dyna/core/pre/Server/kwprocess_pb2_grpc.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ def __init__(self, channel):
339339
request_serializer=kwprocess__pb2.DefineCurveRequest.SerializeToString,
340340
response_deserializer=kwprocess__pb2.DefineCurveReply.FromString,
341341
)
342+
self.CreateDefineCurveFunction = channel.unary_unary(
343+
'/kwgrpc.kwC2S/CreateDefineCurveFunction',
344+
request_serializer=kwprocess__pb2.DefineCurveFunctionRequest.SerializeToString,
345+
response_deserializer=kwprocess__pb2.DefineCurveFunctionReply.FromString,
346+
)
342347
self.CreateDefineVector = channel.unary_unary(
343348
'/kwgrpc.kwC2S/CreateDefineVector',
344349
request_serializer=kwprocess__pb2.DefineVectorRequest.SerializeToString,
@@ -1170,6 +1175,12 @@ def CreateDefineCurve(self, request, context):
11701175
context.set_details('Method not implemented!')
11711176
raise NotImplementedError('Method not implemented!')
11721177

1178+
def CreateDefineCurveFunction(self, request, context):
1179+
"""Missing associated documentation comment in .proto file."""
1180+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
1181+
context.set_details('Method not implemented!')
1182+
raise NotImplementedError('Method not implemented!')
1183+
11731184
def CreateDefineVector(self, request, context):
11741185
"""Missing associated documentation comment in .proto file."""
11751186
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -2017,6 +2028,11 @@ def add_kwC2SServicer_to_server(servicer, server):
20172028
request_deserializer=kwprocess__pb2.DefineCurveRequest.FromString,
20182029
response_serializer=kwprocess__pb2.DefineCurveReply.SerializeToString,
20192030
),
2031+
'CreateDefineCurveFunction': grpc.unary_unary_rpc_method_handler(
2032+
servicer.CreateDefineCurveFunction,
2033+
request_deserializer=kwprocess__pb2.DefineCurveFunctionRequest.FromString,
2034+
response_serializer=kwprocess__pb2.DefineCurveFunctionReply.SerializeToString,
2035+
),
20202036
'CreateDefineVector': grpc.unary_unary_rpc_method_handler(
20212037
servicer.CreateDefineVector,
20222038
request_deserializer=kwprocess__pb2.DefineVectorRequest.FromString,
@@ -3557,6 +3573,23 @@ def CreateDefineCurve(request,
35573573
options, channel_credentials,
35583574
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
35593575

3576+
@staticmethod
3577+
def CreateDefineCurveFunction(request,
3578+
target,
3579+
options=(),
3580+
channel_credentials=None,
3581+
call_credentials=None,
3582+
insecure=False,
3583+
compression=None,
3584+
wait_for_ready=None,
3585+
timeout=None,
3586+
metadata=None):
3587+
return grpc.experimental.unary_unary(request, target, '/kwgrpc.kwC2S/CreateDefineCurveFunction',
3588+
kwprocess__pb2.DefineCurveFunctionRequest.SerializeToString,
3589+
kwprocess__pb2.DefineCurveFunctionReply.FromString,
3590+
options, channel_credentials,
3591+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
3592+
35603593
@staticmethod
35613594
def CreateDefineVector(request,
35623595
target,

src/ansys/dyna/core/pre/Server/kwserver.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,18 @@ def CreateDefineCurve(self, request, context):
604604
print(msg)
605605
return kwprocess_pb2.DefineCurveReply(id=lcid)
606606

607+
def CreateDefineCurveFunction(self, request, context):
608+
lcid = request.lcid
609+
lcid = self.kwdproc.get_data(gdt.KWD_DEFINE_CURVE_LASTID) + 1
610+
function = request.function
611+
card1 = str(lcid)
612+
card2 = function
613+
newk = "*DEFINE_CURVE_FUNCTION\n" + card1 + "\n" + card2
614+
self.kwdproc.newkeyword(newk)
615+
msg = "DefineCurveFunction " + str(lcid) + "Created..."
616+
print(msg)
617+
return kwprocess_pb2.DefineCurveFunctionReply(id=lcid)
618+
607619
def CreateDefineVector(self, request, context):
608620
title = request.title
609621
vid = request.vid

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,18 @@ def create(self, stub):
104104
class Curve:
105105
"""Define a curve [for example, load (ordinate value)] as a function of time."""
106106

107-
def __init__(self, sfo=1, x=[], y=[]):
107+
def __init__(self, sfo=1, x=[], y=[],func=None):
108108
self.sfo = sfo
109109
self.abscissa = x
110110
self.ordinate = y
111+
self.func = func
111112

112113
def create(self, stub):
113114
"""Create curve."""
114-
ret = stub.CreateDefineCurve(DefineCurveRequest(sfo=self.sfo, abscissa=self.abscissa, ordinate=self.ordinate))
115+
if self.func!=None:
116+
ret = stub.CreateDefineCurveFunction(DefineCurveFunctionRequest( function=self.func))
117+
else:
118+
ret = stub.CreateDefineCurve(DefineCurveRequest(sfo=self.sfo, abscissa=self.abscissa, ordinate=self.ordinate))
115119
self.id = ret.id
116120
logging.info(f"Curve {self.id} defined...")
117121
return self.id
@@ -733,6 +737,7 @@ class ShellFormulation(Enum):
733737
BELYTSCHKO_TSAY = 2
734738
SR_HUGHES_LIU = 6
735739
FULLY_INTEGRATED_BELYTSCHKO_TSAY_MEMBRANE = 9
740+
PLANE_STRESS = 12
736741

737742

738743
class IGAFormulation(Enum):

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ def __init__(self):
1919
self.timestep = 0
2020
self.termination = 1e28
2121

22-
def set_timestep(self, timestep=0):
23-
"""Set time step for the fluid problem.
24-
25-
Parameters
26-
----------
27-
dt : float
28-
Time step for the fluid problem.
29-
"""
30-
self.timestep = timestep
31-
3222
def set_termination(self, termination_time):
3323
"""Set total time of simulation for the fluid problem.
3424
@@ -483,6 +473,12 @@ def set_non_slip(self):
483473
logging.info("ICFD boundary nonslip Created...")
484474
return ret
485475

476+
def set_fsi(self):
477+
"""Define fluid surface will be considered in contact with the solid surfaces for fluid-structure interaction (FSI) analysis."""
478+
ret = self.stub.ICFDCreateBdyFSI(ICFDBdyFSIRequest(pid=self.id))
479+
logging.info("ICFD boundary FSI Created...")
480+
return ret
481+
486482
def compute_drag_force(self):
487483
"""Enable the computation of drag forces over given surface parts of the model."""
488484
ret = self.stub.ICFDCreateDBDrag(ICFDDBDragRequest(pid=self.id))

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
free_convection_flow = os.path.join(_module_path, "icfd", "free_convection_flow")
2525
dam_break = os.path.join(_module_path, "icfd", "dam_break")
2626
driven_cavity = os.path.join(_module_path, "icfd", "driven_cavity")
27+
weak_fsi = os.path.join(_module_path, "icfd", "weak_fsi")
2728

2829
iga_sample = os.path.join(_module_path, "iga", "iga_sample")
2930
camry_rc = os.path.join(_module_path, "implicit", "camry_rc")

0 commit comments

Comments
 (0)