Skip to content

Commit d7524b0

Browse files
committed
Merge remote-tracking branch 'origin/zhanqun/dyna-prev4' into main
2 parents 9ad778b + 781252a commit d7524b0

File tree

16 files changed

+5155
-423
lines changed

16 files changed

+5155
-423
lines changed

examples/ICFD/icfd_dam_break.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
"""
2+
Dam break
3+
=========
4+
5+
This example shows a simple free surface example using the ICFD solver. A column of water collapses under the load of gravity.
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+
Curve,
18+
ICFDVolumePart,
19+
MeshedVolume,
20+
ICFDAnalysis,
21+
Gravity,
22+
GravityOption,
23+
Compressible
24+
)
25+
from ansys.dyna.core.pre import examples
26+
27+
28+
hostname = "localhost"
29+
if len(sys.argv) > 1:
30+
hostname = sys.argv[1]
31+
32+
solution = DynaSolution(hostname)
33+
# Import the initial mesh data(nodes and elements)
34+
fns = []
35+
path = examples.dam_break + os.sep
36+
fns.append(path + "dam_break.k")
37+
solution.open_files(fns)
38+
solution.set_termination(termination_time=50)
39+
icfd = DynaICFD()
40+
solution.add(icfd)
41+
42+
icfdanalysis = ICFDAnalysis()
43+
icfdanalysis.set_timestep()
44+
icfd.add(icfdanalysis)
45+
46+
# define model
47+
mat1 = MatICFD(flow_density=1000, dynamic_viscosity=0.001)
48+
mat2 = MatICFD(flag=Compressible.VACUUM)
49+
50+
part1 = ICFDPart(1)
51+
part1.set_material(mat1)
52+
part1.set_free_slip()
53+
icfd.parts.add(part1)
54+
55+
part2 = ICFDPart(2)
56+
part2.set_material(mat2)
57+
part2.set_free_slip()
58+
icfd.parts.add(part2)
59+
60+
part3 = ICFDPart(3)
61+
part3.set_material(mat1)
62+
icfd.parts.add(part3)
63+
64+
g = Gravity(dir=GravityOption.DIR_Y, load=Curve(x=[0, 10000], y=[9.81, 9.81]))
65+
icfd.add(g)
66+
67+
partvol1 = ICFDVolumePart(surfaces=[1, 3])
68+
partvol1.set_material(mat1)
69+
icfd.parts.add(partvol1)
70+
71+
partvol2 = ICFDVolumePart(surfaces=[2, 3])
72+
partvol2.set_material(mat2)
73+
icfd.parts.add(partvol2)
74+
# define the volume space that will be meshed,The boundaries
75+
# of the volume are the surfaces "spids"
76+
meshvol = MeshedVolume(surfaces=[1, 2])
77+
meshvol.set_fluid_interfaces([3])
78+
icfd.add(meshvol)
79+
80+
solution.create_database_binary(dt=0.2)
81+
solution.save_file()
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""
2+
Driven cavity
3+
=============
4+
5+
This example shows the universally famous driven cavity case tested with the second order steady solver and for Re=1000.
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+
Curve,
18+
ICFDVolumePart,
19+
MeshedVolume,
20+
ICFDAnalysis,
21+
ICFD_AnalysisType,
22+
ICFD_MessageLevel,
23+
ICFDDOF
24+
)
25+
from ansys.dyna.core.pre import examples
26+
27+
28+
hostname = "localhost"
29+
if len(sys.argv) > 1:
30+
hostname = sys.argv[1]
31+
32+
solution = DynaSolution(hostname)
33+
# Import the initial mesh data(nodes and elements)
34+
fns = []
35+
path = examples.driven_cavity + os.sep
36+
fns.append(path + "driven_cavity.k")
37+
solution.open_files(fns)
38+
icfd = DynaICFD()
39+
solution.add(icfd)
40+
41+
icfdanalysis = ICFDAnalysis()
42+
icfdanalysis.set_type(analysis_type=ICFD_AnalysisType.STEADY_STATE_ANALYSIS)
43+
icfdanalysis.set_output(messagelevel=ICFD_MessageLevel.FULL_OUTPUT_INFORMATION,iteration_interval=250)
44+
icfdanalysis.set_steady_state(max_iteration=2500,momentum_tol_limit=1e-8,pressure_tol_limit=1e-8,velocity_relax_param=1,pressure_relax_param=1)
45+
icfd.add(icfdanalysis)
46+
47+
# define model
48+
mat = MatICFD(flow_density=1, dynamic_viscosity=0.001)
49+
50+
part1 = ICFDPart(1)
51+
part1.set_material(mat)
52+
part1.set_prescribed_velocity(dof=ICFDDOF.X, motion=Curve(x=[0, 10000], y=[1, 1]))
53+
icfd.parts.add(part1)
54+
55+
part2 = ICFDPart(2)
56+
part2.set_material(mat)
57+
part2.set_non_slip()
58+
icfd.parts.add(part2)
59+
60+
partvol = ICFDVolumePart(surfaces=[1, 2])
61+
partvol.set_material(mat)
62+
icfd.parts.add(partvol)
63+
# define the volume space that will be meshed,The boundaries
64+
# of the volume are the surfaces "spids"
65+
meshvol = MeshedVolume(surfaces=[1, 2])
66+
icfd.add(meshvol)
67+
68+
solution.create_database_binary(dt=250)
69+
solution.save_file()

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

Lines changed: 270 additions & 210 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: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,16 @@ def __init__(self, channel):
479479
request_serializer=kwprocess__pb2.ICFDControlOutputRequest.SerializeToString,
480480
response_deserializer=kwprocess__pb2.ICFDControlOutputReply.FromString,
481481
)
482+
self.ICFDCreateControlSteady = channel.unary_unary(
483+
'/kwgrpc.kwC2S/ICFDCreateControlSteady',
484+
request_serializer=kwprocess__pb2.ICFDControlSteadyRequest.SerializeToString,
485+
response_deserializer=kwprocess__pb2.ICFDControlSteadyReply.FromString,
486+
)
487+
self.ICFDCreateControlFSI = channel.unary_unary(
488+
'/kwgrpc.kwC2S/ICFDCreateControlFSI',
489+
request_serializer=kwprocess__pb2.ICFDControlFSIRequest.SerializeToString,
490+
response_deserializer=kwprocess__pb2.ICFDControlFSIReply.FromString,
491+
)
482492
self.ICFDCreateControlTurbulence = channel.unary_unary(
483493
'/kwgrpc.kwC2S/ICFDCreateControlTurbulence',
484494
request_serializer=kwprocess__pb2.ICFDControlTurbulenceRequest.SerializeToString,
@@ -559,6 +569,11 @@ def __init__(self, channel):
559569
request_serializer=kwprocess__pb2.ICFDBdyNonSlipRequest.SerializeToString,
560570
response_deserializer=kwprocess__pb2.ICFDBdyNonSlipReply.FromString,
561571
)
572+
self.ICFDCreateBdyFSI = channel.unary_unary(
573+
'/kwgrpc.kwC2S/ICFDCreateBdyFSI',
574+
request_serializer=kwprocess__pb2.ICFDBdyFSIRequest.SerializeToString,
575+
response_deserializer=kwprocess__pb2.ICFDBdyFSIReply.FromString,
576+
)
562577
self.ICFDCreateInit = channel.unary_unary(
563578
'/kwgrpc.kwC2S/ICFDCreateInit',
564579
request_serializer=kwprocess__pb2.ICFDInitRequest.SerializeToString,
@@ -1326,6 +1341,18 @@ def ICFDCreateControlOutput(self, request, context):
13261341
context.set_details('Method not implemented!')
13271342
raise NotImplementedError('Method not implemented!')
13281343

1344+
def ICFDCreateControlSteady(self, request, context):
1345+
"""Missing associated documentation comment in .proto file."""
1346+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
1347+
context.set_details('Method not implemented!')
1348+
raise NotImplementedError('Method not implemented!')
1349+
1350+
def ICFDCreateControlFSI(self, request, context):
1351+
"""Missing associated documentation comment in .proto file."""
1352+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
1353+
context.set_details('Method not implemented!')
1354+
raise NotImplementedError('Method not implemented!')
1355+
13291356
def ICFDCreateControlTurbulence(self, request, context):
13301357
"""Missing associated documentation comment in .proto file."""
13311358
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -1422,6 +1449,12 @@ def ICFDCreateBdyNonSlip(self, request, context):
14221449
context.set_details('Method not implemented!')
14231450
raise NotImplementedError('Method not implemented!')
14241451

1452+
def ICFDCreateBdyFSI(self, request, context):
1453+
"""Missing associated documentation comment in .proto file."""
1454+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
1455+
context.set_details('Method not implemented!')
1456+
raise NotImplementedError('Method not implemented!')
1457+
14251458
def ICFDCreateInit(self, request, context):
14261459
"""Missing associated documentation comment in .proto file."""
14271460
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -2124,6 +2157,16 @@ def add_kwC2SServicer_to_server(servicer, server):
21242157
request_deserializer=kwprocess__pb2.ICFDControlOutputRequest.FromString,
21252158
response_serializer=kwprocess__pb2.ICFDControlOutputReply.SerializeToString,
21262159
),
2160+
'ICFDCreateControlSteady': grpc.unary_unary_rpc_method_handler(
2161+
servicer.ICFDCreateControlSteady,
2162+
request_deserializer=kwprocess__pb2.ICFDControlSteadyRequest.FromString,
2163+
response_serializer=kwprocess__pb2.ICFDControlSteadyReply.SerializeToString,
2164+
),
2165+
'ICFDCreateControlFSI': grpc.unary_unary_rpc_method_handler(
2166+
servicer.ICFDCreateControlFSI,
2167+
request_deserializer=kwprocess__pb2.ICFDControlFSIRequest.FromString,
2168+
response_serializer=kwprocess__pb2.ICFDControlFSIReply.SerializeToString,
2169+
),
21272170
'ICFDCreateControlTurbulence': grpc.unary_unary_rpc_method_handler(
21282171
servicer.ICFDCreateControlTurbulence,
21292172
request_deserializer=kwprocess__pb2.ICFDControlTurbulenceRequest.FromString,
@@ -2204,6 +2247,11 @@ def add_kwC2SServicer_to_server(servicer, server):
22042247
request_deserializer=kwprocess__pb2.ICFDBdyNonSlipRequest.FromString,
22052248
response_serializer=kwprocess__pb2.ICFDBdyNonSlipReply.SerializeToString,
22062249
),
2250+
'ICFDCreateBdyFSI': grpc.unary_unary_rpc_method_handler(
2251+
servicer.ICFDCreateBdyFSI,
2252+
request_deserializer=kwprocess__pb2.ICFDBdyFSIRequest.FromString,
2253+
response_serializer=kwprocess__pb2.ICFDBdyFSIReply.SerializeToString,
2254+
),
22072255
'ICFDCreateInit': grpc.unary_unary_rpc_method_handler(
22082256
servicer.ICFDCreateInit,
22092257
request_deserializer=kwprocess__pb2.ICFDInitRequest.FromString,
@@ -3985,6 +4033,40 @@ def ICFDCreateControlOutput(request,
39854033
options, channel_credentials,
39864034
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
39874035

4036+
@staticmethod
4037+
def ICFDCreateControlSteady(request,
4038+
target,
4039+
options=(),
4040+
channel_credentials=None,
4041+
call_credentials=None,
4042+
insecure=False,
4043+
compression=None,
4044+
wait_for_ready=None,
4045+
timeout=None,
4046+
metadata=None):
4047+
return grpc.experimental.unary_unary(request, target, '/kwgrpc.kwC2S/ICFDCreateControlSteady',
4048+
kwprocess__pb2.ICFDControlSteadyRequest.SerializeToString,
4049+
kwprocess__pb2.ICFDControlSteadyReply.FromString,
4050+
options, channel_credentials,
4051+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
4052+
4053+
@staticmethod
4054+
def ICFDCreateControlFSI(request,
4055+
target,
4056+
options=(),
4057+
channel_credentials=None,
4058+
call_credentials=None,
4059+
insecure=False,
4060+
compression=None,
4061+
wait_for_ready=None,
4062+
timeout=None,
4063+
metadata=None):
4064+
return grpc.experimental.unary_unary(request, target, '/kwgrpc.kwC2S/ICFDCreateControlFSI',
4065+
kwprocess__pb2.ICFDControlFSIRequest.SerializeToString,
4066+
kwprocess__pb2.ICFDControlFSIReply.FromString,
4067+
options, channel_credentials,
4068+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
4069+
39884070
@staticmethod
39894071
def ICFDCreateControlTurbulence(request,
39904072
target,
@@ -4257,6 +4339,23 @@ def ICFDCreateBdyNonSlip(request,
42574339
options, channel_credentials,
42584340
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
42594341

4342+
@staticmethod
4343+
def ICFDCreateBdyFSI(request,
4344+
target,
4345+
options=(),
4346+
channel_credentials=None,
4347+
call_credentials=None,
4348+
insecure=False,
4349+
compression=None,
4350+
wait_for_ready=None,
4351+
timeout=None,
4352+
metadata=None):
4353+
return grpc.experimental.unary_unary(request, target, '/kwgrpc.kwC2S/ICFDCreateBdyFSI',
4354+
kwprocess__pb2.ICFDBdyFSIRequest.SerializeToString,
4355+
kwprocess__pb2.ICFDBdyFSIReply.FromString,
4356+
options, channel_credentials,
4357+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
4358+
42604359
@staticmethod
42614360
def ICFDCreateInit(request,
42624361
target,

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,13 +2009,37 @@ def ICFDCreateControlGeneral(self, request, context):
20092009

20102010
def ICFDCreateControlOutput(self, request, context):
20112011
msgl = request.msgl
2012-
card1 = str(msgl)
2012+
itout = request.itout
2013+
card1 = str(msgl) + ",0,0,0,," + str(itout)
20132014
newk = "*ICFD_CONTROL_OUTPUT\n" + card1
20142015
self.kwdproc.newkeyword(newk)
20152016
msg = "ICFD Control Output Created..."
20162017
print(msg)
20172018
return kwprocess_pb2.ICFDControlOutputReply(answer=0)
20182019

2020+
def ICFDCreateControlSteady(self, request, context):
2021+
its = request.its
2022+
tol1 = request.tol1
2023+
tol2 = request.tol2
2024+
tol3 = request.tol3
2025+
rel1 = request.rel1
2026+
rel2 = request.rel2
2027+
card1 = str(its) + "," + str(tol1) + "," + str(tol2) + "," + str(tol3) + "," + str(rel1) + "," + str(rel2) + ",1.0"
2028+
newk = "*ICFD_CONTROL_STEADY\n" + card1
2029+
self.kwdproc.newkeyword(newk)
2030+
msg = "ICFD Control Steady Created..."
2031+
print(msg)
2032+
return kwprocess_pb2.ICFDControlSteadyReply(answer=0)
2033+
2034+
def ICFDCreateControlFSI(self, request, context):
2035+
owc = request.owc
2036+
card1 = str(owc)
2037+
newk = "*ICFD_CONTROL_FSI\n" + card1
2038+
self.kwdproc.newkeyword(newk)
2039+
msg = "ICFD Control FSI Created..."
2040+
print(msg)
2041+
return kwprocess_pb2.ICFDControlFSIReply(answer=0)
2042+
20192043
def ICFDCreateControlTurbulence(self, request, context):
20202044
tmod = request.tmod
20212045
card1 = str(tmod)
@@ -2204,6 +2228,15 @@ def ICFDCreateBdyNonSlip(self, request, context):
22042228
print(msg)
22052229
return kwprocess_pb2.ICFDBdyNonSlipReply(answer=0)
22062230

2231+
def ICFDCreateBdyFSI(self, request, context):
2232+
pid = request.pid
2233+
card1 = str(pid)
2234+
newk = "*ICFD_BOUNDARY_FSI\n" + card1
2235+
self.kwdproc.newkeyword(newk)
2236+
msg = "ICFD boundary FSI " + str(pid) + " Created..."
2237+
print(msg)
2238+
return kwprocess_pb2.ICFDBdyFSIReply(answer=0)
2239+
22072240
def ICFDCreateInit(self, request, context):
22082241
pid = request.pid
22092242
vx = request.vx

0 commit comments

Comments
 (0)