bool operator for where function

Asked by ceguo


How to use where function to locate an area like a<x[0]<b and c<x[1]<d, I tried the bool operation and/or, but it doesn't work. I want to set a imperfection within the domain located at the place. I tried this:

wherePositive(x[0]-a) and whereNegative(x[0]-b) and wherePositive(x[1]-c) and whereNegative(x[1]-d)


Question information

English Edit question
esys-escript Edit question
No assignee Edit question
Solved by:
Lutz Gross
Last query:
Last reply:
Revision history for this message
Best Lutz Gross (l-gross) said :

Use " * " instead of "and":

wherePositive(x[0]-a) * whereNegative(x[0]-b) * wherePositive(x[1]-c) * whereNegative(x[1]-d)

Similarly you can use "+" for "or" but in this case you need to add a wherePositive call in order to bring the values back to binary if you need this.

There is a feature request for a boolean algebra for masks - but ....

Revision history for this message
Joel Fenwick (j-fenwick1) said :

The reason for using * instead of and is that the where???() operations return Data objects composed of 0 and 1 not False and True.

Revision history for this message
ceguo (hhh-guo) said :

Thanks Lutz Gross, that solved my question.