This is my codes to calculate a wave equation by NDSolveValue:
Block[{nSteps = 0, Timer = 0, L = 100, T = 100, a = 0.1, b = 10},
Monitor[
sol = NDSolveValue[
{
D[u[t, x], t, t] - D[u[t, x], x, x] + a Exp[-(x)^2/b] u[t, x] ==
0,
u[0, x] == Exp[-1 (x - 1)^2], Derivative[1, 0][u][0, x] == 0,
DirichletCondition[u[t, x] == 0, True]
}, u, {t, 0, T}, {x, -L, L},
Method -> {"PDEDiscretization" -> {"MethodOfLines",
"SpatialDiscretization" -> {"FiniteElement",
"MeshOptions" -> {"MaxCellMeasure" -> 0.1}}}},
StepMonitor :> (Timer = t; ++nSteps)],
{nSteps, Timer}]
] // AbsoluteTiming
To get a precise solution, I use "MaxCellMeasure" -> 0.1, but the volume of output InterpolatingFunction reaches 1050.8 MB, which makes it run slowly when I try to use the output function sol. So is there a way to get a small output with "MaxCellMeasure" -> 0.1 fixed here?
"MaxCellMeasure" -> 0.1fixed here" Do you mean you don't want to change the spatial grid size inInterpolatingFunction, or you just don't want to change it in solving process? 2. "it run slowly when I try to use the output functionsol", how will you usesol? $\endgroup$InterpolatingFunction. 2. For example,Plot[sol[t,50],{t,0,100}]runs slowly, although I found thatsol[Range[0,100,0.1],50]//ListPlotis acceptable. $\endgroup$Plot[sol[t,50],{t,0,100}]is just a bit slower thansol[Range[0,100,0.1],50]//ListPlot: wolframcloud.com/obj/xzczd/Published/SE%20test.nb (I have to enlargeMaxCellMeasurea bit on cloud, but this should not be a problem. ) Which version are you in? $\endgroup$