Mercurial > repos > public > sbplib
annotate +noname/Discretization.m @ 20:c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Sep 2015 17:35:58 +0200 |
parents | 16bad7c459da |
children | ed6a704b028d |
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 |
20
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
15
diff
changeset
|
31 % getTimeSnapshot returns a struct which represents the solution in ts at current time. |
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
15
diff
changeset
|
32 % if ts is empty or 0 a representation of the initial conditions be returned. |
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
15
diff
changeset
|
33 repr = getTimeSnapshot(obj,ts) |
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
15
diff
changeset
|
34 |
0 | 35 |
36 % Sets up movie recording to a given file. | |
37 % saveFrame is a function_handle with no inputs that records the current state | |
38 % as a frame in the moive. | |
39 saveFrame = setupMov(obj, file) | |
40 | |
41 % Sets up a plot of the discretisation | |
42 % update is a function_handle accepting a timestepper that updates the plot to the | |
43 % state of the timestepper | |
20
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
15
diff
changeset
|
44 % type allows for different kinds of plots. Some special values are used by the lib. 'animate' and 'plot' for example |
c7efff913935
Decoupled plotting and timesteppers. Added possibility of different plot_types. Added functions for printing and plotting solution file content.
Jonatan Werpers <jonatan@werpers.com>
parents:
15
diff
changeset
|
45 [update,hand] = setupPlot(obj, type) |
0 | 46 |
47 end | |
48 | |
49 methods(Abstract,Static) | |
50 % Compare two functions u and v in the discrete l2 norm. | |
51 e = compareSolutions(u, v) | |
52 | |
53 % Compare the functions u to the analytical function g in the discrete l2 norm. | |
54 e = compareSolutionsAnalytical(u, g) | |
55 end | |
56 end |