Skip to content

Commit

Permalink
[matlab] Replace magic number domain types
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Feb 28, 2023
1 parent c5974c9 commit 92dfb97
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 28 deletions.
10 changes: 4 additions & 6 deletions interfaces/matlab/toolbox/1D/@Domain1D/domainType.m
@@ -1,12 +1,10 @@
function i = domainType(d)
function v = domainType(d)
% DOMAINTYPE Get the type of domain.
% i = domainType(d)
% v = domainType(d)
% :param d:
% Instance of class :mat:func:`Domain1D`
% :return:
% This function returns an integer flag denoting the domain
% type.
% This function returns a string describing the domain type.
%

i = domain_methods(d.dom_id, 12);

v = domain_methods(d.dom_id, 12);
9 changes: 2 additions & 7 deletions interfaces/matlab/toolbox/1D/@Domain1D/isFlow.m
Expand Up @@ -7,11 +7,6 @@
% 1 if the domain is a flow domain, and 0 otherwise.
%

t = domainType(d);

% See Domain1D.h for definitions of constants
if t < 100
a = 1;
else
a = 0;
v = domainType(d);
a = int8(strcmp(v, 'free-flow') || strcmp(v, 'stagnation-flow'));
end
6 changes: 1 addition & 5 deletions interfaces/matlab/toolbox/1D/@Domain1D/isInlet.m
Expand Up @@ -7,9 +7,5 @@
% 1 if the domain is an inlet, and 0 otherwise.
%

t = domainType(d);
if t == 104
a = 1;
else
a = 0;
a = int8(strcmp(domainType(d), 'inlet'));
end
6 changes: 1 addition & 5 deletions interfaces/matlab/toolbox/1D/@Domain1D/isSurface.m
Expand Up @@ -7,9 +7,5 @@
% 1 if the domain is a surface, and 0 otherwise.
%

t = domainType(d);
if t == 102
a = 1;
else
a = 0;
a = int8(strcmp(domainType(d), 'surface'));
end
16 changes: 11 additions & 5 deletions src/matlab/onedimmethods.cpp
Expand Up @@ -99,6 +99,16 @@ void onedimmethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
} else if (job == 12) {
checkNArgs(3, nrhs);
int buflen = domain_type3(dom, 0, 0);
char* output_buf = (char*)mxCalloc(buflen, sizeof(char));
int iok = domain_type3(dom, buflen, output_buf);
if (iok < 0) {
reportError();
}
plhs[0] = mxCreateString(output_buf);
return;
} else if (job < 40) {
// methods
int k;
Expand All @@ -112,10 +122,6 @@ void onedimmethods(int nlhs, mxArray* plhs[],
checkNArgs(3, nrhs);
vv = (double) domain_nComponents(dom);
break;
case 12:
checkNArgs(3, nrhs);
vv = domain_type(dom);
break;
case 13:
checkNArgs(3, nrhs);
vv = (double) domain_index(dom);
Expand Down Expand Up @@ -302,7 +308,7 @@ void onedimmethods(int nlhs, mxArray* plhs[],
case 103:
checkNArgs(4, nrhs);
fname = getString(prhs[3]);
iok = sim1D_showSolution(dom, fname);
iok = sim1D_show(dom, fname);
break;
case 104:
checkNArgs(5, nrhs);
Expand Down

0 comments on commit 92dfb97

Please sign in to comment.