I'm trying to solve a PDE using the `NDsolve`

with initial conditions and contour,

```
NDSolve[{D[u[t, x], t]- D[ D[u[t, x], X]]+ D[u[t, x], X]== 10,
you[0, x] == 2,
you[t, 0] == 1,
you[t, 2] == 1
}
you
{t, 0, 5}, {x, 0, 2}, MaxStepSize -> 0.01]
```

it worked. But when I try to assign an initial condition: `you[0,x]= 2`

when `0.5 <= x <= 1`

, `you[0,x]= 1`

elsewhere in [0,2] through `Yes`

```
NDSolve[{D[u[t, x], t]- D[ D[u[t, x], X]]+ D[u[t, x], X]== 10,
Yes[05<=x[05<=x[05<=x[05<=x<= 1, u[0, x] == 2, u[0, x] == 1],
u[t, 0] == 1,
u[t, 2] == 1
},
u,
{t, 0, 5}, {x, 0, 2}, MaxStepSize -> 0.01]
```

the system returned me

```
NDSolve :: deqn: Equation or list of expected equations instead of If[05<=x<=1u[05<=x<=1u[05<=x<=1u[05<=x<=1u[0,x]== 2, u[0,x]== 1]in the first argument {(u ^ (1,0))[t,x]== 10, yes[05<=x<=1u[05<=x<=1u[05<=x<=1u[05<=x<=1u[0,x]== 2, u[0,x]== 1]you[t,0]== 1, u[t,2]== 1}
```

I know something is wrong with the expression of my initial conditions, but how do I assign the initial conditions with an if condition? Or a better way to deal with that?

Thanks for your time!

TO UPDATE:

I followed the advice of @bbgodfrey using DirichletCondition. it worked.

```
NDSolve[{D[u[t, x], t]- D[ D[u[t, x], X]]+ D[u[t, x], X]== 0,
Condition of Dirichlet[u[t, x] == 2, 0.5 <= x <= 1],
DirichletCondition[u[t, x] == 1, {2 >= x> 1, 0 <= x < 0.5}],
u[t, 0] == 1,
u[t, 2] == 1
},
u,
{t, 0, 5}, {x, 0, 2}, MaxStepSize -> 0.01]
```

But comparing with the results of @kglr, the results are different. These are the results using DirichletCondition, which also with an alert.

NDSolve :: femcscd: the PDE is dominated by convection and the result may not be stable. Addition of artificial diffusion can help.

This is the result using Boole.

Thank you!