Problem when defining different materials

Dear all,

I want to define two different materials as in the Tutorial Defining subdomains for different materials — FEniCSx tutorial.

I want the different domains to be defined as follows:

Omega0: {z ≤ 0.5h, z ≥ 0.5h + hg}
Omega0: {z ≥ 0.5h, z ≤ 0.5h + hg}

Therefore, I have defined the functions:

def Omega_0(x):
    return np.any([x[2] <= 0.5*h, x[2] >= 0.5*h + h_g], axis=0)

def Omega_1(x):
    return np.any([x[2] >= 0.5*h, x[2] <= 0.5*h + h_g], axis=0)

However, the results that I am getting seems to be wrong, as if the full structure was made of the same material.

If I just simply say

def Omega_0(x):
    return x[2] <= 0.5*h

def Omega_1(x):
    return x[2] >= 0.5*h

like in the tutorial, the results are correct.

Does anyone know why I am defining wrongly the two functions above?

Thanks in advance.

I solved the issue. The problem was a bad usage of the np.any condition.

The following code worked:

def Omega_0(x):
    return np.logical_or((x[2] <= 0.5*h), (x[2] >= 0.5*h + h_g))

def Omega_1(x):
    return np.logical_and((x[2] >= 0.5*h), (x[2] <= 0.5*h + h_g))