Undefined function ‘ ‘ for input arguments of type ‘gpuArray’. – Why ?
So Im using Paralell Computing Toolbox v. 23.2, on R2023b and having this problem when passing an array from one function to another, and can’t seem to understand what is causing this.
My nested loop looks like this, everything is initiated correctly in its running, except for when I add the nu_t term.
for t_n = 1:t-1
for i = 2:length(X) – 1
for j = 2:length(Y) – 1
nu_t = addTurbulentViscotiy(U_temp, C_s, Delta)
end
end
U_temp = applyNoSlipBoundary(U_temp, t_n);
P_temp = applyNeumannBoundary(P_temp, t_n);
end
And the function that doesnt work looks like this:
function [nu_t] = addTurbulentViscotiy(U, C_s, Delta)
% Computing the strain rate tensor components for S
S_11 = (U(t_n, i+1, j, 1) – U(t_n, i-1, j, 1)) / (2 * Delta);
S_22 = (U(t_n, i, j+1, 2) – U(t_n, i, j-1, 2)) / (2 * Delta);
S_12 = 0.5 * ((U(t_n, i, j+1, 1) – U(t_n, i, j-1, 1)) / (2 * Delta) …
+ (U(t_n, i+1, j, 2) – U(t_n, i-1, j, 2)) / (2 * Delta));
S_21 = S_12;
% Calculating the magnitude of S
S_mag = sqrt(S_11.^2 + S_22.^2 + 2* S12.^2);
% Calculating the turbulent Viscocity
nu_t = (C_s*Delta).^2*S_mag
end
However, these function work. Its the same values being passed:
function [U_bound] = applyNoSlipBoundary(U_field, t_n)
U_field(t_n + 1, 1, :, π = 0; % Top boundary
U_field(t_n + 1, end, :, π = 0; % Bottom boundary
U_field(t_n + 1, :, 1, π = 0; % Left boundary
U_field(t_n + 1, :, end, π = 0; % Right boundary
U_bound = U_field;
end
% Apply Neumann boundary conditions (zero gradient)
function [P_bound] = applyNeumannBoundary(P_temp, t_n)
P_temp(t_n + 1, 1, π = P_temp(t_n + 1, 2, :); % Top boundary
P_temp(t_n + 1, end, π = P_temp(t_n + 1, end-1, :); % Bottom boundary
P_temp(t_n + 1, :, 1) = P_temp(t_n + 1, :, 2); % Left boundary
P_temp(t_n + 1, :, end) = P_temp(t_n + 1, :, end-1); % Right boundary
P_bound = P_temp;
end
The error gotten is
Undefined function ‘NSsolverTest2’ for input arguments of type ‘gpuArray’.
The functions are in the same file, altough not nested.
Why do they work in one function but not the other? What is causing this I looked through the documentations but can’t find anything there. The only difference is where in the loop theyre being called. Anybody that could help me figure this out?
Thanks in advance!So Im using Paralell Computing Toolbox v. 23.2, on R2023b and having this problem when passing an array from one function to another, and can’t seem to understand what is causing this.
My nested loop looks like this, everything is initiated correctly in its running, except for when I add the nu_t term.
for t_n = 1:t-1
for i = 2:length(X) – 1
for j = 2:length(Y) – 1
nu_t = addTurbulentViscotiy(U_temp, C_s, Delta)
end
end
U_temp = applyNoSlipBoundary(U_temp, t_n);
P_temp = applyNeumannBoundary(P_temp, t_n);
end
And the function that doesnt work looks like this:
function [nu_t] = addTurbulentViscotiy(U, C_s, Delta)
% Computing the strain rate tensor components for S
S_11 = (U(t_n, i+1, j, 1) – U(t_n, i-1, j, 1)) / (2 * Delta);
S_22 = (U(t_n, i, j+1, 2) – U(t_n, i, j-1, 2)) / (2 * Delta);
S_12 = 0.5 * ((U(t_n, i, j+1, 1) – U(t_n, i, j-1, 1)) / (2 * Delta) …
+ (U(t_n, i+1, j, 2) – U(t_n, i-1, j, 2)) / (2 * Delta));
S_21 = S_12;
% Calculating the magnitude of S
S_mag = sqrt(S_11.^2 + S_22.^2 + 2* S12.^2);
% Calculating the turbulent Viscocity
nu_t = (C_s*Delta).^2*S_mag
end
However, these function work. Its the same values being passed:
function [U_bound] = applyNoSlipBoundary(U_field, t_n)
U_field(t_n + 1, 1, :, π = 0; % Top boundary
U_field(t_n + 1, end, :, π = 0; % Bottom boundary
U_field(t_n + 1, :, 1, π = 0; % Left boundary
U_field(t_n + 1, :, end, π = 0; % Right boundary
U_bound = U_field;
end
% Apply Neumann boundary conditions (zero gradient)
function [P_bound] = applyNeumannBoundary(P_temp, t_n)
P_temp(t_n + 1, 1, π = P_temp(t_n + 1, 2, :); % Top boundary
P_temp(t_n + 1, end, π = P_temp(t_n + 1, end-1, :); % Bottom boundary
P_temp(t_n + 1, :, 1) = P_temp(t_n + 1, :, 2); % Left boundary
P_temp(t_n + 1, :, end) = P_temp(t_n + 1, :, end-1); % Right boundary
P_bound = P_temp;
end
The error gotten is
Undefined function ‘NSsolverTest2’ for input arguments of type ‘gpuArray’.
The functions are in the same file, altough not nested.
Why do they work in one function but not the other? What is causing this I looked through the documentations but can’t find anything there. The only difference is where in the loop theyre being called. Anybody that could help me figure this out?
Thanks in advance!Β So Im using Paralell Computing Toolbox v. 23.2, on R2023b and having this problem when passing an array from one function to another, and can’t seem to understand what is causing this.
My nested loop looks like this, everything is initiated correctly in its running, except for when I add the nu_t term.
for t_n = 1:t-1
for i = 2:length(X) – 1
for j = 2:length(Y) – 1
nu_t = addTurbulentViscotiy(U_temp, C_s, Delta)
end
end
U_temp = applyNoSlipBoundary(U_temp, t_n);
P_temp = applyNeumannBoundary(P_temp, t_n);
end
And the function that doesnt work looks like this:
function [nu_t] = addTurbulentViscotiy(U, C_s, Delta)
% Computing the strain rate tensor components for S
S_11 = (U(t_n, i+1, j, 1) – U(t_n, i-1, j, 1)) / (2 * Delta);
S_22 = (U(t_n, i, j+1, 2) – U(t_n, i, j-1, 2)) / (2 * Delta);
S_12 = 0.5 * ((U(t_n, i, j+1, 1) – U(t_n, i, j-1, 1)) / (2 * Delta) …
+ (U(t_n, i+1, j, 2) – U(t_n, i-1, j, 2)) / (2 * Delta));
S_21 = S_12;
% Calculating the magnitude of S
S_mag = sqrt(S_11.^2 + S_22.^2 + 2* S12.^2);
% Calculating the turbulent Viscocity
nu_t = (C_s*Delta).^2*S_mag
end
However, these function work. Its the same values being passed:
function [U_bound] = applyNoSlipBoundary(U_field, t_n)
U_field(t_n + 1, 1, :, π = 0; % Top boundary
U_field(t_n + 1, end, :, π = 0; % Bottom boundary
U_field(t_n + 1, :, 1, π = 0; % Left boundary
U_field(t_n + 1, :, end, π = 0; % Right boundary
U_bound = U_field;
end
% Apply Neumann boundary conditions (zero gradient)
function [P_bound] = applyNeumannBoundary(P_temp, t_n)
P_temp(t_n + 1, 1, π = P_temp(t_n + 1, 2, :); % Top boundary
P_temp(t_n + 1, end, π = P_temp(t_n + 1, end-1, :); % Bottom boundary
P_temp(t_n + 1, :, 1) = P_temp(t_n + 1, :, 2); % Left boundary
P_temp(t_n + 1, :, end) = P_temp(t_n + 1, :, end-1); % Right boundary
P_bound = P_temp;
end
The error gotten is
Undefined function ‘NSsolverTest2’ for input arguments of type ‘gpuArray’.
The functions are in the same file, altough not nested.
Why do they work in one function but not the other? What is causing this I looked through the documentations but can’t find anything there. The only difference is where in the loop theyre being called. Anybody that could help me figure this out?
Thanks in advance!Β parallel computing toolbox, gpu, arrays, function, embedded matlab functionΒ MATLAB Answers β New Questions
β