Skip to content

Commit

Permalink
separate sample definitions from precice setup
Browse files Browse the repository at this point in the history
  • Loading branch information
gertjanvanzwieten committed Jan 8, 2024
1 parent 2d3a6b3 commit 6e660e3
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions perpendicular-flap/fluid-nutils/fluid.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
topo[18:20, :10].withboundary(flap='left,right,top')

couplinginterface = domain.boundary['flap']
couplingsample = couplinginterface.sample('gauss', degree=2) # mesh located at Gauss points
couplingsample = couplinginterface.sample('uniform', degree=npoints_per_elem)

bezier = domain.sample('bezier', 2)

# time approximations
t0 = lambda f: function.replace_arguments(f, {arg: function.Argument(arg+'0', shape=shape, dtype=dtype)
Expand All @@ -54,30 +56,6 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
ns.p = 'pbasis_n ?lhs_n' # pressure
ns.qw = 1 / npoints_per_elem

# for visualization
bezier = domain.sample('bezier', 2)

# preCICE setup
configFileName = "../precice-config.xml"
participantName = "Fluid"
solverProcessIndex = 0
solverProcessSize = 1
interface = precice.Interface(participantName, configFileName, solverProcessIndex, solverProcessSize)

# define coupling meshes
meshName = "Fluid-Mesh"
meshID = interface.get_mesh_id(meshName)
dataIndices = interface.set_mesh_vertices(meshID, couplingsample.eval(ns.x0))

# coupling data
writeData = "Force"
readData = "Displacement"
writedataID = interface.get_data_id(writeData, meshID)
readdataID = interface.get_data_id(readData, meshID)

# initialize preCICE
precice_dt = interface.initialize()

# boundary conditions for fluid equations
sqr = domain.boundary['wall,flap'].integral('urel_k urel_k d:x0' @ ns, degree=4)
cons = solver.optimize('lhs', sqr, droptol=1e-15)
Expand Down Expand Up @@ -107,6 +85,18 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
#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)
#lhs0 = solver.solve_linear('lhs', res_stokes, constrain=cons, arguments=dict(meshdofs=meshdofs, meshdofs0=meshdofs0, meshdofs00=meshdofs00, meshdofs000=meshdofs000, dt=dt))

# preCICE setup
solverProcessIndex = 0
solverProcessSize = 1
interface = precice.Interface("Fluid", "../precice-config.xml", solverProcessIndex, solverProcessSize)
meshID = interface.get_mesh_id("Fluid-Mesh")
dataIndices = interface.set_mesh_vertices(meshID, couplingsample.eval(ns.x0))
writedataID = interface.get_data_id("Force", meshID)
readdataID = interface.get_data_id("Displacement", meshID)

# initialize preCICE
precice_dt = interface.initialize()

timestep = 0
arguments = dict(lhs=numpy.zeros(len(ns.ubasis)), F=numpy.zeros(len(ns.ubasis)), meshdofs=numpy.zeros(len(ns.dbasis)), dt=timestepsize)

Expand Down

0 comments on commit 6e660e3

Please sign in to comment.