% vytvori strukturu 'fem', ve ktere je kompletni zadani ulohy pro vypocet
% elasticke deformace v mikrostrukture lambda
addpath('./skripty','./elasticita','./../skripty','./../funkce');

flclear fem

% COMSOL version
clear vrsn
vrsn.name = 'COMSOL 3.3';
vrsn.ext = '';
vrsn.major = 0;
vrsn.build = 405;
vrsn.rcs = '$Name:  $';
vrsn.date = '$Date: 2006/08/31 18:03:47 $';
fem.version = vrsn;

% Geometry
lambda3Dgeom1

% Analyzed geometry
clear s
s.objs={g1,g2};
s.name={'g1','g2'};
s.tags={'g1','g2'};

fem.draw=struct('s',s);
fem.geom=geomgroup(fem,'imprint','off','paircand','none');

% Application mode 1
clear appl
appl.mode.class = 'SmeSolid3';
appl.module = 'SME';
appl.prop.elemdefault='Lag3';
appl.assignsuffix = '_smsld';
clear bnd
bnd.R = {0,{'u+x-Fx';'v+y-Fy';'w+z-Fz'},0};
bnd.constrcond = {'free','displacement','fixed'};
bnd.constrtype = {'standard','general','standard'};
bnd.ind = [1,1,1,1,1,1,1,1,1,2,1,1,1,3,1,2,1,1,1,1,1,1];
appl.bnd = bnd;
clear equ
equ.D = {{Cb(1,1),Cb(1,2),Cb(1,3),Cb(1,4),Cb(1,5),Cb(1,6); ...
Cb(1,2),Cb(2,2),Cb(2,3),Cb(2,4),Cb(2,5),Cb(2,6);Cb(1,3),Cb(2,3), ...
Cb(3,3),Cb(3,4),Cb(3,5),Cb(3,6);Cb(1,4),Cb(2,4),Cb(3,4),Cb(4,4), ...
Cb(4,5),Cb(4,6);Cb(1,5),Cb(2,5),Cb(3,5),Cb(4,5),Cb(5,5),Cb(5,6); ...
Cb(1,6),Cb(2,6),Cb(3,6),Cb(4,6),Cb(5,6),Cb(6,6)},{Cab(1,1), ...
Cab(1,2),Cab(1,3),Cab(1,4),Cab(1,5),Cab(1,6);Cab(1,2),Cab(2,2), ...
Cab(2,3),Cab(2,4),Cab(2,5),Cab(2,6);Cab(1,3),Cab(2,3),Cab(3,3), ...
Cab(3,4),Cab(3,5),Cab(3,6);Cab(1,4),Cab(2,4),Cab(3,4),Cab(4,4), ...
Cab(4,5),Cab(4,6);Cab(1,5),Cab(2,5),Cab(3,5),Cab(4,5),Cab(5,5), ...
Cab(5,6);Cab(1,6),Cab(2,6),Cab(3,6),Cab(4,6),Cab(5,6),Cab(6,6)}, ...
{Ci(1,1),Ci(1,2),Ci(1,3),Ci(1,4),Ci(1,5),Ci(1,6);Ci(1,2), ...
Ci(2,2),Ci(2,3),Ci(2,4),Ci(2,5),Ci(2,6);Ci(1,3),Ci(2,3),Ci(3,3), ...
Ci(3,4),Ci(3,5),Ci(3,6);Ci(1,4),Ci(2,4),Ci(3,4),Ci(4,4),Ci(4,5), ...
Ci(4,6);Ci(1,5),Ci(2,5),Ci(3,5),Ci(4,5),Ci(5,5),Ci(5,6);Ci(1,6), ...
Ci(2,6),Ci(3,6),Ci(4,6),Ci(5,6),Ci(6,6)},{Ccd(1,1),Ccd(1,2), ...
Ccd(1,3),Ccd(1,4),Ccd(1,5),Ccd(1,6);Ccd(1,2),Ccd(2,2),Ccd(2,3), ...
Ccd(2,4),Ccd(2,5),Ccd(2,6);Ccd(1,3),Ccd(2,3),Ccd(3,3),Ccd(3,4), ...
Ccd(3,5),Ccd(3,6);Ccd(1,4),Ccd(2,4),Ccd(3,4),Ccd(4,4),Ccd(4,5), ...
Ccd(4,6);Ccd(1,5),Ccd(2,5),Ccd(3,5),Ccd(4,5),Ccd(5,5),Ccd(5,6); ...
Ccd(1,6),Ccd(2,6),Ccd(3,6),Ccd(4,6),Ccd(5,6),Ccd(6,6)}};
equ.materialmodel = 'aniso';
equ.ind = [1,2,3,4];
appl.equ = equ;
fem.appl{1} = appl;
fem.frame = {'ref'};
fem.border = 1;
clear units;
units.basesystem = 'SI';
fem.units = units;

% Coupling variable elements
clear elemcpl
% Extrusion coupling variables
clear elem
elem.elem = 'elcplextr';
elem.g = {'1'};
src = cell(1,1);
clear bnd
bnd.expr = {{{},'u+x',{}},{{},'v+y',{}},{{},'w+z',{}},{{},{},'u+x'}, ...
    {{},{},'v+y'},{{},{},'w+z'}};
bnd.map = {{'1','1','1'},{'1','1','1'},{'1','1','1'},{'1','1','1'}, ...
    {'1','1','1'},{'1','1','1'}};
bnd.ind = {{'1','2','3','5','7','8','9','10','11','12','13','14','15', ...
'16','17','18','19','20','21','22'},{'4'},{'6'}};
src{1} = {{},{},bnd,{}};
elem.src = src;
geomdim = cell(1,1);
clear bnd
bnd.map = {{{},{},'2'},{{},{},'2'},{{},{},'2'},{{},'3',{}},{{},'3',{}}, ...
{{},'3',{}}};
bnd.ind = {{'1','2','3','4','5','6','7','8','9','11','12','13','14', ...
'15','17','18','19','20','21','22'},{'16'},{'10'}};
geomdim{1} = {{},{},bnd,{}};
elem.geomdim = geomdim;
elem.var = {'Fx','Fy','Fz','Fx','Fy','Fz'};
map = cell(1,3);
clear submap
submap.type = 'unit';
map{1} = submap;
clear submap
submap.type = 'linear';
submap.sg = '1';
submap.sv = {'11','14','20'};
submap.dg = '1';
submap.dv = {'2','4','8'};
map{2} = submap;
clear submap
submap.type = 'linear';
submap.sg = '1';
submap.sv = {'14','20','22'};
submap.dg = '1';
submap.dv = {'4','8','10'};
map{3} = submap;
elem.map = map;
elemcpl{1} = elem;
fem.elemcpl = elemcpl;

% Multiphysics
fem=multiphysics(fem);
