-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreadSw.m
93 lines (87 loc) · 2.87 KB
/
readSw.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
function [sw,tvec2] = readSw(fileName,Tend, Nx, Ny,Nz, tvec)
% readSw reads the adgprs output file .sim.timesteps.vars.txt file and
% plots the sw map at some given time steps and saves them in fig and emf
% formats.
% readSw(filename,Tend, Nx, Ny, tvec)
% Inputs:
% filename: input file name (string)
% Tend: end time of simulation ( last time that the simulation state
% variables are saved in the file)
% Nx, Ny: dimension of the reservoir
% tvec: vector of time steps that the saturation map should be plotted
% Note: Tend must be the last entry of tvec
% Outputs:
% X: a 2 dimensional matrix that contains the saturations at tvec
% Example:
% tvec = [210,420,630,840,1050,1260,1470,1680,3000];
% Tend = 3000;
% %fileName = 'OUTPUT1.sim.timesteps.vars.txt';
% fileName = 'D:\Academic\Research\sequential well placement\CLFD\60 by 60\failed_job.1.1\simForOptFiles\OUTPUT1.sim.timesteps.vars.txt'
% Nx = 60; Ny = 60;
% sw = readSw(fileName,Tend, Nx, Ny, tvec)
% -------------------------
% Written by Mehrdad Gharib Shirangi
% July 13 2013
tvec2 = [];
fid = fopen(fileName, 'r');
% format = '%s %s %f';
Nsteps = length(tvec);
% sw = zeros(Nx*Ny*Nz,Nsteps);
sw = [];
counter = 0;
format = '%f ';
for i = 1 : 13
format = [format '%f '];
end
disp(fileName);
while 1
tline = fgetl(fid);
if tline == -1
break
end
[time count ] = sscanf(tline(7:end),'%f');
disp(time)
% if (time == tvec(counter+1))
counter = counter+1;
%skip the next line (title line)
tline = fgetl(fid);
sat = zeros(Nx*Ny*Nz,1);
% for k = 1 : Nz
for i = 1 : Nz*Nx*Ny
tline = fgetl(fid);
[A count] = sscanf(tline,format);
%p T S1 S2 S3 Z1 Z2 Z3 X11 X21 X31 X12 X22 X32 X13 X23 X33
sat(i) = A(5); % oil saturation
end
% end
% sw(:,counter) = sat;
sw = [sw, sat];
tvec2 = [tvec2; time];
% else
% % the states at this time step are not required
% tline = fgetl(fid);
% for i = 1 : Nx*Ny
% fgetl(fid);
% end
% end
if (time == Tend), break, end
tline = fgetl(fid); % skip the empty line before each time step
end
fclose(fid);
close all
figure(1)
% set(gcf,'units','normalized','outerposition',[0 0 1 1]);
set(0,'defaultaxesfontsize',20);
set(0,'defaulttextfontsize',20);
% for counter = 1 : Nsteps
% swmap = reshape(sw(:,counter),60,60)';
% imagesc(swmap);
% colorbar;
% s = sprintf('sw%d',tvec(counter));
% saveas(gcf, s , 'emf')
% saveas(gcf, s, 'fig')
% s4 = [s '.pdf'];
% % saveas2(s4,500)
% end
%
%