clear; clc;
mrstModule add ad-core ad-props co2lab coarsegrid mrst-gui
load('HSG_G.mat');
load('HSG_rock.mat');
A = diff(G.cells.facePos);
B = find(A ~= 6);
C = A(B, :);
D = G.cells.centroids(B, :);
index = [B, C, D];
writematrix(index, 'SQF_index.txt');
figure('Position', [200, 200, 1000, 800]);
hold on;
plotGrid(G, 'FaceColor', 'none', 'EdgeColor', [0.8, 0.8, 0.8]);
plot3(D(:, 1), D(:, 2), D(:, 3), 'ro', 'MarkerSize', 10, 'MarkerFaceColor', 'r');
xlabel('X-coordinate');
ylabel('Y-coordinate');
zlabel('Z-coordinate');
title('Non-Hexahedral Cells in the Mesh');
view(3);
grid on;
hold off;