Mercurial > repos > public > sbplib
annotate +noname/Discretization.m @ 17:30ae48efc7ae
Added utility function findFiledWidth. Added function for calculating and saving solutions.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Sep 2015 14:27:21 +0200 |
parents | 16bad7c459da |
children | c7efff913935 |
rev | line source |
---|---|
0 | 1 classdef Discretization < handle |
2 properties (Abstract) | |
3 name %Short description | |
4 description %Longer description | |
5 order %Order of accuracy | |
6 end | |
7 | |
8 methods (Abstract) | |
9 % Prints some info about the discretisation | |
10 printInfo() | |
11 | |
12 % Return the number of DOF | |
13 n = size(obj) | |
14 | |
15 % Returns a timestepper for integrating the discretisation in time | |
16 % method is a string that states which timestepping method should be used. | |
17 % The implementation should switch on the string and deliver | |
18 % the appropriate timestepper. It should also provide a default value. | |
15
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
19 % k is a desired timestep |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
20 % cfl is a choses cfl constant used to set the timestep. ignored if k is set. |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
21 ts = getTimestepper(obj,method,k,cfl) |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
22 |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
23 % Calculates a timestep for the discretization and a given timestepping method. |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
24 % Can take order, differnt types of scaling in h, or other parameters in Discr into |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
25 % account. |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
26 % method -- time stepping method for which to give a timestep. |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
27 % cfl -- [optioanal] a cfl constant to use to calculate the timetep. |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
28 % if skipped getTimestep should use a precomputed value. |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
29 k = getTimestep(obj, method, cfl) |
16bad7c459da
Added abstract methods to allow for comparing of solutions. Added a bunch of error functions.
Jonatan Werpers <jonatan@werpers.com>
parents:
2
diff
changeset
|
30 |
0 | 31 |
32 % Sets up movie recording to a given file. | |
33 % saveFrame is a function_handle with no inputs that records the current state | |
34 % as a frame in the moive. | |
35 saveFrame = setupMov(obj, file) | |
36 | |
37 % Sets up a plot of the discretisation | |
38 % update is a function_handle accepting a timestepper that updates the plot to the | |
39 % state of the timestepper | |
40 [update,hand] = setupPlot(obj) | |
41 | |
42 end | |
43 | |
44 methods(Abstract,Static) | |
45 % Compare two functions u and v in the discrete l2 norm. | |
46 e = compareSolutions(u, v) | |
47 | |
48 % Compare the functions u to the analytical function g in the discrete l2 norm. | |
49 e = compareSolutionsAnalytical(u, g) | |
50 end | |
51 end |