fe_mk, fe_mknl
Purpose
Assembly of finite element model matrices.
Syntax
[m,k,mdof] = fe_mknl(model);
model = fe_mk(model,'Options',Opt)
[m,k,mdof] = fe_mk( ... ,[0 OtherOptions])
[mat,mdof] = fe_mk( ... ,[MatType OtherOptions])
[Case,model.DOF]=fe_mknl('init',model);
mat=fe_mknl('assemble',model,Case,def,MatType);
Description
fe_mk and fe_mknl take models and return assembled matrices and/or right hand side vectors. fe_mknl is the most efficient but has some limitations in the support of superelements. It should be used by default.
Input arguments are
- model a model data structure describing nodes, elements, material properties, element properties, and possibly a case.
- Case a data structure describing loads, boundary conditions, etc. This may be stored in the model and be retrieved automatically using fe_case(model,'GetCase').
- def a data structure describing the current state of the model for model/residual assembly using fe_mknl. def is expected to use model DOFs. If Case DOFs are used, they are reexpanded to model DOFs using def=struct('def',Case.T*def.def,'DOF',model.DOF). This is currently used to by the *b.m element family for geometrically non-linear matrices.
- MatType or Opt describing the desired output, appropriate handling of linear constraints, ect.
Output formats are
- model with the additional field model.K containing the matrices. The corresponding types are stored in model.Opt(2,:). The model.DOF field is properly filled.
- [m,k,mdof] returning both mass and stiffness when Opt(1)==0
- [Mat,mdof] returning a matrix with type specified in Opt(1), see MatType below.
mdof is the DOF definition vector describing the DOFs of output matrices.
When fixed boundary conditions or linear constraints are considered, mdof is equal to the set of master or independent degrees of freedom Case.DOF which can also be obtained with fe_case(model,'gettdof'). Additional unused DOFs can then be eliminated unless Opt(2) is set to 1 to prevent that elimination. To prevent constraint elimination in fe_mknl use Assemble NoT.
In some cases, you may want to assemble the matrices but not go through the constraint elimination phase. This is done by setting Opt(2) to 2. mdof is then equal to model.DOF.
This is illustrated in the example below
femesh('reset');
model =femesh('testubeam');
model.DOF=[];% an non empty model.DOF would eliminate all other DOFs
model =fe_case(model,'fixdof','Base','z==0');
model = fe_mk(model,'Options',[0 2]);
[k,mdof] = fe_mk(model,'options',[0 0]);
fprintf('With constraints %i DOFs\n',size(k,1));
fprintf('Without %i DOFs',size(model.K{1},1));
Case=fe_case(model,'gett');
isequal(Case.DOF,mdof) % mdof is the same as Case.DOF
For other information on constraint handling see section 7.13.
Assembly is decomposed in two phases. The initialization prepares everything that will stay constant during a non-linear run. The assembly call performs other operations.
Init
The fe_mknl Init phase initializes the Case.T (basis of vectors verifying linear constraints see section 7.13), Case.GroupInfo fields (detailed below) and Case.MatGraph (preallocated sparse matrix associated with the model topology for optimized (re)assembly). Case.GroupInfo is a cell array with rows giving information about each element group in the model (see section 7.14.1 for details).
Case = fe_mknl('initNoCon', model) can be used to initialize the case structure without building the matrix connectivity (sparse matrix with preallocation of all possible non zero values). InitKeep can be used to prevent changint the model.DOF DOF list. This is typically used for submodel assembly.
The initialization phase is decomposed into the following steps
-
Generation of a complete list of DOFs using the feutil('getdof',model) call.
- get the material and element property tables in a robust manner. Generate node positions in a global reference frame.
- For each element group, build the GroupInfo data (DOF positions).
- For each element group, determine the unique pairs of [MatId ProId] values in the current group of elements and build a separate integ and constit for each pair. One then has the constitutive parameters for each type of element in the current group. pointers rows 6 and 7 give for each element the location of relevent information in the integ and constit tables.
- For each element group, perform other initializations as defined by evaluating the callback string obtained using elem('GroupInit'). For example, intialize integration rule data structures, define local bases or normal maps, allocate memory for internal state variables...
- If requested (call without NoCon), preallocate a sparse matrix to store the assembled model. This topology assumes non zero values at all components of element matrices so that it is identical for all possible matrices and constant during non-linear iterations.
Assemble [ , NoT]
The second phase, assembly, is optimized for speed and multiple runs (in non-linear sequences it is repeated as long as the element connectivity information does not change). In fe_mk the second phase is optimized for robustness. The following example illustrates the interest of multiple phase assembly
femesh('reset');
model =femesh('test hexa8 divide 100 10 10');
% traditional FE_MK assembly
tic;[m1,k1,mdof] = fe_mk(model);toc
% Multi-step approach for NL operation
tic;[Case,model.DOF]=fe_mknl('init',model);toc
tic;
m=fe_mknl('assemble',model,Case,2);
k=fe_mknl('assemble',model,Case,1);
toc
Matrix types are numeric indications of what needs to be computed during assembly. Currently defined types for OpenFEM are
-
0 mass and stiffness assembly. 1 stiffness, 2 mass, 3 viscous damping, 4 hysteretic damping, 5 tangent stiffness in geometric non-linear mechanics. Gyroscopic coupling and stiffness are supported in fe_cyclic;
- 100 volume load, 101 pressure load, 102 inertia load, 103 initial stress load. Note that some load types are only supported with the mat_og element family;
- 200 stress at node, 201 stress at element center, 202 stress at gauss point
- 251 energy associated with matrix type 1 (stiffness), 252 energy associated with matrix type 2 (mass), ...
- 300 compute initial stress field associated with an initial deformation. This value is set in Case.GroupInfo{jGroup,5} directly (be careful with the fact that such direct modification INPUTS is not a MATLAB standard feature). 301 compute the stresses induced by a thermal field.
Opt
fe_mk options are given by calls of the form fe_mk(model,'Options',Opt) or the obsolete fe_mk(node,elt,pl,il,[],adof,opt).
| opt(1) |
MatType see above |
| opt(2) |
if active DOFs are specified using model.DOF (or the obsolete call with adof), DOFs in
model.DOF but not used by the model (either linked to no element or with a zero on the matrix or both the mass and stiffness diagonals) are eliminated unless opt(2) is set to 1 (but case constraints are then still considered) or 2 (all constraints are ignored). |
| opt(3) |
Assembly method (0 default, 1 symmetric mass and stiffness (OBSOLETE), 2 disk (to be preferred for large problems)). The disk assembly method creates temporary files using the MATLAB tempname function. This minimizes memory usage so that it should be preferred for very large models. |
| opt(4) |
0 (default) nothing done for less than 1000 DOF method 1 otherwise. 1 DOF numbering optimized using current ofact SymRenumber method. Since new solvers renumber at factorization time this option is no longer interesting. |
Old formats
[m,k,mdof]=fe_mk(node,elt,pl,il) returns mass and stiffness matrices when given nodes, elements, material properties, element properties rather than the corresponding model data structure.
[mat,mdof]=fe_mk(node,elt,pl,il,[],adof,opt) lets you specify
DOFs to be retained with adof (same as defining a
Case entry with {'KeepDof', 'Retained', adof}).
These formats are kept for backward compatibility but they do not allow support of local coordinate systems, handling of boundary conditions through cases, ...
Notes
fe_mk no longer supports complex matrix assembly in order to allow a number of speed optimization steps. You are thus expected to assemble the real and imaginary parts successively.
See also
Element functions in chapter 8,
fe_c, feplot, fe_eig, upcom, fe_mat, femesh, etc.
©1991-2007 by SDTools