# 偏微分方程和事件

 In[1]:= XSubscript[\[CapitalOmega], 1] = ImplicitRegion[x^4 + y^4 <= 1, {x, y}]; Subscript[\[CapitalOmega], 2] = ImplicitRegion[x^2 + y^2 <= 1, {x, y}]; Subscript[\[CapitalOmega], 3] = ImplicitRegion[Abs[x] + Abs[y] <= 1, {x, y}]; Subscript[\[CapitalOmega], 4] = ImplicitRegion[Sqrt[Abs[x]] + Sqrt[Abs[y]] <= 1, {x, y}];

 In[2]:= XTable[uhsol[i] = NDSolveValue[{\!\( \*SubscriptBox[\(\[PartialD]\), \(t\)]\(u[t, x, y]\)\) == Inactive[Laplacian][u[t, x, y], {x, y}], DirichletCondition[u[t, x, y] == 1, True], u[0, x, y] == 0, WhenEvent[ u[t, 0, 0] == 1/2, {Subscript[T, i] = t, "StopIntegration"}]}, u, {t, 0, 1}, {x, y} \[Element] Subscript[\[CapitalOmega], i], Method -> {"PDEDiscretization" -> {"MethodOfLines", "DifferentiateBoundaryConditions" -> {True, "ScaleFactor" -> 10^3}}}]; Subscript[T, i], {i, 1, 4}]
 Out[2]=

 In[3]:= XTable[Plot3D[ uhsol[i][Subscript[T, i], x, y], {x, y} \[Element] uhsol[i]["ElementMesh"], PlotPoints -> 40, Mesh -> None, ColorFunction -> "TemperatureMap"], {i, 4}]
 Out[3]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »