pyoomph.generic.assembly module
- class pyoomph.generic.assembly.FixedMeshMaxQuadraticNonlinearAssembly(cache_at_fixed_parameters=True)[source]
Bases:
CustomAssemblyBaseFor a problem with max. quadratic non-linearities with non-moving, non-adaptive meshes, this assembly hander saves a lot of time. It only works for first order time stepping and assumes BDF2 time-stepping, where the first step is degraded. The residuals must be writeable as
\(\vec{R}(\vec{U})=\vec{R}_0+\mathbf{M}_0\partial_t \vec{U}+\mathbf{J}_0\vec{U}+\frac{1}{2}\vec{U}\cdot\mathbf{H}_0\cdot\vec{U}\)
where \(\vec{R}_0\), \(\mathbf{M}_0\), \(\mathbf{J}_0\) and \(\mathbf{H}_0\) are the residual vector, mass matrix, Jacobian and Hessian rank-3-tensor evaluated at the trivial dof vector U=0. In particular, \(\mathbf{H}_0\) must be independent of \(\vec{U}\). Parameters may appear in all terms, however, it depends on the passed parameter of cache_at_fixed_parameters. This controlls whether the tensor cache is evaluated at fixed or zero parameters. In the latter case, the parameter contribution is added, which requires some overhead, but allows to vary the parameter without the demanding update of the tensor cache. If a global parameter frequenly changes its value, it is better to use cache_at_fixed_parameters=False or to pass a set of all other (rather constant) parameters to cache_at_fixed_parameters. However, frequently varying parameters excluded by cache_at_fixed_parameters (either by passing False or a set not including those) may not appear in the Hessian term H, i.e. they may appear at maximum as factor for linear or constant terms.
Furthermore, you must activate the analytical Hessian via problem.set_analytic_hessian_products(True).
In particular, the mesh(es) must be non-moving, as moving meshes are usually highly nonlinear.
- actions_after_successful_newton_solve()[source]
Whenever we successfully take a time step, we can backup the degrees of freedom for the next step to save some time
- Return type:
None
- get_history_dofs(index)[source]
Get the history dofs at previous time step ‘index’. These are buffered to save some time,
- Parameters:
index (int) – 0 means current step, 1 means last step and 2 means the degrees of freedom two time steps ago.
- Returns:
Degrees of freedom of the system.
- Return type:
NPFloatArray
- get_residuals_and_jacobian(require_jacobian, dparameter=None)[source]
Get the residual vector (and potentially the Jacobian) based on the current and history dofs using the cached tensors.
When a parameter changes, for which we have evaluted the tensor, we have to recalculate the cache.
- Parameters:
require_jacobian (bool) – Do we require the Jacobian or not?
- Returns:
Either the residual vector or the residual vector and the Jacobian.
- Return type:
Union[NPFloatArray,Tuple[NPFloatArray,csr_matrix]]
- invalidate_cache()[source]
Called when the system changes. This invokes a demanding recalculation of all cached tensors.
- Return type:
None