You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.0 KiB

3 years ago
  1. from fenics import *
  2. from mshr import *
  3. import numpy as np
  4. finalt = 5 #Final time
  5. steps = 5000 #number of steps
  6. dt = finalt/steps #time steps
  7. # model parameters
  8. mu = 0.001 #dynamic viscosity
  9. rho = 1 #density
  10. #creating mesh
  11. channel = Rectangle(Point(0,0), Point(2.2, 0.41))
  12. cylinder = Circle(Point(0.2,0.2), 0.05)
  13. domain = channel - cylinder
  14. mesh = generate_mesh(domain,64)
  15. #Defining spaces
  16. V = VectorFunctionSpace(mesh,'P', 2)
  17. Q = FunctionSpace(mesh, 'P', 1)
  18. #defining boundaries:
  19. inflow = 'near(x[0], 0)'
  20. outflow = 'near(x[0], 2.2)'
  21. walls = 'near(x[1], 0) || near(x[1], 0.41)'
  22. cylinder = 'on_boundary && x[0]>0.1 && x[0]<0.3 &&x[1]>0.1 && x[1]<0.3'
  23. #defining inflow profile
  24. inflowProfile('4.0*1.5*x[1]*(0.41-x[1])/pow(0.41,2)', '0')
  25. #defining boundary conditions:
  26. bcuInflow = DirichletBC(V,Expression(inflowProfile, degree=2), inflow)
  27. bcuWalls = DirichletBC(V, Constant((0, 0)), walls)
  28. bcuCylinder = DirichletBC(V, Constant((0,0)), cylinder)
  29. bcpOutflow = DirichletBC(Q, Constant(0), outflow)
  30. bcu = [bcuInflow, bcuWalls, bcuCylinder]
  31. bcp = [bcpOutflow]