Solver
fenics-constitutive: Interfaces for solver of own constitutive models following models interface for dolfinx
__all__
module-attribute
__all__ = ['CDMSolver', 'CorotationalIncrSmallStrainProblem', 'IncrSmallStrainProblem', 'critical_timestep', 'diagonal_inverted_mass']
CDMSolver
Class to solve the incremental small strain problem using the central difference method.
This class will also determine the critical timestep . The user may however prescribe a
timestep in the IncrSmallStrainProblem to be used instead. The solver will then use
with being the safety factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
IncrSmallStrainProblem
|
The incremental small strain problem to be solved. |
required |
|
list[float] | float
|
The density of the material. This is either a single value for a homogenous domain or a list of values for each submesh. |
required |
|
Function
|
The initial displacement. This is used to set the initial condition for the solver. |
required |
|
Function
|
The initial velocity. This is used to set the initial condition for the solver. |
required |
|
float
|
The safety factor for the time step. The time step is set to the critical time step multiplied by the safety factor. This should be a value between 0 and 1. |
required |
Source code in src/fenics_constitutive/solver/central_difference_method.py
step
Advance the solution by
Source code in src/fenics_constitutive/solver/central_difference_method.py
CorotationalIncrSmallStrainProblem
Bases: IncrSmallStrainProblem
Corotational extension of IncrSmallStrainProblem that adds objective stress-rate rotation and mesh-update steps.
This subclass reuses all core functionality of the base solver and
overrides only the initialization and form method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
A list of tuples where the first element is the constitutive law and the second element is the cells for the submesh. If only one law is provided, it is assumed that the domain is homogenous. The cell indices should be local indices of the MPI-process. |
required | |
|
The displacement field. This is the unknown in the nonlinear problem. |
required | |
|
The Dirichlet boundary conditions. |
required | |
|
The quadrature degree (Polynomial degree which the quadrature rule needs to integrate exactly). |
required | |
|
The maximal allowed time increment between steps. This is relevant if an explicit solver is used or if the material model depends on the time, e.g. viscoelasticity. The actually used timestep may be overwritten by the solver if convergence issues occur or if the critical timestep is smaller. |
required | |
|
The external forces applied to the system. This should be a list of ufl Forms which are subtracted from the residual. The user can use this to apply body forces or Neumann boundary conditions. |
required | |
|
The options for the form compiler. |
required | |
|
The options for the JIT compiler. |
required |
Source code in src/fenics_constitutive/solver/corotational_solver.py
form
Assemble the nonlinear form using a corotational midpoint configuration.
This override performs a mesh update to the midpoint configuration and applies a corotational stress rotation before evaluating the constitutive laws. The mesh is updated to final configuration prior to scattering stress and tangent fields.
Source code in src/fenics_constitutive/solver/corotational_solver.py
IncrSmallStrainProblem
Bases: NonlinearProblem
A nonlinear problem for incremental small strain models. To be used with the dolfinx NewtonSolver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[tuple[IncrSmallStrainModel, ndarray]] | IncrSmallStrainModel
|
A list of tuples where the first element is the constitutive law and the second element is the cells for the submesh. If only one law is provided, it is assumed that the domain is homogenous. The cell indices should be local indices of the MPI-process. |
required |
|
Function
|
The displacement field. This is the unknown in the nonlinear problem. |
required |
|
list[DirichletBC]
|
The Dirichlet boundary conditions. |
required |
|
int
|
The quadrature degree (Polynomial degree which the quadrature rule needs to integrate exactly). |
required |
|
float
|
The maximal allowed time increment between steps. This is relevant if an explicit solver is used or if the material model depends on the time, e.g. viscoelasticity. The actually used timestep may be overwritten by the solver if convergence issues occur or if the critical timestep is smaller. |
1.0
|
|
list[Form] | None
|
The external forces applied to the system. This should be a list of ufl Forms which are subtracted from the residual. The user can use this to apply body forces or Neumann boundary conditions. |
None
|
|
dict | None
|
The options for the form compiler. |
None
|
|
dict | None
|
The options for the JIT compiler. |
None
|
Source code in src/fenics_constitutive/solver/_solver.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
form
This function is called before the residual or Jacobian is computed. This is usually used to update ghost values, but here we use it to update the stress, tangent and history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Vec
|
The vector containing the latest solution |
required |
Source code in src/fenics_constitutive/solver/_solver.py
form_without_petsc
This function should be used when the solver does not require PETSc. We assume that the current solution
is stored in self.incr_displ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Whether to evaluate the tangent. If |
required |
Source code in src/fenics_constitutive/solver/_solver.py
update
Update the current displacement, stress and history. Any sensor evaluations that require you to know the current and the previous state should be done before calling this function, as it will update the previous state to the current state.
Source code in src/fenics_constitutive/solver/_solver.py
critical_timestep
critical_timestep(laws: list[tuple[IncrSmallStrainModel, ndarray]], density: list[float], u: Function, method: str = 'cdm', h: float | None = None) -> np.ndarray
Determines the critical timesteps for all submeshes. This assumes that the constitutive law returns a linear elastic tangent for . The input is not verified for consistency as this function is supposed to be called in the CDMSolver or any other solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[tuple[IncrSmallStrainModel, ndarray]]
|
A list of tuples containing the constitutive law and the corresponding cells for each submesh. |
required |
|
list[float]
|
A list of densities for each submesh. |
required |
|
Function
|
The current displacement. This is used to determine the geometric dimension and the function space of the problem. |
required |
|
str
|
The time integration method. This is used to determine the factor for the critical time step. Currently only "cdm" is implemented, which corresponds to the central difference method. The factor for the central difference method is 2, which means that the time step should be halved. |
'cdm'
|
|
float | None
|
The mesh size. If this is not provided, the mesh size will be determined based on the mesh and the cells for each submesh.
This can be used to override the mesh size if the user already knows |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
An array containing the critical timesteps of all submeshes. |
Source code in src/fenics_constitutive/solver/central_difference_method.py
diagonal_inverted_mass
diagonal_inverted_mass(function_space: FunctionSpace, density: list[float], cells: list[ndarray]) -> df.fem.Function
Determine the inverse of the diagonal mass matrix. For intervals, quadrilaterals and hexahedra, the Gauss-Lobatto-Legendre quadrature is used to compute the mass matrix, which results in a diagonal mass matrix. For other cell types, this function is not implemented and an exception is raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
FunctionSpace
|
The function space for which the mass matrix is computed. |
required |
|
list[float]
|
The density of the material. This is either a single value for a homogenous domain or a list of values for each submesh. |
required |
|
list[ndarray]
|
The cells corresponding to each submesh. This is used to assign the density to the correct cells in the mass matrix assembly. |
required |
Returns:
| Type | Description |
|---|---|
Function
|
The inverted diagonal mass matrix as a function object. |
Source code in src/fenics_constitutive/solver/central_difference_method.py
ufl_mandel_strain
Compute the strain in Mandel notation from the displacement field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Expr
|
Displacement field. |
required |
|
StressStrainConstraint
|
Constraint that the model is implemented for. |
required |
Returns:
| Type | Description |
|---|---|
Expr
|
Vector-valued UFL expression of the strain in Mandel notation. |