mtnlion.variable module¶
Variables are used to define the relationship between trial functions, in both time and approximations, to test functions and the mapping between both functions and their FEniCS subdomain mapping.
-
exception
mtnlion.variable.
SingleDomainError
[source]¶ Bases:
Exception
This exception is raised when the number of domains should have been reduced to one for the operation.
-
class
mtnlion.variable.
UVMap
[source]¶ Bases:
tuple
Mapping between the trial functions (u), test functions (v), and the mapping of elements to the trial functions.
Trial functions are represented as a list of functions in time. Each element of the list is a dictionary of the applicable domains containing a list of related functions. Test functions are not effected by time stepping schemes, so there is no need to provide a list in time. Similarly, the element types are not allowed to change with each step in time.
-
element_map
¶ Alias for field number 2
-
test_function
¶ Alias for field number 1
-
trial_function
¶ Alias for field number 0
-
-
class
mtnlion.variable.
UVMapSingleDomain
[source]¶ Bases:
tuple
Mapping between the trial functions (u), test functions (v), and the mapping of elements to the trial functions restricted to a single domain.
Trial functions are represented as a list of functions in time. Each element of the list is a list of related functions. Test functions are not effected by time stepping schemes, so there is no need to provide a list in time. Similarly, the element types are not allowed to change with each step in time.
-
element_map
¶ Alias for field number 2
-
test_function
¶ Alias for field number 1
-
trial_function
¶ Alias for field number 0
-
-
class
mtnlion.variable.
UndefinedDomain
(domain: str)[source]¶ Bases:
object
Used to represent objects with an undefined domain.
-
class
mtnlion.variable.
Variable
(name: str, domains: Iterable[str], num_functions: int = 1)[source]¶ Bases:
object
This class allows the partial definition of trial functions and test functions allowing them to be defined and used before the relationships in time, function approximations, and element mappings are defined.
- Variable’s are able to then define the relationships in formulations without worrying about the specifics of
time discretization schemes or function approximations.
-
get_domain
(domain: str) → mtnlion.variable.Variable[source]¶ Retrieve a Variable object defined only on the given domain using UVMapSingleDomain.
- Parameters
domain – Domain to restrict the variable to
- Returns
Variable defined on a single domain
-
is_defined
¶ Indicates whether or not the variable has been defined by checking the uv map element map.
- Returns
true if the elements have been defined
-
test
(subfunction: int = 0, all_funcs: bool = False) → Union[List[Optional[ufl.indexed.Indexed]], ufl.indexed.Indexed, None][source]¶ Retrieve the test function for this Variable.
If no constraints are applied, the entire test function will be returned.
- Parameters
subfunction – Index of the desired subfunction
all_funcs – return all subfunctions
- Returns
Desired test function
-
trial
(history: Optional[int] = None, subfunction: int = 0, all_funcs: bool = False) → Union[ufl.indexed.Indexed, None, List[Union[ufl.indexed.Indexed, mtnlion.variable.UndefinedDomain]], List[List[Union[ufl.indexed.Indexed, mtnlion.variable.UndefinedDomain]]]][source]¶ Retrieve the trial function for this Variable.
History and subfunction constraints may be applied simultaneously. If no constraints are applied, the entire trial function will be returned.
- Parameters
history – Index in time to retrieve the trial function, 0 represents the current time, one is the previous time step, etc.
subfunction – Index of the desired subfunction
all_funcs – return all subfunctions
- Returns
Desired trial function