markmesh.py 455 B

1234567891011121314151617181920
  1. '''
  2. Mark mesh with boundary function
  3. '''
  4. from dolfin import *
  5. mesh = UnitCubeMesh(5,5,5)
  6. V = FunctionSpace(mesh, "Lagrange", 1)
  7. class left(SubDomain):
  8. def inside(self, x, on_boundary):
  9. return on_boundary and abs(x[0]) < DOLFIN_EPS
  10. left = left()
  11. tcond = MeshFunction("size_t", mesh, 0)
  12. tcond.set_all(0)
  13. left.mark(tcond, 1)
  14. ##################################
  15. from vedo.dolfin import plot
  16. plot(tcond, cmap='cool', elevation=20, text=__doc__)