2 % Data Tree element which can be filtered by time instants.
4 % The children branches of
this data tree node are all tagged with a time
5 % interval, either discrete (time steps) or continuous (time instants).
7 % The branches can then be accessed via the
'nt' argument of the get_index()
11 properties (SetAccess =
protected)
12 % an
object of type
XPartMap holding the time intervals.
17 % Data node type identifier
18 data_node_type =
'TPart';
21 properties (Access =
protected)
22 %
struct mapping between time instants and indices of children. (?)
25 % an optional argument specifying whether the time slices overlap, and how
28 % refiner = [];%DefaultRefiner;
32 function tpdn =
TpartNode(tpart_map, initvalues, overlap)
33 %
function tpdn =
TpartNode(tpart_map, initvalues, overlap)
37 % tpart_map: the T-partitioning map of type
XPartMap.
38 % initivalues: a cell array of
DataTree.
INode objects
for the initial
39 % values of the children.
40 % overlap: initial value
for #overlap
property.
43 tpdn.overlap = overlap;
47 elseif isnumeric(tpart_map)
48 tpart_map = XPartMap(1, 2, tpart_map([1,end]), tpart_map');
50 tpart_map = copy(tpart_map);
52 tpdn.tpart_map = tpart_map;
53 tpdn.values = cell(1,tpart_map.siz);
56 assert(length(initvalues) == length(tpdn.values))
57 tpdn.values = initvalues;
61 function tstop = index_valid_till(this, index)
62 % function tstop = index_valid_till(this, index)
63 % returns the last valid time instance of a given entity in the
67 % index: index of the T-Partitioning interval.
70 % tstop: time instance when the requested time interval ends.
73 gid = this.tpart_map.leaf_enum(index);
74 interval = get_coords(this.tpart_map, gid);
76 tstop = min(tstop, index_valid_till(get(this, index(1)), index(2:end)));
84 function index = get_index(this,
id, mu, nt)
85 % function index = get_index(this,
id, mu, nt)
92 index = coords2elem(this.tpart_map, nt);
100 function indices = get_indices_in_region(this, ids, mu_geo, tslice)
101 % function indices = get_indices_in_region(this, ids, mu_geo, tslice)
102 % needs to be implemented... @todo implement
105 function tree = create_tree(this, creator, ids, mu_cube, tslice, basepath)
106 % function tree = create_tree(this, creator, ids, mu_cube, tslice, basepath)
111 % Calls
DataTreeCreator.create_tpart_node() to build new elements.
126 tslice = [-inf; inf];
129 [stm, old_leaf_enum] = sub_xpart_map(this.tpart_map, tslice);
131 initvalues = cell(1, length(old_leaf_enum));
132 for i = 1:length(old_leaf_enum)
133 % crop local tslice if necessary
134 new_tslice = stm.get_coords(stm.leaf_enum(i));
135 old_child = get(this, old_leaf_enum(i));
136 old_bp = [basepath, old_leaf_enum(i)];
137 initvalues{i} = create_tree(old_child, creator, ids, mu_cube, new_tslice, old_bp);
140 if length(old_leaf_enum) == 1
141 tree = initvalues{1};
142 elseif isempty(old_leaf_enum)
143 throw('Merge of trees failed because given time region was not found!');
145 tree = create_tpart_node(creator, stm, initvalues);
150 function refine(this, indices, midpoints)
151 % function refine(this, indices, midpoints)
152 % refines the T-Partitioning by refining the
#tpart_map.
155 % indices: indices of partitioning intervals to be refined.
156 % midpoints: optional parameter
for the refinement method
157 % XPartMap.refine() specifying how the geometries shall be
158 % split. (
default =
'[]')
162 [co,
new] = tpart_refine(
this, this.storage2lid(indices), midpoints);
163 oldvalues = this.values(co);
165 this.values = [this.values(setdiff(1:length(this.values), co)),...
166 cell(1,length(
new(:)))];
167 this.values(
new(1,:)) = oldvalues;
Interface for a node in a DataTree.
Default implementation for a DataTree.INode.
a geometric tree where every nodes has geometry information attached.
Data Tree element which can be filtered by time instants.