-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPDE.m
93 lines (78 loc) · 3.08 KB
/
PDE.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
classdef PDE
properties
% these all need to be removed or moved to opts
solvePoisson = 0; % Controls the "workflow" ... something we still don't know how to do generally.
applySpecifiedE = 0; % Controls the "workflow" ... something we still don't know how to do generally.
% checkAnalytic = 1; % Will only work if an analytic solution is provided within the PDE.
set_dt = @(pde,CFL) 1; % Function which accepts the pde (after being updated with CMD args).
dimensions = {};
terms = {};
params = {};
sources = {};
termsLHS = {};
transform_blocks = {}; % will be updated in asgard.m
analytic_solutions_1D = {}; % to be removed when transition all to many_solution_capable
boundary_conditions = {};
% MSC = Many Solution Capable fields
% (all PDEs will transition to this soon)
solutions = {};
initial_conditions = {};
moments = {};
% Old hash table - to be removed when support for oldhashtable is
% removed
hash_table = [];
% In case of use_connectivity = true
connectivity = {};
end
methods
function lev_vec = get_lev_vec(pde)
num_dims = numel(pde.dimensions);
for d=1:num_dims
lev_vec(d,1) = pde.dimensions{d}.lev;
end
end
function pde = PDE(opts,dimensions,terms,LHS_terms,sources,params,set_dt,analytic_solutions_1D,initial_conditions_MSC,solutions_MSC,moments_MSC)
pde.dimensions = dimensions;
pde.terms = terms;
pde.termsLHS = LHS_terms;
pde.sources = sources;
pde.analytic_solutions_1D = analytic_solutions_1D;
pde.params = params;
pde.set_dt = set_dt;
[~,pde.transform_blocks] = OperatorTwoScale_wavelet2(opts.deg, opts.max_lev);
if nargin > 8
pde.solutions = solutions_MSC;
pde.initial_conditions = initial_conditions_MSC;
end
if nargin > 10
%Add moments from input
pde.moments = moments_MSC;
else
%Create mass moment for asgard run
num_dims = numel(dimensions);
moment_cell = cell(num_dims+1,1);
for i=1:num_dims
moment_cell{i} = @(x,p,t) 0*x+1; %Initialize to 1
end
moment_cell{num_dims+1} = @(t,p) 0*t+1;
pde.moments = {MOMENT({new_md_func(num_dims,moment_cell)})};
end
pde.dimensions = set_levels(opts.lev,dimensions);
end
end
end
function dimensions_out = set_levels(lev,dimensions_in)
num_dims = numel(dimensions_in);
num_levs = numel(lev);
if num_levs > 1
assert(num_dims == num_levs);
end
for d=1:num_dims
dimensions_out{d} = dimensions_in{d};
if num_levs == 1
dimensions_out{d}.lev = lev;
else
dimensions_out{d}.lev = lev(d);
end
end
end