Hi,
i have problem with fluid flow simulations. I tried using oasicsx pckg but constantly either simulation explodes or i get errors. Bellow a simple example for Poisseuile like channel flow, based on the taylor-green example from github Oasicsx/demo
from mpi4py import MPI
from petsc4py import PETSc
import dolfinx
from dolfinx import fem, mesh
import numpy as np
import oasisx
from oasisx import DirichletBC, LocatorMethod, FractionalStep_AB_CN
from tqdm import tqdm
from typing import List
domain = mesh.create_rectangle(MPI.COMM_WORLD, [np.array([0, 0]), np.array([10, 1])], [50, 5], cell_type=mesh.CellType.triangle)
bcs_p: List[oasisx.PressureBC] = []
bc_inlet = DirichletBC(dolfinx.fem.Constant(domain, 1.), method=LocatorMethod.GEOMETRICAL, marker=lambda x: np.isclose(x[0], 0))
bc_wall = DirichletBC(dolfinx.fem.Constant(domain, 0.), method=LocatorMethod.GEOMETRICAL, marker=lambda x: np.logical_or(np.isclose(x[1], 0), np.isclose(x[1], 1)))
bcs_u = [[bc_inlet], [bc_wall]]
# fractional step solver
solver = FractionalStep_AB_CN(
mesh=domain,
u_element=("Lagrange", 2),
p_element=("Lagrange", 1),
bcs_u=bcs_u,
bcs_p=bcs_p,
solver_options={"tentative": {"ksp_type": "preonly", "pc_type": "lu"},"pressure": {"ksp_type": "preonly", "pc_type": "lu"},"scalar": {"ksp_type": "preonly", "pc_type": "lu"}},
body_force=None
)
# Time-stepping
T_start, T_end, dt = 0.0, 0.1, 0.01
num_steps = int((T_end - T_start) // dt)
for step in tqdm(range(num_steps)):
solver.solve(dt, nu=0.01, max_iter=10)
with the result: