function solvemodel(event)

frame=event;

fem=getdata(frame);

%Declare variables
lq=0;
lTinf=0;
lh=0;
lT=0;
rq=0;
rTinf=0;
rh=0;
rT=0;
tq=0;
tTinf=0;
th=0;
tT=0;
bq=0;
bTinf=0;
bh=0;
bT=0;

% Read data from input fields
source=frame.get('source').getValue;
cond=frame.get('cond').getValue;

bndtypes = {'q','T','q0'};
leftbc=bndtypes{frame.get('leftbc').getSelectedIndex};
rightbc=bndtypes{frame.get('rightbc').getSelectedIndex};
bottombc=bndtypes{frame.get('bottombc').getSelectedIndex};
topbc=bndtypes{frame.get('topbc').getSelectedIndex};

if strcmp(leftbc,bndtypes{1})
    lq=frame.get('lq').getValue;
    lTinf=frame.get('lTinf').getValue;
    lh=frame.get('lh').getValue;
elseif strcmp(leftbc,bndtypes{2})
    lT=frame.get('lT').getValue;
end

if strcmp(rightbc,bndtypes{1})
    rq=frame.get('rq').getValue;
    rTinf=frame.get('rTinf').getValue;
    rh=frame.get('rh').getValue;
elseif strcmp(rightbc,bndtypes{2})
    rT=frame.get('rT').getValue;
end

if strcmp(topbc,bndtypes{1})
    tq=frame.get('tq').getValue;
    tTinf=frame.get('tTinf').getValue;
    th=frame.get('th').getValue;
elseif strcmp(topbc,bndtypes{2})
    tT=frame.get('tT').getValue;
end

if strcmp(bottombc,bndtypes{1})
    bq=frame.get('bq').getValue;
    bTinf=frame.get('bTinf').getValue;
    bh=frame.get('bh').getValue;
elseif strcmp(bottombc,bndtypes{2})
    bT=frame.get('bT').getValue;
end

meshorder=frame.get('meshorder').getSelectedIndex;

if meshorder==1
 type={'shlag(1,''T'')'};
 gp=2;
 cp=1;
else
 type={'shlag(2,''T'')'};
 gp=4;
 cp=2;
end

bndtype = {rightbc,leftbc,bottombc,topbc};

% Application mode 1
clear appl
appl.mode.class = 'HeatTransfer';
appl.shape = type;
appl.gporder = gp;
appl.cporder = cp;
appl.assignsuffix = '_ht';
clear prop
prop.analysis='static';
appl.prop = prop;
clear bnd
bnd.type = bndtype;
bnd.h = {rh,lh,bh,th};
bnd.T0 = {rT,lT,bT,tT};
bnd.Tinf = {rTinf,lTinf,bTinf,tTinf};
bnd.q0 = {rq,lq,bq,tq};
bnd.ind = [2,3,4,1];
appl.bnd = bnd;
clear equ
equ.k = cond;
equ.Q = source;
equ.ind = [1];
appl.equ = equ;
fem.appl{1} = appl;
fem.frame = {'ref'};
fem.border = 1;
fem.outform = 'general';
fem.units = 'SI';

% Multiphysics
fem=multiphysics(fem);

% Extend mesh
fem.xmesh=meshextend(fem);

% Solve problem
fem.sol=femnlin(fem);

storedata(frame,fem);

plotmodel(event);
