Classes of variables for equations/terms.
A finite element field variable.
field .. field description of variable (borrowed)
Apply essential (Dirichlet) and periodic boundary conditions to vector vec, starting at offset.
Apply initial conditions conditions to vector vec, starting at offset.
Convert the DOF vector to a dictionary of output data usable by Mesh.write().
Parameters: | vec : array, optional
key : str, optional
extend : bool
fill_value : float or complex
linearization : Struct or None
|
---|
Create the mapping of active DOFs from/to all DOFs.
Sets n_adof.
Returns: | active_bcs : set
|
---|
Evaluate various quantities related to the variable according to mode in quadrature points defined by integral.
The evaluated data are cached in the variable instance in evaluate_cache attribute.
Parameters: | mode : one of ‘val’, ‘grad’, ‘div’, ‘cauchy_strain’
region : Region instance, optional
integral : Integral instance, optional
integration : ‘volume’, ‘surface’, ‘surface_extra’, or ‘point’
step : int, default 0
time_derivative : None or ‘dt’
is_trace : bool, default False
dt : float, optional
bf : Base function, optional
|
---|---|
Returns: | out : array
|
Evaluate the variable in the given physical coordinates. Convenience wrapper around Field.evaluate_at(), see its docstring for more details.
Get element data dimensions for given approximation.
Parameters: | integral : Integral instance
integration : ‘volume’, ‘surface’, ‘surface_extra’, ‘point’ or ‘custom’
region_name : str
|
---|---|
Returns: | data_shape : 5 ints
|
Notes
Get active dof connectivity of a variable.
Notes
The primary and dual variables must have the same Region.
Get the full DOF vector satisfying E(P)BCs from a reduced DOF vector.
Notes
The reduced vector starts in r_vec at r_offset. Passing a force_value overrides the EBC values. Optionally, vec argument can be provided to store the full vector (in place) starting at offset.
Get the physical coordinates to interpolate into, based on the strategy used.
Get the reference element mapping of the underlying field.
See also
sfepy.discrete.fem.fields.Field.get_mapping
Get the reduced DOF vector, with EBC and PBC DOFs removed.
Notes
The full vector starts in vec at offset. If ‘follow_epbc’ is True, values of EPBC master DOFs are not simply thrown away, but added to the corresponding slave DOFs, just like when assembling. For vectors with state (unknown) variables it should be set to False, for assembled vectors it should be set to True.
Get DOFs of the variable in the given region.
Parameters: | region : Region
reshape : bool
step : int, default 0
|
---|---|
Returns: | out : array
|
Returns: | flag : int
|
---|
Invalidate variable data in evaluate cache for time step given by step (0 is current, -1 previous, ...).
This should be done, for example, prior to every nonlinear solver iteration.
Save the field mesh and the variable values into a file for visualization. Only the vertex values are stored.
Set DOFs of variable using values in quadrature points corresponding to the given integral.
Set the variable using another variable. Undefined values (e.g. outside the other mesh) are set to numpy.nan, or extrapolated.
Parameters: | strategy : ‘projection’ or ‘interpolation’
|
---|
Notes
If the other variable uses the same field mesh, the coefficients are set directly.
If the other variable uses the same field mesh, only deformed slightly, it is advisable to provide directly the node ids as a hint where to start searching for a containing element; the order of nodes does not matter then.
Otherwise (large deformation, unrelated meshes, ...) there are basically two ways: a) query each node (its coordinates) using a KDTree of the other nodes - this completely disregards the connectivity information; b) iterate the mesh nodes so that the subsequent ones are close to each other - then also the elements of the other mesh should be close to each other: the previous one can be used as a start for the directional neighbour element crawling to the target point.
Not sure which way is faster, depends on implementation efficiency and the particular meshes.
Advance in time the DOF state history. A copy of the DOF vector is made to prevent history modification.
Get the dual variable.
Returns: | var : Variable instance
|
---|
Get the corresponding primary variable.
Returns: | var : Variable instance
|
---|
Set data (vector of DOF values) of the variable.
Parameters: | data : array
indx : int, optional
step : int, optional
preserve_caches : bool
|
---|
Container holding instances of Variable.
Apply essential (Dirichlet) and periodic boundary conditions defined for the state variables to vector vec.
Apply initial conditions defined for the state variables to vector vec.
Check whether the shape of the DOF vector corresponds to the total number of DOFs of the state variables.
Parameters: | vec : array
stripped : bool
|
---|
Create the mapping of active DOFs from/to all DOFs for all state variables.
Parameters: | ebcs : Conditions instance
epbcs : Conditions instance
ts : TimeStepper instance
functions : Functions instance
problem : Problem instance, optional
active_only : bool
|
---|---|
Returns: | active_bcs : set
|
This method resets the variable counters for automatic order!
Get names of pairs of dual variables.
Returns: | duals : dict
|
---|
Return parts of a state vector corresponding to individual state variables.
Parameters: | vec : array, optional
|
---|---|
Returns: | out : dict
|
Link state variables with corresponding virtual variables, and assign link to self to each variable instance.
Usually, when solving a PDE in the weak form, each state variable has a corresponding virtual variable.
Make a full DOF vector satisfying E(P)BCs from a reduced DOF vector.
Parameters: | svec : array
force_value : float, optional
|
---|---|
Returns: | vec : array
|
Set all active DOF connectivities to self as well as relevant sub-dicts to the individual variables.
Set data (vectors of DOF values) of variables.
Parameters: | data : array
step : int, optional
ignore_unknown : bool, optional
preserve_caches : bool
|
---|
Set variables with names in var_names from state variables with names in var_names_state using DOF values in the state vector state.
Setup data types of state variables - all have to be of the same data type, one of nm.float64 or nm.complex128.
Prepare linear combination BC operator matrix and right-hand side vector.
Convert a state vector to a dictionary of output data usable by Mesh.write().
Get the reduced DOF vector, with EBC and PBC DOFs removed.
Notes
If ‘follow_epbc’ is True, values of EPBC master dofs are not simply thrown away, but added to the corresponding slave dofs, just like when assembling. For vectors with state (unknown) variables it should be set to False, for assembled vectors it should be set to True.
Given a node connectivity, number of DOFs per node and equation mapping, create the active dof connectivity.
Locally (in a connectivity row), the DOFs are stored DOF-by-DOF (u_0 in all local nodes, u_1 in all local nodes, ...).
Globally (in a state vector), the DOFs are stored node-by-node (u_0, u_1, ..., u_X in node 0, u_0, u_1, ..., u_X in node 1, ...).
Create active DOF connectivities for all variables referenced in conn_info.
If a variable has not the equation mapping, a trivial mapping is assumed and connectivity with all DOFs active is created.
DOF connectivity key is a tuple (primary variable name, region name, type, is_trace flag).
Notes
If active_only is False, the DOF connectivities contain all DOFs, with the E(P)BC-constrained ones stored as -1 - <DOF number>, so that the full connectivities can be reconstructed for the matrix graph creation.