3%
4% [sig,Nx0,h0,t0,mu] = manufacturedSolution(M,tFinal,s,beta)
5% returns in sig a cell array of M density function handles
6%
7% Input values:
8% M: number of spring scatterers (sources)
9% tFinal: final time
10% tol: error tolerance for the full problem (to compute starting dt)
11% gam: pad gam*Nyquist for window function (to compute starting dt)
12%
13% Outputs:
14% sig: function handle in terms of time that produces a vector of density
15% values evaluated at a specific time t:
16% [sig_1(t),...,sig_M(t)]
17% Nx0, h0: Number of grid points needed to ensure sig is resolved on the
18% time grid, as well as the maximum step-size.
19% t0, mu : (to document)
20% dataParam: is a struct involving t0,mu and sig.
21%
22% Notes:
23% Take the densities to be Gaussians for testing.
520bc24updated readme file and cleaned up codenalhassanieh 25if nargin == 0, test_manufacturedSolution(); return; end
8748c66added codenalhassanieh 27override = 0; % turn on '1' to avoid restrictions on chosen test function
30mu = linspace(2,5,M)';
32% choose t0 such that sig(0) = eps
33t0 = sqrt(log(1/eps)./mu);
8748c66added codenalhassanieh 34
36dt0_vec = pi./(4*sqrt(mu*log(1/eps)));
37dt0 = min(dt0_vec);
8748c66added codenalhassanieh 38
39% ensure that the forcing function is bandlimited within the computational time domain
40if(any(2*t0>tFinal)&&(override == 0))
41 error('Forcing inappropriate for testing. For tFinal=%1.2f\nChoose other mu or tFinal',tFinal);
42end
44% Define the density functions to be Gaussians
45sig = @(t) exp(-mu.*((t - t0).^2));
47dataParam.sig = sig;
48dataParam.t0 = t0;
49dataParam.mu = mu;
51end
520bc24updated readme file and cleaned up codenalhassanieh 52
53%%%%
54function test_manufacturedSolution()
56M = 1; tFinal = 3*pi;
57[dt0,dataParam] = manufacturedSolution(M,tFinal);
59t = linspace(0,tFinal,1000);
60figure(1)
61plot(t,dataParam.sig(t)); grid on;
63end