forked from project-asgard/DG-SparseGrid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_dimension.m
More file actions
42 lines (33 loc) · 1020 Bytes
/
check_dimension.m
File metadata and controls
42 lines (33 loc) · 1020 Bytes
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
function default_dim = check_dimension(num_dimensions,dim)
% Set defaults for dimension
default_dim.name = 'x';
% default_dim.BCL = 'N'; % neumann
% default_dim.BCR = 'N'; % neumann
% for d=1:num_dimensions % BC variation in all dimensions
% default_dim.BCL_fList{d} = @(x,p,t) x.*0;
% default_dim.BCR_fList{d} = @(x,p,t) x.*0;
% end
% default_dim.BCL_fList{num_dimensions+1} = @(t,p) 1; % time variation of BCS
% default_dim.BCR_fList{num_dimensions+1} = @(t,p) 1;
default_dim.domainMin = 0;
default_dim.domainMax = 1;
default_dim.lev = 2;
default_dim.FMWT = []; % Gets filled in later
default_dim.init_cond_fn = @(x,p) x.*0;
% Check to make sure all fields exist.
% If not, use default.
fn = fieldnames(default_dim);
for k=1:numel(fn)
if isfield(dim,fn{k})
default_dim.(fn{k}) = dim.(fn{k});
end
end
%%
% Check for erroneous fields
fn = fieldnames(dim);
for k=1:numel(fn)
if ~isfield(default_dim,fn{k})
error(strcat('Unrecognized field in dim: ', fn{k}));
end
end
end