Skip to content

Commit bb42037

Browse files
work in progress
1 parent 404e5e1 commit bb42037

File tree

1 file changed

+20
-6
lines changed
  • channel-transport-particles/fluid-nutils

1 file changed

+20
-6
lines changed

channel-transport-particles/fluid-nutils/fluid.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,25 @@ def main():
4343
# that's the only reason
4444
ns.ubasis = domain.basis("std", degree=2).vector(2)
4545
ns.pbasis = domain.basis("std", degree=1)
46+
ns.εbasis = gauss.basis()
47+
ns.Fbasis = gauss.basis().vector(2)
4648
ns.u_i = "ubasis_ni ?u_n" # solution
49+
ns.u0_i = "ubasis_ni ?u0_n" # solution
4750
ns.p = "pbasis_n ?p_n" # solution
48-
ns.dudt_i = "ubasis_ni (?u_n - ?u0_n) / ?dt" # time derivative
51+
ns.ε = "εbasis_ni ?ε_n" # solid fraction
52+
ns.ε0 = "εbasis_ni ?ε0_n" # solid fraction
53+
ns.F_i = "Fbasis_ni ?F_n" # drag force
54+
ns.g = numpy.array([0, -9.81])
55+
ns.ρ = 1.0 # density TODO FIX VALUE
56+
ns.DεDt = "(ε - ε0) / ?dt + (ε u_i)_,i"
57+
ns.DρεuDt_i = "ρ (ε u_i - ε0 u0_i) / ?dt + ρ (ε u_i u_j)_,j"
4958
ns.μ = 0.5 # viscosity
5059
ns.σ_ij = "μ (u_i,j + u_j,i) - p δ_ij"
5160
ns.uin = "10 x_1 (2 - x_1)" # inflow profile
5261

5362
# define the weak form, Stokes problem
54-
ures = gauss.integral("ubasis_ni,j σ_ij d:x" @ ns)
55-
pres = gauss.integral("pbasis_n u_k,k d:x" @ ns)
63+
ures = gauss.integral("(ubasis_ni (DρεuDt_i - ε ρ g_i + F_i) + ubasis_ni,j ε σ_ij) d:x" @ ns) # TODO correct weak form
64+
pres = gauss.integral("pbasis_n DεDt d:x" @ ns)
5665

5766
# Dirichlet boundary condition
5867
sqr = domain.boundary["inflow"].integral("(u_0 - uin)^2 d:x" @ ns, degree=2)
@@ -81,10 +90,11 @@ def main():
8190
precice_dt = participant.get_max_time_step_size()
8291
dt = min(precice_dt, solver_dt)
8392

84-
state = solver.solve_linear(("u", "p"), (ures, pres), constrain=cons) # initial condition
93+
## TODO: INITIAL CONDITION
94+
#state = solver.solve_linear(("u", "p"), (ures, pres), constrain=cons) # initial condition
8595

86-
# add convective term and time derivative for Navier-Stokes
87-
ures += gauss.integral("ubasis_ni (dudt_i + μ (u_i u_j)_,j) d:x" @ ns)
96+
## add convective term and time derivative for Navier-Stokes
97+
#ures += gauss.integral("ubasis_ni (dudt_i + μ (u_i u_j)_,j) d:x" @ ns)
8898

8999
while participant.is_coupling_ongoing():
90100

@@ -105,8 +115,12 @@ def main():
105115
# drag_force_name = participant.read_data(mesh_name, drag_force_name, vertex_ids, ...)
106116
# Checkpointing for implicit coupling is generally not required
107117

118+
state['ε'] = 1 - participant.read_data(mesh_name, solid_fraction_name, vertex_ids, dt)
119+
state['F'] = participant.read_data(mesh_name, drag_force_name, vertex_ids, dt)
120+
108121
# solve Nutils timestep
109122
state["u0"] = state["u"]
123+
state["ε0"] = state["ε"]
110124
state["dt"] = dt
111125
state = solver.newton(("u", "p"), (ures, pres), constrain=cons, arguments=state).solve(1e-10)
112126

0 commit comments

Comments
 (0)