forked from jaolive/SiStER
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SiStER_thermal_update.m
67 lines (53 loc) · 1.49 KB
/
SiStER_thermal_update.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
% SiStER THERMAL SOLVE
% get previous temperature on nodes
[n2interp] = SiStER_interp_markers_to_shear_nodes(xm,ym,icn,jcn,qd,x,y,Tm);
Told(:,:) = n2interp(1).data;
% enforce Dirichlet boundary conditions to avoid mismatch between markers
% and nodes
if BCtherm.top(1)==1
Told(1,:)=BCtherm.top(2);
end
if BCtherm.bot(1)==1
Told(Ny,:)=BCtherm.bot(2);
end
if BCtherm.left(1)==1
Told(:,1)=BCtherm.left(2);
end
if BCtherm.right(1)==1
Told(:,Nx)=BCtherm.right(2);
end
% GET VARIABLE DIFFUSIVITY AND CP
if isfield(MAT,'cp')==0 || isfield(MAT,'k')==0
cpfield=PARAMS.cpref*ones(size(T));
kfield=PARAMS.kref*ones(size(T));
rhofield=PARAMS.rhoref*ones(size(T));
else
[km, cpm]=SiStER_get_thermal_properties(im,MAT);
[rhom]=SiStER_get_density(im,Tm,MAT);
[n2interp] = SiStER_interp_markers_to_shear_nodes(xm,ym,icn,jcn,qd,x,y,km,cpm,rhom);
kfield=n2interp(1).data;
cpfield=n2interp(2).data;
rhofield=n2interp(3).data;
end
% THERMAL SOLVE
[T]=SiStER_thermal_solver_sparse_CFD(x,y,Told,rhofield,cpfield,kfield,dt_m,BCtherm,zeros(size(T)));
% temperature change
dT=T-Told;
% enforce Dirichlet boundary conditions to avoid mismatch between markers
% and nodes
if BCtherm.top(1)==1
dT(1,:)=0;
end
if BCtherm.bot(1)==1
dT(Ny,:)=0;
end
if BCtherm.left(1)==1
dT(:,1)=0;
end
if BCtherm.right(1)==1
dT(:,Nx)=0;
end
[Tm]=SiStER_interp_shear_nodes_to_markers(T,x,y,xm,ym,icn,jcn);
if PARAMS.ynTreset==1 % reset T=T0 in top layer
Tm(im==1)=PARAMS.T0;
end