[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Getfem-users] Forces recovery

From: Yves Renard
Subject: Re: [Getfem-users] Forces recovery
Date: Mon, 29 Jan 2018 15:18:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

Dear Simon,

A priori, you computation seems ok to me. May be apart that you extract mesh vertex indices with gf_mesh_get(magn_mesh, 'pid'); and not the finite element node indices which are generally non-coinciding (use gf_mesh_fem_get instead of gf_mesh_get).

Of course, representing the force density would be simpler (and note that extraction/interpolation of values is easier with the use of interpolation functions. for instance gf_model_get(md, 'interpolation', 'mult_on_u', set_of_points | mf) can directly get you the value of an arbitrary _expression_ on a set of points or on a Lagrange fem).

Best regards,


Le 24/01/2018 à 10:32, SIMON AMEYE a écrit :

Hi all,


As I was not able to use the contact brick between two meshes, I now try to use another way:

I want to compute the forces at the boundary (dirichlet condition) with my first part.

And then, I want to use those forces on a second finite element analysis.

Everything is ok except I am not able to associate the forces I get with the correct nodes.

I use this code :


% End of the fem computation

gf_model_set(md, 'add generalized Dirichlet condition with multipliers', mim, 'u', mfu, 1,'VECTOR', 'H');

gf_model_get(md, 'solve');

U = gf_model_get(md, 'variable', 'u');

VM = gf_model_get(md, 'compute isotropic linearized Von Mises or Tresca', 'u', 'lambda', 'mu', mfdu);


% Forces recovery (from previous getfem++ thread)

% get the tangent matrix

tangent_matrix = gf_model_get(md, 'tangent_matrix');

% get the multipliers

mult = gf_model_get(md, 'variable', 'mult_on_u');

% mult2 = gf_model_get(md, 'variable', 'mult_on_u');


% get the number of multipliers and DOFs

nb_mult = size(mult,2);

nb_dof = gf_mesh_fem_get(mfu,'nbdof');


% part of the tangent matrix concerning the multipliers

    mult_matrix = zeros(nb_dof,nb_mult);

    for i = 1:nb_dof

        for j = 1:nb_mult

            mult_matrix(i,j) = tangent_matrix(nb_mult+i,j);




% computing the nodal forces by multiplying the multipliers

% with the right part of the tangent matrix

    nodalforce = -(mult_matrix*transpose(mult));


% extract the x-, y- components      

    for i = 0:(size(nodalforce,1)/2)-1

        nodalforce_x(i+1) = nodalforce(2*i+1);

        nodalforce_y(i+1) = nodalforce(2*i+2);



% Associate the forces with the nodes

[nodalforce_x,nodalforce_y] = GetTheForce(md,mfu,'mult_on_u');

F = [nodalforce_x' nodalforce_y'];

ID =  gf_mesh_get(magn_mesh, 'pid');

Coor = gf_mesh_get(magn_mesh, 'pts',ID)';

Coor = Coor(1:end,:);


% Plot the forces with segments on nodes

gf_plot(mfdu,VM,'deformed_mesh','on', 'deformation',U,'deformation_mf',mfu,'refine', 4, 'deformation_scale',DEFO_SCALE*100*0*mod(i,2));hold on;





Result :


As you can see with this result, the forces are not well located as there are forces outside the boundary.

(The boundary used for the dirichlet condition is the outside of the mesh)


Do anyone have a solution ?


Thank you again,








Apprenti IFP School






  Yves Renard (address@hidden)       tel : (33)
  Pole de Mathematiques, INSA-Lyon             fax : (33)
  20, rue Albert Einstein
  69621 Villeurbanne Cedex, FRANCE


reply via email to

[Prev in Thread] Current Thread [Next in Thread]