How to apply boundary condition like this

Please follow Read before posting: How do I get my question answered?
which describes how to make a minimal working example.