Hi Todd, really appreciate your help. I looked into the vtk files. Is it true that the problem starts from POINTS data. Sorry for keeping asking stupid questions.
Below is the part of Matlab code used to save the data into vtk files. Do you notice any obvious mistake that could cause the problem.
function PlotReservoirSolution(obj, Reservoir, Grid)
%Write a VTK file for Reservoir
fileID = fopen(strcat(obj.FileName, '_Reservoir', num2str(obj.VTKindex,'%04d'),'.vtk'), 'w');
fprintf(fileID, '# vtk DataFile Version 2.0\n');
fprintf(fileID, 'DARSim 2 Reservoir Simulator\n');
if obj.isBinary
fprintf(fileID, 'BINARY\n');
else
fprintf(fileID, 'ASCII\n');
end
fprintf(fileID, '\n');
%
fprintf(fileID, 'DATASET UNSTRUCTURED_GRID\n');
VTK_Nodes = Grid.CornerPointGridData.Nodes;
if Grid.CornerPointGridData.N_TotalCells ~= Grid.CornerPointGridData.N_ActiveCells
obj.ReferenceDepth = max(VTK_Nodes(:,3));
% If the domain is a Cartesian box, there is no need to invert the Z coordinates.
% But if the domain is not a Cartesian boxTherefore, the Z coordinates are inverted only for the sake of the visualization.
VTK_Nodes(:,3) = obj.ReferenceDepth - VTK_Nodes(:,3);
end
fprintf(fileID, ['POINTS ' num2str(Grid.CornerPointGridData.N_Nodes) ' double\n']);
if obj.isBinary
fwrite(fileID, VTK_Nodes','float', 'b');
else
fprintf(fileID, '%f %f %f\n',VTK_Nodes');
end
fprintf(fileID, '\n');
%
fprintf(fileID, ['CELLS ' num2str(Grid.N) ' ' num2str(Grid.N*(1+8)) '\n']);
indMatrix = horzcat(8*ones(Grid.N,1) , Grid.CornerPointGridData.Cells.Vertices-1 );
if obj.isBinary
fwrite(fileID, indMatrix','float', 'b');
else
fprintf(fileID, '%d %d %d %d %d %d %d %d %d\n', indMatrix');
end
fprintf(fileID, '\n');
%
fprintf(fileID, ['CELL_TYPES ' num2str(Grid.N) '\n']);
if obj.isBinary
fwrite(fileID, 11*ones(1,Grid.N),'float', 'b');
else
fprintf(fileID, '%d ', 11*ones(1,Grid.N));
end
fprintf(fileID, '\n\n');
% Print all existing variables
fprintf(fileID, 'CELL_DATA %d\n', Grid.N);
N_var = double(Reservoir.State.Properties.Count);
Names = Reservoir.State.Properties.keys;
for i=1:N_var
if strcmp(Reservoir.State.Properties(Names{i}).Type, 'scalar')
obj.PrintScalar2VTK(fileID, Reservoir.State.Properties(Names{i}).Value, [' ',Names{i}]);
else
obj.PrintVector2VTK(fileID, Reservoir.State.Properties(Names{i}).Value, [' ',Names{i}]);
end
fprintf(fileID, '\n');
end
% Add the "isFractured" flag for reservoir grid cells that are overlapped by a fracture (if any)
if ~isempty(Grid.ListOfFracturedReservoirCells)
isFractured = zeros(Grid.N,1);
isFractured(Grid.ListOfFracturedReservoirCells) = 1;
obj.PrintScalar2VTK(fileID, isFractured, ' isFractured');
fprintf(fileID, '\n');
end
% Add the "isPerforated" flag for reservoir grid cells that are overlapped by a fracture (if any)
if ~isempty(Grid.ListOfPerforatedCells)
isPerforated = zeros(Grid.N,1);
isPerforated(Grid.ListOfPerforatedCells) = 1;
obj.PrintScalar2VTK(fileID, isPerforated, ' isPerforated');
fprintf(fileID, '\n');
end
% Add the cell indices
obj.PrintScalar2VTK(fileID, [1:Grid.N]', ' Index');
fprintf(fileID, '\n');
% Add the cell volumes
obj.PrintScalar2VTK(fileID, Grid.Volume, ' Volume');
fprintf(fileID, '\n');
% Add ADM ACTIVETime
obj.PrintScalar2VTK(fileID, Grid.ActiveTime, ' ACTIVETime');
fprintf(fileID, '\n');
% Add ADM ACTIVEFine (coarse grids)
obj.PrintScalar2VTK(fileID, Grid.Active, ' ACTIVEFine');
fprintf(fileID, '\n');
fclose(fileID);
if obj.PlotInterfaces
obj.PlotInternalFaces(Reservoir, Grid);
end
end