Skip to content

Commit d406c27

Browse files
separate sample definitions from precice setup
1 parent 6c2a551 commit d406c27

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

perpendicular-flap/fluid-nutils/fluid.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01):
2727
topo[18:20, :10].withboundary(flap='left,right,top')
2828

2929
couplinginterface = domain.boundary['flap']
30-
couplingsample = couplinginterface.sample('gauss', degree=2) # mesh located at Gauss points
30+
couplingsample = couplinginterface.sample('uniform', degree=npoints_per_elem)
31+
32+
bezier = domain.sample('bezier', 2)
3133

3234
# time approximations
3335
t0 = lambda f: function.replace_arguments(f, {arg: function.Argument(arg+'0', shape=shape, dtype=dtype)
@@ -54,30 +56,6 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01):
5456
ns.p = 'pbasis_n ?lhs_n' # pressure
5557
ns.qw = couplingsample.asfunction(numpy.concatenate([p.weights for p in couplingsample.points]))
5658

57-
# for visualization
58-
bezier = domain.sample('bezier', 2)
59-
60-
# preCICE setup
61-
configFileName = "../precice-config.xml"
62-
participantName = "Fluid"
63-
solverProcessIndex = 0
64-
solverProcessSize = 1
65-
interface = precice.Interface(participantName, configFileName, solverProcessIndex, solverProcessSize)
66-
67-
# define coupling meshes
68-
meshName = "Fluid-Mesh"
69-
meshID = interface.get_mesh_id(meshName)
70-
dataIndices = interface.set_mesh_vertices(meshID, couplingsample.eval(ns.x0))
71-
72-
# coupling data
73-
writeData = "Force"
74-
readData = "Displacement"
75-
writedataID = interface.get_data_id(writeData, meshID)
76-
readdataID = interface.get_data_id(readData, meshID)
77-
78-
# initialize preCICE
79-
precice_dt = interface.initialize()
80-
8159
# boundary conditions for fluid equations
8260
sqr = domain.boundary['wall,flap'].integral('urel_k urel_k d:x0' @ ns, degree=4)
8361
cons = solver.optimize('lhs', sqr, droptol=1e-15)
@@ -107,6 +85,18 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01):
10785
#res_stokes = domain.integral('(ubasis_ni,j ((u_i,j + u_j,i) rho nu - p δ_ij) + pbasis_n u_k,k) d:x' @ ns, degree=4)
10886
#lhs0 = solver.solve_linear('lhs', res_stokes, constrain=cons, arguments=dict(meshdofs=meshdofs, meshdofs0=meshdofs0, meshdofs00=meshdofs00, meshdofs000=meshdofs000, dt=dt))
10987

88+
# preCICE setup
89+
solverProcessIndex = 0
90+
solverProcessSize = 1
91+
interface = precice.Interface("Fluid", "../precice-config.xml", solverProcessIndex, solverProcessSize)
92+
meshID = interface.get_mesh_id("Fluid-Mesh")
93+
dataIndices = interface.set_mesh_vertices(meshID, couplingsample.eval(ns.x0))
94+
writedataID = interface.get_data_id("Force", meshID)
95+
readdataID = interface.get_data_id("Displacement", meshID)
96+
97+
# initialize preCICE
98+
precice_dt = interface.initialize()
99+
110100
timestep = 0
111101
arguments = dict(lhs=numpy.zeros(len(ns.ubasis)), meshdofs=numpy.zeros(len(ns.dbasis)), dt=timestepsize)
112102

0 commit comments

Comments
 (0)