Dear Ronan,
You have to define both the two level-set functions. A levelset object can
contain in fact two level-set functions. This is due to the fact that the goal
was to model a crack geometry. The first level-set describe the geometry of the
crack and the second one the crack front (the intersection of the two level-
set is the crack front). This is rather standard. The two level-set functions
have to be such that the iso-values are nearly orthogonal and define a system
of coordinate. So x,y is defined relatively to this system of coordinate whan
level-set are used.
Moreoever, you have to replace 'outside' by 'inside' in your mesh_im (and in
fact you can use a regular integration method in your case). this gives:
m = gfMesh('cartesian', 0:1, 0:1); % Unit square with only one element.
gf = gfGlobalFunction('parser', '1'); % Global function is 1.
ls = gfLevelSet(m, 1, 'x-2', 'y-2');
mls = gfMeshLevelSet(m);
mls.set('add', ls);
mfg = gfMeshFem('global function', m, ls, {gf});
mim = gf_mesh_im(m, gf_integ('IM_QUAD(3)'));
volume = gf_asm('volumic', m.get('cvid'), 'V(#1)+=comp(Base(#1))(:)', mim,
mfg);
But of course, you are right, it should be possible to use it without a level-
set (but this is not possible for the moment even in the c++ code). In fact it
would be sufficient to define a "global_function_not_on_levelseté similar to
"global_function_on_levelset" in getfem_mesh_fem_global_function.cc and
interface it in gf_mesh_fem.cc.
Yves.
On jeudi 14 octobre 2010, Ronan Perrussel wrote:
Dear getfem users,
I am still trying to use gf_global_function with the Matlab interface.
It seems not possible to use gf_global_function under the Matlab
interface without using levelset (but it is possible in C++) and I try
to understand how it works.
I try a (new) stupid example to understand :
m = gfMesh('cartesian', 0:1, 0:1); % Unit square with only one element.
gf = gfGlobalFunction('parser', '1'); % Global function is 1.
ls = gfLevelSet(m, 1);
ls.set('values', 'x-2.'); % With this levelset p(x, y)< 0 inside the
domain.
mls = gfMeshLevelSet(m);
mls.set('add', ls);
mfg = gfMeshFem('global function', m, ls, {gf});
mils = gf_mesh_im('levelset', mls, 'outside', gf_integ('IM_QUAD(3)'));
volume = gf_asm('volumic', m.get('cvid'), 'V(#1)+=comp(Base(#1))(:)',
mils, mfg); % I integrate my global function over the whole domain.
As my global function is 1 over the domain (and the mesh contains only
one element), I thought that I would obtain the area of the domain but I
just got zero. What is wrong?
Thank you in advance for your advice,
Best regards,
Ronan