fedoo.constraint.MeanValueConstraint
- class MeanValueConstraint(mesh, variable: str | list[str] = 'Disp', value: float = 0.0, node_set=None, weights=None, space: ModelingSpace | None = None, name: str = 'MeanValue')
Enforce the weighted mean of a field over a set of nodes.
For each variable, the constraint reads:
\[\sum_i w_i \; u(i) = value\]where the weights \(w_i\) sum to 1 (mean value). The constraint is enforced with one Lagrange multiplier per variable (one additional global dof, see
fedoo.Problem.add_global_dof()), leading to a bordered (saddle-point) system.The main application is the removal of the rigid body translation in periodic homogenization problems: constraining the mean displacement of the RVE to zero avoids pinning an arbitrary node and makes the solution independent of the choice of that node.
One MPC equation is created per variable and enforced by
fedoo.LagrangeMultiplierAssembly.- Parameters:
mesh (fedoo.Mesh) – Mesh associated with the constraint. It should have the same nodes as the assembly with which the constraint is summed.
variable (str or list of str, default = "Disp") – Vector name (for example,
"Disp"), variable name (for example,"DispX"), or list of variable names. One scalar constraint and one Lagrange multiplier are created per variable.value (float or array, default = 0.) – Imposed mean value. A scalar is applied to every constrained variable; an array specifies one value per variable. Values are not affected by the problem time factor (no ramp).
node_set (str, array of int or None, default = None) – Nodes over which the mean is computed. If None, all mesh nodes are used.
weights (None, "volume" or array, default = None) –
Weights used to compute the mean:
None: uniform weights
1 / n_nodes(simple nodal average)."volume": nodal integration weights, giving the true volume average of the interpolated field.Array with the same length as
node_set: custom weights, normalized so that their sum is 1.
space (ModelingSpace, optional) – Modeling space. If None, the active modeling space is used.
name (str, default = "MeanValue") – Constraint name. The Lagrange multiplier DOFs are named
{name}_{variable}and gathered in the global vector{name}. Use distinct names for multiple mean-value constraints on the same problem.
Notes
The constraint is a linear relation enforced exactly at each Newton iteration, so it can be used with both linear and nonlinear problems.
Lagrange multipliers give the system a zero diagonal block and an indefinite saddle-point structure. A direct solver is required; iterative solvers such as conjugate gradient are not suitable.
A multiplier can be extracted with
pb.get_dof_solution("{name}_{variable}").
Example
Remove rigid-body translation from a periodic problem:
>>> import fedoo as fd >>> # ... mesh, material and weak-form definitions ... >>> solid = fd.Assembly.create(wf, mesh) >>> mean_value = fd.constraint.MeanValueConstraint(mesh) >>> pb = fd.problem.Linear(solid + mean_value) >>> pb.bc.add(fd.constraint.PeriodicBC()) >>> pb.bc.add("Dirichlet", "MeanStrain", [0.01, 0, 0, 0, 0, 0]) >>> pb.solve()
- __init__(mesh, variable: str | list[str] = 'Disp', value: float = 0.0, node_set=None, weights=None, space: ModelingSpace | None = None, name: str = 'MeanValue')
Methods
Launch the assembly of global matrix.
Delete Global Matrix and Global Vector related to the assembly.
Return a dict with all the known Assembly (with a name).
Get the last computed global matrix.
Get the last computed global vector.
Initialize the assembly for the current problem.
Iterate over the leaf assemblies contained in this object.
Register global DOFs required by the assembly on a problem.
Reset the assembly.
Begin a new time iteration.
Restart the current time iteration.
MeanValueConstraint.update(pb[, compute])Update the assembly for the current problem state.
Name of the assembly if defined.
Modeling space associated to the assembly.
Assembly associated to the mesh of the deformed geometry.
AssemblySum object that contains the assembly.