getfem-users
[Top][All Lists]
Advanced

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

Performance differences in different MATLAB interface


From: Moritz Jena
Subject: Performance differences in different MATLAB interface
Date: Wed, 5 Aug 2020 15:37:28 +0200

Dear Getfem-users,

due to a change in our system architecture from Windows 32Bit to 64Bit, our numerical calculation core has to be updated.
Currently we are working with the MATLAB interface of GetFEM version 4.2.

During tests with the available MATLAB interface of GetFEM version 5.2 I noticed that it works much slower
than the interface of version 4.2.

The tests were performed with different test programs of our numerical calculation core.
The runtime difference can be determined to be approximately four times higher.

Can anyone explain to me, using the attached test program, where this difference could come from?
Are there differences in the implementation of the functions in the different versions?

With best regards,

Moritz Jena        


Example test-program: Runtime difference: v4.2 * 3.6 = v5.2 (v4.3: 12.35s vs. v5.2: 44.96s)

%%  ---------- Mesh ----------
L = 10;
m = gfMesh('cartesian', 0:.5:L, 0:.5:1, 0:.5:1);

%% ---------- FEM ----------
n = gf_mesh_get(m, 'dim');
k = 1; % Degree

% FEM u
f =  gf_fem(sprintf('FEM_QK(%d,%d)',n,k));
mfu = gf_mesh_fem(m,3); gf_mesh_fem_set(mfu, 'fem', f);

% FEM Von Mises
f2 = gf_fem(sprintf('FEM_QK_DISCONTINUOUS(%d,1)', n));
mfvm = gf_mesh_fem(m,1);  gf_mesh_fem_set(mfvm, 'fem', f2);

%% ---------- IM ----------
k_i = 2*k;
INTEG_TYPE = sprintf('IM_GAUSS_PARALLELEPIPED(%d,%d)',n,k_i);
im = gf_integ(INTEG_TYPE); mim = gf_mesh_im(m,im);

%% ---------- region ----------
P = get(m,'pts');
boundary_left = gf_mesh_get(m, 'faces from pid', find(abs(P(1,:))<1e-6));
boundary_right = gf_mesh_get(m, 'faces from pid', find(abs(P(1,:) - L)<1e-6));
gf_mesh_set(m, 'region', 1, boundary_left);
gf_mesh_set(m, 'region', 2, boundary_right);

%% ---------- data ----------
E = 200000;
nu = 0.3;
% Lamé
lambda = nu*E/((1+nu)*(1-2*nu));
mu = E/(2*(1+nu));
%% ---------- model ----------
md = gf_model('real');

gf_model_set(md, 'add fem variable', 'u', mfu);
gf_model_set(md, 'add initialized data', 'lambda', lambda);
gf_model_set(md, 'add initialized data', 'mu', mu);

gf_model_set(md, 'add isotropic linearized elasticity brick', ...
    mim, 'u', 'lambda', 'mu');

% homogenous Dirichlet on the left (region 1)
% gf_model_set(md, 'add Dirichlet condition with penalization', ...
%       mim, 'u', 1e10, 1);
gf_model_set(md, 'add Dirichlet condition with multipliers', ...
    mim, 'u', mfu, 1);

alt = 1; %alternative 1 Force, alternative 2 Displacement

% alternative 1: Force on the right side (region 2)
if alt ==1
    F = [0 -100 0];
    gf_model_set(md, 'add initialized data', 'Kraft', F);
    gf_model_set(md, 'add source term brick', mim, 'u', 'Kraft', 2);
else
    % alternative 2: Displacement on the right side (region 2)
    diri = [0 -1.5 0];
    gf_model_set(md, 'add initialized data', 'dirichletdata', diri);
    gf_model_set(md, 'add Dirichlet condition with penalization', ...
        mim, 'u', 1e10, 2);
    %       gf_model_set(md, 'add Dirichlet condition with multipliers', ...
    %     mim, 'u', mfu, 2, 'dirichletdata');
end

%% ---------- solving ----------
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', mfvm);

figure
gf_plot(mfvm,VM, 'deformation',u, 'deformation_mf',mfu, 'deformed_mesh', ...
    'on', 'cvlst', get(m, 'outer faces'), 'deformation_scale', 1, ...
    'disp_options', 'off');
colorbar;
xlabel('x'); ylabel('y'); zlabel('z');
reply via email to

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