/usr/lib/petscdir/3.7.7/x86_64-linux-gnu-complex-debug/share/petsc/matlab/PetscReadBinaryTrajectory.m is in libpetsc-complex-3.7.7-dbg 3.7.7+dfsg1-2build5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | function [varargout] = PetscBinaryReadTrajectory(inarg)
%
% [varargout] = PetscBinaryReadTrajectory(inarg)
%
% Read in the trajectory information saved in a folder of PETSc binary file
% Emit as Matlab struct
%
% Examples: A = PetscBinaryReadTrajectory('myfolder'); read from myfolder.
% A = PetscBinaryReadTrajectory(); read from folder 'SA-data' or 'Visualization-data' if they exist, SA-data has the priority.
%
if nargin < 1
if exist('SA-data','dir')
inarg = 'SA-data';
else if exist('Visualization-data','dir')
inarg = 'Visualization-data';
else
error('Can not find the folder of trajectory files!');
indices = 'int32';
precision = 'float64';
maxsteps = 10000;
t = zeros(1,maxsteps);
for stepnum=1:maxsteps
filename = sprintf('SA-%06d.bin',stepnum-1);
fullname = fullfile(inarg,filename);
if exist(fullname,'file') ~= 2
steps = stepnum-1;
break;
end
fd = PetscOpenFile(fullname);
header = double(read(fd,1,indices));
if isempty(header)
steps = stepnum-1;
break;
end
if header == 1211214 % Petsc Vec Object
%% Read state vector
m = double(read(fd,1,indices));
if (stepnum == 1)
x = zeros(m,maxsteps);
end
v = read(fd,m,precision);
x(:,stepnum) = v;
%% Read time
t(stepnum) = read(fd,1,precision);
end
% close the reader if we opened it
close(fd);
end
if size > 1
varargout{1} = {t(1:steps)};
varargout{2} = {x(:,1:steps)};
end
end
|