Nektar++
|
Public Member Functions | |
def | __init__ (self) |
def | tree_complexity (self, **kw) |
def | get_units (self) |
def | classify_variables (self, dependencies_only=False, needs_special_treatment=lambda n:None) |
def | evaluate (self) |
def | __init__ (self) |
Public Member Functions inherited from CellMLToNektar.pycml.mathml | |
def | __init__ (self) |
def | __repr__ (self) |
def | __deepcopy__ (self, memo) |
def | clone_self (self, register=False) |
def | get_original_of_clone (self) |
def | get_component (self) |
def | model (self) |
def | eval (self, elt) |
Public Member Functions inherited from CellMLToNektar.pycml.element_base | |
def | __init__ (self) |
def | __delattr__ (self, key) |
def | __setattr__ (self, key, value) |
def | rootNode (self) |
def | cmeta_id (self) |
def | xml_remove_child_at (self, index=-1) |
def | xml_doc (self) |
def | xml_properties (self) |
Static Public Member Functions | |
def | create_new (elt, pieces, otherwise=None) |
Static Public Member Functions inherited from CellMLToNektar.pycml.mathml | |
def | clone (expr) |
Private Member Functions | |
def | _set_in_units (self, units, no_act=False) |
def | _get_binding_time (self) |
def | _reduce (self, check_operator=True) |
Private Attributes | |
_cml_units | |
_cml_binding_time | |
Additional Inherited Members | |
Public Attributes inherited from CellMLToNektar.pycml.element_base | |
xml_attributes | |
Properties inherited from CellMLToNektar.pycml.mathml | |
component = property(get_component) | |
def CellMLToNektar.pycml.mathml_piecewise.__init__ | ( | self | ) |
Reimplemented from CellMLToNektar.pycml.mathml_constructor.
Definition at line 5033 of file pycml.py.
References CellMLToNektar.pycml.mathml_piecewise.__init__().
Referenced by CellMLToNektar.pycml.mathml_piecewise.__init__().
|
private |
Return the binding time of this expression. The binding time will be computed recursively and cached. It will also be made available as an attribute in the XML. It is computed by taking the least upper bound of the binding times of (some of) the conditions and cases. Condition & case binding times are computed in the order given in the file. If a condition is static with value False, its associated case is not considered. If a condition is static with value True, subsequent conditions & cases and the otherwise (if present) will not be considered.
Definition at line 5228 of file pycml.py.
References CellMLToNektar.pycml.cellml_variable._cml_binding_time, CellMLToNektar.pycml.mathml_apply._cml_binding_time, CellMLToNektar.pycml.mathml_piecewise._cml_binding_time, CellMLToNektar.pycml.mathml_constructor._get_element_binding_time(), CellMLToNektar.pycml.child_i(), and CellMLToNektar.pycml.mathml.eval().
Referenced by CellMLToNektar.pycml.mathml_ci._reduce(), CellMLToNektar.pycml.mathml_apply._reduce(), CellMLToNektar.pycml.mathml_piecewise._reduce(), CellMLToNektar.pycml.cellml_variable.get_value(), and CellMLToNektar.pycml.cellml_variable.is_statically_const().
|
private |
Reduce this expression by evaluating its static parts. Even in a dynamic conditional, where a condition is static and evaluates to False, the associated case is discarded.
Definition at line 5285 of file pycml.py.
References CellMLToNektar.pycml.mathml_constructor._eval_self(), CellMLToNektar.pycml.cellml_variable._get_binding_time(), CellMLToNektar.pycml.mathml_cn._get_binding_time(), CellMLToNektar.pycml.mathml_ci._get_binding_time(), CellMLToNektar.pycml.mathml_piecewise._get_binding_time(), CellMLToNektar.pycml.mathml_diff._get_binding_time(), CellMLToNektar.pycml.mathml_and._get_binding_time(), CellMLToNektar.pycml.mathml_or._get_binding_time(), CellMLToNektar.pycml.mathml_eq._get_binding_time(), CellMLToNektar.pycml.mathml_apply._get_binding_time(), CellMLToNektar.pycml.mathml_constructor._get_element_binding_time(), CellMLToNektar.pycml.mathml_constructor._reduce_elt(), CellMLToNektar.pycml.mathml_constructor._update_usage_counts(), CellMLToNektar.pycml.child_i(), and CellMLToNektar.pycml.mathml.eval().
|
private |
Set the units this expression should be given in. This is done recursively by setting the units for each option. We also set the units on each condition to be boolean, since subexpressions of the conditions may need units conversions added.
Definition at line 5106 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_units, CellMLToNektar.pycml.cellml_component._cml_units, CellMLToNektar.pycml.mathml_units_mixin_tokens._cml_units, CellMLToNektar.pycml.mathml_units_mixin_container._cml_units, CellMLToNektar.pycml.mathml_cn._cml_units, CellMLToNektar.pycml.mathml_ci._cml_units, CellMLToNektar.pycml.mathml_apply._cml_units, CellMLToNektar.pycml.mathml_piecewise._cml_units, CellMLToNektar.pycml.mathml_units_mixin._set_element_in_units(), CellMLToNektar.pycml.child_i(), CellMLToNektar.pycml.get_units_by_name(), CellMLToNektar.processors.ModelModifier.model, CellMLToNektar.pycml.cellml_variable.model(), CellMLToNektar.pycml.mathml.model(), and CellMLToNektar.translators.CellMLTranslator.model.
def CellMLToNektar.pycml.mathml_piecewise.classify_variables | ( | self, | |
dependencies_only = False , |
|||
needs_special_treatment = lambda n: None |
|||
) |
Classify variables in this expression according to how they are used. In the process, compute and return a set of variables on which this expression depends. If dependencies_only then the variable classification will not be done, only dependencies will be analysed. This is useful for doing a 'light' re-analysis if the dependency set has been reduced; if the set has increased then the topological sort of equations may need to be redone. The function needs_special_treatment may be supplied to override the default recursion into sub-trees. It takes a single sub-tree as argument, and should either return the dependency set for that sub-tree, or None to use the default recursion. This is used when re-analysing dependencies after applying lookup tables, since table lookups only depend on the keying variable.
Definition at line 5176 of file pycml.py.
|
static |
Create a new piecewise element. elt is any element in the current document. pieces is a list of pairs of expressions: (case, condition). otherwise, if given, is the default case.
Definition at line 5358 of file pycml.py.
References CellMLToNektar.pycml.check_append_safety().
def CellMLToNektar.pycml.mathml_piecewise.evaluate | ( | self | ) |
Evaluate this piecewise expression. Tests choices in the order they occur in the file. Only evaluates a choice if its condition evaluates to True.
Definition at line 5205 of file pycml.py.
References CellMLToNektar.pycml._child1(), CellMLToNektar.pycml.child_i(), and CellMLToNektar.pycml.mathml.eval().
Referenced by CellMLToNektar.pycml.mathml_constructor._eval_self(), and CellMLToNektar.pycml.mathml_ci._reduce().
def CellMLToNektar.pycml.mathml_piecewise.get_units | ( | self | ) |
Recursively check this expression for dimensional consistency. The first child elements of each <piece> and <otherwise> element should have dimensionally equivalent units (the resulting <units> element will be dimensionally equivalent to these). The second child elements of each <piece> should have units of cellml:boolean. If consistent, returns a <units> element for the whole expression. Throws a UnitsError if the units are inconsistent.
Definition at line 5125 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_units, CellMLToNektar.pycml.cellml_component._cml_units, CellMLToNektar.pycml.mathml_units_mixin_tokens._cml_units, CellMLToNektar.pycml.mathml_units_mixin_container._cml_units, CellMLToNektar.pycml.mathml_cn._cml_units, CellMLToNektar.pycml.mathml_ci._cml_units, CellMLToNektar.pycml.mathml_apply._cml_units, CellMLToNektar.pycml.mathml_piecewise._cml_units, CellMLToNektar.pycml.mathml_constructor._get_element_units(), CellMLToNektar.pycml.child_i(), CellMLToNektar.pycml.copy(), CellMLToNektar.pycml.get_units_by_name(), CellMLToNektar.processors.ModelModifier.model, CellMLToNektar.pycml.cellml_variable.model(), CellMLToNektar.pycml.mathml.model(), and CellMLToNektar.translators.CellMLTranslator.model.
Referenced by CellMLToNektar.pycml.mathml._ensure_units_exist(), CellMLToNektar.pycml.mathml_units_mixin_tokens._set_in_units(), and CellMLToNektar.pycml.mathml_apply._set_in_units().
def CellMLToNektar.pycml.mathml_piecewise.tree_complexity | ( | self, | |
** | kw | ||
) |
Calculate a rough estimate of the computation time for evaluating this <piecewise> element. The real evaluation time will generally depend on run time data, which makes things tricky. Here we estimate by taking the sum of the complexities of the conditions and the maximum of the complexity of the cases, in order to obtain an upper bound. If lookup_tables is True, then assume we're using lookup tables where possible. If algebraic is True, the complexity is calculated as a dictionary, mapping node types to the number of occurences of that type. If self.rootNode.num_lookup_tables exists, this method will update the count of lookup tables based on this expression, unless the argument 'count_tables' is False or algebraic is True.
Definition at line 5038 of file pycml.py.
References CellMLToNektar.pycml.mathml_constructor._tree_complexity(), CellMLToNektar.utilities.add_dicts(), CellMLToNektar.pycml.child_i(), CellMLToNektar.utilities.max_i(), and CellMLToNektar.pycml.element_base.rootNode().
|
private |
|
private |
Definition at line 5035 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model._build_units_dictionary(), CellMLToNektar.pycml.cellml_component._build_units_dictionary(), CellMLToNektar.pycml.mathml_apply._set_in_units(), CellMLToNektar.pycml.mathml_piecewise._set_in_units(), CellMLToNektar.pycml.cellml_model.add_units(), CellMLToNektar.pycml.cellml_component.add_units(), CellMLToNektar.pycml.cellml_model.get_all_units(), CellMLToNektar.pycml.cellml_component.get_all_units(), CellMLToNektar.pycml.mathml_apply.get_units(), CellMLToNektar.pycml.mathml_piecewise.get_units(), CellMLToNektar.pycml.mathml_cn.get_units(), CellMLToNektar.pycml.mathml_ci.get_units(), CellMLToNektar.pycml.cellml_model.get_units_by_name(), CellMLToNektar.pycml.cellml_component.get_units_by_name(), and CellMLToNektar.pycml.cellml_model.has_units().