Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add passive scalars for readnek #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions readnek.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
% - metau: metadata for velocity field
% - metap: metadata for pressure field
% - metat: metadata for temperature field
% - metas: metadata for passive scalar field(s)
%
%
% Last edit: 20170810 Jacopo Canton ([email protected])
Expand All @@ -45,6 +46,7 @@
metau = [];
metap = [];
metat = [];
metas = [];

%--------------------------------------------------------------------------
% OPEN THE FILE
Expand Down Expand Up @@ -134,8 +136,8 @@
var(4) = 1;
end
if sum(fields == 'S') > 0
var(5) = 0; % TODO: scalars not implemented
disp('Passive scalars are not implemented')
ids = find(fields == 'S');
var(5) = sscanf(fields(ids+1:ids+2),'%d',1);
end
nfields = sum(var);
%
Expand Down Expand Up @@ -180,6 +182,11 @@
else
metat = [];
end
if var(5) ~= 0
metas = fread(infile,2*nel*var(5),'*float32');
else
metas = [];
end
end


Expand Down
12 changes: 9 additions & 3 deletions writenek.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
var(4) = 1;
end
if sum(fields == 'S') > 0
var(5) = 0; % TODO: scalars not implemented
disp('Passive scalars are not implemented')
ids = find(fields == 'S');
var(5) = sscanf(fields(ids+1:ids+2),'%d',1);
end
nfields = sum(var);
%
Expand Down Expand Up @@ -105,14 +105,20 @@
end
%
% write data
for ivar = 1:length(var)
for ivar = 1:4 % exclude passive scalar
idim0 = sum(var(1:ivar-1));
for iel = elmap
for idim = (1:var(ivar))+idim0
fwrite(outfile,data(iel,:,idim),realtype);
end
end
end
idim0 = sum(var(1:4)); % write passive scalars here
for idim = (1:var(5))+idim0
for iel = elmap
fwrite(outfile,data(iel,:,idim),realtype);
end
end

%--------------------------------------------------------------------------
% WRITE "METADATA": max and min of every field in every element
Expand Down