return on_boundary and near(x[0], Length)


def exact_solution(domain):
    P7 = VectorElement("Lagrange", "triangle", degree=8, dim=2)
    P2 = FiniteElement("Lagrange", "triangle", 3)
    coeff = (P_inlet-P_outlet)/(2*Length*visc)
    u_exact = Expression(("C*x[1]*(H - x[1])", "0.0"), C=coeff,H=Height, element=P7, domain=domain)
    p_exact = Expression("dP-dP/L*x[0]", dP=(P_inlet-P_outlet), L=Length, element=P2, domain=domain)
    return u_exact, p_exact

# 1. Mesh from fenics 
nx=4
mesh = RectangleMesh(Point(0,0), Point(Length, Height), int(nx*Length), nx, "right")

zero_vec = np.zeros(mesh.geometry().dim())

# Define boundaries
mark = {"Internal":0,"wall": 98,"inlet": 99,"outlet": 100 }

boundaries = MeshFunction('size_t', mesh, mesh.topology().dim() - 1)
boundaries.set_all(mark["Internal"])
wall=Noslip()
wall.mark(boundaries, mark["wall"])
left = Left()
left.mark(boundaries, mark["inlet"])
right = Right()
right.mark(boundaries, mark["outlet"])

ds = Measure('ds',domain=mesh,subdomain_data=boundaries)
n = FacetNormal(mesh)
    Lpml = 1.0    # width of the PML layer
    Lx   = 10.0   # width of the interior domain
    Ly   = 10.0   # heigth of the interior domain

        
    # Attenuation functions
    beta_0  = physical_parameters.beta_0    # 280  # propagation
    alpha_0 = physical_parameters.alpha_0   # 2.76 # evanescent
        
    # Mesh generation and refinement
    nx = 80
    ny = 80
    mesh = RectangleMesh(Point(- 0.5 * Lx - Lpml, 0.0), Point(0.5 * Lx + Lpml, - Ly - Lpml), nx, ny, "crossed")

    # Markers for Dirichlet bc
    ff = MeshFunction("size_t", mesh, mesh.geometry().dim() - 1)
    Dirichlet().mark(ff, 1)

    # Markers for disk source
    mf = MeshFunction("size_t", mesh, mesh.geometry().dim())
    circle().mark(mf, 1)

    # Create function spaces
    VE = VectorElement("CG", mesh.ufl_cell(), 1, dim=2)
    TE = TensorElement("DG", mesh.ufl_cell(), 0, shape=(2, 2), symmetry=True)

    W = FunctionSpace(mesh, MixedElement([VE, TE]))
    F = FunctionSpace(mesh, "CG", 2)
    V = W.sub(0).collapse()
    M = W.sub(1).collapse()