bool operator for where function

Asked by ceguo

Hi,

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)

Ning

Question information

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

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 :
#2

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 :
#3

Thanks Lutz Gross, that solved my question.