2
$\begingroup$

I create an ImplicitRegion from a box-shaped region with one face replaced by a function h[x,y]. If h[x,y] is a "normal" function, e.g.

h[x_,y_]:=y/(1+x^2)
solnRegn = ImplicitRegion[{z > h[x,y]},{{x, -60, 700}, {y, -60, 700}, {z, 110, 240}}];

then my region is a ConstantRegion. If it is created from an Interpolation, e.g.

data = {{539, 700, 135}, {586, 700, 135}, {413, 700, 113}, {277, 700, 
110}, {441, 700, 120}, {154, 700, 115}, {0, 700, 121}, {539, 640, 
135}, {586, 640, 135}, {413, 640, 113}, {277, 640, 110}, {441, 
640, 120}, {154, 640, 115}, {0, 640, 121}, {0, 103, 170}, {0, 257,
 155}, {0, 219, 160}, {0, 77, 200}, {0, 395, 133}, {0, 494, 
128}, {0, 0, 235}, {0, -60, 235}, {-60, 700, 121}, {-60, 640, 
121}, {-60, 103, 170}, {-60, 257, 155}, {-60, 219, 160}, {-60, 77,
 200}, {-60, 395, 133}, {-60, 494, 128}, {-60, 0, 235}, {413, 0, 
225}, {280, 0, 235}, {50, 0, 230}, {573, 0, 225}, {90, 0, 
235}, {640, 0, 215}, {700, 0, 215}, {-60, -60, 235}, {413, -60, 
225}, {280, -60, 235}, {50, -60, 230}, {573, -60, 225}, {90, -60, 
235}, {640, -60, 215}, {640, 345, 200}, {640, 193, 224}, {640, 
461, 135}, {640, 393, 160}, {640, 640, 125}, {640, 700, 
125}, {700, -60, 215}, {700, 345, 200}, {700, 193, 224}, {700, 
461, 135}, {700, 393, 160}, {700, 640, 125}, {700, 700, 
125}, {436, 451, 125}, {252, 442, 125}, {252, 336, 125}, {336, 
336, 125}, {220, 444, 135}, {196, 353, 135}, {347, 47, 225}, {151,
 402, 175}, {90, 543, 120}, {518, 543, 130}, {566, 612, 
165}, {583, 565, 165}, {169, 274, 150}, {420, 274, 150}, {169, 
366, 150}, {409, 75, 220}, {236, 104, 185}, {205, 249, 140}, {472,
 168, 175}, {426, 168, 175}, {426, 381, 138}, {138, 168, 
215}, {259, 196, 140}, {473, 257, 205}, {259, 257, 130}, {473, 
196, 175}, {299, 99, 200}, {400, 351, 140}, {299, 351, 121}, {400,
 99, 195}, {260, 91, 200}, {369, 91, 185}, {527, 601, 125}, {149, 
601, 115}, {527, 403, 205}, {320, 141, 160}, {537, 454, 
190}, {320, 454, 116}, {537, 141, 225}, {32, 193, 160}, {32, 345, 
142}, {112, 270, 200}, {597, 359, 205}, {112, 359, 195}, {597, 
270, 220}, {128, 89, 210}, {468, 397, 160}, {128, 397, 175}, {468,
 89, 222}, {151, 327, 150}, {151, 454, 145}, {450, 327, 
205}, {490, 436, 150}, {159, 436, 163}, {490, 116, 220}, {158, 81,
 235}, {579, 167, 229}, {224, 475, 145}, {286, 516, 130}, {224, 
516, 130}, {286, 475, 125}, {70, 166, 165}, {179, 446, 160}, {481,
 586, 130}, {432, 586, 130}, {481, 534, 130}, {464, 551, 
136}, {529, 374, 210}, {432, 534, 130}, {45, 147, 160}, {68, 219, 
165}, {361, 619, 110}, {361, 494, 114}, {68, 395, 140}, {59, 60, 
180}, {98, 326, 193}, {59, 326, 155}, {98, 60, 200}, {589, 310, 
215}, {589, 588, 160}, {558, 572, 160}, {503, 572, 127}, {558, 
398, 205}, {325, 205, 135}, {325, 96, 182}, {255, 74, 220}, {105, 
188, 190}, {155, 188, 201}, {82, 70, 180}, {486, 316, 215}, {525, 
316, 217}, {486, 388, 190}, {410, 298, 150}, {513, 257, 
220}, {513, 103, 225}, {170, 133, 223}, {198, 133, 210}, {519, 
461, 161}, {590, 506, 167}, {519, 506, 136}, {590, 461, 
180}, {434, 202, 150}, {150, 268, 172}, {163, 217, 164}, {347, 
123, 160}, {387, 141, 155}, {411, 186, 155}, {411, 247, 
150}, {446, 147, 205}, {446, 176, 165}, {95, 115, 175}, {95, 157, 
175}, {271, 126, 160}, {377, 191, 140}, {377, 257, 140}, {328, 
267, 130}, {232, 158, 158}, {208, 190, 159}, {247, 127, 
160}, {211, 45, 235}, {557, 545, 160}, {557, 505, 160}, {125, 207,
 208}, {278, 71, 225}, {436, 242, 160}};
data = 1. data;(*Fix precision*)
h = 
 Interpolation[data, InterpolationOrder -> 1];
Print["Test ", h[2, 3]];
Needs["NDSolve`FEM`"];
solnRegn = 
  ImplicitRegion[{z > h[x, y]}, {{x, -60, 700}, {y, -60, 700}, {z, 
     110, 240}}];
ConstantRegionQ[solnRegn]
ToBoundaryMesh[solnRegn]["Wireframe"]

then ConstantRegionQ returns "False":

enter image description here

although, as can be seen, the ToBoundaryMesh function does in fact work. But why is ConstantRegionQ False? Something wrong with my interpolation?

It is somewhat surprising (but perfectly fine, of course) that both ToBoundaryMesh and ToElementMesh work with this, since ConstantRegionQ is False and their documentation says that they require ConstantRegionQ=True.

$\endgroup$
2
  • $\begingroup$ Works just fine for me. If you make a post make sure that you have included all information to reproduce the issue you are seeing. What is data, xMn etc. $\endgroup$ – user21 Feb 24 '20 at 7:08
  • $\begingroup$ I have edited the question to be more explicit about the input variables/data. $\endgroup$ – Paul Harrison Feb 24 '20 at 11:25
3
$\begingroup$

Works just fine for me:

Needs["NDSolve`FEM`"]
data = Flatten[Table[{{x, y}, LCM[x, y]}, {x, 4}, {y, 4}], 1];
if = Interpolation[data, InterpolationOrder -> 1];
solnRegn = 
  ImplicitRegion[{z > if[x, y]}, {{x, 0, 1}, {y, 0, 1}, {z, 0, 1}}];
ConstantRegionQ[solnRegn]
ToBoundaryMesh[solnRegn]["Wireframe"]

(* False *)

enter image description here

$\endgroup$
7
  • $\begingroup$ When I paste exactly your code (above) into my notebook, ConstantRegionQ[solnRegn] returns False. I am using MMA 12.0.0 on Mac. $\endgroup$ – Paul Harrison Feb 24 '20 at 21:40
  • $\begingroup$ I am not sure if the False that is returned from ConstantRegionQ is correct. The reason that the ref pages have this mention of ConstantRegionQ is that a region like Disk[{0,0},variableR] can not be discretized if variableR is not defined. In any case ToElementMesh happily performs the discretization which is good. $\endgroup$ – user21 Feb 25 '20 at 7:58
  • $\begingroup$ Thanks for your feedback. I guess it is a bug in ConstantRegionQ then, since regions created thus are manifestly ConstantRegions. I agree that it is good that the ToElementMesh works anyway. $\endgroup$ – Paul Harrison Feb 25 '20 at 8:34
  • $\begingroup$ I forwarded the question about ConstantRegionQ in house and we'll see what people have to say. $\endgroup$ – user21 Feb 25 '20 at 8:36
  • $\begingroup$ @PaulHarrison, sorry forgot to @ you. $\endgroup$ – user21 Feb 25 '20 at 8:57
2
$\begingroup$

One workaround is to define a function that's explicitly numeric:

data = Flatten[Table[{{x, y}, LCM[x, y]}, {x, 4}, {y, 4}], 1];
if = Interpolation[data, InterpolationOrder -> 1];

SetAttributes[g, NumericFunction];
g[x_?NumericQ, y_] := if[x, y]

reg = ImplicitRegion[z > g[x, y], {{x, 1, 4}, {y, 1, 4}, {z, 1, 4}}];

ConstantRegionQ[reg]
True
$\endgroup$
3
  • $\begingroup$ Thanks Chip, that looks a promising way forward. I will try it. $\endgroup$ – Paul Harrison Feb 22 '20 at 15:48
  • $\begingroup$ As a work-around, your suggestion works, Chip, thanks. It of course does not explain why ToElementMesh works for my Interpolated function without the workaround, but ToBoundaryMesh does not. $\endgroup$ – Paul Harrison Feb 23 '20 at 9:24
  • $\begingroup$ Correction, ToBoundaryMesh also works, even though ConstantRegionQ is False for the original input. $\endgroup$ – Paul Harrison Feb 24 '20 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.