-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.m
69 lines (61 loc) · 1.95 KB
/
Main.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
66
67
68
69
close all; clear all; clc;
fclose('all');
addpath(genpath('Src'));
addpath(genpath('Tests'));
Sets = {};
Geos = {};
batchMode = 0;
inputMode = 8;
if batchMode
fid = fopen(fullfile('Src', 'Input', 'batchParameters.txt'));
tline = fgetl(fid);
tlines = cell(0,1);
while ischar(tline)
[Geo, Set] = menu_input(inputMode, batchMode);
eval(tline)
Sets{end+1} = Set;
Geos{end+1} = Geo;
tline = fgetl(fid);
clear Set Geo
end
fclose(fid);
else
[Geo,Set] = menu_input(inputMode, batchMode);
Sets{1} = Set;
Geos{1} = Geo;
tlines = {'"Single execution"'};
end
clear Geo Set
%delete(gcp('nocreate'));
%parpool(5);
for numLine = 1:length(Sets)
prevLog = '';
tStart = tic;
didNotConverge = false;
try
Geo = Geos{numLine};
Set = Sets{numLine};
Geo.log = sprintf('--------- SIMULATION STARTS ---------\n');
[Set, Geo, Dofs, t, tr, Geo_0, backupVars, Geo_n, numStep, relaxingNu, EnergiesPerTimeStep] = InitializeVertexModel(Set, Geo);
while t<=Set.tend && ~didNotConverge
if batchMode
if ~relaxingNu
disp(strcat('Simulation_', num2str(numLine), ' - Time: ', num2str(t)))
end
else
disp(strrep(Geo.log, prevLog, ''))
prevLog = Geo.log;
end
[Geo, Geo_n, Geo_0, Set, Dofs, EnergiesPerTimeStep, t, numStep, tr, relaxingNu, backupVars, didNotConverge] = IterateOverTime(Geo, Geo_n, Geo_0, Set, Dofs, EnergiesPerTimeStep, t, numStep, tr, relaxingNu, backupVars);
end
catch ME
disp(ME.message)
Geo.log = sprintf("%s\n ERROR: %s", Geo.log, ME.message);
end
tEnd = duration(seconds(toc(tStart)));
tEnd.Format = 'hh:mm:ss';
Geo.log = sprintf("%s Total real run time %s \n", Geo.log, tEnd);
fid = fopen(Set.log, 'wt');
fprintf(fid, '%s\n', Geo.log);
fclose(fid);
end