Matlab Interface
Matlab Interface
Release 5.3
1 Introduction 1
2 Installation 3
3 Preliminary 5
4 GetFEM organization 7
4.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.2 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5 Examples 11
5.1 A step-by-step basic example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2 Another Laplacian with exact solution . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.3 Linear and non-linear elasticity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.4 Avoiding the bricks framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.5 Other examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.6 Using Matlab Object-Oriented features . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7 Command reference 27
7.1 gf_asm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7.2 gf_compute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
7.3 gf_cont_struct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7.4 gf_cont_struct_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.5 gf_cvstruct_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
7.6 gf_delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
7.7 gf_eltm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
7.8 gf_fem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
7.9 gf_fem_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7.10 gf_geotrans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.11 gf_geotrans_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
i
7.12 gf_global_function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
7.13 gf_global_function_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.14 gf_integ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.15 gf_integ_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.16 gf_levelset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.17 gf_levelset_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.18 gf_levelset_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.19 gf_linsolve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.20 gf_mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.21 gf_mesh_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.22 gf_mesh_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.23 gf_mesh_fem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7.24 gf_mesh_fem_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
7.25 gf_mesh_fem_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7.26 gf_mesh_im . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
7.27 gf_mesh_im_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
7.28 gf_mesh_im_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.29 gf_mesh_im_data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.30 gf_mesh_im_data_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
7.31 gf_mesh_im_data_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
7.32 gf_mesh_levelset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.33 gf_mesh_levelset_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.34 gf_mesh_levelset_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
7.35 gf_mesher_object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
7.36 gf_mesher_object_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.37 gf_model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.38 gf_model_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.39 gf_model_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.40 gf_poly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
7.41 gf_precond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
7.42 gf_precond_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
7.43 gf_slice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
7.44 gf_slice_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
7.45 gf_slice_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
7.46 gf_spmat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
7.47 gf_spmat_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
7.48 gf_spmat_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
7.49 gf_util . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
7.50 gf_workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Index 145
ii
CHAPTER 1
Introduction
This guide provides a reference about the MatLab interface of GetFEM. For a complete reference of
GetFEM, please report to the specific guides, but you should be able to use the getfem-interface’s without
any particular knowledge of the GetFEM internals, although a basic knowledge about Finite Elements
is required. This documentation is however not self contained. You should in particular refer to the user
documentation to have a more extensive description of the structures algorithms and concepts used.
Copyright © 2004-2018 GetFEM project.
The text of the GetFEM website and the documentations are available for modification and reuse under
the terms of the GNU Free Documentation License
GetFEM is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version along with the GCC Runtime Library Exception either version
3.1 or (at your option) any later version. This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and GCC
Runtime Library Exception for more details. You should have received a copy of the GNU Lesser
General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51
Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
1
Matlab Interface, Release 5.3
2 Chapter 1. Introduction
CHAPTER 2
Installation
The installation of the getfem-interface toolbox can be somewhat tricky, since it combines a C++ com-
piler, libraries and MatLab interaction. . . In case of troubles with a non-GNU compiler, gcc/g++ (>=
4.8) should be a safe solution.
See the download and install page for the installation of GetFEM on different plateforms.
3
Matlab Interface, Release 5.3
4 Chapter 2. Installation
CHAPTER 3
Preliminary
This is just a short summary of the terms employed in this manual. If you are not familiar with finite
elements, this should be useful (but in any case, you should definitively read the dp).
The mesh is composed of convexes. What we call convexes can be simple line segments, prisms,
tetrahedrons, curved triangles, of even something which is not convex (in the geometrical sense). They
all have an associated reference convex: for segments, this will be the [0, 1] segment, for tri-
angles this will be the canonical triangle (0, 0) − (0, 1) − (1, 0), etc. All convexes of the mesh are
constructed from the reference convex through a geometric transformation. In simple cases
(when the convexes are simplices for example), this transformation will be linear (hence it is easily in-
verted, which can be a great advantage). In order to define the geometric transformation, one defines
geometrical nodes on the reference convex. The geometrical transformation maps these nodes to
the mesh nodes.
On the mesh, one defines a set of basis functions: the FEM. A FEM is associated at each convex. The
basis functions are also attached to some geometrical points (which can be arbitrarily chosen). These
points are similar to the mesh nodes, but they don’t have to be the same (this only happens on very
simple cases, such as a classical 𝑃1 fem on a triangular mesh). The set of all basis functions on the mesh
forms the basis of a vector space, on which the PDE will be solved. These basis functions (and their
associated geometrical point) are the degrees of freedom (contracted to dof). The FEM is said
to be Lagrangian when each of its basis functions is equal to one at its attached geometrical point,
and is null at the geometrical points of others basis functions. This is an important property as it is very
easy to interpolate an arbitrary function on the finite elements space.
The finite elements method involves evaluation of integrals of these basis functions (or product of ba-
sis functions etc.) on convexes (and faces of convexes). In simple cases (polynomial basis functions
and linear geometrical transformation), one can evaluate analytically these integrals. In other cases,
one has to approximate it using quadrature formulas. Hence, at each convex is attached an
integration method along with the FEM. If you have to use an approximate integration method,
always choose carefully its order (i.e. highest degree of the polynomials who are exactly integrated with
the method): the degree of the FEM, of the polynomial degree of the geometrical transformation, and the
nature of the elementary matrix have to be taken into account. If you are unsure about the appropriate
degree, always prefer a high order integration method (which will slow down the assembly) to a low
order one which will produce a useless linear-system.
5
Matlab Interface, Release 5.3
The process of construction of a global linear system from integrals of basis functions on each convex is
the assembly.
A mesh, with a set of FEM attached to its convexes is called a mesh_fem object in GetFEM.
A mesh, with a set of integration methods attached to its convexes is called a mesh_im object in
GetFEM.
A mesh_fem can be used to approximate scalar fields (heat, pression, . . . ), or vector fields (displacement,
electric field, . . . ). A mesh_im will be used to perform numerical integrations on these fields. Most of
the finite elements implemented in GetFEM are scalar (however, 𝑇 𝑅0 and edges elements are also
available). Of course, these scalar FEMs can be used to approximate each component of a vector field.
This is done by setting the 𝑄𝑑𝑖𝑚 of the mesh_fem to the dimension of the vector field (i.e. 𝑄𝑑𝑖𝑚 = 1
IRightarrow scalar field, 𝑄𝑑𝑖𝑚 = 2 IRightarrow 2D vector field etc.).
When solving a PDE, one often has to use more than one FEM. The most important one will be of course
the one on which is defined the solution of the PDE. But most PDEs involve various coefficients, for
example:
∇ · (𝜆(𝑥)∇𝑢) = 𝑓 (𝑥).
Hence one has to define an FEM for the main unknown 𝑢, but also for the data 𝜆(𝑥) and 𝑓 (𝑥) if they
are not constant. In order to interpolate easily these coefficients in their finite element space, one often
choose a Lagrangian FEM.
The convexes, mesh nodes, and dof are all numbered. We sometimes refer to the number associated
to a convex as its convex id (contracted to cvid). Mesh node numbers are also called point id
(contracted to pid). Faces of convexes do not have a global numbering, but only a local number in each
convex. Hence functions which need or return a list of faces will always use a two-rows matrix, the first
one containing convex ids, and the second one containing local face number.
While the dof are always numbered consecutively, this is not always the case for point ids and convex
ids, especially if you have removed points or convexes from the mesh. To ensure that they form a
continuous sequence (starting from 1), you have to call:
6 Chapter 3. Preliminary
CHAPTER 4
GetFEM organization
The GetFEM toolbox is just a convenient interface to the GetFEM library: you must have a working
GetFEM installed on your computer. This toolbox provides a big mex-file (c++ binary callable from
MatLab) and some additional m-files (documentation and extra-functionalities). All the functions of
GetFEM are prefixed by gf_ (hence typing gf_ at the MatLab prompt and then pressing the <tab>
key is a quick way to obtain the list of getfem functions).
4.1 Functions
7
Matlab Interface, Release 5.3
4.2 Objects
Various “objects” can be manipulated by the GetFEM toolbox, see fig. GetFEM objects hierarchy.. The
MESH and MESHFEM objects are the two most important objects.
4.2. Objects 9
Matlab Interface, Release 5.3
• gfMeshFem : object linked to a mesh, where each convex has been assigned an FEM. Created
with gf_mesh_fem.
• gfMeshImM : object linked to a mesh, where each convex has been assigned an integration
method. Created with gf_mesh_im.
• gfMeshSlice : object linked to a mesh, very similar to a P1-discontinuous gfMeshFem. Used
for fast interpolation and plotting.
• gfMdBrick : gfMdBrick , an abstraction of a part of solver (for example, the part which build
the tangent matrix, the part which handles the dirichlet conditions, etc.). These objects are stacked
to build a complete solver for a wide variety of problems. They typically use a number of gfMesh-
Fem, gfMeshIm etc. Deprecated object, replaced now by gfModel.
• gfMdState : “model state”, holds the global data for a stack of mdbricks (global tangent matrix,
right hand side etc.). Deprecated object, replaced now by gfModel.
• gfModel : “model”, holds the global data, variables and description of a model. Evolution of
“model state” object for 4.0 version of GetFEM.
The GetFEM toolbox uses its own memory management. Hence GetFEM objects are not cleared
when a:
should be used. The various GetFEM object can be accessed via handles (or descriptors), which are just
MatLab structures containing 32-bits integer identifiers to the real objects. Hence the MatLab command:
>> whos
does not report the memory consumption of GetFEM objects (except the marginal space used by the
handle). Instead, you should use:
>> gf_workspace('stats')
Examples
This example shows the basic usage of getfem, on the über-canonical problem above all others: solving
the Laplacian, −∆𝑢 = 𝑓 on a square, with the Dirichlet condition 𝑢 = 𝑔(𝑥) on the domain bound-
ary. You can find the m-file of this example under the name demo_step_by_step.m in the directory
interface/tests/matlab/ of the GetFEM distribution.
The first step is to create a mesh. It is possible to create simple structured meshes or unstructured
meshes for simple geometries (see gf_mesh('generate', mesher_object mo, scalar
h)) or to rely on an external mesher (see gf_mesh('import', string FORMAT, string
FILENAME))). For this example, we just consider a regular cartesian mesh whose nodes are
{𝑥𝑖=0...10,𝑗=0..10 = (𝑖/10, 𝑗/10)}:
If you try to look at the value of m, you’ll notice that it appears to be a structure containing two integers.
The first one is its identifier, the second one is its class-id, i.e. an identifier of its type. This small
structure is just an “handle” or “descriptor” to the real object, which is stored in the GetFEM memory
and cannot be represented via MatLab data structures. Anyway, you can still inspect the GetFEM objects
via the command gf_workspace('stats').
Now we can try to have a look at the mesh, with its vertices numbering and the convexes numbering:
As you can see, the mesh is regular, and the numbering of its nodes and convexes is also regular (this is
guaranteed for cartesian meshes, but do not hope a similar numbering for the degrees of freedom).
The next step is to create a mesh_fem object. This one links a mesh with a set of FEM:
11
Matlab Interface, Release 5.3
The first instruction builds a new gfMeshFem object, the second argument specifies that this object
will be used to interpolate scalar fields (since the unknown 𝑢 is a scalar field). The second instruction
assigns the 𝑄2 FEM to every convex (each basis function is a polynomial of degree 4, remember that
𝑃 𝑘 IRightarrow polynomials of degree 𝑘, while 𝑄𝑘 IRightarrow polynomials of degree 2𝑘). As 𝑄2 is a
polynomial FEM, you can view the expression of its basis functions on the reference convex:
It is also possible to make use of the “object oriented” features of MatLab. As you may have noticed,
when a class “foo” is provided by the getfem-interface, it is build with the function gf_foo, and manip-
ulated with the functions gf_foo_get and gf_foo_set. But (with matlab 6.x and better) you may
also create the object with the gfFoo constructor , and manipulated with the get(..) and set(..)
methods. For example, the previous steps could have been:
>> gfFem('FEM_QK(2,2)');
gfFem object ID=0 dim=2, target_dim=1, nbdof=9,[EQUIV, POLY, LAGR], est.
˓→degree=4
-> FEM_QK(2,2)
>> m=gfMesh('cartesian', [0:.1:1], [0:.1:1]);
gfMesh object ID=0 [16512 bytes], dim=2, nbpts=121, nbcvs=100
>> mf=gfMeshFem(m,1);
gfMeshFem object: ID=1 [804 bytes], qdim=1, nbdof=0,
linked gfMesh object: dim=2, nbpts=121, nbcvs=100
>> set(mf, 'fem', gfFem('FEM_QK(2,2)'));
>> mf
gfMeshFem object: ID=1 [1316 bytes], qdim=1, nbdof=441,
linked gfMesh object: dim=2, nbpts=121, nbcvs=100
Now, in order to perform numerical integrations on mf, we need to build a mesh_im object:
The integration method will be used to compute the various integrals on each element: here we choose
to perform exact computations (no quadrature formula), which is possible since the geometric
transformation of these convexes from the reference convex is linear (this is true for all simplices, and
this is also true for the parallelepipeds of our regular mesh, but it is not true for general quadrangles), and
the chosen FEM is polynomial. Hence it is possible to analytically integrate every basis function/product
of basis functions/gradients/etc. There are many alternative FEM methods and integration methods (see
ud).
12 Chapter 5. Examples
Matlab Interface, Release 5.3
Note however that in the general case, approximate integration methods are a better choice than exact
integration methods.
Now we have to find the “boundary” of the domain, in order to set a Dirichlet condition. A mesh
object has the ability to store some sets of convexes and convex faces. These sets (called “regions”) are
accessed via an integer #id:
Here we find the faces of the convexes which are on the boundary of the mesh (i.e. the faces which are
not shared by two convexes).
Remark:
we could have used gf_mesh_get(m, 'OuTEr_faCes'), as the interface
is case-insensitive, and whitespaces can be replaced by underscores.
The array border has two rows, on the first row is a convex number, on the second row is a face number
(which is local to the convex, there is no global numbering of faces). Then this set of faces is assigned
to the region number 42.
At this point, we just have to describe the model and run the solver to get the solution! The “model” is
created with the gf_model (or gfModel) constructor. A model is basically an object which build a
global linear system (tangent matrix for non-linear problems) and its associated right hand side. Typical
modifications are insertion of the stiffness matrix for the problem considered (linear elasticity, laplacian,
etc), handling of a set of contraints, Dirichlet condition, addition of a source term to the right hand side
etc. The global tangent matrix and its right hand side are stored in the “model” structure.
Let us build a problem with an easy solution: 𝑢 = 𝑥(𝑥 − 1)𝑦(𝑦 − 1) + 𝑥5 , then we have ∆𝑢 =
2(𝑥2 + 𝑦 2 ) − 2(𝑥 + 𝑦) + 20𝑥3 (the FEM won’t be able to catch the exact solution since we use a 𝑄2
method).
We start with an empty real model:
(a model is either 'real' or 'complex'). And we declare that u is an unknown of the system on the
finite element method mf by:
Now, we add a “generic elliptic” brick, which handles −∇ · (𝐴 : ∇𝑢) = . . . problems, where 𝐴 can be a
scalar field, a matrix field, or an order 4 tensor field. By default, 𝐴 = 1. We add it on our main variable
u with:
The two first lines defines a data of the model which represents the value of the Dirichlet condition.
The third one add a Dirichlet condition to the variable u on the boundary number 42. The dirich-
let condition is imposed with lagrange multipliers. Another possibility is to use a penalization. A
∫︀gfMeshFem argument
∫︀ is also required, as the Dirichlet condition 𝑢 = 𝑔 is imposed in a weak form
Γ 𝑢(𝑥)𝑣(𝑥) = Γ 𝑔(𝑥)𝑣(𝑥) ∀𝑣 where 𝑣 is taken in the space of multipliers given by here by mf.
Remark:
the polynomial expression was interpolated on mf. It is possible only if mf is of Lagrange type. In
this first example we use the same gfMeshFem for the unknown and for the data such as g, but in
the general case, mf won’t be Lagrangian and another (Lagrangian) mesh_fem will be used for the
description of Dirichlet conditions, source terms etc.
It only remains now to launch the solver. The linear system is assembled and solve with the instruction:
The model now contains the solution (as well as other things, such as the linear system which was
solved). It is extracted, a display into a MatLab figure:
% trace on;
gf_workspace('clear all');
m = gf_mesh('cartesian',[0:.1:1],[0:.1:1]);
%m=gf_mesh('import','structured','GT="GT_QK(2,1)";SIZES=[1,1];NOISED=1;
˓→NSUBDIV=[1,1];')
14 Chapter 5. Examples
Matlab Interface, Release 5.3
md=gf_model('real');
gf_model_set(md, 'add fem variable', 'u', mf);
gf_model_set(md, 'add Laplacian brick', mim, 'u');
gf_model_set(md, 'add initialized fem data', 'VolumicData', mf, F);
gf_model_set(md, 'add source term brick', mim, 'u', 'VolumicData');
gf_model_set(md, 'add initialized fem data', 'DirichletData', mf, Uexact);
gf_model_set(md, 'add Dirichlet condition with multipliers', mim, 'u', mf,
˓→1, 'DirichletData');
gf_model_get(md, 'solve');
U = gf_model_get(md, 'variable', 'u');
subplot(2,1,1); gf_plot(mf,U,'mesh','on','contour',.01:.01:.1);
colorbar; title('computed solution');
subplot(2,1,2); gf_plot(mf,U-Uexact,'mesh','on');
colorbar;title('difference with exact solution');
This example uses a mesh that was generated with GiD. The object is meshed with quadratic tetrahe-
drons. You can find the m-file of this example under the name demo_tripod.m in the directory
tests/matlab of the toolbox distribution.
linear = 1
incompressible = 0
gf_workspace('clear all');
% import the mesh
m=gfMesh('import','gid','../meshes/tripod.GiD.msh');
mfu=gfMeshFem(m,3); % mesh-fem supporting a 3D-vector field
mfd=gfMeshFem(m,1); % scalar mesh_fem, for data fields.
% the mesh_im stores the integration methods for each tetrahedron
mim=gfMeshIm(m,gf_integ('IM_TETRAHEDRON(5)'));
% we choose a P2 fem for the main unknown
gf_mesh_fem_set(mfu,'fem',gf_fem('FEM_PK(3,2)'));
% the material is homogeneous, hence we use a P0 fem for the data
gf_mesh_fem_set(mfd,'fem',gf_fem('FEM_PK(3,0)'));
% display some informations about the mesh
disp(sprintf('nbcvs=%d, nbpts=%d, nbdof=%d',gf_mesh_get(m,'nbcvs'),...
gf_mesh_get(m,'nbpts'),gf_mesh_fem_get(mfu,'nbdof')));
P=gf_mesh_get(m,'pts'); % get list of mesh points coordinates
pidtop=find(abs(P(2,:)-13)<1e-6); % find those on top of the object
pidbot=find(abs(P(2,:)+10)<1e-6); % find those on the bottom
% build the list of faces from the list of points
ftop=gf_mesh_get(m,'faces from pid',pidtop);
fbot=gf_mesh_get(m,'faces from pid',pidbot);
% assign boundary numbers
gf_mesh_set(m,'boundary',1,ftop);
gf_mesh_set(m,'boundary',2,fbot);
E = 1e3; Nu = 0.3;
% set the Lame coefficients
lambda = E*Nu/((1+Nu)*(1-2*Nu));
mu = E/(2*(1+Nu));
16 Chapter 5. Examples
Matlab Interface, Release 5.3
mds=gfMdState(b3)
disp('running solve...')
t0=cputime;
mfdu=gf_mesh_fem(m,1);
% the P2 fem is not derivable across elements, hence we use a discontinuous
% fem for the derivative of U.
gf_mesh_fem_set(mfdu,'fem',gf_fem('FEM_PK_DISCONTINUOUS(3,1)'));
VM=get(b0, 'von mises',mds,mfdu);
caxis([0 100]);
(continues on next page)
The model bricks are very convenient, as they hide most of the details of the assembly of the final linear
systems. However it is also possible to stay at a lower level, and handle the assembly of linear systems,
and their resolution, directly in MatLab. For example, the demonstration demo_tripod_alt.m is
very similar to the demo_tripod.m except that the assembly is explicit:
nbd=get(mfd, 'nbdof');
F = gf_asm('boundary_source', 1, mim, mfu, mfd, repmat([0;-10;0],1,nbd));
K = gf_asm('linear_elasticity', mim, mfu, mfd, ...
lambda*ones(1,nbd),mu*ones(1,nbd));
18 Chapter 5. Examples
Matlab Interface, Release 5.3
In getfem-interface, the assembly of vectors, and matrices∫︀ is done via the gf_asm ∫︀ function. The Dirich-
let condition 𝑢(𝑥) = 𝑟(𝑥) is handled in the weak form (ℎ(𝑥)𝑢(𝑥)).𝑣(𝑥) = 𝑟(𝑥).𝑣(𝑥) ∀𝑣 (where
ℎ(𝑥) is a 3 × 3 matrix field – here it is constant and equal to the identity). The reduced system KK UU =
FF is then built via the elimination of Dirichlet constraints from the original system. Note that it might
be more efficient (and simpler) to deal with Dirichlet condition via a penalization technique.
The basic functions of the GetFEM toolbox do not use any advanced MatLab features (except that the
handles to getfem objects are stored in a small MatLab structure). But the toolbox comes with a set of
MatLab objects, which encapsulate the handles and make them look as real MatLab objects. The aim is
not to provide extra-functionalities, but to have a better integration of the toolbox with MatLab.
Here is an example of its use:
>> m=gf_mesh('cartesian',0:.1:1,0:.1:1)
m =
id: 0
cid: 0
>> m2=gfMesh('cartesian',0:.1:1,0:.1:1)
gfMesh object ID=1 [17512 bytes], dim=2, nbpts=121, nbcvs=100
% while \kw{m} is a simple structure, \kw{m2} has been flagged by |mlab|
% as an object of class gfMesh. Since the \texttt{display} method for
% these objects have been overloaded, the toolbox displays some
% information about the mesh instead of the content of the structure.
>> gf_mesh_get(m,'nbpts')
ans =
121
% pseudo member access (which calls ##gf_mesh_get(m2,'nbpts'))
>> m2.nbpts
ans =
121
20 Chapter 5. Examples
CHAPTER 6
6.1 gf_colormap
Synopsis
c=gf_colormap(name)
Description :
return a colormap, or change the current colormap. name can be: ‘tripod’, ‘chouette’,
‘froid’, ‘tank’ or ‘earth’.
6.2 gf_plot
Synopsis
21
Matlab Interface, Release 5.3
Description :
The function expects U to be a row vector. If U is a scalar field, then gf\_plot(mf,U)
will fill the mesh with colors representing the values of U. If U is a vector field, then the
default behavior of gf_plot is to draw vectors representing the values of U.
On output, this function returns the handles to the various graphical objects created: hmesh
is the handles to the mesh lines, hbound is the handles to the edges of the boundaries,
hfill is the handle of the patch objects of faces, hvert (resp hconv, hdof) is the
handles of the vertices (resp. convexes, dof) labels.
For example, plotting a scalar field on the border of a 3D mesh can be done with
mf=gf_mesh_fem('load', 'strange.mesh_fem')
U=rand(1, gf_mesh_fem_get(mf, 'nbdof')); # random field that will
˓→be drawn
gf_plot(mf, U, 'refine', 25, 'cvlst', gf_mesh_get(mf,'outer faces
˓→'), 'mesh','on');
6.3 gf_plot_1D
Synopsis
'style', 'bo-' : the line style and dof marker style (same syntax as
˓→in the matlab command 'plot').
'color', [] : override the line color.
(continues on next page)
Description :
This function plots a 1D finite elements field.
6.4 gf_plot_mesh
Synopsis
gf_plot_mesh(m, ...)
Description :
This function is used to display a mesh.
Example
6.5 gf_plot_slice
Synopsis
gf_plot_slice(sl, ...)
6.4. gf_plot_mesh 23
Matlab Interface, Release 5.3
Description :
This function can be used to plot mesh slices. It is also used by the gf_plot_mesh and
gf_plot functions.
Example : consider that you have a 3D mesh_fem mf and a vector field U de-
fined on this mesh_fem, solution of the Stokes problem in a tank (see the demo
demo_stokes_3D_tank_draw.m in the tests directory).
figure;
% slice the mesh with two half spaces, and take the boundary of
˓→the resulting quarter-cylinder
sl=gf_slice(\{'boundary',\{'intersection',\{'planar',+1,[0;0;0],
˓→[0;1;0]\},\ldots
\{'planar',+1,[0;0;0],
˓→[1;0;0]\}\}\},m,6);
Usl=gf_compute(pde.mf_u,U,'interpolate on', sl); % interpolate
˓→the solution on the slice
% show the norm of the displacement on this slice
gf_plot_slice(sl,'mesh','on','data',sqrt(sum(Usl.^2,1)),'mesh_
˓→slice_edges','off');
6.5. gf_plot_slice 25
Matlab Interface, Release 5.3
Command reference
Please remember that this documentation is not self contained. You should in particular refer to the user
documentation to have a more extensive description of the structures algorithms and concepts used.
The expected type of each function argument is indicated in this reference. Here is a list of these types:
Arguments listed between square brackets are optional. Lists between braces indicate that the argument
27
Matlab Interface, Release 5.3
means that the dummy function takes two or three arguments, its first being an integer value, the second
a string which is either ‘foo’ or ‘bar’, and a third optional argument. It returns two values (with the usual
matlab meaning, i.e. the caller can always choose to ignore them).
7.1 gf_asm
Synopsis
{...} = gf_asm('generic', mesh_im mim, int order, string expression, int
˓→region, [model model, ['Secondary_domain', 'name',]] [string varname,
˓→int is_variable[, {mesh_fem mf, mesh_imd mimd}], value], ['select_output
˓→', 'varname1'[, 'varname2]], ...)
M = gf_asm('mass matrix', mesh_im mim, mesh_fem mf1[, mesh_fem mf2[, int
˓→region]])
L = gf_asm('laplacian', mesh_im mim, mesh_fem mf_u, mesh_fem mf_d, vec a[,
˓→int region])
Le = gf_asm('linear elasticity', mesh_im mim, mesh_fem mf_u, mesh_fem mf_d,
˓→ vec lambda_d, vec mu_d[, int region])
Description :
General assembly function.
Many of the functions below use more than one mesh_fem: the main mesh_fem (mf_u) used
for the main unknown, and data mesh_fem (mf_d) used for the data. It is always assumed
that the Qdim of mf_d is equal to 1: if mf_d is used to describe vector or tensor data, you
just have to “stack” (in fortran ordering) as many scalar fields as necessary.
Command list :
{...} = gf_asm('generic', mesh_im mim, int order, string
expression, int region, [model model, ['Secondary_domain',
'name',]] [string varname, int is_variable[, {mesh_fem mf,
mesh_imd mimd}], value], ['select_output', 'varname1'[,
'varname2]], ...)
High-level generic assembly procedure for volumic or boundary assembly.
Performs the generic assembly of expression with the integration method mim
on the mesh region of index region (-1 means all elements of the mesh). The
same mesh should be shared by the integration method and all the finite element
methods or mesh_im_data corresponding to the variables.
order indicates either that the (scalar) potential (order = 0) or the (vector) residual
(order = 1) or the tangent (matrix) (order = 2) is to be computed.
model is an optional parameter allowing to take into account all variables and
data of a model. Note that all enabled variables of the model will occupy space
in the returned vector/matrix corresponding to their degrees of freedom in the
global system, even if they are not present in expression.
The variables and constants (data) are listed after the region number (or option-
ally the model). For each variable/constant, a name must be given first (as it is
referred in the assembly string), then an integer equal to 1 or 0 is expected re-
spectively for declaring a variable or a constant, then the finite element method
if it is a fem variable/constant or the mesh_im_data if it is data defined on in-
tegration points, and the vector representing the value of the variable/constant.
It is possible to give an arbitrary number of variable/constant. The difference
7.1. gf_asm 29
Matlab Interface, Release 5.3
between a variable and a constant is that test functions are only available for
variables, not for constants.
select_output is an optional parameter which allows to reduce the output vec-
tor (for order equal to 1) or the matrix (for order equal to 2) to the degrees of
freedom of the specified variables. One variable has to be specified for a vector
output and two for a matrix output.
Note that if several variables are given, the assembly of the tangent ma-
trix/residual vector will be done considering the order in the call of the function
(the degrees of freedom of the first variable, then of the second one, and so on).
If a model is provided, all degrees of freedom of the model will be counted first,
even if some of the model variables do not appear in expression.
For example, the L2 norm of a vector field “u” can be computed with:
Assembles terms (tangent matrix and right hand side) for nonlinear elasticity.
The solution U is required at the current time-step. The law may be choosen
among:
• ‘SaintVenant Kirchhoff’: Linearized law, should be avoided. This law has
the two usual Lame coefficients as parameters, called lambda and mu.
• ‘Mooney Rivlin’: This law has three parameters, called C1, C2 and D1. Can
be preceded with the words ‘compressible’ or ‘incompressible’ to force a
specific version. By default, the incompressible version is considered which
requires only the first two material coefficients.
• ‘neo Hookean’: A special case of the ‘Mooney Rivlin’ law that requires one
material coefficient less (C2 = 0). By default, its compressible version is
used.
• ‘Ciarlet Geymonat’: This law has 3 parameters, called lambda, mu and
gamma, with gamma chosen such that gamma is in ]-lambda/2-mu, -mu[.
The parameters of the material law are described on the mesh_fem mf_d. The
matrix params should have nbdof(mf_d) columns, each row correspounds to a
parameter.
The last argument selects what is to be built: either the tangent matrix, or the
right hand side. If the incompressibility is considered, it should be followed by
a mesh_fem mf_p, for the pression.
Return a spmat object (tangent matrix), vec object (right hand side), tuple of
spmat objects (incompressible tangent matrix), or tuple of vec objects (incom-
pressible right hand side).
A = gf_asm('helmholtz', mesh_im mim, mesh_fem mf_u, mesh_fem
mf_d, vec k[, int region])
Assembly of the matrix for the Helmholtz problem.
∆𝑢 + 𝑘 2 𝑢 = 0, with k complex scalar.
Return a spmat object.
A = gf_asm('bilaplacian', mesh_im mim, mesh_fem mf_u,
mesh_fem mf_d, vec a[, int region])
Assembly of the matrix for the Bilaplacian problem.
∆(𝑎(𝑥)∆𝑢) = 0 with a scalar.
Return a spmat object.
A = gf_asm('bilaplacian KL', mesh_im mim, mesh_fem mf_u,
mesh_fem mf_d, vec a, vec nu[, int region])
Assembly of the matrix for the Bilaplacian problem with Kirchhoff-Love formu-
lation.
∆(𝑎(𝑥)∆𝑢) = 0 with a scalar.
Return a spmat object.
V = gf_asm('volumic source', mesh_im mim, mesh_fem mf_u,
mesh_fem mf_d, vec fd[, int region])
7.1. gf_asm 31
Matlab Interface, Release 5.3
if u is a 2D vector field.
Of course, if the unknown is a scalar field, you just have to set H = ones(1, N),
where N is the number of dof of mf_d.
This is basically the same than calling gf_asm(‘boundary qu term’) for H and
calling gf_asm(‘neumann’) for R, except that this function tries to produce a
‘better’ (more diagonal) constraints matrix (when possible).
See also gf_spmat_get(spmat S, ‘Dirichlet_nullspace’).
Q = gf_asm('boundary qu term',int boundary_num, mesh_im mim,
mesh_fem mf_u, mesh_fem mf_d, mat q)
Assembly of a boundary qu term.
q should be be a [Qdim x Qdim x N] array, where N is the number of dof of
mf_d, and Qdim is the dimension of the unkown u (that is set when creating the
mesh_fem).
Return a spmat object.
gf_asm('define function', string name, int nb_args, string
expression[, string expression_derivative_t[, string
expression_derivative_u]])
Define a new function name which can be used in high level generic assembly.
The function can have one or two parameters. In expression all available prede-
fined function or operation of the generic assembly can be used. However, no
reference to some variables or data can be specified. The argument of the func-
tion is t for a one parameter function and t and u for a two parameter function.
For instance ‘sin(pi*t)+2*t*t’ is a valid expression for a one parameter function
gf_asm('volumic','u=data(#1); V()+=u(i).u(j).comp(Base(
˓→#1).Base(#1))(i,j)',mim,mf,U)
7.1. gf_asm 33
Matlab Interface, Release 5.3
gf_asm('volumic','a=data(#2);M(#1,#1)+=sym(comp(Grad(#1).
˓→Grad(#1).Base(#2))(:,i,:,i,j).a(j))', mim,mf,mf_data,A);
7.2 gf_compute
Synopsis
n = gf_compute(mesh_fem MF, vec U, 'L2 norm', mesh_im mim[, mat CVids])
n = gf_compute(mesh_fem MF, vec U, 'L2 dist', mesh_im mim, mesh_fem mf2,
˓→vec U2[, mat CVids])
n = gf_compute(mesh_fem MF, vec U, 'H1 semi norm', mesh_im mim[, mat
˓→CVids])
7.2. gf_compute 35
Matlab Interface, Release 5.3
Description :
Various computations involving the solution U to a finite element problem.
Command list :
n = gf_compute(mesh_fem MF, vec U, 'L2 norm', mesh_im mim[,
mat CVids])
Compute the L2 norm of the (real or complex) field U.
If CVids is given, the norm will be computed only on the listed elements.
n = gf_compute(mesh_fem MF, vec U, 'L2 dist', mesh_im mim,
mesh_fem mf2, vec U2[, mat CVids])
Compute the L2 distance between U and U2.
If CVids is given, the norm will be computed only on the listed elements.
n = gf_compute(mesh_fem MF, vec U, 'H1 semi norm', mesh_im
mim[, mat CVids])
Compute the L2 norm of grad(U).
If CVids is given, the norm will be computed only on the listed elements.
n = gf_compute(mesh_fem MF, vec U, 'H1 semi dist', mesh_im
mim, mesh_fem mf2, vec U2[, mat CVids])
Compute the semi H1 distance between U and U2.
If CVids is given, the norm will be computed only on the listed elements.
n = gf_compute(mesh_fem MF, vec U, 'H1 norm', mesh_im mim[,
mat CVids])
Compute the H1 norm of U.
If CVids is given, the norm will be computed only on the listed elements.
n = gf_compute(mesh_fem MF, vec U, 'H2 semi norm', mesh_im
mim[, mat CVids])
Compute the L2 norm of D^2(U).
If CVids is given, the norm will be computed only on the listed elements.
n = gf_compute(mesh_fem MF, vec U, 'H2 norm', mesh_im mim[,
mat CVids])
Compute the H2 norm of U.
If CVids is given, the norm will be computed only on the listed elements.
DU = gf_compute(mesh_fem MF, vec U, 'gradient', mesh_fem
mf_du)
7.2. gf_compute 37
Matlab Interface, Release 5.3
7.3 gf_cont_struct
Synopsis
˓→.])
Description :
General constructor for cont_struct objects.
This object serves for storing parameters and data used in numerical continuation of solution
branches of models (for more details about continuation see the GetFEM user documenta-
tion).
Command list :
S = gf_cont_struct(model md, string dataname_parameter[,
string dataname_init, string dataname_final, string
dataname_current], scalar sc_fac[, ...])
The variable dataname_parameter should parametrise the model given by
md. If the parameterization is done via a vector datum, dataname_init and
dataname_final should store two given values of this datum determining the pa-
rameterization, and dataname_current serves for actual values of this datum.
sc_fac is a scale factor involved in the weighted norm used in the continuation.
Additional options:
• ‘lsolver’, string SOLVER_NAME name of the solver to be used for the
incorporated linear systems (the default value is ‘auto’, which lets
getfem choose itself); possible values are ‘superlu’, ‘mumps’ (if sup-
ported), ‘cg/ildlt’, ‘gmres/ilu’ and ‘gmres/ilut’;
• ‘h_init’, scalar HIN initial step size (the default value is 1e-2);
• ‘h_max’, scalar HMAX maximum step size (the default value is 1e-1);
• ‘h_min’, scalar HMIN minimum step size (the default value is 1e-5);
• ‘h_inc’, scalar HINC factor for enlarging the step size (the default value
is 1.3);
• ‘h_dec’, scalar HDEC factor for diminishing the step size (the default
value is 0.5);
• ‘max_iter’, int MIT maximum number of iterations allowed in the correc-
tion (the default value is 10);
• ‘thr_iter’, int TIT threshold number of iterations of the correction for en-
larging the step size (the default value is 4);
• ‘max_res’, scalar RES target residual value of a new point on the solution
curve (the default value is 1e-6);
• ‘max_diff’, scalar DIFF determines a convergence criterion for two con-
secutive points (the default value is 1e-6);
• ‘min_cos’, scalar MCOS minimal value of the cosine of the angle be-
tween tangents to the solution curve at an old point and a new one (the
default value is 0.9);
• ‘max_res_solve’, scalar RES_SOLVE target residual value for the linear
systems to be solved (the default value is 1e-8);
• ‘singularities’, int SING activates tools for detection and treatment of sin-
gular points (1 for limit points, 2 for bifurcation points and points re-
quiring special branching techniques);
7.3. gf_cont_struct 39
Matlab Interface, Release 5.3
7.4 gf_cont_struct_get
Synopsis
Description :
General function for querying information about cont_struct objects and for applying them
to numerical continuation.
Command list :
h = gf_cont_struct_get(cont_struct CS, 'init step size')
Return an initial step size for continuation.
7.4. gf_cont_struct_get 41
Matlab Interface, Release 5.3
Return the last value of the bifurcation test function and eventually the whole
calculated graph when passing between different sub-domains of differentiabil-
ity.
{X, gamma, T_X, T_gamma} = gf_cont_struct_get(cont_struct
CS, 'sing_data')
Return a singular point (X, gamma) stored in the cont_struct object and a cou-
ple of arrays (T_X, T_gamma) of tangents to all located solution branches that
emanate from there.
s = gf_cont_struct_get(cont_struct CS, 'char')
Output a (unique) string representation of the cont_struct.
This can be used for performing comparisons between two different cont_struct
objects. This function is to be completed.
gf_cont_struct_get(cont_struct CS, 'display')
Display a short summary for a cont_struct object.
7.5 gf_cvstruct_get
Synopsis
Description :
General function for querying information about convex_structure objects.
The convex structures are internal structures of GetFEM. They do not contain points po-
sitions. These structures are recursive, since the faces of a convex structures are convex
structures.
Command list :
n = gf_cvstruct_get(cvstruct CVS, 'nbpts')
Get the number of points of the convex structure.
d = gf_cvstruct_get(cvstruct CVS, 'dim')
Get the dimension of the convex structure.
cs = gf_cvstruct_get(cvstruct CVS, 'basic structure')
Get the simplest convex structure.
For example, the ‘basic structure’ of the 6-node triangle, is the canonical 3-noded
triangle.
cs = gf_cvstruct_get(cvstruct CVS, 'face', int F)
7.6 gf_delete
Synopsis
gf_delete(I[, J, K,...])
Description :
Delete an existing getfem object from memory (mesh, mesh_fem, etc.).
SEE ALSO: gf_workspace, gf_mesh, gf_mesh_fem.
Command list :
gf_delete(I[, J, K,...])
I should be a descriptor given by gf_mesh(), gf_mesh_im(), gf_slice() etc.
Note that if another object uses I, then object I will be deleted only when both
have been asked for deletion.
Only objects listed in the output of gf_workspace(‘stats’) can be deleted (for
example gf_fem objects cannot be destroyed).
You may also use gf_workspace(‘clear all’) to erase everything at once.
7.7 gf_eltm
Synopsis
Description :
General constructor for eltm objects.
7.6. gf_delete 43
Matlab Interface, Release 5.3
This object represents a type of elementary matrix. In order to obtain a numerical value of
these matrices, see gf_mesh_im_get(mesh_im MI, ‘eltm’).
If you have very particular assembling needs, or if you just want to check the content of
an elementary matrix, this function might be useful. But the generic assembly abilities of
gf_asm(. . . ) should suit most needs.
Command list :
E = gf_eltm('base', fem FEM)
return a descriptor for the integration of shape functions on elements, using the
fem FEM.
E = gf_eltm('grad', fem FEM)
return a descriptor for the integration of the gradient of shape functions on ele-
ments, using the fem FEM.
E = gf_eltm('hessian', fem FEM)
return a descriptor for the integration of the hessian of shape functions on ele-
ments, using the fem FEM.
E = gf_eltm('normal')
return a descriptor for the unit normal of convex faces.
E = gf_eltm('grad_geotrans')
return a descriptor to the gradient matrix of the geometric transformation.
E = gf_eltm('grad_geotrans_inv')
return a descriptor to the inverse of the gradient matrix of the geometric trans-
formation (this is rarely used).
E = gf_eltm('product', eltm A, eltm B)
return a descriptor for the integration of the tensorial product of elementary ma-
trices A and B.
7.8 gf_fem
Synopsis
Description :
General constructor for fem objects.
This object represents a finite element method on a reference element.
Command list :
7.8. gf_fem 45
Matlab Interface, Release 5.3
7.9 gf_fem_get
Synopsis
Description :
General function for querying information about FEM objects.
Command list :
n = gf_fem_get(fem F, 'nbdof'[, int cv])
Return the number of dof for the fem.
Some specific fem (for example ‘interpolated_fem’) may require a convex num-
ber cv to give their result. In most of the case, you can omit this convex number.
n = gf_fem_get(fem F, 'index of global dof', cv)
Return the index of global dof for special fems such as interpolated fem.
d = gf_fem_get(fem F, 'dim')
Return the dimension (dimension of the reference convex) of the fem.
td = gf_fem_get(fem F, 'target_dim')
Return the dimension of the target space.
The target space dimension is usually 1, except for vector fem.
P = gf_fem_get(fem F, 'pts'[, int cv])
Get the location of the dof on the reference element.
Some specific fem may require a convex number cv to give their result (for exam-
ple ‘interpolated_fem’). In most of the case, you can omit this convex number.
b = gf_fem_get(fem F, 'is_equivalent')
Return 0 if the fem is not equivalent.
Equivalent fem are evaluated on the reference convex. This is the case of most
classical fem’s.
b = gf_fem_get(fem F, 'is_lagrange')
Return 0 if the fem is not of Lagrange type.
b = gf_fem_get(fem F, 'is_polynomial')
Return 0 if the basis functions are not polynomials.
d = gf_fem_get(fem F, 'estimated_degree')
Return an estimation of the polynomial degree of the fem.
This is an estimation for fem which are not polynomials.
E = gf_fem_get(fem F, 'base_value',mat p)
7.9. gf_fem_get 47
Matlab Interface, Release 5.3
7.10 gf_geotrans
Synopsis
GT = gf_geotrans(string name)
Description :
General constructor for geotrans objects.
The geometric transformation must be used when you are building a custom mesh convex by
convex (see the add_convex() function of mesh): it also defines the kind of convex (triangle,
hexahedron, prism, etc..)
Command list :
GT = gf_geotrans(string name)
The name argument contains the specification of the geometric transformation
as a string, which may be:
• GT_PK(n,k) : Transformation on simplexes, dim n, degree k.
• GT_QK(n,k) : Transformation on parallelepipeds, dim n, degree k.
• GT_PRISM(n,k) : Transformation on prisms, dim n, degree k.
• GT_PRODUCT(A,B) : Tensorial product of two transformations.
7.11 gf_geotrans_get
Synopsis
Description :
General function for querying information about geometric transformations objects.
Command list :
d = gf_geotrans_get(geotrans GT, 'dim')
Get the dimension of the geotrans.
This is the dimension of the source space, i.e. the dimension of the reference
convex.
b = gf_geotrans_get(geotrans GT, 'is_linear')
Return 0 if the geotrans is not linear.
n = gf_geotrans_get(geotrans GT, 'nbpts')
Return the number of points of the geotrans.
P = gf_geotrans_get(geotrans GT, 'pts')
Return the reference convex points of the geotrans.
The points are stored in the columns of the output matrix.
N = gf_geotrans_get(geotrans GT, 'normals')
Get the normals for each face of the reference convex of the geotrans.
The normals are stored in the columns of the output matrix.
Pt = gf_geotrans_get(geotrans GT, 'transform',mat G, mat Pr)
Apply the geotrans to a set of points.
G is the set of vertices of the real convex, Pr is the set of points (in the reference
convex) that are to be transformed. The corresponding set of points in the real
convex is returned.
s = gf_geotrans_get(geotrans GT, 'char')
Output a (unique) string representation of the geotrans.
This can be used to perform comparisons between two different geotrans objects.
7.11. gf_geotrans_get 49
Matlab Interface, Release 5.3
7.12 gf_global_function
Synopsis
Description :
General constructor for global_function objects.
Global function object is represented by three functions:
• The function val.
• The function gradient grad.
• The function Hessian hess.
this type of function is used as local and global enrichment function. The global function
Hessian is an optional parameter (only for fourth order derivative problems).
Command list :
GF = gf_global_function('cutoff', int fn, scalar r, scalar
r1, scalar r0)
Create a cutoff global function.
GF = gf_global_function('crack', int fn)
Create a near-tip asymptotic global function for modelling cracks.
GF = gf_global_function('parser', string val[, string grad[,
string hess]])
Create a global function from strings val, grad and hess. This function could
be improved by using the derivation of the generic assembly language . . . to be
done.
GF = gf_global_function('product', global_function F,
global_function G)
Create a product of two global functions.
GF = gf_global_function('add', global_function gf1,
global_function gf2)
Create a add of two global functions.
7.13 gf_global_function_get
Synopsis
Description :
General function for querying information about global_function objects.
Command list :
VALs = gf_global_function_get(global_function GF, 'val',mat
PTs)
Return val function evaluation in PTs (column points).
GRADs = gf_global_function_get(global_function GF, 'grad',
mat PTs)
Return grad function evaluation in PTs (column points).
On return, each column of GRADs is of the form [Gx,Gy].
HESSs = gf_global_function_get(global_function GF, 'hess',
mat PTs)
Return hess function evaluation in PTs (column points).
On return, each column of HESSs is of the form [Hxx,Hxy,Hyx,Hyy].
s = gf_global_function_get(global_function GF, 'char')
Output a (unique) string representation of the global_function.
This can be used to perform comparisons between two different global_function
objects. This function is to be completed.
gf_global_function_get(global_function GF, 'display')
displays a short summary for a global_function object.
7.14 gf_integ
Synopsis
I = gf_integ(string method)
Description :
General constructor for integ objects.
General object for obtaining handles to various integrations methods on convexes (used
when the elementary matrices are built).
Command list :
7.13. gf_global_function_get 51
Matlab Interface, Release 5.3
I = gf_integ(string method)
Here is a list of some integration methods defined in GetFEM (see the description
of finite element and integration methods for a complete reference):
• IM_EXACT_SIMPLEX(n) : Exact integration on simplices (works only
with linear geometric transformations and PK fem’s).
• IM_PRODUCT(A,B) : Product of two integration methods.
• IM_EXACT_PARALLELEPIPED(n) : Exact integration on paral-
lelepipeds.
• IM_EXACT_PRISM(n) : Exact integration on prisms.
• IM_GAUSS1D(k) : Gauss method on the segment, order k=1,3,. . . ,99.
• IM_NC(n,k) : Newton-Cotes approximative integration on simplexes, order
k.
• IM_NC_PARALLELEPIPED(n,k) : Product of Newton-Cotes integration
on parallelepipeds.
• IM_NC_PRISM(n,k) : Product of Newton-Cotes integration on prisms.
• IM_GAUSS_PARALLELEPIPED(n,k) : Product of Gauss1D integration
on parallelepipeds.
• IM_TRIANGLE(k) : Gauss methods on triangles
k=1,3,5,6,7,8,9,10,13,17,19.
• IM_QUAD(k) : Gauss methods on quadrilaterons k=2,3,5, . . . ,17. Note that
IM_GAUSS_PARALLELEPIPED should be prefered for QK fem’s.
• IM_TETRAHEDRON(k) : Gauss methods on tetrahedrons k=1,2,3,5,6 or
8.
• IM_SIMPLEX4D(3) : Gauss method on a 4-dimensional simplex.
• IM_STRUCTURED_COMPOSITE(im,k) : Composite method on a grid
with k divisions.
• IM_HCT_COMPOSITE(im) : Composite integration suited to the HCT
composite finite element.
Example:
• I = gf_integ(‘IM_PRODUCT(IM_GAUSS1D(5),IM_GAUSS1D(5))’)
is the same as:
• I = gf_integ(‘IM_GAUSS_PARALLELEPIPED(2,5)’)
Note that ‘exact integration’ should be avoided in general, since they only apply
to linear geometric transformations, are quite slow, and subject to numerical
stability problems for high degree fem’s.
7.15 gf_integ_get
Synopsis
b = gf_integ_get(integ I, 'is_exact')
d = gf_integ_get(integ I, 'dim')
n = gf_integ_get(integ I, 'nbpts')
Pp = gf_integ_get(integ I, 'pts')
Pf = gf_integ_get(integ I, 'face_pts',F)
Cp = gf_integ_get(integ I, 'coeffs')
Cf = gf_integ_get(integ I, 'face_coeffs',F)
s = gf_integ_get(integ I, 'char')
gf_integ_get(integ I, 'display')
Description :
General function for querying information about integration method objects.
Command list :
b = gf_integ_get(integ I, 'is_exact')
Return 0 if the integration is an approximate one.
d = gf_integ_get(integ I, 'dim')
Return the dimension of the reference convex of the method.
n = gf_integ_get(integ I, 'nbpts')
Return the total number of integration points.
Count the points for the volume integration, and points for surface integration on
each face of the reference convex.
Only for approximate methods, this has no meaning for exact integration meth-
ods!
Pp = gf_integ_get(integ I, 'pts')
Return the list of integration points
Only for approximate methods, this has no meaning for exact integration meth-
ods!
Pf = gf_integ_get(integ I, 'face_pts',F)
Return the list of integration points for a face.
Only for approximate methods, this has no meaning for exact integration meth-
ods!
Cp = gf_integ_get(integ I, 'coeffs')
Returns the coefficients associated to each integration point.
Only for approximate methods, this has no meaning for exact integration meth-
ods!
Cf = gf_integ_get(integ I, 'face_coeffs',F)
Returns the coefficients associated to each integration of a face.
Only for approximate methods, this has no meaning for exact integration meth-
ods!
s = gf_integ_get(integ I, 'char')
7.15. gf_integ_get 53
Matlab Interface, Release 5.3
7.16 gf_levelset
Synopsis
Description :
General constructor for levelset objects.
The level-set object is represented by a primary level-set and optionally a secondary level-
set used to represent fractures (if p(x) is the primary level-set function and s(x) is the sec-
ondary level-set, the crack is defined by 𝑝(𝑥) = 0 and 𝑠(𝑥) ≤ 0 : the role of the secondary
is to determine the crack front/tip).
note:
All tools listed below need the package qhull installed on your system. This
package is widely available. It computes convex hull and delaunay triangulations
in arbitrary dimension.
Command list :
LS = gf_levelset(mesh m, int d[, string 'ws'| string f1[,
string f2 | string 'ws']])
Create a levelset object on a mesh represented by a primary function (and op-
tional secondary function, both) defined on a lagrange mesh_fem of degree d.
If ws (with secondary) is set; this levelset is represented by a primary function
and a secondary function. If f1 is set; the primary function is defined by that
expression (with the syntax of the high generic assembly language). If f2 is
set; this levelset is represented by a primary function and a secondary function
defined by these expressions.
7.17 gf_levelset_get
Synopsis
Description :
7.18 gf_levelset_set
Synopsis
Description :
General function for modification of LEVELSET objects.
Command list :
gf_levelset_set(levelset LS, 'values', {mat v1|string
func_1}[, mat v2|string func_2])
Set values of the vector of dof for the level-set functions.
Set the primary function with the vector of dof v1 (or the expression func_1)
and the secondary function (if any) with the vector of dof v2 (or the expression
func_2)
gf_levelset_set(levelset LS, 'simplify'[, scalar eps=0.01])
Simplify dof of level-set optionally with the parameter eps.
7.18. gf_levelset_set 55
Matlab Interface, Release 5.3
7.19 gf_linsolve
Synopsis
Description :
Various linear system solvers.
Command list :
X = gf_linsolve('gmres', spmat M, vec b[, int restart][,
precond P][,'noisy'][,'res', r][,'maxiter', n])
Solve M.X = b with the generalized minimum residuals method.
Optionally using P as preconditioner. The default value of the restart parameter
is 50.
X = gf_linsolve('cg', spmat M, vec b [, precond P][,
'noisy'][,'res', r][,'maxiter', n])
Solve M.X = b with the conjugated gradient method.
Optionally using P as preconditioner.
X = gf_linsolve('bicgstab', spmat M, vec b [, precond P][,
'noisy'][,'res', r][,'maxiter', n])
Solve M.X = b with the bi-conjugated gradient stabilized method.
Optionally using P as a preconditioner.
{U, cond} = gf_linsolve('lu', spmat M, vec b)
Alias for gf_linsolve(‘superlu’,. . . )
{U, cond} = gf_linsolve('superlu', spmat M, vec b)
Solve M.U = b apply the SuperLU solver (sparse LU factorization).
The condition number estimate cond is returned with the solution U.
{U, cond} = gf_linsolve('mumps', spmat M, vec b)
Solve M.U = b using the MUMPS solver.
7.20 gf_mesh
Synopsis
Description :
General constructor for mesh objects.
This object is able to store any element in any dimension even if you mix elements with
different dimensions.
Note that for recent (> 6.0) versions of matlab, you should replace the calls to ‘gf_mesh’
with ‘gfMesh’ (this will instruct Matlab to consider the getfem mesh as a regular matlab
object that can be manipulated with get() and set() methods).
Command list :
M = gf_mesh('empty', int dim)
Create a new empty mesh.
M = gf_mesh('cartesian', vec X[, vec Y[, vec Z,..]])
Build quickly a regular mesh of quadrangles, cubes, etc.
M = gf_mesh('pyramidal', vec X[, vec Y[, vec Z,..]])
Build quickly a regular mesh of pyramids, etc.
M = gf_mesh('cartesian Q1', vec X, vec Y[, vec Z,..])
Build quickly a regular mesh of quadrangles, cubes, etc. with Q1 elements.
M = gf_mesh('triangles grid', vec X, vec Y)
Build quickly a regular mesh of triangles.
This is a very limited and somehow deprecated function (See also
gf_mesh('ptND'), gf_mesh('regular simplices') and
gf_mesh('cartesian')).
M = gf_mesh('regular simplices', vec X[, vec Y[, vec Z,...
]]['degree', int k]['noised'])
Mesh a n-dimensional parallelepiped with simplices (triangles, tetrahedrons etc)
.
7.20. gf_mesh 57
Matlab Interface, Release 5.3
The optional degree may be used to build meshes with non linear geometric
transformations.
M = gf_mesh('curved', mesh m, vec F)
Build a curved (n+1)-dimensions mesh from a n-dimensions mesh m.
The points of the new mesh have one additional coordinate, given by the vector
F. This can be used to obtain meshes for shells. m may be a mesh_fem object,
in that case its linked mesh will be used.
M = gf_mesh('prismatic', mesh m, int nl[, int degree])
Extrude a prismatic mesh M from a mesh m.
In the additional dimension there are nl layers of elements distributed from 0
to 1. If the optional parameter degree is provided with a value greater than
the default value of 1, a non-linear transformation of corresponding degree is
considered in the extrusion direction.
M = gf_mesh('pt2D', mat P, imat T[, int n])
Build a mesh from a 2D triangulation.
Each column of P contains a point coordinate, and each column of T contains
the point indices of a triangle. n is optional and is a zone number. If n is specified
then only the zone number n is converted (in that case, T is expected to have 4
rows, the fourth containing these zone numbers).
Can be used to Convert a “pdetool” triangulation exported in variables P and T
into a GETFEM mesh.
M = gf_mesh('ptND', mat P, imat T)
Build a mesh from a n-dimensional “triangulation”.
Similar function to ‘pt2D’, for building simplexes meshes from a triangulation
given in T, and a list of points given in P. The dimension of the mesh will be the
number of rows of P, and the dimension of the simplexes will be the number of
rows of T.
M = gf_mesh('load', string filename)
Load a mesh from a GetFEM ascii mesh file.
See also gf_mesh_get(mesh M, 'save', string filename).
M = gf_mesh('from string', string s)
Load a mesh from a string description.
For example, a string returned by gf_mesh_get(mesh M, 'char').
M = gf_mesh('import', string format, string filename)
Import a mesh.
format may be:
• ‘gmsh’ for a mesh created with Gmsh
• ‘gid’ for a mesh created with GiD
• ‘cdb’ for a mesh created with ANSYS
7.21 gf_mesh_get
Synopsis
d = gf_mesh_get(mesh M, 'dim')
np = gf_mesh_get(mesh M, 'nbpts')
nc = gf_mesh_get(mesh M, 'nbcvs')
P = gf_mesh_get(mesh M, 'pts'[, ivec PIDs])
Pid = gf_mesh_get(mesh M, 'pid')
PIDs = gf_mesh_get(mesh M, 'pid in faces', imat CVFIDs)
PIDs = gf_mesh_get(mesh M, 'pid in cvids', imat CVIDs)
PIDs = gf_mesh_get(mesh M, 'pid in regions', imat RIDs)
PIDs = gf_mesh_get(mesh M, 'pid from coords', mat PTS[, scalar radius=0])
{Pid, IDx} = gf_mesh_get(mesh M, 'pid from cvid'[, imat CVIDs])
{Pts, IDx} = gf_mesh_get(mesh M, 'pts from cvid'[, imat CVIDs])
CVid = gf_mesh_get(mesh M, 'cvid')
m = gf_mesh_get(mesh M, 'max pid')
m = gf_mesh_get(mesh M, 'max cvid')
[E,C] = gf_mesh_get(mesh M, 'edges' [, CVLST][, 'merge'])
[E,C] = gf_mesh_get(mesh M, 'curved edges', int N [, CVLST])
PIDs = gf_mesh_get(mesh M, 'orphaned pid')
CVIDs = gf_mesh_get(mesh M, 'cvid from pid', ivec PIDs[, bool share=False])
CVFIDs = gf_mesh_get(mesh M, 'faces from pid', ivec PIDs)
CVFIDs = gf_mesh_get(mesh M, 'outer faces'[, dim][, CVIDs])
CVFIDs = gf_mesh_get(mesh M, 'inner faces'[, CVIDs])
CVFIDs = gf_mesh_get(mesh M, 'all faces'[, CVIDs])
CVFIDs = gf_mesh_get(mesh M, 'outer faces with direction', vec v, scalar
˓→angle[, dim][, CVIDs])
CVFIDs = gf_mesh_get(mesh M, 'outer faces in box', vec pmin, vec pmax[,
˓→dim][, CVIDs])
CVFIDs = gf_mesh_get(mesh M, 'outer faces in ball', vec center, scalar
˓→radius[, dim][, CVIDs])
(continues on next page)
7.21. gf_mesh_get 59
Matlab Interface, Release 5.3
Description :
General mesh inquiry function. All these functions accept also a mesh_fem argument in-
stead of a mesh M (in that case, the mesh_fem linked mesh will be used). Note that when
your mesh is recognized as a Matlab object , you can simply use “get(M, ‘dim’)” instead of
“gf_mesh_get(M, ‘dim’)”.
Command list :
d = gf_mesh_get(mesh M, 'dim')
Get the dimension of the mesh (2 for a 2D mesh, etc).
np = gf_mesh_get(mesh M, 'nbpts')
Get the number of points of the mesh.
nc = gf_mesh_get(mesh M, 'nbcvs')
Get the number of convexes of the mesh.
P = gf_mesh_get(mesh M, 'pts'[, ivec PIDs])
Return the list of point coordinates of the mesh.
Each column of the returned matrix contains the coordinates of one point.
If the optional argument PIDs was given, only the points whose #id is
listed in this vector are returned. Otherwise, the returned matrix will have
gf_mesh_get(mesh M, ‘max_pid’) columns, which might be greater than
gf_mesh_get(mesh M, ‘nbpts’) (if some points of the mesh have been destroyed
and no call to gf_mesh_set(mesh M, ‘optimize structure’) have been issued).
The columns corresponding to deleted points will be filled with NaN. You can
use gf_mesh_get(mesh M, ‘pid’) to filter such invalid points.
Pid = gf_mesh_get(mesh M, 'pid')
Return the list of points #id of the mesh.
Note that their numbering is not supposed to be contiguous from 1 to
gf_mesh_get(mesh M, ‘nbpts’), especially if some points have been removed
from the mesh. You can use gf_mesh_set(mesh M, ‘optimize_structure’) to en-
force a contiguous numbering. Pid is a row vector.
PIDs = gf_mesh_get(mesh M, 'pid in faces', imat CVFIDs)
Return point #id listed in CVFIDs.
CVFIDs is a two-rows matrix, the first row lists convex #ids, and the second lists
face numbers. On return, PIDs is a row vector containing points #id.
PIDs = gf_mesh_get(mesh M, 'pid in cvids', imat CVIDs)
Return point #id listed in CVIDs.
PIDs is a row vector containing points #id.
PIDs = gf_mesh_get(mesh M, 'pid in regions', imat RIDs)
Return point #id listed in RIDs.
PIDs is a row vector containing points #id.
PIDs = gf_mesh_get(mesh M, 'pid from coords', mat PTS[,
scalar radius=0])
Return point #id whose coordinates are listed in PTS.
PTS is an array containing a list of point coordinates. On return, PIDs is a row
vector containing points #id for each point found in eps range, and -1 for those
which where not found in the mesh.
{Pid, IDx} = gf_mesh_get(mesh M, 'pid from cvid'[, imat
CVIDs])
Return the points attached to each convex of the mesh.
If CVIDs is omitted, all the convexes will be considered (equivalent to CVIDs
= gf_mesh_get(mesh M, ‘max cvid’)). IDx is a row vector, length(IDx) =
length(CVIDs)+1. Pid is a row vector containing the concatenated list of #id
of points of each convex in CVIDs. Each entry of IDx is the position of the cor-
responding convex point list in Pid. Hence, for example, the list of #id of points
of the second convex is Pid(IDx(2):IDx(3)-1).
If CVIDs contains convex #id which do not exist in the mesh, their point list will
be empty.
{Pts, IDx} = gf_mesh_get(mesh M, 'pts from cvid'[, imat
CVIDs])
Search point listed in CVID.
Return Pts and IDx. If CVIDs is omitted, all the convexes will be considered
(equivalent to CVIDs = gf_mesh_get(mesh M, ‘max cvid’)). IDx is a row vector,
7.21. gf_mesh_get 61
Matlab Interface, Release 5.3
7.21. gf_mesh_get 63
Matlab Interface, Release 5.3
The output CVFIDs is a two-rows matrix, the first row lists convex #ids, and the
second one lists face numbers (local number in the convex). The argument dim
works as in outer_faces(). If CVIDs is given, it returns portion of the boundary
of the convex set defined by the #ids listed in CVIDs.
CVFIDs = gf_mesh_get(mesh M, 'adjacent face', int cvid, int
fid)
Return convex face of the neighbor element if it exists. If the convex have more
than one neighbor relatively to the face f (think to bar elements in 3D for in-
stance), return the first face found.
CVFIDs = gf_mesh_get(mesh M, 'faces from cvid'[, ivec
CVIDs][, 'merge'])
Return a list of convex faces from a list of convex #id.
CVFIDs is a two-rows matrix, the first row lists convex #ids, and the second
lists face numbers (local number in the convex). If CVIDs is not given, all con-
vexes are considered. The optional argument ‘merge’ merges faces shared by the
convex of CVIDs.
[mat T] = gf_mesh_get(mesh M, 'triangulated surface', int
Nrefine [,CVLIST])
[DEPRECATED FUNCTION! will be removed in a future release]
Similar function to gf_mesh_get(mesh M, ‘curved edges’) : split (if necessary,
i.e. if the geometric transformation if non-linear) each face into sub-triangles
and return their coordinates in T (see also gf_compute(‘eval on P1 tri mesh’))
N = gf_mesh_get(mesh M, 'normal of face', int cv, int f[,
int nfpt])
Return the normal vector of convex cv, face f at the nfpt point of the face.
If nfpt is not specified, then the normal is evaluated at each geometrical node of
the face.
N = gf_mesh_get(mesh M, 'normal of faces', imat CVFIDs)
Return matrix of (at face centers) the normal vectors of convexes.
CVFIDs is supposed a two-rows matrix, the first row lists convex #ids, and the
second lists face numbers (local number in the convex).
CVIDs = gf_mesh_get(mesh M, 'convexes in box', vec pmin, vec
pmax)
Return the set of convexes lying entirely within the box defined by the corner
points pmin and pmax.
The output CVIDs is a two-rows matrix, the first row lists convex #ids, and the
second one lists face numbers (local number in the convex). If CVIDs is given,
it returns portion of the boundary of the convex set defined by the #ids listed in
CVIDs.
Q = gf_mesh_get(mesh M, 'quality'[, ivec CVIDs])
Return an estimation of the quality of each convex (0 ≤ 𝑄 ≤ 1).
7.21. gf_mesh_get 65
Matlab Interface, Release 5.3
7.22 gf_mesh_set
Synopsis
Description :
General function for modification of a mesh object.
Command list :
PIDs = gf_mesh_set(mesh M, 'pts', mat PTS)
Replace the coordinates of the mesh points with those given in PTS.
7.22. gf_mesh_set 67
Matlab Interface, Release 5.3
Assigns the region number rnum to the set of convexes or/and convex faces pro-
vided in the matrix CVFIDs.
The first row of CVFIDs contains convex #ids, and the second row contains a
face number in the convex (or 0 for the whole convex (regions are usually used to
store a list of convex faces, but you may also use them to store a list of convexes).
If a vector is provided (or a one row matrix) the region will represent the corre-
sponding set of convex.
gf_mesh_set(mesh M, 'extend region', int rnum, mat CVFIDs)
Extends the region identified by the region number rnum to include the set
of convexes or/and convex faces provided in the matrix CVFIDs, see also
gf_mesh_set(mesh M, 'set region).
gf_mesh_set(mesh M, 'region intersect', int r1, int r2)
Replace the region number r1 with its intersection with region number r2.
gf_mesh_set(mesh M, 'region merge', int r1, int r2)
Merge region number r2 into region number r1.
gf_mesh_set(mesh M, 'region subtract', int r1, int r2)
Replace the region number r1 with its difference with region number r2.
gf_mesh_set(mesh M, 'delete boundary', int rnum, mat CVFIDs)
DEPRECATED FUNCTION. Use ‘delete region’ instead.
gf_mesh_set(mesh M, 'delete region', ivec RIDs)
Remove the regions whose #ids are listed in RIDs
gf_mesh_set(mesh M, 'merge', mesh m2[, scalar tol])
Merge with the mesh m2.
Overlapping points, within a tolerance radius tol, will not be duplicated. If m2 is
a mesh_fem object, its linked mesh will be used.
gf_mesh_set(mesh M, 'optimize structure'[, int
with_renumbering])
Reset point and convex numbering.
After optimisation, the points (resp. convexes) will be consecutively numbered
from 1 to gf_mesh_get(mesh M, ‘max pid’) (resp. gf_mesh_get(mesh M, ‘max
cvid’)).
gf_mesh_set(mesh M, 'refine'[, ivec CVIDs])
Use a Bank strategy for mesh refinement.
If CVIDs is not given, the whole mesh is refined. Note that the regions, and the
finite element methods and integration methods of the mesh_fem and mesh_im
objects linked to this mesh will be automagically refined.
7.23 gf_mesh_fem
Synopsis
Description :
General constructor for mesh_fem objects.
This object represents a finite element method defined on a whole mesh.
Command list :
MF = gf_mesh_fem(mesh m[, int Qdim1=1[, int Qdim2=1, ...]])
Build a new mesh_fem object.
The Qdim parameters specifies the dimension of the field represented by the
finite element method. Qdim1 = 1 for a scalar field, Qdim1 = n for a vector field
off size n, Qdim1=m, Qdim2=n for a matrix field of size mxn . . . Returns the
handle of the created object.
MF = gf_mesh_fem('load', string fname[, mesh m])
Load a mesh_fem from a file.
If the mesh m is not supplied (this kind of file does not store the mesh), then
it is read from the file fname and its descriptor is returned as the second output
argument.
MF = gf_mesh_fem('from string', string s[, mesh m])
Create a mesh_fem object from its string description.
See also gf_mesh_fem_get(mesh_fem MF, 'char')
MF = gf_mesh_fem('clone', mesh_fem mf)
Create a copy of a mesh_fem.
MF = gf_mesh_fem('sum', mesh_fem mf1, mesh_fem mf2[,
mesh_fem mf3[, ...]])
Create a mesh_fem that spans two (or more) mesh_fem’s.
All mesh_fem must share the same mesh.
After that, you should not modify the FEM of mf1, mf2 etc.
MF = gf_mesh_fem('product', mesh_fem mf1, mesh_fem mf2)
7.23. gf_mesh_fem 69
Matlab Interface, Release 5.3
Create a mesh_fem that spans all the product of a selection of shape functions of
mf1 by all shape functions of mf2. Designed for Xfem enrichment.
mf1 and mf2 must share the same mesh.
After that, you should not modify the FEM of mf1, mf2.
MF = gf_mesh_fem('levelset', mesh_levelset mls, mesh_fem mf)
Create a mesh_fem that is conformal to implicit surfaces defined in
mesh_levelset.
MF = gf_mesh_fem('global function', mesh m, levelset ls,
{global_function GF1,...}[, int Qdim_m])
Create a mesh_fem whose base functions are global function given by the user in
the system of coordinate defined by the iso-values of the two level-set function
of ls.
MF = gf_mesh_fem('partial', mesh_fem mf, ivec DOFs[, ivec
RCVs])
Build a restricted mesh_fem by keeping only a subset of the degrees of freedom
of mf.
If RCVs is given, no FEM will be put on the convexes listed in RCVs.
7.24 gf_mesh_fem_get
Synopsis
Description :
General function for inquiry about mesh_fem objects.
Command list :
n = gf_mesh_fem_get(mesh_fem MF, 'nbdof')
Return the number of degrees of freedom (dof) of the mesh_fem.
n = gf_mesh_fem_get(mesh_fem MF, 'nb basic dof')
Return the number of basic degrees of freedom (dof) of the mesh_fem.
DOF = gf_mesh_fem_get(mesh_fem MF, 'dof from cv',mat CVids)
Deprecated function. Use gf_mesh_fem_get(mesh_fem MF, ‘basic dof from cv’)
instead.
DOF = gf_mesh_fem_get(mesh_fem MF, 'basic dof from cv',mat
CVids)
Return the dof of the convexes listed in CVids.
WARNING: the Degree of Freedom might be returned in ANY order, do not use
this function in your assembly routines. Use ‘basic dof from cvid’ instead, if you
want to be able to map a convex number with its associated degrees of freedom.
One can also get the list of basic dof on a set on convex faces, by indicating on
the second row of CVids the faces numbers (with respect to the convex number
on the first row).
{DOFs, IDx} = gf_mesh_fem_get(mesh_fem MF, 'dof from cvid'[,
mat CVids])
Deprecated function. Use gf_mesh_fem_get(mesh_fem MF, ‘basic dof from
cvid’) instead.
{DOFs, IDx} = gf_mesh_fem_get(mesh_fem MF, 'basic dof from
cvid'[, mat CVids])
7.24. gf_mesh_fem_get 71
Matlab Interface, Release 5.3
cvid=gf_mesh_get(mf,'cvid');
[f,c2f]=gf_mesh_fem_get(mf, 'fem');
for i=1:size(f), sf{i}=gf_fem_get('char',f(i)); end;
for i=1:size(c2f),
disp(sprintf('the fem of convex %d is %s',...
cvid(i),sf{i}));
end;
7.24. gf_mesh_fem_get 73
Matlab Interface, Release 5.3
Return the list of dof (after the optional reduction) lying on one of the mesh
regions listed in Rs.
More precisely, this function returns the basic dof whose support is non-null on
one of regions whose #ids are listed in Rs (note that for boundary regions, some
dof nodes may not lie exactly on the boundary, for example the dof of Pk(n,0)
lies on the center of the convex, but the base function in not null on the convex
border).
For a reduced mesh_fem a dof is lying on a region if its potential corresponding
shape function is nonzero on this region. The extension matrix is used to make
the correspondence between basic and reduced dofs.
DOFpts = gf_mesh_fem_get(mesh_fem MF, 'dof nodes'[, mat
DOFids])
Deprecated function. Use gf_mesh_fem_get(mesh_fem MF, ‘basic dof nodes’)
instead.
DOFpts = gf_mesh_fem_get(mesh_fem MF, 'basic dof nodes'[,
mat DOFids])
Get location of basic degrees of freedom.
Return the list of interpolation points for the specified dof #IDs in DOFids (if
DOFids is omitted, all basic dof are considered).
DOFP = gf_mesh_fem_get(mesh_fem MF, 'dof partition')
Get the ‘dof_partition’ array.
Return the array which associates an integer (the partition number) to each con-
vex of the mesh_fem. By default, it is an all-zero array. The degrees of freedom
of each convex of the mesh_fem are connected only to the dof of neighboring
convexes which have the same partition number, hence it is possible to create
partially discontinuous mesh_fem very easily.
gf_mesh_fem_get(mesh_fem MF, 'save',string filename[, string
opt])
Save a mesh_fem in a text file (and optionally its linked mesh object if opt is the
string ‘with_mesh’).
gf_mesh_fem_get(mesh_fem MF, 'char'[, string opt])
Output a string description of the mesh_fem.
By default, it does not include the description of the linked mesh object, except
if opt is ‘with_mesh’.
gf_mesh_fem_get(mesh_fem MF, 'display')
displays a short summary for a mesh_fem object.
m = gf_mesh_fem_get(mesh_fem MF, 'linked mesh')
Return a reference to the mesh object linked to mf.
m = gf_mesh_fem_get(mesh_fem MF, 'mesh')
Return a reference to the mesh object linked to mf. (identical to
gf_mesh_get(mesh M, ‘linked mesh’))
7.24. gf_mesh_fem_get 75
Matlab Interface, Release 5.3
Return the amount of memory (in bytes) used by the mesh_fem object.
The result does not take into account the linked mesh object.
gf_mesh_fem_get(mesh_fem MF, 'has_linked_mesh_levelset')
Is a mesh_fem_level_set or not.
gf_mesh_fem_get(mesh_fem MF, 'linked_mesh_levelset')
if it is a mesh_fem_level_set gives the linked mesh_level_set.
U = gf_mesh_fem_get(mesh_fem MF, 'eval', expr [, DOFLST])
Call gf_mesh_fem_get_eval. This function interpolates an expression on a la-
grangian mesh_fem (for all dof except if DOFLST is specified). The expression
can be a numeric constant, or a cell array containing numeric constants, string
expressions or function handles. For example:
U1=gf_mesh_fem_get(mf,'eval',1)
U2=gf_mesh_fem_get(mf,'eval',[1;0]) % output has two rows
U3=gf_mesh_fem_get(mf,'eval',[1 0]) % output has one row,
˓→only valid if qdim(mf)==2
U4=gf_mesh_fem_get(mf,'eval',{'x';'y.*z';4;
˓→@myfunctionofxyz})
7.25 gf_mesh_fem_set
Synopsis
Description :
General function for modifying mesh_fem objects.
Command list :
gf_mesh_fem_set(mesh_fem MF, 'fem', fem f[, ivec CVids])
Set the Finite Element Method.
Assign an FEM f to all convexes whose #ids are listed in CVids. If CVids is not
given, the integration is assigned to all convexes.
See the help of gf_fem to obtain a list of available FEM methods.
7.25. gf_mesh_fem_set 77
Matlab Interface, Release 5.3
7.26 gf_mesh_im
Synopsis
Description :
General constructor for mesh_im objects.
This object represents an integration method defined on a whole mesh (an potentially on its
boundaries).
Command list :
MIM = gf_mesh_im('load', string fname[, mesh m])
Load a mesh_im from a file.
If the mesh m is not supplied (this kind of file does not store the mesh), then it is
read from the file and its descriptor is returned as the second output argument.
MIM = gf_mesh_im('from string', string s[, mesh m])
Create a mesh_im object from its string description.
See also gf_mesh_im_get(mesh_im MI, 'char')
MIM = gf_mesh_im('clone', mesh_im mim)
Create a copy of a mesh_im.
MIM = gf_mesh_im('levelset', mesh_levelset mls, string
where, integ im[, integ im_tip[, integ im_set]])
Build an integration method conformal to a partition defined implicitly by a lev-
elset.
The where argument define the domain of integration with respect to the levelset,
it has to be chosen among ‘ALL’, ‘INSIDE’, ‘OUTSIDE’ and ‘BOUNDARY’.
it can be completed by a string defining the boolean operation to define the inte-
gration domain when there is more than one levelset.
the syntax is very simple, for example if there are 3 different levelset,
7.27 gf_mesh_im_get
Synopsis
Description :
General function extracting information from mesh_im objects.
Command list :
{I, CV2I} = gf_mesh_im_get(mesh_im MI, 'integ'[, mat CVids])
Return a list of integration methods used by the mesh_im.
I is an array of all integ objects found in the convexes given in CVids. If CV2I
was supplied as an output argument, it contains, for each convex listed in CVids,
the index of its correspounding integration method in I.
Convexes which are not part of the mesh, or convexes which do not have any
integration method have their correspounding entry in CV2I set to -1.
7.27. gf_mesh_im_get 79
Matlab Interface, Release 5.3
Example:
cvid=gf_mesh_get(mim,'cvid');
[f,c2f]=gf_mesh_im_get(mim, 'integ');
for i=1:size(f), sf{i}=gf_integ_get('char',f(i)); end;
for i=1:size(c2f),
disp(sprintf('the integration of convex %d is %s',...
cvid(i),sf{i}));
end;
Return the amount of memory (in bytes) used by the mesh_im object.
The result does not take into account the linked mesh object.
7.28 gf_mesh_im_set
Synopsis
Description :
General function for modifying mesh_im objects
Command list :
gf_mesh_im_set(mesh_im MI, 'integ',{integ im|int
im_degree}[, ivec CVids])
Set the integration method.
Assign an integration method to all convexes whose #ids are listed in CVids.
If CVids is not given, the integration is assigned to all convexes. It is possible
to assign a specific integration method with an integration method handle im
obtained via gf_integ(‘IM_SOMETHING’), or to let getfem choose a suitable
integration method with im_degree (choosen such that polynomials of degree ≤
im_degree are exactly integrated. If im_degree=-1, then the dummy integration
method IM_NONE will be used.)
gf_mesh_im_set(mesh_im MI, 'adapt')
For a mesh_im levelset object only. Adapt the integration methods to a change
of the levelset function.
7.29 gf_mesh_im_data
Synopsis
Description :
General constructor for mesh_im_data objects.
This object represents data defined on a mesh_im object.
Command list :
MIMD = gf_mesh_im_data(mesh_im mim, int region, ivec size)
Build a new mesh_imd object linked to a mesh_im object. If region is provided,
considered integration points are filtered in this region. size is a vector of integers
that specifies the dimensions of the stored data per integration point. If not given,
the scalar stored data are considered.
7.28. gf_mesh_im_set 81
Matlab Interface, Release 5.3
7.30 gf_mesh_im_data_get
Synopsis
Description :
General function extracting information from mesh_im_data objects.
Command list :
gf_mesh_im_data_get(mesh_im_data MID, 'region')
Output the region that the mesh_imd is restricted to.
gf_mesh_im_data_get(mesh_im_data MID, 'nbpts')
Output the number of integration points (filtered in the considered region).
gf_mesh_im_data_get(mesh_im_data MID, 'nb tensor elements')
Output the size of the stored data (per integration point).
gf_mesh_im_data_get(mesh_im_data MID, 'tensor size')
Output the dimensions of the stored data (per integration point).
gf_mesh_im_data_get(mesh_im_data MID, 'display')
displays a short summary for a mesh_imd object.
m = gf_mesh_im_data_get(mesh_im_data MID, 'linked mesh')
Returns a reference to the mesh object linked to mim.
7.31 gf_mesh_im_data_set
Synopsis
Description :
General function for modifying mesh_im objects
Command list :
gf_mesh_im_data_set(mesh_im_data MID, 'region', int rnum)
Set the considered region to rnum.
gf_mesh_im_data_set(mesh_im_data MID, 'tensor size',)
Set the size of the data per integration point.
7.32 gf_mesh_levelset
Synopsis
MLS = gf_mesh_levelset(mesh m)
Description :
General constructor for mesh_levelset objects.
General constructor for mesh_levelset objects. The role of this object is to provide a mesh
cut by a certain number of level_set. This object is used to build conformal integration
method (object mim and enriched finite element methods (Xfem)).
Command list :
MLS = gf_mesh_levelset(mesh m)
Build a new mesh_levelset object from a mesh and returns its handle.
7.33 gf_mesh_levelset_get
Synopsis
Description :
General function for querying information about mesh_levelset objects.
Command list :
M = gf_mesh_levelset_get(mesh_levelset MLS, 'cut_mesh')
Return a mesh cut by the linked levelset’s.
LM = gf_mesh_levelset_get(mesh_levelset MLS, 'linked_mesh')
Return a reference to the linked mesh.
nbls = gf_mesh_levelset_get(mesh_levelset MLS, 'nb_ls')
Return the number of linked levelset’s.
LS = gf_mesh_levelset_get(mesh_levelset MLS, 'levelsets')
Return a list of references to the linked levelset’s.
CVIDs = gf_mesh_levelset_get(mesh_levelset MLS,
'crack_tip_convexes')
Return the list of convex #id’s of the linked mesh on which have a tip of any
linked levelset’s.
7.32. gf_mesh_levelset 83
Matlab Interface, Release 5.3
7.34 gf_mesh_levelset_set
Synopsis
Description :
General function for modification of mesh_levelset objects.
Command list :
gf_mesh_levelset_set(mesh_levelset MLS, 'add', levelset ls)
Add a link to the levelset ls.
Only a reference is kept, no copy is done. In order to indicate that the linked
mesh is cut by a levelset one has to call this method, where ls is an levelset
object. An arbitrary number of levelset can be added.
WARNING
The mesh of ls and the linked mesh must be the same.
gf_mesh_levelset_set(mesh_levelset MLS, 'sup', levelset ls)
Remove a link to the levelset ls.
gf_mesh_levelset_set(mesh_levelset MLS, 'adapt')
Do all the work (cut the convexes with the levelsets).
To initialice the mesh_levelset object or to actualize it when the value of any
levelset function is modified, one has to call this method.
7.35 gf_mesher_object
Synopsis
Description :
General constructor for mesher_object objects.
This object represents a geometric object to be meshed by the experimental meshing proce-
dure of Getfem.
Command list :
MF = gf_mesher_object('ball', vec center, scalar radius)
Represents a ball of corresponding center and radius.
MF = gf_mesher_object('half space', vec origin, vec
normal_vector)
Represents an half space delimited by the plane which contains the origin and
normal to normal_vector. The selected part is the part in the direction of the
normal vector. This allows to cut a geometry with a plane for instance to build a
polygon or a polyhedron.
MF = gf_mesher_object('cylinder', vec origin, vec n, scalar
length, scalar radius)
Represents a cylinder (in any dimension) of a certain radius whose axis is deter-
mined by the origin, a vector n and a certain length.
MF = gf_mesher_object('cone', vec origin, vec n, scalar
length, scalar half_angle)
Represents a cone (in any dimension) of a certain half-angle (in radians) whose
axis is determined by the origin, a vector n and a certain length.
MF = gf_mesher_object('torus', scalar R, scalar r)
Represents a torus in 3d of axis along the z axis with a great radius equal to R
and small radius equal to r. For the moment, the possibility to change the axis is
not given.
MF = gf_mesher_object('rectangle', vec rmin, vec rmax)
Represents a rectangle (or parallelepiped in 3D) parallel to the axes.
MF = gf_mesher_object('intersect', mesher_object object1 ,
mesher_object object2, ...)
7.35. gf_mesher_object 85
Matlab Interface, Release 5.3
7.36 gf_mesher_object_get
Synopsis
Description :
General function for querying information about mesher_object objects.
Command list :
s = gf_mesher_object_get(mesher_object MO, 'char')
Output a (unique) string representation of the mesher_object.
This can be used to perform comparisons between two different mesher_object
objects. This function is to be completed.
gf_mesher_object_get(mesher_object MO, 'display')
displays a short summary for a mesher_object object.
7.37 gf_model
Synopsis
MD = gf_model('real')
MD = gf_model('complex')
Description :
General constructor for model objects.
model variables store the variables and the state data and the description of a model. This
includes the global tangent matrix, the right hand side and the constraints. There are two
kinds of models, the real and the complex models.
Command list :
MD = gf_model('real')
Build a model for real unknowns.
MD = gf_model('complex')
7.38 gf_model_get
Synopsis
b = gf_model_get(model M, 'is_complex')
T = gf_model_get(model M, 'nbdof')
dt = gf_model_get(model M, 'get time step')
t = gf_model_get(model M, 'get time')
T = gf_model_get(model M, 'tangent_matrix')
gf_model_get(model M, 'rhs')
gf_model_get(model M, 'brick term rhs', int ind_brick[, int ind_term, int
˓→sym, int ind_iter])
z = gf_model_get(model M, 'memsize')
gf_model_get(model M, 'variable list')
gf_model_get(model M, 'brick list')
gf_model_get(model M, 'list residuals')
V = gf_model_get(model M, 'variable', string name)
V = gf_model_get(model M, 'interpolation', string expr, {mesh_fem mf |
˓→mesh_imd mimd | vec pts, mesh m}[, int region[, int extrapolation[, int
˓→rg_source]]])
˓→region])
V = gf_model_get(model M, 'compute second Piola Kirchhoff tensor', string
˓→varname, string lawname, string dataname, mesh_fem mf_sigma)
gf_model_get(model M, 'elastoplasticity next iter', mesh_im mim, string
˓→varname, string previous_dep_name, string projname, string datalambda,
˓→string datamu, string datathreshold, string datasigma)
7.38. gf_model_get 87
Matlab Interface, Release 5.3
Description :
Get information from a model object.
Command list :
b = gf_model_get(model M, 'is_complex')
Return 0 is the model is real, 1 if it is complex.
T = gf_model_get(model M, 'nbdof')
Return the total number of degrees of freedom of the model.
dt = gf_model_get(model M, 'get time step')
Gives the value of the time step.
t = gf_model_get(model M, 'get time')
Give the value of the data t corresponding to the current time.
T = gf_model_get(model M, 'tangent_matrix')
Return the tangent matrix stored in the model .
gf_model_get(model M, 'rhs')
Return the right hand side of the tangent problem.
7.38. gf_model_get 89
Matlab Interface, Release 5.3
Gives the name of the multiplier variable for a Dirichlet brick. If the brick is
not a Dirichlet condition with multiplier brick, this function has an undefined
behavior
I = gf_model_get(model M, 'interval of variable', string
varname)
Gives the interval of the variable varname in the linear system of the model.
V = gf_model_get(model M, 'from variables')
Return the vector of all the degrees of freedom of the model consisting of the
concatenation of the variables of the model (useful to solve your problem with
you own solver).
gf_model_get(model M, 'assembly'[, string option])
Assembly of the tangent system taking into account the terms from all bricks.
option, if specified, should be ‘build_all’, ‘build_rhs’, ‘build_matrix’. The de-
fault is to build the whole tangent linear system (matrix and rhs). This function
is useful to solve your problem with you own solver.
{nbit, converged} = gf_model_get(model M, 'solve'[, ...])
Run the standard getfem solver.
Note that you should be able to use your own solver if you want (it is possible to
obtain the tangent matrix and its right hand side with the gf_model_get(model
M, ‘tangent matrix’) etc.).
Various options can be specified:
• ‘noisy’ or ‘very_noisy’ the solver will display some information showing
the progress (residual values etc.).
• ‘max_iter’, int NIT set the maximum iterations numbers.
• ‘max_res’, @float RES set the target residual value.
• ‘diverged_res’, @float RES set the threshold value of the residual beyond
which the iterative method is considered to diverge (default is 1e200).
• ‘lsolver’, string SOLVER_NAME select explicitely the solver used for
the linear systems (the default value is ‘auto’, which lets getfem choose
itself). Possible values are ‘superlu’, ‘mumps’ (if supported), ‘cg/ildlt’,
‘gmres/ilu’ and ‘gmres/ilut’.
• ‘lsearch’, string LINE_SEARCH_NAME select explicitely the line
search method used for the linear systems (the default value is ‘de-
fault’). Possible values are ‘simplest’, ‘systematic’, ‘quadratic’ or
‘basic’.
Return the number of iterations, if an iterative method is used.
Note that it is possible to disable some variables (see gf_model_set(model
M, ‘disable variable’) ) in order to solve the problem only with respect to a
subset of variables (the disabled variables are then considered as data) for
instance to replace the global Newton strategy with a fixed point one.
gf_model_get(model M, 'test tangent matrix'[, scalar EPS[,
int NB[, scalar scale]]])
Test the consistency of the tangent matrix in some random positions and random
directions (useful to test newly created bricks). EPS is the value of the small
parameter for the finite difference computation of the derivative is the random
direction (default is 1E-6). NN is the number of tests (default is 100). scale is a
parameter for the random position (default is 1, 0 is an acceptable value) around
the current position. Each dof of the random position is chosen in the range
[current-scale, current+scale].
gf_model_get(model M, 'test tangent matrix term', string
varname1, string varname2[, scalar EPS[, int NB[, scalar
scale]]])
Test the consistency of a part of the tangent matrix in some random positions and
random directions (useful to test newly created bricks). The increment is only
made on variable varname2 and tested on the part of the residual correspond-
ing to varname1. This means that only the term (varname1, varname2) of the
tangent matrix is tested. EPS is the value of the small parameter for the finite dif-
ference computation of the derivative is the random direction (default is 1E-6).
NN is the number of tests (default is 100). scale is a parameter for the random
position (default is 1, 0 is an acceptable value) around the current position. Each
dof of the random position is chosen in the range [current-scale, current+scale].
expr = gf_model_get(model M, 'Neumann term', string varname,
int region)
Gives the assembly string corresponding to the Neumann term of the fem vari-
able varname on region. It is deduced from the assembly string declared by
the model bricks. region should be the index of a boundary region on the mesh
where varname is defined. Care to call this function only after all the volumic
bricks have been declared. Complains, if a brick omit to declare an assembly
string.
V = gf_model_get(model M, 'compute isotropic linearized Von
Mises or Tresca', string varname, string dataname_lambda,
string dataname_mu, mesh_fem mf_vm[, string version])
Compute the Von-Mises stress or the Tresca stress of a field (only valid for
isotropic linearized elasticity in 3D). version should be ‘Von_Mises’ or ‘Tresca’
(‘Von_Mises’ is the default). Parametrized by Lame coefficients.
V = gf_model_get(model M, 'compute isotropic linearized
Von Mises pstrain', string varname, string data_E, string
data_nu, mesh_fem mf_vm)
Compute the Von-Mises stress of a displacement field for isotropic linearized
elasticity in 3D or in 2D with plane strain assumption. Parametrized by Young
modulus and Poisson ratio.
V = gf_model_get(model M, 'compute isotropic linearized
Von Mises pstress', string varname, string data_E, string
data_nu, mesh_fem mf_vm)
Compute the Von-Mises stress of a displacement field for isotropic linearized
elasticity in 3D or in 2D with plane stress assumption. Parametrized by Young
modulus and Poisson ratio.
7.38. gf_model_get 91
Matlab Interface, Release 5.3
computed displacement to the data that stores the displacement of the previous
time step (typically ‘u’ to ‘Previous_u’). It has to be called before any use of
compute_small_strain_elastoplasticity_Von_Mises.
V = gf_model_get(model M, 'small strain elastoplasticity Von
Mises', mesh_im mim, mesh_fem mf_vm, string lawname, string
unknowns_type [, string varnames, ...] [, string params, ..
.] [, string theta = '1' [, string dt = 'timestep']] [, int
region])
This function computes the Von Mises stress field with respect to a
small strain elastoplasticity term, approximated on mf_vm, and stores
the result into VM. All other parameters have to be exactly the
same as for add_small_strain_elastoplasticity_brick. Remember that
small_strain_elastoplasticity_next_iter has to be called before any call of this
function.
V = gf_model_get(model M, 'compute elastoplasticity Von
Mises or Tresca', string datasigma, mesh_fem mf_vm[, string
version])
Compute on mf_vm the Von-Mises or the Tresca stress of a field for plasticity
and return it into the vector V. datasigma is a vector which contains the stress
constraints values supported by the mesh. version should be ‘Von_Mises’ or
‘Tresca’ (‘Von_Mises’ is the default).
V = gf_model_get(model M, 'compute plastic part',
mesh_im mim, mesh_fem mf_pl, string varname, string
previous_dep_name, string projname, string datalambda,
string datamu, string datathreshold, string datasigma)
Compute on mf_pl the plastic part and return it into the vector V. datasigma is a
vector which contains the stress constraints values supported by the mesh.
gf_model_get(model M, 'finite strain elastoplasticity next
iter', mesh_im mim, string lawname, string unknowns_type, [,
string varnames, ...] [, string params, ...] [, int region =
-1])
Function that allows to pass from a time step to another for the finite strain
plastic brick. The parameters have to be exactly the same than the one of
add_finite_strain_elastoplasticity_brick, so see the documentation of this func-
tion for the explanations. Basically, this brick computes the plastic strain and
the plastic multiplier and stores them for the next step. For the Simo-Miehe law
which is currently the only one implemented, this function updates the state vari-
ables defined in the last two entries of varnames, and resets the plastic multiplier
field given as the second entry of varnames.
V = gf_model_get(model M, 'compute finite strain
elastoplasticity Von Mises', mesh_im mim, mesh_fem mf_vm,
string lawname, string unknowns_type, [, string varnames,
...] [, string params, ...] [, int region = -1])
Compute on mf_vm the Von-Mises or the Tresca stress of a field for plasticity
and return it into the vector V. The first input parameters ar as in the function
‘finite strain elastoplasticity next iter’.
7.38. gf_model_get 93
Matlab Interface, Release 5.3
7.39 gf_model_set
Synopsis
gf_model_set(model M, 'clear')
gf_model_set(model M, 'add fem variable', string name, mesh_fem mf)
gf_model_set(model M, 'add filtered fem variable', string name, mesh_fem
˓→mf, int region) (continues on next page)
7.39. gf_model_set 95
Matlab Interface, Release 5.3
˓→region])
ind = gf_model_set(model M, 'add finite strain elastoplasticity brick',
˓→mesh_im mim , string lawname, string unknowns_type [, string varnames, ..
˓→.] [, string params, ...] [, int region = -1])
ind = gf_model_set(model M, 'add nonlinear incompressibility brick', mesh_
˓→im mim, string varname, string multname_pressure[, int region])
(continues on next page)
7.39. gf_model_set 97
Matlab Interface, Release 5.3
˓→region)
ind = gf_model_set(model M, 'add normal derivative Dirichlet condition
˓→with multipliers', mesh_im mim, string varname, mult_description, int
˓→region [, string dataname, int R_must_be_derivated])
ind = gf_model_set(model M, 'add normal derivative Dirichlet condition
˓→with penalization', mesh_im mim, string varname, scalar coeff, int
˓→ int rg1, int rg2[, int slave1, int slave2, int augmented_version])
ind = gf_model_set(model M, 'add integral contact between nonmatching
˓→meshes brick', mesh_im mim, string varname_u1, string varname_u2,
˓→string multname, string dataname_r [, string dataname_friction_coeff],
˓→int region1, int region2 [, int option [, string dataname_alpha [,
˓→string dataname_wt1 , string dataname_wt2]]])
7.39. gf_model_set 99
Matlab Interface, Release 5.3
Description :
Modifies a model object.
Command list :
gf_model_set(model M, 'clear')
Clear the model.
gf_model_set(model M, 'add fem variable', string name,
mesh_fem mf)
Add a variable to the model linked to a mesh_fem. name is the variable name.
gf_model_set(model M, 'add filtered fem variable', string
name, mesh_fem mf, int region)
Add a variable to the model linked to a mesh_fem. The variable is filtered in the
sense that only the dof on the region are considered. name is the variable name.
gf_model_set(model M, 'add variable', string name, sizes)
Add a variable to the model of constant sizes. sizes is either a integer (for a scalar
or vector variable) or a vector of dimensions for a tensor variable. name is the
variable name.
gf_model_set(model M, 'delete variable', string name)
Delete a variable or a data from the model.
gf_model_set(model M, 'resize variable', string name, sizes)
Resize a constant size variable of the model. sizes is either a integer (for a scalar
or vector variable) or a vector of dimensions for a tensor variable. name is the
variable name.
gf_model_set(model M, 'add multiplier', string name,
mesh_fem mf, string primalname[, mesh_im mim, int region])
Add a particular variable linked to a fem being a multiplier with respect to a pri-
mal variable. The dof will be filtered with the gmm::range_basis function
applied on the terms of the model which link the multiplier and the primal vari-
able. This in order to retain only linearly independent constraints on the primal
variable. Optimized for boundary multipliers.
gf_model_set(model M, 'add im data', string name, mesh_imd
mimd)
Add a data set to the model linked to a mesh_imd. name is the data name.
gf_model_set(model M, 'add fem data', string name, mesh_fem
mf[, sizes])
Add a data to the model linked to a mesh_fem. name is the data name, sizes
an optional parameter which is either an integer or a vector of suplementary
dimensions with respect to mf.
gf_model_set(model M, 'add initialized fem data', string
name, mesh_fem mf, vec V[, sizes])
Add a data to the model linked to a mesh_fem. name is the data name. The data
is initiakized with V. The data can be a scalar or vector field. sizes an optional
parameter which is either an integer or a vector of suplementary dimensions with
respect to mf.
gf_model_set(model M, 'add data', string name, int size)
Add a fixed size data to the model. sizes is either a integer (for a scalar or vector
data) or a vector of dimensions for a tensor data. name is the data name.
gf_model_set(model M, 'add macro', string name, string expr)
Define a new macro for the high generic assembly language. The name in-
clude the parameters. For instance name=’sp(a,b)’, expr=’a.b’ is a valid defi-
nition. Macro without parameter can also be defined. For instance name=’x1’,
expr=’X[1]’ is valid. The form name=’grad(u)’, expr=’Grad_u’ is also allowed
but in that case, the parameter ‘u’ will only be allowed to be a variable name
when using the macro. Note that macros can be directly defined inside the as-
sembly strings with the keyword ‘Def’.
gf_model_set(model M, 'del macro', string name)
Delete a previously defined macro for the high generic assembly language.
gf_model_set(model M, 'add initialized data', string name,
vec V[, sizes])
Add an initialized fixed size data to the model. sizes an optional parameter which
is either an integer or a vector dimensions that describes the format of the data.
By default, the data is considered to b a vector field. name is the data name and
V is the value of the data.
gf_model_set(model M, 'variable', string name, vec V)
Set the value of a variable or data. name is the data name.
gf_model_set(model M, 'to variables', vec V)
Set the value of the variables of the model with the vector V. Typically, the vector
V results of the solve of the tangent linear system (useful to solve your problem
with you own solver).
gf_model_set(model M, 'delete brick', int ind_brick)
Delete a variable or a data from the model.
gf_model_set(model M, 'define variable group', string name[,
string varname, ...])
Defines a group of variables for the interpolation (mainly for the raytracing in-
terpolation transformation.
gf_model_set(model M, 'add elementary rotated RT0
projection', string transname)
Add the elementary transformation corresponding to the projection on rotated
RT0 element for two-dimensional elements to the model. The name is the name
given to the elementary transformation.
gf_model_set(model M, 'add elementary P0 projection', string
transname)
Add the elementary transformation corresponding to the projection P0 element.
The name is the name given to the elementary transformation.
gf_model_set(model M, 'add HHO reconstructed gradient',
string transname)
Add to the model the elementary transformation corresponding to the recon-
struction of a gradient for HHO methods. The name is the name given to the
elementary transformation.
gf_model_set(model M, 'add HHO reconstructed symmetrized
gradient', string transname)
Add to the model the elementary transformation corresponding to the reconstruc-
tion of a symmetrized gradient for HHO methods. The name is the name given
to the elementary transformation.
gf_model_set(model M, 'add HHO reconstructed value', string
transname)
Add to the model the elementary transformation corresponding to the recon-
struction of the variable for HHO methods. The name is the name given to the
elementary transformation.
gf_model_set(model M, 'add HHO reconstructed symmetrized
value', string transname)
Add to the model the elementary transformation corresponding to the reconstruc-
tion of the variable for HHO methods using a symmetrized gradient. The name
is the name given to the elementary transformation.
gf_model_set(model M, 'add HHO stabilization', string
transname)
Add to the model the elementary transformation corresponding to the HHO sta-
bilization operator. The name is the name given to the elementary transforma-
tion.
gf_model_set(model M, 'add HHO symmetrized stabilization',
string transname)
Add to the model the elementary transformation corresponding to the HHO sta-
bilization operator using a symmetrized gradient. The name is the name given to
the elementary transformation.
gf_model_set(model M, 'add interpolate transformation
from expression', string transname, mesh source_mesh, mesh
target_mesh, string expr)
Add a transformation to the model from mesh source_mesh to mesh target_mesh
given by the expression expr which corresponds to a high-level generic assem-
bly expression which may contains some variable of the model. CAUTION: the
derivative of the transformation with used variable is taken into account in the
computation of the tangen system. However, order two derivative is not imple-
mented, so such tranformation is not allowed in the definition of a potential.
gf_model_set(model M, 'add element extrapolation
transformation', string transname, mesh source_mesh, mat
elt_corr)
Add a special interpolation transformation which represents the identity transfor-
mation but allows to evaluate the expression on another element than the current
element by polynomial extrapolation. It is used for stabilization term in fictitious
domain applications. the array elt_cor should be a two entry array whose first
line contains the elements concerned by the transformation and the second line
the respective elements on which the extrapolation has to be made. If an element
is not listed in elt_cor the evaluation is just made on the current element.
gf_model_set(model M, 'add standard secondary domain',
string name, mesh_im mim, int region = -1)
Add a secondary domain to the model which can be used in a weak-form lan-
guage expression for integration on the product of two domains. name is the
name of the secondary domain, mim is an integration method on this domain and
region the region on which the integration is to be performed.
gf_model_set(model M, 'set element extrapolation
correspondence', string transname, mat elt_corr)
Change the correspondence map of an element extrapolation interpolate trans-
formation.
gf_model_set(model M, 'add raytracing transformation',
string transname, scalar release_distance)
Add a raytracing interpolate transformation called transname to a model to be
used by the generic assembly bricks. CAUTION: For the moment, the derivative
of the transformation is not taken into account in the model solve.
gf_model_set(model M, 'add master contact boundary to
raytracing transformation', string transname, mesh m, string
dispname, int region)
variables and if the expression is a potential or of first order (i.e. describe the
weak form, not the derivative of the weak form), the expression will be derivated
with respect to all variables. You can specify if the term is symmetric, coercive
or not. If you are not sure, the better is to declare the term not symmetric and not
coercive. But some solvers (conjugate gradient for instance) are not allowed for
non-coercive problems. brickname is an optional name for the brick.
ind = gf_model_set(model M, 'add linear twodomain term',
mesh_im mim, string expression, int region, string
secondary_domain[, int is_symmetric[, int is_coercive]])
Adds a linear term given by a weak form language expression like
gf_model_set(model M, ‘add linear term’) but for an integration on a direct prod-
uct of two domains, a first specfied by mim and region and a second one by
secondary_domain which has to be declared first into the model.
ind = gf_model_set(model M, 'add linear generic assembly
brick', mesh_im mim, string expression[, int region[, int
is_symmetric[, int is_coercive]]])
Deprecated. Use gf_model_set(model M, ‘add linear term’) instead.
ind = gf_model_set(model M, 'add nonlinear term', mesh_im
mim, string expression[, int region[, int is_symmetric[, int
is_coercive]]])
Adds a nonlinear term given by the assembly string expr which will be assem-
bled in region region and with the integration method mim. The expression can
describe a potential or a weak form. Second order terms (i.e. containing second
order test functions, Test2) are not allowed. You can specify if the term is sym-
metric, coercive or not. If you are not sure, the better is to declare the term not
symmetric and not coercive. But some solvers (conjugate gradient for instance)
are not allowed for non-coercive problems. brickname is an optional name for
the brick.
ind = gf_model_set(model M, 'add nonlinear twodomain
term', mesh_im mim, string expression, int region, string
secondary_domain[, int is_symmetric[, int is_coercive]])
Adds a nonlinear term given by a weak form language expression like
gf_model_set(model M, ‘add nonlinear term’) but for an integration on a di-
rect product of two domains, a first specfied by mim and region and a second
one by secondary_domain which has to be declared first into the model.
ind = gf_model_set(model M, 'add nonlinear generic assembly
brick', mesh_im mim, string expression[, int region[, int
is_symmetric[, int is_coercive]]])
Deprecated. Use gf_model_set(model M, ‘add nonlinear term’) instead.
ind = gf_model_set(model M, 'add source term', mesh_im mim,
string expression[, int region])
Adds a source term given by the assembly string expr which will be assembled in
region region and with the integration method mim. Only the residual term will
be taken into account. Take care that if the expression contains some variables
and if the expression is a potential, the expression will be derivated with respect
to all variables. brickname is an optional name for the brick.
ind = gf_model_set(model M, 'add twodomain source term',
mesh_im mim, string expression, int region, string
secondary_domain)
Adds a source term given by a weak form language expression like
gf_model_set(model M, ‘add source term’) but for an integration on a direct
product of two domains, a first specfied by mim and region and a second one
by secondary_domain which has to be declared first into the model.
ind = gf_model_set(model M, 'add source term generic
assembly brick', mesh_im mim, string expression[, int
region])
Deprecated. Use gf_model_set(model M, ‘add source term’) instead.
gf_model_set(model M, 'add assembly assignment', string
dataname, string expression[, int region[, int order[, int
before]]])
Adds expression expr to be evaluated at assembly time and being assigned to the
data dataname which has to be of im_data type. This allows for instance to store
a sub-expression of an assembly computation to be used on an other assembly.
It can be used for instance to store the plastic strain in plasticity models. order
represents the order of assembly where this assignement has to be done (poten-
tial(0), weak form(1) or tangent system(2) or at each order(-1)). The default
value is 1. If before = 1, the the assignement is perfromed before the computa-
tion of the other assembly terms, such that the data can be used in the remaining
of the assembly as an intermediary result (be careful that it is still considered as
a data, no derivation of the expression is performed for the tangent system). If
before = 0 (default), the assignement is done after the assembly terms.
gf_model_set(model M, 'clear assembly assignment')
Delete all added assembly assignments
ind = gf_model_set(model M, 'add Laplacian brick', mesh_im
mim, string varname[, int region])
Add a Laplacian term to the model relatively to the variable varname (in fact
with a minus : −div(∇𝑢)). If this is a vector valued variable, the Laplacian term
is added componentwise. region is an optional mesh region on which the term
is added. If it is not specified, it is added on the whole mesh. Return the brick
index in the model.
ind = gf_model_set(model M, 'add generic elliptic brick',
mesh_im mim, string varname, string dataname[, int region])
Add a generic elliptic term to the model relatively to the variable varname. The
shape of the elliptic term depends both on the variable and the data. This corre-
sponds to a term −div(𝑎∇𝑢) where 𝑎 is the data and 𝑢 the variable. The data can
be a scalar, a matrix or an order four tensor. The variable can be vector valued or
not. If the data is a scalar or a matrix and the variable is vector valued then the
term is added componentwise. An order four tensor data is allowed for vector
valued variable only. The data can be constant or describbed on a fem. Of course,
when the data is a tensor describe on a finite element method (a tensor field) the
data can be a huge vector. The components of the matrix/tensor have to be stored
with the fortran order (columnwise) in the data vector (compatibility with blas).
The symmetry of the given matrix/tensor is not verified (but assumed). If this
is a vector valued variable, the elliptic term is added componentwise. region
is an optional mesh region on which the term is added. If it is not specified,
it is added on the whole mesh. Note that for the real version which uses the
high-level generic assembly language, dataname can be any regular expression
of the high-level generic assembly language (like “1”, “sin(X(1))” or “Norm(u)”
for instance) even depending on model variables. Return the brick index in the
model.
ind = gf_model_set(model M, 'add source term brick', mesh_im
mim, string varname, string dataexpr[, int region[, string
directdataname]])
Add a source term to the model relatively to the variable varname. The source
term is represented by dataexpr which could be any regular expression of the
high-level generic assembly language (except for the complex version where it
has to be a declared data of the model). region is an optional mesh region on
which the term is added. An additional optional data directdataname can be
provided. The corresponding data vector will be directly added to the right hand
side without assembly. Note that when region is a boundary, this brick allows to
prescribe a nonzero Neumann boundary condition. Return the brick index in the
model.
ind = gf_model_set(model M, 'add normal source term brick',
mesh_im mim, string varname, string dataname, int region)
Add a source term on the variable varname on a boundary region. This region
should be a boundary. The source term is represented by the data dataepxpr
which could be any regular expression of the high-level generic assembly lan-
guage (except for the complex version where it has to be a declared data of the
model). A scalar product with the outward normal unit vector to the boundary
is performed. The main aim of this brick is to represent a Neumann condition
with a vector data without performing the scalar product with the normal as a
pre-processing. Return the brick index in the model.
ind = gf_model_set(model M, 'add Dirichlet condition
with simplification', string varname, int region[, string
dataname])
Adds a (simple) Dirichlet condition on the variable varname and the mesh region
region. The Dirichlet condition is prescribed by a simple post-treatment of the
final linear system (tangent system for nonlinear problems) consisting of modi-
fying the lines corresponding to the degree of freedom of the variable on region
(0 outside the diagonal, 1 on the diagonal of the matrix and the expected value on
the right hand side). The symmetry of the linear system is kept if all other bricks
are symmetric. This brick is to be reserved for simple Dirichlet conditions (only
dof declared on the corresponding boundary are prescribed). The application
of this brick on reduced dof may be problematic. Intrinsic vectorial finite ele-
ment method are not supported. dataname is the optional right hand side of the
Dirichlet condition. It could be constant (but in that case, it can only be applied
to Lagrange f.e.m.) or (important) described on the same finite element method
vectors. In that case the prescribed constraint is the scalar product of the variable
at the corresponding point with the corresponding unit vector. The optional data
dataname_val is the vector of values to be prescribed at the different points. This
brick is specifically designed to kill rigid displacement in a Neumann problem.
Returns the brick index in the model.
gf_model_set(model M, 'change penalization coeff', int
ind_brick, scalar coeff)
Change the penalization coefficient of a Dirichlet condition with penalization
brick. If the brick is not of this kind, this function has an undefined behavior.
ind = gf_model_set(model M, 'add Helmholtz brick', mesh_im
mim, string varname, string dataexpr[, int region])
Add a Helmholtz term to the model relatively to the variable varname. dataexpr
is the wave number. region is an optional mesh region on which the term is
added. If it is not specified, it is added on the whole mesh. Return the brick
index in the model.
ind = gf_model_set(model M, 'add Fourier Robin brick',
mesh_im mim, string varname, string dataexpr, int region)
Add a Fourier-Robin term to the model relatively
∫︀ to the variable varname. This
corresponds to a weak term of the form (𝑞𝑢).𝑣. dataexpr is the parameter 𝑞
of the Fourier-Robin condition. It can be an arbitrary valid expression of the
high-level generic assembly language (except for the complex version for which
it should be a data of the model). region is the mesh region on which the term is
added. Return the brick index in the model.
ind = gf_model_set(model M, 'add constraint with
multipliers', string varname, string multname, spmat B, {vec
L | string dataname})
Add an additional explicit constraint on the variable varname thank to a multi-
plier multname peviously added to the model (should be a fixed size variable).
The constraint is 𝐵𝑈 = 𝐿 with B being a rectangular sparse matrix. It is possible
to change the constraint at any time with the methods gf_model_set(model M,
‘set private matrix’) and gf_model_set(model M, ‘set private rhs’). If dataname
is specified instead of L, the vector L is defined in the model as data with the
given name. Return the brick index in the model.
ind = gf_model_set(model M, 'add constraint with
penalization', string varname, scalar coeff, spmat B, {vec
L | string dataname})
Add an additional explicit penalized constraint on the variable varname. The
constraint is :math‘BU=L‘ with B being a rectangular sparse matrix. Be aware
that B should not contain a plain row, otherwise the whole tangent matrix will
be plain. It is possible to change the constraint at any time with the methods
gf_model_set(model M, ‘set private matrix’) and gf_model_set(model M, ‘set
private rhs’). The method gf_model_set(model M, ‘change penalization coeff’)
can be used. If dataname is specified instead of L, the vector L is defined in the
model as data with the given name. Return the brick index in the model.
ind = gf_model_set(model M, 'add explicit matrix', string
varname1, string varname2, spmat B[, int issymmetric[, int
iscoercive]])
Add a brick representing an explicit matrix to be added to the tangent linear
system relatively to the variables varname1 and varname2. The given matrix
should have has many rows as the dimension of varname1 and as many columns
as the dimension of varname2. If the two variables are different and if issym-
metric is set to 1 then the transpose of the matrix is also added to the tangent
system (default is 0). Set iscoercive to 1 if the term does not affect the coer-
civity of the tangent system (default is 0). The matrix can be changed by the
command gf_model_set(model M, ‘set private matrix’). Return the brick index
in the model.
ind = gf_model_set(model M, 'add explicit rhs', string
varname, vec L)
Add a brick representing an explicit right hand side to be added to the right
hand side of the tangent linear system relatively to the variable varname. The
given rhs should have the same size than the dimension of varname. The rhs
can be changed by the command gf_model_set(model M, ‘set private rhs’). If
dataname is specified instead of L, the vector L is defined in the model as data
with the given name. Return the brick index in the model.
gf_model_set(model M, 'set private matrix', int indbrick,
spmat B)
For some specific bricks having an internal sparse matrix (explicit bricks: ‘con-
straint brick’ and ‘explicit matrix brick’), set this matrix.
gf_model_set(model M, 'set private rhs', int indbrick, vec
B)
For some specific bricks having an internal right hand side vector (explicit bricks:
‘constraint brick’ and ‘explicit rhs brick’), set this rhs.
ind = gf_model_set(model M, 'add isotropic linearized
elasticity brick', mesh_im mim, string varname, string
dataname_lambda, string dataname_mu[, int region])
Add an isotropic linearized elasticity term to the model relatively to the variable
varname. dataname_lambda and dataname_mu should contain the Lame coeffi-
cients. region is an optional mesh region on which the term is added. If it is not
specified, it is added on the whole mesh. Return the brick index in the model.
ind = gf_model_set(model M, 'add isotropic linearized
elasticity brick pstrain', mesh_im mim, string varname,
string data_E, string data_nu[, int region])
Add an isotropic linearized elasticity term to the model relatively to the variable
varname. data_E and data_nu should contain the Young modulus and Poisson
ratio, respectively. region is an optional mesh region on which the term is added.
If it is not specified, it is added on the whole mesh. On two-dimensional meshes,
the term will correpsond to a plain strain approximation. On three-dimensional
meshes, it will correspond to the standard model. Return the brick index in the
model.
ind = gf_model_set(model M, 'add isotropic linearized
elasticity brick pstress', mesh_im mim, string varname,
coefficient.
IMPORTANT : if the variable is defined on a 2D mesh, the plane strain approx-
imation is automatically used. params is a vector of parameters for the consti-
tutive law. Its length depends on the law. It could be a short vector of constant
values or a vector field described on a finite element method for variable coeffi-
cients. region is an optional mesh region on which the term is added. If it is not
specified, it is added on the whole mesh. This brick use the high-level generic
assembly. Returns the brick index in the model.
ind = gf_model_set(model M, 'add small strain
elastoplasticity brick', mesh_im mim, string lawname, string
unknowns_type [, string varnames, ...] [, string params, ..
.] [, string theta = '1' [, string dt = 'timestep']] [, int
region = -1])
Adds a small strain plasticity term to the model M. This is the main GetFEM
brick for small strain plasticity. lawname is the name of an implemented plas-
tic law, unknowns_type indicates the choice between a discretization where the
plastic multiplier is an unknown of the problem or (return mapping approach)
just a data of the model stored for the next iteration. Remember that in both
cases, a multiplier is stored anyway. varnames is a set of variable and data
names with length which may depend on the plastic law (at least the displace-
ment, the plastic multiplier and the plastic strain). params is a list of expressions
for the parameters (at least elastic coefficients and the yield stress). These ex-
pressions can be some data names (or even variable names) of the model but can
also be any scalar valid expression of the high level assembly language (such
as ‘1/2’, ‘2+sin(X[0])’, ‘1+Norm(v)’ . . . ). The last two parameters optionally
provided in params are the theta parameter of the theta-scheme (generalized
trapezoidal rule) used for the plastic strain integration and the time-step‘dt‘. The
default value for theta if omitted is 1, which corresponds to the classical Back-
ward Euler scheme which is first order consistent. theta=1/2 corresponds to
the Crank-Nicolson scheme (trapezoidal rule) which is second order consistent.
Any value between 1/2 and 1 should be a valid value. The default value of
dt is ‘timestep’ which simply indicates the time step defined in the model (by
md.set_time_step(dt)). Alternatively it can be any expression (data name, con-
stant value . . . ). The time step can be altered from one iteration to the next one.
region is a mesh region.
The available plasticity laws are:
• ‘Prandtl Reuss’ (or ‘isotropic perfect plasticity’). Isotropic elasto-plasticity
with no hardening. The variables are the displacement, the plastic multiplier
and the plastic strain. The displacement should be a variable and have a cor-
responding data having the same name preceded by ‘Previous_’ correspond-
ing to the displacement at the previous time step (typically ‘u’ and ‘Previ-
ous_u’). The plastic multiplier should also have two versions (typically
‘xi’ and ‘Previous_xi’) the first one being defined as data if unknowns_type
‘ is ‘DISPLACEMENT_ONLY’ or the integer value 0, or as a variable if
‘unknowns_type is DISPLACEMENT_AND_PLASTIC_MULTIPLIER or
the integer value 1. The plastic strain should represent a n x n data tensor
field stored on mesh_fem or (preferably) on an im_data (corresponding to
mim). The data are the first Lame coefficient, the second one (shear modu-
lus) and the uniaxial yield stress. A typical call is gf_model_get(model M,
‘add small strain elastoplasticity brick’, mim, ‘Prandtl Reuss’, 0, ‘u’, ‘xi’,
‘Previous_Ep’, ‘lambda’, ‘mu’, ‘sigma_y’, ‘1’, ‘timestep’); IMPORTANT:
Note that this law implements the 3D expressions. If it is used in 2D, the ex-
pressions are just transposed to the 2D. For the plane strain approximation,
see below.
• “plane strain Prandtl Reuss” (or “plane strain isotropic perfect plasticity”)
The same law as the previous one but adapted to the plane strain approxi-
mation. Can only be used in 2D.
• “Prandtl Reuss linear hardening” (or “isotropic plasticity linear hardening”).
Isotropic elasto-plasticity with linear isotropic and kinematic hardening. An
additional variable compared to “Prandtl Reuss” law: the accumulated plas-
tic strain. Similarly to the plastic strain, it is only stored at the end of the
time step, so a simple data is required (preferably on an im_data). Two addi-
tional parameters: the kinematic hardening modulus and the isotropic one.
3D expressions only. A typical call is gf_model_get(model M, ‘add small
strain elastoplasticity brick’, mim, ‘Prandtl Reuss linear hardening’, 0, ‘u’,
‘xi’, ‘Previous_Ep’, ‘Previous_alpha’, ‘lambda’, ‘mu’, ‘sigma_y’, ‘H_k’,
H_i’, ‘1’, ‘timestep’);
• “plane strain Prandtl Reuss linear hardening” (or “plane strain isotropic
plasticity linear hardening”). The same law as the previous one but adapted
to the plane strain approximation. Can only be used in 2D.
See GetFEM user documentation for further explanations on the discretization
of the plastic flow and on the implemented plastic laws. See also GetFEM user
documentation on time integration strategy (integration of transient problems).
IMPORTANT : remember that small_strain_elastoplasticity_next_iter has to be
called at the end of each time step, before the next one (and before any post-
treatment : this sets the value of the plastic strain and plastic multiplier).
ind = gf_model_set(model M, 'add elastoplasticity brick',
mesh_im mim ,string projname, string varname, string
previous_dep_name, string datalambda, string datamu, string
datathreshold, string datasigma[, int region])
Old (obsolete) brick which do not use the high level generic assembly. Add
a nonlinear elastoplastic term to the model relatively to the variable varname,
in small deformations, for an isotropic material and for a quasistatic model.
projname is the type of projection that used: only the Von Mises projection is
available with ‘VM’ or ‘Von Mises’. datasigma is the variable representing the
constraints on the material. previous_dep_name represents the displacement at
the previous time step. Moreover, the finite element method on which varname
is described is an K ordered mesh_fem, the datasigma one have to be at least
an K-1 ordered mesh_fem. datalambda and datamu are the Lame coefficients
of the studied material. datathreshold is the plasticity threshold of the material.
The three last variables could be constants or described on the same finite ele-
ment method. region is an optional mesh region on which the term is added. If
it is not specified, it is added on the whole mesh. Return the brick index in the
model.
ind = gf_model_set(model M, 'add finite strain
elastoplasticity brick', mesh_im mim , string lawname,
Add a finite strain incompressibility condition on variable (for large strain elas-
ticity). multname_pressure is a variable which represent the pressure. Be aware
that an inf-sup condition between the finite element method describing the pres-
sure and the primal variable has to be satisfied. region is an optional mesh re-
gion on which the term is added. If it is not specified, it is added on the whole
mesh. Return the brick index in the model. This brick is equivalent to the
nonlinear incompressibility brick but uses the high-level generic
assembly adding the term p*(1-Det(Id(meshdim)+Grad_u)) if p is the
multiplier and u the variable which represent the displacement.
ind = gf_model_set(model M, 'add bilaplacian brick', mesh_im
mim, string varname, string dataname [, int region])
Add a bilaplacian brick on the variable varname and on the mesh region region.
This represent a term ∆(𝐷∆𝑢). where 𝐷(𝑥) is a coefficient determined by
dataname which
∫︀ could be constant or described on a f.e.m. The corresponding
weak form is 𝐷(𝑥)∆𝑢(𝑥)∆𝑣(𝑥)𝑑𝑥. Return the brick index in the model.
ind = gf_model_set(model M, 'add Kirchhoff-Love plate
brick', mesh_im mim, string varname, string dataname_D,
string dataname_nu [, int region])
Add a bilaplacian brick on the variable varname and on the mesh region region.
This represent a term ∆(𝐷∆𝑢) where 𝐷(𝑥) is a the flexion modulus determined
by dataname_D. The term is integrated by part following a Kirchhoff-Love plate
model with dataname_nu the poisson ratio. Return the brick index in the model.
ind = gf_model_set(model M, 'add normal derivative source
term brick', mesh_im mim, string varname, string dataname,
int region)
∫︀
Add a normal derivative source term brick 𝐹 = 𝑏.𝜕𝑛 𝑣 on the variable varname
and the mesh region region.
Update the right hand side of the linear system. dataname represents b and
varname represents v. Return the brick index in the model.
ind = gf_model_set(model M, 'add Kirchhoff-Love Neumann
term brick', mesh_im mim, string varname, string dataname_M,
string dataname_divM, int region)
Add a Neumann term brick for Kirchhoff-Love model on the variable varname
and the mesh region region. dataname_M represents the bending moment tensor
and dataname_divM its divergence. Return the brick index in the model.
ind = gf_model_set(model M, 'add normal derivative Dirichlet
condition with multipliers', mesh_im mim, string varname,
mult_description, int region [, string dataname, int
R_must_be_derivated])
Add a Dirichlet condition on the normal derivative of the variable varname and
on
∫︀ the mesh region∫︀ region (which should be a boundary). The general form is
𝜕𝑛 𝑢(𝑥)𝑣(𝑥) = 𝑟(𝑥)𝑣(𝑥)∀𝑣 where 𝑟(𝑥) is the right hand side for the Dirich-
let condition (0 for homogeneous conditions) and 𝑣 is in a space of multipliers
defined by mult_description. If mult_description is a string this is assumed to
be the variable name corresponding to the multiplier (which should be first de-
clared as a multiplier variable on the mesh region in the model). If it is a finite
Add a contact with or without friction brick to the model. If U is the vector of
degrees of freedom on which the unilateral constraint is applied, the matrix BN
have to be such that this constraint is defined by 𝐵𝑁 𝑈 ≤ 0. A friction con-
dition can be considered by adding the three parameters multname_t, BT and
dataname_friction_coeff. In this case, the tangential displacement is 𝐵𝑇 𝑈 and
the matrix BT should have as many rows as BN multiplied by 𝑑 − 1 where 𝑑 is
the domain dimension. In this case also, dataname_friction_coeff is a data which
represents the coefficient of friction. It can be a scalar or a vector representing
a value on each contact condition. The unilateral constraint is prescribed thank
to a multiplier multname_n whose dimension should be equal to the number of
rows of BN. If a friction condition is added, it is prescribed with a multiplier
multname_t whose dimension should be equal to the number of rows of BT. The
augmentation parameter r should be chosen in a range of acceptabe values (see
Getfem user documentation). dataname_gap is an optional parameter represent-
ing the initial gap. It can be a single value or a vector of value. dataname_alpha
is an optional homogenization parameter for the augmentation parameter (see
Getfem user documentation). The parameter augmented_version indicates the
augmentation strategy : 1 for the non-symmetric Alart-Curnier augmented La-
grangian, 2 for the symmetric one (except for the coupling between contact and
Coulomb friction), 3 for the unsymmetric method with augmented multipliers, 4
for the unsymmetric method with augmented multipliers and De Saxce projec-
tion.
ind = gf_model_set(model M, 'add basic contact brick two
deformable bodies', string varname_u1, string varname_u2,
string multname_n, string dataname_r, spmat BN1, spmat
BN2[, string dataname_gap[, string dataname_alpha[, int
augmented_version]]])
Add a frictionless contact condition to the model between two deformable
bodies. If U1, U2 are the vector of degrees of freedom on which the
unilateral constraint is applied, the matrices BN1 and BN2 have to be
such that this condition is defined by $B_{N1} U_1 B_{N2} U_2 + le
gap$. The constraint is prescribed thank to a multiplier multname_n whose
dimension should be equal to the number of lines of BN. The augmentation
parameter r should be chosen in a range of acceptabe values (see Getfem
user documentation). dataname_gap is an optional parameter representing
the initial gap. It can be a single value or a vector of value. dataname_alpha
is an optional homogenization parameter for the augmentation parameter
(see Getfem user documentation). The parameter aug_version indicates the
augmentation strategy : 1 for the non-symmetric Alart-Curnier augmented
Lagrangian, 2 for the symmetric one, 3 for the unsymmetric method with
augmented multiplier.
gf_model_set(model M, 'contact brick set BN', int indbrick,
spmat BN)
Can be used to set the BN matrix of a basic contact/friction brick.
gf_model_set(model M, 'contact brick set BT', int indbrick,
spmat BT)
Can be used to set the BT matrix of a basic contact with friction brick.
ind = gf_model_set(model M, 'add nodal contact with rigid
placement fields are given. Integers rg1 and rg2 represent the regions expected
to come in contact with each other. In the single displacement variable case
the regions defined in both rg1 and rg2 refer to the variable varname_u1. In
the case of two displacement variables, rg1 refers to varname_u1 and rg2 refers
to varname_u2. multname_n should be a fixed size variable whose size is the
number of degrees of freedom on those regions among the ones defined in rg1
and rg2 which are characterized as “slaves”. It represents the contact equiva-
lent nodal normal forces. multname_t should be a fixed size variable whose size
corresponds to the size of multname_n multiplied by qdim - 1 . It represents the
contact equivalent nodal tangent (frictional) forces. The augmentation parameter
r should be chosen in a range of acceptabe values (close to the Young modulus
of the elastic body, see Getfem user documentation). The friction coefficient
stored in the parameter fr is either a single value or a vector of the same size as
multname_n. The optional parameters slave1 and slave2 declare if the regions
defined in rg1 and rg2 are correspondingly considered as “slaves”. By default
slave1 is true and slave2 is false, i.e. rg1 contains the slave surfaces, while ‘rg2’
the master surfaces. Preferrably only one of slave1 and slave2 is set to true. The
parameter augmented_version indicates the augmentation strategy : 1 for the
non-symmetric Alart-Curnier augmented Lagrangian, 2 for the symmetric one
(except for the coupling between contact and Coulomb friction), 3 for the new
unsymmetric method. Basically, this brick computes the matrices BN and BT
and the vectors gap and alpha and calls the basic contact brick.
ind = gf_model_set(model M, 'add nonmatching meshes contact
brick', mesh_im mim1[, mesh_im mim2], string varname_u1[,
string varname_u2], string multname_n[, string multname_t],
string dataname_r[, string dataname_fr], int rg1, int rg2[,
int slave1, int slave2, int augmented_version])
DEPRECATED FUNCTION. Use ‘add nodal contact between nonmatching
meshes brick’ instead.
ind = gf_model_set(model M, 'add integral contact between
nonmatching meshes brick', mesh_im mim, string varname_u1,
string varname_u2, string multname, string dataname_r [,
string dataname_friction_coeff], int region1, int region2 [,
int option [, string dataname_alpha [, string dataname_wt1 ,
string dataname_wt2]]])
Add a contact with or without friction condition between nonmatching meshes
to the model. This brick adds a contact which is defined in an integral way. It
is the direct approximation of an augmented agrangian formulation (see Getfem
user documentation) defined at the continuous level. The advantage should be a
better scalability: the number of Newton iterations should be more or less inde-
pendent of the mesh size. The condition is applied on the variables varname_u1
and varname_u2 on the boundaries corresponding to region1 and region2. mult-
name should be a fem variable representing the contact stress for the frictionless
case and the contact and friction stress for the case with friction. An inf-sup
condition between multname and varname_u1 and varname_u2 is required. The
augmentation parameter dataname_r should be chosen in a range of acceptable
values. The optional parameter dataname_friction_coeff is the friction coeffi-
cient which could be constant or defined on a finite element method on the same
mesh as varname_u1. Possible values for option is 1 for the non-symmetric
Adds a master contact boundary to an existing large sliding contact with friction
brick.
gf_model_set(model M, 'add slave contact boundary to large
sliding contact brick', int indbrick, mesh_im mim, int
region, string dispname, string lambdaname[, string wname])
Adds a slave contact boundary to an existing large sliding contact with friction
brick.
gf_model_set(model M, 'add master slave contact boundary to
large sliding contact brick', int indbrick, mesh_im mim, int
region, string dispname, string lambdaname[, string wname])
Adds a contact boundary to an existing large sliding contact with friction brick
which is both master and slave (allowing the self-contact).
ind = gf_model_set(model M, 'add Nitsche large sliding
contact brick raytracing', bool unbiased_version, string
dataname_r, scalar release_distance[, string dataname_fr[,
string dataname_alpha[, int version]]])
Adds a large sliding contact with friction brick to the model based on the
Nitsche’s method. This brick is able to deal with self-contact, contact between
several deformable bodies and contact with rigid obstacles. It uses the high-level
generic assembly. It adds to the model a raytracing_interpolate_transformation
object. “unbiased_version” refers to the version of Nische’s method to be used.
(unbiased or biased one). For each slave boundary a material law should be de-
fined as a function of the dispacement variable on this boundary. The release
distance should be determined with care (generally a few times a mean element
size, and less than the thickness of the body). Initially, the brick is added with
no contact boundaries. The contact boundaries and rigid bodies are added with
special functions. version is 0 (the default value) for the non-symmetric version
and 1 for the more symmetric one (not fully symmetric even without friction).
gf_model_set(model M, 'add rigid obstacle to Nitsche large
sliding contact brick', int indbrick, string expr, int N)
Adds a rigid obstacle to an existing large sliding contact with friction brick. expr
is an expression using the high-level generic assembly language (where x is the
current point n the mesh) which should be a signed distance to the obstacle. N is
the mesh dimension.
gf_model_set(model M, 'add master contact boundary to biased
Nitsche large sliding contact brick', int indbrick, mesh_im
mim, int region, string dispname[, string wname])
Adds a master contact boundary to an existing biased Nitsche’s large sliding
contact with friction brick.
gf_model_set(model M, 'add slave contact boundary to biased
Nitsche large sliding contact brick', int indbrick, mesh_im
mim, int region, string dispname, string lambdaname[, string
wname])
Adds a slave contact boundary to an existing biased Nitsche’s large sliding con-
tact with friction brick.
7.40 gf_poly
Synopsis
gf_poly(poly P, 'print')
gf_poly(poly P, 'product')
Description :
Performs various operations on the polynom POLY.
Command list :
gf_poly(poly P, 'print')
Prints the content of P.
gf_poly(poly P, 'product')
To be done . . . !
7.41 gf_precond
Synopsis
PC = gf_precond('identity')
PC = gf_precond('cidentity')
PC = gf_precond('diagonal', vec D)
PC = gf_precond('ildlt', spmat m)
PC = gf_precond('ilu', spmat m)
PC = gf_precond('ildltt', spmat m[, int fillin[, scalar threshold]])
PC = gf_precond('ilut', spmat m[, int fillin[, scalar threshold]])
PC = gf_precond('superlu', spmat m)
PC = gf_precond('spmat', spmat m)
Description :
General constructor for precond objects.
The preconditioners may store REAL or COMPLEX values. They accept getfem sparse
matrices and Matlab sparse matrices.
Command list :
PC = gf_precond('identity')
Create a REAL identity precondioner.
PC = gf_precond('cidentity')
7.42 gf_precond_get
Synopsis
Description :
General function for querying information about precond objects.
Command list :
7.43 gf_slice
Synopsis
Description :
General constructor for slice objects.
Creation of a mesh slice. Mesh slices are very similar to a P1-discontinuous mesh_fem on
which interpolation is very fast. The slice is built from a mesh object, and a description of
the slicing operation, for example:
sl = gf_slice({'planar',+1,[0;0],[1;0]}, m, 5);
cuts the original mesh with the half space {y>0}. Each convex of the original mesh m is
simplexified (for example a quadrangle is splitted into 2 triangles), and each simplex is
refined 5 times.
Slicing operations can be:
• cutting with a plane, a sphere or a cylinder
• intersection or union of slices
• isovalues surfaces/volumes
• “points”, “streamlines” (see below)
If the first argument is a mesh_fem mf instead of a mesh, and if it is followed by a mf -field u
(with size(u,1) == gf_mesh_fem_get(mesh_fem MF, ‘nbdof’)), then the deformation u will
be applied to the mesh before the slicing operation.
The first argument can also be a slice.
Command list :
sl = gf_slice(sliceop, {slice sl|{mesh m| mesh_fem mf, vec
U}, int refine}[, mat CVfids])
Create a slice using sliceop operation.
sliceop operation is specified with Matlab CELL arrays (i.e. with braces) . The
first element is the name of the operation, followed the slicing options:
• {‘none’} : Does not cut the mesh.
• {‘planar’, int orient, vec p, vec n} : Planar cut. p and n define a half-space,
p being a point belong to the boundary of the half-space, and n being its
normal. If orient is equal to -1 (resp. 0, +1), then the slicing operation
will cut the mesh with the “interior” (resp. “boundary”, “exterior”) of the
half-space. orient may also be set to +2 which means that the mesh will be
sliced, but both the outer and inner parts will be kept.
• {‘ball’, int orient, vec c, scalar r} : Cut with a ball of center c and radius r.
• {‘cylinder’, int orient, vec p1, vec p2, scalar r} : Cut with a cylinder whose
axis is the line (p1, p2) and whose radius is r.
• {‘isovalues’, int orient, mesh_fem mf, vec U, scalar s} : Cut using the iso-
surface of the field U (defined on the mesh_fem mf ). The result is the set
{x such that :math:‘U(x) leq s}‘ or {x such that ‘U‘(x)=‘s}‘ or {x such that
‘U‘(x) >= ‘s}‘ depending on the value of orient.
• {‘boundary’[, SLICEOP]} : Return the boundary of the result of SLICEOP,
where SLICEOP is any slicing operation. If SLICEOP is not speci-
fied, then the whole mesh is considered (i.e. it is equivalent to {‘bound-
ary’,{‘none’}}).
• {‘explode’, mat Coef} : Build an ‘exploded’ view of the mesh: each convex
is shrinked (0 < Coef ≤ 1). In the case of 3D convexes, only their faces are
kept.
• {‘union’, SLICEOP1, SLICEOP2} : Returns the union of slicing opera-
tions.
• {‘intersection’, SLICEOP1, SLICEOP2} : Returns the intersection of slic-
ing operations, for example:
sl = gf_slice({intersection',{'planar',+1,[0;0;0],[0;
˓→0;1]},
{'isovalues',-1,mf2,u2,0}},
˓→mf,u,5)
7.44 gf_slice_get
Synopsis
d = gf_slice_get(slice S, 'dim')
a = gf_slice_get(slice S, 'area')
CVids = gf_slice_get(slice S, 'cvs')
n = gf_slice_get(slice S, 'nbpts')
ns = gf_slice_get(slice S, 'nbsplxs'[, int dim])
P = gf_slice_get(slice S, 'pts')
{S, CV2S} = gf_slice_get(slice S, 'splxs',int dim)
{P, E1, E2} = gf_slice_get(slice S, 'edges')
Usl = gf_slice_get(slice S, 'interpolate_convex_data', mat Ucv)
m = gf_slice_get(slice S, 'linked mesh')
m = gf_slice_get(slice S, 'mesh')
z = gf_slice_get(slice S, 'memsize')
gf_slice_get(slice S, 'export to vtk', string filename, ...)
gf_slice_get(slice S, 'export to pov', string filename)
gf_slice_get(slice S, 'export to dx', string filename, ...)
gf_slice_get(slice S, 'export to pos', string filename[, string name][[,
˓→mesh_fem mf1], mat U1, string nameU1[[,mesh_fem mf1], mat U2, string
˓→nameU2,...])
s = gf_slice_get(slice S, 'char')
gf_slice_get(slice S, 'display')
Description :
General function for querying information about slice objects.
Command list :
d = gf_slice_get(slice S, 'dim')
Return the dimension of the slice (2 for a 2D mesh, etc..).
a = gf_slice_get(slice S, 'area')
s = gf_slice_get(slice S, 'char')
Output a (unique) string representation of the slice.
This can be used to perform comparisons between two different slice objects.
This function is to be completed.
gf_slice_get(slice S, 'display')
displays a short summary for a slice object.
7.45 gf_slice_set
Synopsis
Description :
Edition of mesh slices.
Command list :
gf_slice_set(slice S, 'pts', mat P)
Replace the points of the slice.
The new points P are stored in the columns the matrix. Note that you can use
the function to apply a deformation to a slice, or to change the dimension of the
slice (the number of rows of P is not required to be equal to gf_slice_get(slice S,
‘dim’)).
7.46 gf_spmat
Synopsis
Description :
General constructor for spmat objects.
Create a new sparse matrix in GetFEM format(, i.e. sparse matrices which are stored in the
getfem workspace, not the matlab sparse matrices). These sparse matrix can be stored as
CSC (compressed column sparse), which is the format used by Matlab, or they can be stored
as WSC (internal format to getfem). The CSC matrices are not writable (it would be very
inefficient), but they are optimized for multiplication with vectors, and memory usage. The
WSC are writable, they are very fast with respect to random read/write operation. However
their memory overhead is higher than CSC matrices, and they are a little bit slower for
matrix-vector multiplications.
By default, all newly created matrices are build as WSC matrices. This can be changed
later with gf_spmat_set(spmat S, 'to_csc',...), or may be changed auto-
matically by getfem (for example gf_linsolve() converts the matrices to CSC).
The matrices may store REAL or COMPLEX values.
Command list :
SM = gf_spmat('empty', int m [, int n])
Create a new empty (i.e. full of zeros) sparse matrix, of dimensions m x n. If n
is omitted, the matrix dimension is m x m.
SM = gf_spmat('copy', mat K [, I [, J]])
Duplicate a matrix K (which might be a spmat or a native matlab sparse matrix).
If index I and/or J are given, the matrix will be a submatrix of K. For example:
7.47 gf_spmat_get
Synopsis
n = gf_spmat_get(spmat S, 'nnz')
Sm = gf_spmat_get(spmat S, 'full'[, list I[, list J]])
MV = gf_spmat_get(spmat S, 'mult', vec V)
MtV = gf_spmat_get(spmat S, 'tmult', vec V)
D = gf_spmat_get(spmat S, 'diag'[, list E])
s = gf_spmat_get(spmat S, 'storage')
{ni,nj} = gf_spmat_get(spmat S, 'size')
b = gf_spmat_get(spmat S, 'is_complex')
{JC, IR} = gf_spmat_get(spmat S, 'csc_ind')
V = gf_spmat_get(spmat S, 'csc_val')
{N, U0} = gf_spmat_get(spmat S, 'dirichlet nullspace', vec R)
gf_spmat_get(spmat S, 'save', string format, string filename)
s = gf_spmat_get(spmat S, 'char')
gf_spmat_get(spmat S, 'display')
{mantissa_r, mantissa_i, exponent} = gf_spmat_get(spmat S, 'determinant')
Description :
Command list :
n = gf_spmat_get(spmat S, 'nnz')
Return the number of non-null values stored in the sparse matrix.
Sm = gf_spmat_get(spmat S, 'full'[, list I[, list J]])
Return a full (sub-)matrix.
The optional arguments I and J, are the sub-intervals for the rows and columns
that are to be extracted.
MV = gf_spmat_get(spmat S, 'mult', vec V)
Product of the sparse matrix M with a vector V.
For matrix-matrix multiplications, see gf_spmat(‘mult’).
MtV = gf_spmat_get(spmat S, 'tmult', vec V)
Product of M transposed (conjugated if M is complex) with the vector V.
D = gf_spmat_get(spmat S, 'diag'[, list E])
Return the diagonal of M as a vector.
If E is used, return the sub-diagonals whose ranks are given in E.
s = gf_spmat_get(spmat S, 'storage')
Return the storage type currently used for the matrix.
The storage is returned as a string, either ‘CSC’ or ‘WSC’.
{ni,nj} = gf_spmat_get(spmat S, 'size')
Return a vector where ni and nj are the dimensions of the matrix.
b = gf_spmat_get(spmat S, 'is_complex')
Return 1 if the matrix contains complex values.
{JC, IR} = gf_spmat_get(spmat S, 'csc_ind')
7.48 gf_spmat_set
Synopsis
Description :
Modification of the content of a getfem sparse matrix.
Command list :
gf_spmat_set(spmat S, 'clear'[, list I[, list J]])
Erase the non-zero entries of the matrix.
The optional arguments I and J may be specified to clear a sub-matrix instead of
the entire matrix.
gf_spmat_set(spmat S, 'scale', scalar v)
Multiplies the matrix by a scalar value v.
gf_spmat_set(spmat S, 'transpose')
Transpose the matrix.
gf_spmat_set(spmat S, 'conjugate')
Conjugate each element of the matrix.
gf_spmat_set(spmat S, 'transconj')
Transpose and conjugate the matrix.
gf_spmat_set(spmat S, 'to_csc')
Convert the matrix to CSC storage.
CSC storage is recommended for matrix-vector multiplications.
gf_spmat_set(spmat S, 'to_wsc')
Convert the matrix to WSC storage.
Read and write operation are quite fast with WSC storage.
gf_spmat_set(spmat S, 'to_complex')
Store complex numbers.
gf_spmat_set(spmat S, 'diag', mat D [, ivec E])
Change the diagonal (or sub-diagonals) of the matrix.
If E is given, D might be a matrix and each column of E will contain the sub-
diagonal number that will be filled with the corresponding column of D.
gf_spmat_set(spmat S, 'assign', ivec I, ivec J, mat V)
Copy V into the sub-matrix ‘M(I,J)’.
V might be a sparse matrix or a full matrix.
gf_spmat_set(spmat S, 'add', ivec I, ivec J, mat V)
7.49 gf_util
Synopsis
Description :
Performs various operations which do not fit elsewhere.
Command list :
gf_util('save matrix', string FMT, string FILENAME, mat A)
Exports a sparse matrix into the file named FILENAME, using Harwell-Boeing
(FMT=’hb’) or Matrix-Market (FMT=’mm’) formatting.
A = gf_util('load matrix', string FMT, string FILENAME)
Imports a sparse matrix from a file.
tl = gf_util('trace level' [, int level])
Set the verbosity of some GetFEM routines.
Typically the messages printed by the model bricks, 0 means no trace message
(default is 3). if no level is given, the current trace level is returned.
tl = gf_util('warning level', int level)
Filter the less important warnings displayed by getfem.
0 means no warnings, default level is 3. if no level is given, the current warning
level is returned.
7.50 gf_workspace
Synopsis
gf_workspace('push')
gf_workspace('pop', [,i,j, ...])
gf_workspace('stat')
gf_workspace('stats')
gf_workspace('keep', i[,j,k...])
gf_workspace('keep all')
gf_workspace('clear')
gf_workspace('clear all')
gf_workspace('class name', i)
Description :
GetFEM OO-commands
The toolbox comes with a set of MatLab objects mathworks-oo, (look at the @gf* sub-directories in
the toolbox directory). These object are no more than the getfem object handles, which are flagged by
MatLab as objects.
In order to use these objects, you have to call their constructors: gfMesh, gfMeshFem, gfGeoTrans,
gfFem, gfInteg. These constructor just call the corresponding GetFEM function (i.e. gf_mesh,
gf_mesh_fem, . . . ), and convert the structure returned by these function into a MatLab object. There
is also a gfObject function which converts any getfem handle into the corresponding MatLab object.
With such object, the most interesting feature is that you do not have to call the “long” functions
names gf_mesh_fem_get(obj,...), gf_slice_set(obj,...) etc., instead you just call
the shorter get(obj,...) or set(obj,...) whatever the type of obj is.
A small number of “pseudo-properties” are also defined on these objects, for example if m is a gfMesh
object, you can use directly m.nbpts instead of get(m, 'nbpts').
As an example:
143
Matlab Interface, Release 5.3
>> mf=gfMeshFem('load','many_element.mesh_fem')
gfMeshFem object: ID=5 [1600 bytes], qdim=1, nbdof=99,
linked gfMesh object: dim=3, nbpts=40, nbcvs=7
>> mf.mesh
gfMesh object ID=4 [11544 bytes], dim=3, nbpts=40, nbcvs=7
% accessing the linked mesh object
>> mf.mesh.nbpts
ans =
40
>> get(mf.mesh, 'pid_from_cvid', 3)
ans =
8 9 11 15 17 16 18 10 12
>> mf.nbdof
ans =
99
Although this interface seems more convenient, you must be aware that this always induce a call to a
mex-file, and additional MatLab code:
Hence you should always try to store data in MatLab arrays instead of repetitively calling the getfem
functions.
Avalaible object types are gfCvStruct, gfGeoTrans, gfEltm, gfInteg, gfFem, gfMesh,
gfMeshFem, gfMeshIm, gfMdBrick, gfMdState, gfModel, gfSpmat, gfPrecond, and
gfSlice.
A gfMeshSlice, 10
assembly, 6 gfModel, 10, 144
gfPrecond, 144
B gfSlice, 144
boundary, 13 gfSpmat, 144
integration method, 5
C interpolate, 5
convex id, 6 Lagrangian, 5
convexes, 5 Laplacian, 11
cvid, 6 memory management, 10
mesh, 5
D mesh nodes, 5
degrees of freedom, 5 mesh_fem, 6
dof, 5 mesh_im, 6
mex-file, 7
E model, 13
environment variable pid, 6
assembly, 6 point id, 6
boundary, 13 quadrature formula, 12
convex id, 6 quadrature formulas, 5
convexes, 5 reference convex, 5
cvid, 6 Von Mises, 18
degrees of freedom, 5
dof, 5 F
FEM, 5 FEM, 5
geometric transformation, 5
geometrical nodes, 5 G
gfCvStruct, 9, 144 geometric transformation, 5
gfEltm, 144 geometrical nodes, 5
gfFem, 9, 144 gfCvStruct, 9, 144
gfGeoTrans, 9, 144 gfEltm, 144
gfGlobalFunction, 9 gfFem, 9, 144
gfInteg, 9, 144 gfGeoTrans, 9, 144
gfMdBrick, 10, 144 gfGlobalFunction, 9
gfMdState, 10, 144 gfInteg, 9, 144
gfMesh, 9, 144 gfMdBrick, 10, 144
gfMeshFem, 10, 144 gfMdState, 10, 144
gfMeshIm, 144 gfMesh, 9, 144
gfMeshImM, 10 gfMeshFem, 10, 144
145
Matlab Interface, Release 5.3
gfMeshIm, 144
gfMeshImM, 10
gfMeshSlice, 10
gfModel, 10, 144
gfPrecond, 144
gfSlice, 144
gfSpmat, 144
I
integration method, 5
interpolate, 5
L
Lagrangian, 5
Laplacian, 11
M
memory management, 10
mesh, 5
mesh nodes, 5
mesh_fem, 6
mesh_im, 6
mex-file, 7
model, 13
P
pid, 6
point id, 6
Q
quadrature formula, 12
quadrature formulas, 5
R
reference convex, 5
V
Von Mises, 18
146 Index