Finite Element Analysis Toolbox
FEATool uses a struct format with several fields to specify and set up problem definitions. The FEATool GUI will automatically manage these fields, however if the model is exported, modified on the command line, or built from scratch it is important to know how these fields are used, which is explained below.
The FEATool problem definition struct consists of the following main fields
|sdim||Cell array of space dimension names|
|phys||Physics mode structs|
|dvar||Cell array of dependent variable names|
|sfun||Cell array of shape functions|
|coef||Cell array of coefficient and expression definitions|
|eqn||Equation specification struct|
|bdr||Boundary specification struct|
|pnt||Point source and constraint specification struct|
|sol||Solution vector and list of solution times|
A cell array of geometry objects used for grid generation is contained in the geom.objects field.
The grid struct field, which defines the computational grid, is explained in the Grid section.
The sdim field contains a cell array of strings with names for the space dimensions. These can be used in equation/boundary specification and postprocessing.
The optional phys struct contains predefined physics modes that have been added with the addphys function. After editing and setting the appropriate physics mode coefficients the parsephys command will expand the dvar, sfun, coef, eqn, and bdr fields.
The dvar field contains a cell array of strings with names of the dependent (equation) variables which should be solved for.
Similarly, the sfun field contains a cell array of strings with function names of the finite element shape functions to use for each dependent variable.
The coef field is a (n_coef, 4) sized cell array of coefficient expressions that can be used in equation definitions and postprocessing. The first column gives the coefficient names, second a short description, third a long description, and the fourth column is a sub cell array for the coefficient expression definitions in each subdomain. (If any of the fields const, expr, and vars exist they will be merged internally with the coef field.)
The eqn, bdr, and pnt structs are used to specify equations, boundary conditions, and point constraints. The composition of these fields is explained below in the corresponding subsections.
After solving a problem the sol field will contain the solution vector u which has rows corresponding to the degrees of freedom. For time dependent problems the columns in u correspond to solutions at different times, and additionally the output times will be stored in the tlist vector.
The equation struct contains the following fields
|eqn.m.form||Form specifications for temporal terms|
|eqn.m.coef||Coefficient specifications for temporal terms|
|eqn.a.form||Bilinear form specifications|
|eqn.a.coef||Coefficient specifications for bilinear forms|
|eqn.a.sfun||Shape function specification for bilinear forms|
|eqn.f.form||Linear form specifications for right hand side/load vector|
|eqn.f.coef||Coefficient specifications for right hand side/load vector|
|eqn.f.sfun||Shape function specifications for right hand side/load vector|
|eqn.dofm||Degree of freedom n numbering map for each cell|
The eqn.m field contains specifications for the time dependent term (with time derivative). Similarly the eqn.a field contains specifications for the bilinear forms used in the iteration (stiffness) matrix, and the eqn.f field specifies the linear forms in the right hand side/load vector.
The above struct fields contain the form field which specifies the (bi-)linear forms to build and assemble. For bilinear forms the first row corresponds to the trial function space, and the second row the test function space. Linear forms only need to contain one row. In the form specification a 1 indicates a function value, 2 x-derivative, and 3 y-derivative. For example a form specification [2 3;2 3] indicates a bilinear form with two terms, one term with both x-derivatives for the test and trial function spaces, and one with y-derivatives for both spaces (this is a typical two-dimensional diffusion operator).
The coef field, is a cell array with coefficient values or expressions used for each term in the form field.
The sfun field is a cell array of shape function names used in the form assembly. This field is usually automatically constructed when calling the parseprob function.
dofm is an array specifying the local to global degree of freedom numbering for each dependent variable. The rows correspond to local degrees of freedoms on each cell and the columns give the cell numbers. (For linear conforming shape functions the dof mapping will be identical to the grid.c field.) This field is created when parseprob calls the mapdofbdr function.
The boundary struct contains the following fields
|bdr.d||Dirichlet boundary coefficients|
|bdr.n||Neumann (flux) boundary coefficients|
|bdr.bdrm||Boundary degree of freedom numbering maps|
Dirichlet boundary coefficient expressions for each boundary segment are specified in a cell array in the d field. If an entry is empty, then Neumann (flux) conditions will be used for the corresponding boundary segment. The Dirichlet boundary conditions are set in the function bdrsetd.
Similar to Dirichlet conditions, Neumann conditions are specified in the n field (bdrneu). An empty cell entry indicates homogeneous Neumann condition to be used (zero flux) for that boundary segment.
The bdrm arrays specifies the boundary condition mapping for each dependent variable. In an bdrm array the first row gives the global degree of freedom number, second the cell number, third cell edge number, fourth boundary section number, and fifth local degree of freedom number. This field is created when parseprob calls the mapdofbdr function.
The point struct contains the following fields
|pnt.index||Index to grid point (in grid.p)|
|pnt.type||Specifies either sources or constraint|
|pnt.dvar||Integer or string corresponding a dependent variable|
|pnt.expr||scalar or string expression for constraint|
Point sources and Dirichlet point constraints can be specified in a pnt struct. The type field specifies either a point 'source' or 'constraint' for each point with a corresponding string value. Point sources are applied to the right hand side load vector f while constraints are applied to both f and the global matrix A with the information in the finite element problem struct (pntsetf and pntset). The sources or constraints will be applied to the degree of freedom closest to the grid point specified in the index field. The dvar field contains an integer or string expression pointing to a dependent variable in dvar. The sources or constraints are specified in the expr field either as a string expression or scalar so that pnt.dvar(grid.p(:,pnt.index)) = pnt.expr. (Note that a point constraint will override the usual Dirichlet boundary conditions at the given point).