Interface for a node in a DataTree.
A DataTree consists of nodes with an arbitrary number of children or DataTree.ILeafNode's which store data. In the abstract version of a DataTree, non-leaf nodes can be one of:
Each of these nodes specify information about the data stored in the leaf nodes.
Considering e.g. the tree configuration
the red leaf element is tagged with the id "implicit" and valid inside the time slice interval \([11,30]\). Children are numbered consecutively and can be received by using a concatenation of indices. The read leaf element could for example be reached via
where the index vector is obtainable via a call to the get_index() method
There exist generic specializations for DataTrees representing detailed data (Greedy.DataTree.Detailed.INode, Greedy.DataTree.Detailed.ILeafNode) and reduced data (Greedy.User.RbReducedDataDefault) which have no extra functionality for non-leaf node elements.
Public Member Functions | |
virtual function INode data = | get (index) |
Access to a child of the current node. More... | |
virtual function index = | get_index (id, mu, nt) |
Obtains the leaf index vector that best fits the child description given by the three arguments. More... | |
virtual function DataTree.INode tree = | create_tree (DataTree.ICreator creator, ids, mu_cube, tslice, basepath) |
Creates a new tree from a subtree specified by ids, parameter and time index regions. More... | |
virtual function
children = | length () |
Returns the number of children of the node. More... | |
virtual function this = | set (index, value) |
Sets a child at the given path in the tree hierarchy. More... | |
function | leaf_func (funcptr, ids, mu_cube, tslice) |
applies a function to all leafs of a DataTree More... | |
function tree = | create_scalar_tree (funcptr, ids, mu_cube, tslice) |
copies the current trees with different leafs. These leafs are computes by a function returning scalar values. More... | |
function
start_index = | traverse_start () |
Start iterator for a full traverse of the DataTree. More... | |
function
next_index = | traverse_next (this_index) |
iterator for a full traverse of the DataTree. More... | |
function
description = | get_active_leaf_description (IModel model, ids) |
returns an enumeration of all leaves' basepath index vectors with a description of their parents. More... | |
function
description = | get_leaf_description (ids, mu_cube, tslice) |
returns an enumeration of all leaves' basepath index vectors with a description of their parents. More... | |
function tstop = | index_valid_till (index) |
Returns the last valid time step index of a time slice. More... | |
function INode data = | get_by_description (id, mu, nt) |
A combination of get_index() and get() More... | |
function
active_leaf_index = | get_active_leaf_index (IModel model, id) |
retuns the leaf element index for the current IDetailedModel configuration. More... | |
function
DataTree.LeafNode active_leaf = | get_active_leaf (IModel model, id) |
retuns the leaf element for the current IDetailedModel configuration. More... | |
function | display (fn, basepath, name) |
overwrites the standard display method for DataTree objects More... | |
function lines = | disp_node (basepath, fn) |
returns a cell array of strings with information on the node. More... | |
function tree = DataTree.INode.create_scalar_tree | ( | funcptr, | |
ids, | |||
mu_cube, | |||
tslice | |||
) |
copies the current trees with different leafs. These leafs are computes by a function returning scalar values.
For example, one can extract a field available in all leafs with this function, like the reduced basis size N
in a reduced data structure.
funcptr | function handle of the function to be applied to all leaf elements. |
ids | ID filter. See create_tree() for details. |
mu_cube | parameter filter. See create_tree() for details. |
tslice | time filter. See create_tree() for details. |
tree | tree |
Definition at line 207 of file INode.m.
|
pure virtual |
Creates a new tree from a subtree specified by ids, parameter and time index regions.
The method creates a new DataTree for all nodes tagged by an id in ids, lying in the time slice given by tslice and inside the parameter space region given by mu_rect. At each of these nodes a method from a creator is called to build the tree.
creator | an object creating the new tree. |
ids | a cell array of ids which shall be filtered. An empty cell array means that all ids are accepted. (default = []) |
mu_cube | a 1x2 -cell array of vectors { lower_left, upper_right } specifying the lower left and the upper right corner of a cube in the parameter space for filtering parameter vectors. An empty array disables the filtering (default = []). |
tslice | a 2D vector specifying an interval of time step indices for time slicing. An empty vector disables the filtering (default = []) |
basepath | a vector specifying the relation of the current node to the parent node at which the merge began. |
tree | the newly created tree |
function lines = DataTree.INode.disp_node | ( | basepath, | |
fn | |||
) |
returns a cell array of strings with information on the node.
The default implementation adds the output of the disp
command.
basepath | the index path needed to reach this element from the root. |
fn | a file name string for a dot file that can be generated |
lines | the cell array of strings |
Definition at line 536 of file INode.m.
function DataTree.INode.display | ( | fn, | |
basepath, | |||
name | |||
) |
overwrites the standard display method for DataTree objects
fn | Optional filename under which a dot-file depicting the tree structure is stored. |
basepath | only used in recursive calls of this method |
name | only used in recursive calls of this method |
Definition at line 489 of file INode.m.
|
pure virtual |
Access to a child of the current node.
Access a children node by an index which is usually retrieved by a call to get_index()
index | vector describing the father-child relation |
data | the children node |
Implemented in DataTree.IdMapNode, NonlinEvol.ReducedData, TwoPhaseFlow.ReducedData, DataTree.ILeafNode, Greedy.DataTree.Detailed.InfoNode, DataTree.DummyLeafNode, and DataTree.DefaultNode.
function DataTree.LeafNode active_leaf = DataTree.INode.get_active_leaf | ( | IModel | model, |
id | |||
) |
retuns the leaf element for the current IDetailedModel configuration.
model | a reduced or detailed model holding information about the selected parameters and maybe the time instant. |
id | optional parameter defining a special ID that shall be attached to the leaf element. |
active_leaf | leaf element to be returned. |
descr —
ModelDescr object specifying the problem discretization descr.t —
current time step number Definition at line 456 of file INode.m.
function description = DataTree.INode.get_active_leaf_description | ( | IModel | model, |
ids | |||
) |
returns an enumeration of all leaves' basepath index vectors with a description of their parents.
model | a reduced or detailed model holding information about the selected parameters and maybe the time instant. |
ids | ID filter. See create_tree() for details. |
description | description |
descr —
ModelDescr object specifying the problem discretization descr.t —
current time step number Definition at line 313 of file INode.m.
function active_leaf_index = DataTree.INode.get_active_leaf_index | ( | IModel | model, |
id | |||
) |
retuns the leaf element index for the current IDetailedModel configuration.
model | a reduced or detailed model holding information about the selected parameters and maybe the time instant. |
id | optional parameter defining a special ID that shall be attached to the leaf element. |
active_leaf_index | leaf element index to be returned. |
descr —
ModelDescr object specifying the problem discretization descr.t —
current time step number Definition at line 426 of file INode.m.
function INode data = DataTree.INode.get_by_description | ( | id, | |
mu, | |||
nt | |||
) |
A combination of get_index() and get()
This methods gets the child node described by id, mu and nt.
id | a string id filtered through an DataTree.IdMapNode in the tree hierarchy. |
mu | a parameter vector filtered through a DataTree.PpartNode instance in the tree hierarchy. |
nt | an integer corresponding to a time step index filtered through a DataTree.TpartNode instance in the tree hierarchy. |
data | the children node |
Definition at line 398 of file INode.m.
|
pure virtual |
Obtains the leaf index vector that best fits the child description given by the three arguments.
The leaf child description consists of an
id | a string id filtered through an DataTree.IdMapNode in the tree hierarchy. |
mu | a parameter vector filtered through a DataTree.PpartNode instance in the tree hierarchy. |
nt | an integer corresponding to a time step index filtered through a DataTree.TpartNode instance in the tree hierarchy. |
index | the most-specific (longest possible) index vector leading to a DataTree.ILeafNode element matching the child description. |
Implemented in DataTree.IdMapNode, NonlinEvol.ReducedData, TwoPhaseFlow.ReducedData, DataTree.TpartNode, Greedy.DataTree.Detailed.InfoNode, DataTree.DefaultNode, DataTree.DummyLeafNode, and DataTree.ILeafNode.
function description = DataTree.INode.get_leaf_description | ( | ids, | |
mu_cube, | |||
tslice | |||
) |
returns an enumeration of all leaves' basepath index vectors with a description of their parents.
ids | ID filter. See create_tree() for details. |
mu_cube | parameter filter. See create_tree() for details. |
tslice | time filter. See create_tree() for details. |
description | description |
Definition at line 345 of file INode.m.
function tstop = DataTree.INode.index_valid_till | ( | index | ) |
Returns the last valid time step index of a time slice.
This method can be used to obtain the last time slice index for the node given by get(this, index)
index | the index vector of the child for which the time slice shall be analyzed. |
tstop | last valid time step index |
function DataTree.INode.leaf_func | ( | funcptr, | |
ids, | |||
mu_cube, | |||
tslice | |||
) |
applies a function to all leafs of a DataTree
funcptr | function handle of the function to be applied to all leaf elements. |
ids | ID filter. See create_tree() for details. |
mu_cube | parameter filter. See create_tree() for details. |
tslice | time filter. See create_tree() for details. |
Definition at line 177 of file INode.m.
|
pure virtual |
Returns the number of children of the node.
For leaf elements this method should return 0.
children | the number of childres of the current node |
Implemented in Greedy.DataTree.Detailed.InfoNode, DataTree.DefaultNode, and DataTree.ILeafNode.
|
pure virtual |
Sets a child at the given path in the tree hierarchy.
Usually this method is used to set a leaf data node with attached data.
index | the path index where the node shall be injected |
value | the node that shall be attached as a child |
this | the modified DataTree node. |
Implemented in Fem.CompositeFunctionSpace, Greedy.DataTree.Detailed.InfoNode, and DataTree.DefaultNode.
function next_index = DataTree.INode.traverse_next | ( | this_index | ) |
iterator for a full traverse of the DataTree.
Use this method to get the next index for a tree traversal. Every node is touched during a traversal, until an empty index is returned.
this_index | previous index. |
next_index | the next index vector for tree traversal. Empty vector after the last node. |
Definition at line 262 of file INode.m.
function start_index = DataTree.INode.traverse_start | ( | ) |
Start iterator for a full traverse of the DataTree.
Use this method to get a start index for a tree traversal. Subsequently, indices can be obtained by calls to traverse_next(). Every node is touched during a traversal, until an empty index is returned.
start_index | the start index vector for tree traversal. |
Definition at line 241 of file INode.m.