-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainB.m
More file actions
47 lines (37 loc) · 1.02 KB
/
mainB.m
File metadata and controls
47 lines (37 loc) · 1.02 KB
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
% mainB
% Script to verify the pseudo-pressure algorithm.
%% PRE
% Init
L = 1; % mesh size [m]
XY = [0 L];
N = 10; % # of elements
mesh = msh.SquareMesh(XY, N);
% Find middle points
[~, indmc] = min( sum( abs(mesh.coor - L/2), 1 ) );
indmv = find(mesh.cn(4, :) == indmc);
if mod(mesh.Nx, 2) == 0
% is even
indm = [0 1] + indmv;
else
% is odd
indm = [0 2] + indmv;
end
%% TEST
% Arbitrary velocity field that fulfills global mass conservation
uv = zeros(2, mesh.NV);
uv(2, indm) = [-1 +1];
% Corrected velocity field
uvcorr = mesh.correction(uv);
%% POST
% Mass conservation verification: b = div(U)
[~, b] = mesh.cv.getPseudoPressure(mesh, uv);
[~, bcorr] = mesh.cv.getPseudoPressure(mesh, uvcorr);
% Print results
disp('Norm of div(U)');
disp(['- Before correction: ' num2str(norm(b))]);
disp(['- After correction: ' num2str(norm(bcorr))]);
% Plot velocity field: before & after
util.quiver(mesh, uv, true);
title('Velocity field before correction');
util.quiver(mesh, uvcorr, true);
title('Velocity field after correction');