Commit fa55e1d9 authored by Andreas Zilian's avatar Andreas Zilian
Browse files

Make sure internal variable is intialised.

parent 1cf0f84d
......@@ -38,8 +38,6 @@ classdef FeProblem < handle
end
%% assemble system K matrix
function A = assembleSystemStiffnessMatrix(self)
tic
% create system stiffness matrix
est_entries = round( length(self.elems) * 12*12 * 1.10 );
num_entries = 0;
......@@ -62,41 +60,58 @@ classdef FeProblem < handle
num_entries = num_entries + e_size;
end
A = sparse( id1(1:num_entries), id2(1:num_entries), mat(1:num_entries) );
toc
return
tic
%
%A = self.assembleSystemStiffnessMatrixElastic() + self.assembleSystemStiffnessMatrixGeometric();
end
%% assemble system K matrix: elastic
function A = assembleSystemStiffnessMatrixElastic(self)
% create system stiffness matrix
id1 = zeros(0,1);
id2 = zeros(0,1);
mat = zeros(0,1);
est_entries = round( length(self.elems) * 12*12 * 1.10 );
num_entries = 0;
id1 = zeros(est_entries,1);
id2 = zeros(est_entries,1);
mat = zeros(est_entries,1);
% loop over all elements and collect element stiffness matrices
for elem = self.elems
% get element index vector
e_idx = elem.getDofSysIndices();
% get element matrix
e_mat = elem.stiffness();
e_mat = elem.stiffnessElastic();
% determine number of entries
e_size = length(e_idx)^2;
% add element contribution to system matrix
id1 = [ id1, repmat( e_idx, 1, length(e_idx) ) ]; % TODO: clean up here
id2 = [ id2; reshape( repmat( e_idx, length(e_idx), 1 ), [], 1 ) ];
mat = [ mat; reshape( e_mat', [], 1 ) ];
id1(1+num_entries:num_entries+e_size) = repmat( e_idx, 1, length(e_idx) );
id2(1+num_entries:num_entries+e_size) = reshape( repmat( e_idx, length(e_idx), 1 ), [], 1 );
mat(1+num_entries:num_entries+e_size) = reshape( e_mat', [], 1 );
% add up to total number of entries
num_entries = num_entries + e_size;
end
A = sparse( id1, id2, mat );
toc
tic
% create system mass matrix
A = sparse(self.ndofs, self.ndofs);
% loop over all elements and collect element mass matrices
A = sparse( id1(1:num_entries), id2(1:num_entries), mat(1:num_entries) );
end
%% assemble system K matrix: geometric
function A = assembleSystemStiffnessMatrixGeometric(self)
% create system stiffness matrix
est_entries = round( length(self.elems) * 12*12 * 1.10 );
num_entries = 0;
id1 = zeros(est_entries,1);
id2 = zeros(est_entries,1);
mat = zeros(est_entries,1);
% loop over all elements and collect element stiffness matrices
for elem = self.elems
% get element index vector
e_idx = elem.getDofSysIndices();
% get element matrix
e_mat = elem.stiffness();
e_mat = elem.stiffnessGeometric();
% determine number of entries
e_size = length(e_idx)^2;
% add element contribution to system matrix
A(e_idx,e_idx) = A(e_idx,e_idx) + e_mat;
id1(1+num_entries:num_entries+e_size) = repmat( e_idx, 1, length(e_idx) );
id2(1+num_entries:num_entries+e_size) = reshape( repmat( e_idx, length(e_idx), 1 ), [], 1 );
mat(1+num_entries:num_entries+e_size) = reshape( e_mat', [], 1 );
% add up to total number of entries
num_entries = num_entries + e_size;
end
toc
A = sparse( id1(1:num_entries), id2(1:num_entries), mat(1:num_entries) );
end
%% assemble system M matrix
function A = assembleSystemMassMatrix(self)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment