sfepy.terms.terms module¶
- class sfepy.terms.terms.Term(name, arg_str, integral, region, **kwargs)[source]¶
-
- arg_geometry_types = {}¶
- arg_shapes = {}¶
- arg_types = ()¶
- assemble_to(asm_obj, val, iels, mode='vector', diff_var=None)[source]¶
Assemble the results of term evaluation.
For standard terms, assemble the values in val corresponding to elements/cells iels into a vector or a CSR sparse matrix asm_obj, depending on mode.
For terms with a dynamic connectivity (e.g. contact terms), in ‘matrix’ mode, return the extra COO sparse matrix instead. The extra matrix has to be added to the global matrix by the caller. By default, this is done in
Equations.evaluate()
.
- assign_args(variables, materials, user=None)[source]¶
Check term argument existence in variables, materials, user data and assign the arguments to terms. Also check compatibility of field and term regions.
- classify_args()[source]¶
Classify types of the term arguments and find matching call signature.
A state variable can be in place of a parameter variable and vice versa.
- diff_info = {}¶
- evaluate(mode='eval', diff_var=None, standalone=True, ret_status=False, **kwargs)[source]¶
Evaluate the term.
- Parameters:
- mode‘eval’ (default), or ‘weak’
The term evaluation mode.
- Returns:
- valfloat or array
In ‘eval’ mode, the term returns a single value (the integral, it does not need to be a scalar), while in ‘weak’ mode it returns an array for each element.
- statusint, optional
The flag indicating evaluation success (0) or failure (nonzero). Only provided if ret_status is True.
- ielsarray of ints, optional
The local elements indices in ‘weak’ mode. Only provided in non-‘eval’ modes.
- geometries = ['1_2', '2_3', '2_4', '3_4', '3_8']¶
- get(variable, quantity_name, bf=None, integration=None, step=None, time_derivative=None)[source]¶
Get the named quantity related to the variable.
Notes
This is a convenience wrapper of Variable.evaluate() that initializes the arguments using the term data.
- get_arg_name(arg_type, full=False, join=None)[source]¶
Get the name of the argument specified by arg_type.
- Parameters:
- arg_typestr
The argument type string.
- fullbool
If True, return the full name. For example, if the name of a variable argument is ‘u’ and its time derivative is requested, the full name is ‘du/dt’.
- joinstr, optional
Optionally, the material argument name tuple can be joined to a single string using the join string.
- Returns:
- namestr
The argument name.
- get_args(arg_types=None, **kwargs)[source]¶
Return arguments by type as specified in arg_types (or self.ats). Arguments in **kwargs can override the ones assigned at the term construction - this is useful for passing user data.
- get_assembling_cells(shape=None)[source]¶
Return the assembling cell indices into a DOF connectivity.
- get_data_shape(variable)[source]¶
Get data shape information from variable.
Notes
This is a convenience wrapper of FieldVariable.get_data_shape() that initializes the arguments using the term data.
- get_kwargs(keys, **kwargs)[source]¶
Extract arguments from **kwargs listed in keys (default is None).
- get_mapping(variable, get_saved=False, return_key=False)[source]¶
Get the reference mapping from a variable.
Notes
This is a convenience wrapper of Field.get_mapping() that initializes the arguments using the term data.
- get_physical_qps()[source]¶
Get physical quadrature points corresponding to the term region and integral.
- get_state_names()[source]¶
If variables are given, return only true unknowns whose data are of the current time step (0).
- get_vector(variable)[source]¶
Get the vector stored in variable according to self.arg_steps and self.arg_derivatives. Supports only the backward difference w.r.t. time.
- integration = 'cell'¶
- integration_order = None¶
- name = ''¶
- static new(name_args, integral, region, **kwargs)[source]¶
Create a new Term instance.
- Parameters:
- name_argsstr
The term name and arguments, e.g. ‘dw_laplace(m.coef, v, u)’.
- integralIntegral instance
The integral defining the term quadrature.
- regionRegion instance
The term region (domain of integration for most terms).
- **kwargskeyword arguments, optional
The actual term arguments. Their compatibility with name_args is checked when a term is added to an Equation instance, or when evaluated.
- class sfepy.terms.terms.Terms(objs=None)[source]¶
- sfepy.terms.terms.get_arg_kinds(arg_types)[source]¶
Translate arg_types of a Term to a canonical form.
- Parameters:
- arg_typestuple of strings
The term argument types, as given in the arg_types attribute.
- Returns:
- arg_kindslist of strings
The argument kinds - one of ‘virtual_variable’, ‘state_variable’, ‘parameter_variable’, ‘opt_material’, ‘ts’, ‘user’.
- sfepy.terms.terms.get_shape_kind(integration)[source]¶
Get data shape kind for given integration type.
- sfepy.terms.terms.split_complex_args(args)[source]¶
Split complex arguments to real and imaginary parts.
- Returns:
- newargsdictionary
Dictionary with lists corresponding to args such that each argument of numpy.complex128 data type is split to its real and imaginary part. The output depends on the number of complex arguments in ‘args’:
0: list (key ‘r’) identical to input one
1: two lists with keys ‘r’, ‘i’ corresponding to real and imaginary parts
2: output dictionary contains four lists:
‘r’ - real(arg1), real(arg2)
‘i’ - imag(arg1), imag(arg2)
‘ri’ - real(arg1), imag(arg2)
‘ir’ - imag(arg1), real(arg2)