sfepy.discrete.evaluate module¶
- class sfepy.discrete.evaluate.Evaluator(problem, matrix_hook=None)[source]¶
This class provides the functions required by a nonlinear solver for a given problem.
- sfepy.discrete.evaluate.apply_ebc_to_matrix(mtx, ebc_rows, epbc_rows=None)[source]¶
Apply E(P)BC to matrix rows: put 1 to the diagonal for EBC DOFs, 1 to the diagonal for master EPBC DOFs, -1 to the [master, slave] entries. It is assumed, that the matrix contains zeros in EBC and master EPBC DOFs rows and columns.
- sfepy.discrete.evaluate.assemble_by_blocks(conf_equations, problem, ebcs=None, epbcs=None, dw_mode='matrix', active_only=True)[source]¶
Instead of a global matrix, return its building blocks as defined in conf_equations. The name and row/column variables of each block have to be encoded in the equation’s name, as in:
conf_equations = { 'A,v,u' : "dw_lin_elastic.i1.Y2( inclusion.D, v, u )", }
Notes
ebcs, epbcs must be either lists of BC names, or BC configuration dictionaries.
- sfepy.discrete.evaluate.create_evaluable(expression, fields, materials, variables, integrals, regions=None, ebcs=None, epbcs=None, lcbcs=None, ts=None, functions=None, auto_init=False, mode='eval', extra_args=None, active_only=True, eterm_options=None, verbose=True, kwargs=None)[source]¶
Create evaluable object (equations and corresponding variables) from the expression string.
- Parameters
- expressionstr
The expression to evaluate.
- fieldsdict
The dictionary of fields used in variables.
- materialsMaterials instance
The materials used in the expression.
- variablesVariables instance
The variables used in the expression.
- integralsIntegrals instance
The integrals to be used.
- regionsRegion instance or list of Region instances
The region(s) to be used. If not given, the regions defined within the fields domain are used.
- ebcsConditions instance, optional
The essential (Dirichlet) boundary conditions for ‘weak’ mode.
- epbcsConditions instance, optional
The periodic boundary conditions for ‘weak’ mode.
- lcbcsConditions instance, optional
The linear combination boundary conditions for ‘weak’ mode.
- tsTimeStepper instance, optional
The time stepper.
- functionsFunctions instance, optional
The user functions for boundary conditions, materials etc.
- auto_initbool
Set values of all variables to all zeros.
- modeone of ‘eval’, ‘el_avg’, ‘qp’, ‘weak’
The evaluation mode - ‘weak’ means the finite element assembling, ‘qp’ requests the values in quadrature points, ‘el_avg’ element averages and ‘eval’ means integration over each term region.
- extra_argsdict, optional
Extra arguments to be passed to terms in the expression.
- active_onlybool
If True, in ‘weak’ mode, the (tangent) matrices and residual vectors (right-hand sides) contain only active DOFs.
- eterm_optionsdict, optional
The einsum-based terms evaluation options.
- verbosebool
If False, reduce verbosity.
- kwargsdict, optional
The variables (dictionary of (variable name) : (Variable instance)) to be used in the expression.
- Returns
- equationEquation instance
The equation that is ready to be evaluated.
- variablesVariables instance
The variables used in the equation.
- sfepy.discrete.evaluate.eval_equations(equations, variables, names=None, preserve_caches=False, mode='eval', dw_mode='vector', term_mode=None, active_only=True, verbose=True)[source]¶
Evaluate the equations.
- Parameters
- equationsEquations instance
The equations returned by
create_evaluable()
.- variablesVariables instance
The variables returned by
create_evaluable()
.- namesstr or sequence of str, optional
Evaluate only equations of the given name(s).
- preserve_cachesbool
If True, do not invalidate evaluate caches of variables.
- modeone of ‘eval’, ‘el_avg’, ‘qp’, ‘weak’
The evaluation mode - ‘weak’ means the finite element assembling, ‘qp’ requests the values in quadrature points, ‘el_avg’ element averages and ‘eval’ means integration over each term region.
- dw_mode‘vector’ or ‘matrix’
The assembling mode for ‘weak’ evaluation mode.
- term_modestr
The term call mode - some terms support different call modes and depending on the call mode different values are returned.
- active_onlybool
If True, in ‘weak’ mode, the (tangent) matrices and residual vectors (right-hand sides) contain only active DOFs.
- verbosebool
If False, reduce verbosity.
- Returns
- outdict or result
The evaluation result. In ‘weak’ mode it is the vector or sparse matrix, depending on dw_mode. Otherwise, it is a dict of results with equation names as keys or a single result for a single equation.
- sfepy.discrete.evaluate.eval_in_els_and_qp(expression, iels, coors, fields, materials, variables, functions=None, mode='eval', term_mode=None, extra_args=None, active_only=True, verbose=True, kwargs=None)[source]¶
Evaluate an expression in given elements and points.
- Parameters
- expressionstr
The expression to evaluate.
- fieldsdict
The dictionary of fields used in variables.
- materialsMaterials instance
The materials used in the expression.
- variablesVariables instance
The variables used in the expression.
- functionsFunctions instance, optional
The user functions for materials etc.
- modeone of ‘eval’, ‘el_avg’, ‘qp’
The evaluation mode - ‘qp’ requests the values in quadrature points, ‘el_avg’ element averages and ‘eval’ means integration over each term region.
- term_modestr
The term call mode - some terms support different call modes and depending on the call mode different values are returned.
- extra_argsdict, optional
Extra arguments to be passed to terms in the expression.
- active_onlybool
If True, in ‘weak’ mode, the (tangent) matrices and residual vectors (right-hand sides) contain only active DOFs.
- verbosebool
If False, reduce verbosity.
- kwargsdict, optional
The variables (dictionary of (variable name) : (Variable instance)) to be used in the expression.
- Returns
- outarray
The result of the evaluation.