From a7ba7c793c96f84ba0db85f2e03337ba57b72e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Sun, 6 Oct 2013 08:45:40 +0200 Subject: [PATCH] Octave Interface: Fixed wrong timestep array detection The test to check whether an argument was a array of timestep indices was not good enough. Text was also interpreted as a matrix. Typechecking of the arguments is difficult due to the lack of documentation of the octave API --- .../OctaveScripts/ResInsightIterfaceUnitTest.m | 17 ++++++++--------- OctavePlugin/riGetActiveCellProperty.cpp | 4 ++-- OctavePlugin/riGetGridProperty.cpp | 2 +- OctavePlugin/riSetActiveCellProperty.cpp | 2 +- OctavePlugin/riSetGridProperty.cpp | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m b/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m index d059ae7241..65ab9950fe 100644 --- a/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m +++ b/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m @@ -1,7 +1,6 @@ ### The case with caseid 1 has to be selected/active in ResInsight when running this test-script ### Coarsening and Dual porosity is not exercised by this tes yet. We need models - ### CaseInfo riGetCurrentCase() printf ("===== Testing ====> riGetCurrentCase\n"); caseInfo = riGetCurrentCase(); @@ -58,25 +57,25 @@ PropertyInfos4 = riGetPropertyNames(1, "Matrix"); ### Matrix[numActiveCells][numTimestepsRequested] riGetActiveCellProperty([CaseId], PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) printf ("===== Testing ====> riGetActiveCellProperty\n"); ActivePropData1 = riGetActiveCellProperty("SOIL"); -##ActivePropData2 = riGetActiveCellProperty("SOIL", "Matrix"); +ActivePropData2 = riGetActiveCellProperty("SOIL", "Matrix"); ActivePropData3 = riGetActiveCellProperty("SOIL", [1,3]); ActivePropData4 = riGetActiveCellProperty("SOIL", [1,3], "Matrix"); ActivePropData5 = riGetActiveCellProperty(1, "SOIL"); ActivePropData6 = riGetActiveCellProperty(1, "SOIL", [1,3]); ActivePropData7 = riGetActiveCellProperty(1, "SOIL", [1,3], "Matrix"); -##ActivePropData8 = riGetActiveCellProperty(1, "SOIL", "Matrix"); +ActivePropData8 = riGetActiveCellProperty(1, "SOIL", "Matrix"); ### Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) printf ("===== Testing ====> riGetGridProperty\n"); GridProps1 = riGetGridProperty( 0 , "SOIL" ); GridProps2 = riGetGridProperty( 0 , "SOIL", [1,3]); GridProps3 = riGetGridProperty( 0 , "SOIL", [1,3], "Matrix"); -##GridProps4 = riGetGridProperty( 0 , "SOIL", "Matrix"); +GridProps4 = riGetGridProperty( 0 , "SOIL", "Matrix"); GridProps5 = riGetGridProperty(1, 0 , "SOIL" ); GridProps6 = riGetGridProperty(1, 0 , "SOIL", [1,3]); GridProps7 = riGetGridProperty(1, 0 , "SOIL", [1,3], "Matrix"); -##GridProps8 = riGetGridProperty(1, 0 , "SOIL", "Matrix"); +GridProps8 = riGetGridProperty(1, 0 , "SOIL", "Matrix"); ### riSetActiveCellProperty( Matrix[numActiveCells][numTimeSteps], [CaseId], PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) @@ -85,22 +84,22 @@ riSetActiveCellProperty( ActivePropData1, "PropertyName1" ); riSetActiveCellProperty( ActivePropData3, "PropertyName2", [1,3]); riSetActiveCellProperty( ActivePropData3, "PropertyName3", [1,3], "Matrix"); -##riSetActiveCellProperty( ActivePropData1, "PropertyName4", "Matrix"); +riSetActiveCellProperty( ActivePropData1, "PropertyName4", "Matrix"); riSetActiveCellProperty( ActivePropData1, 1, "PropertyName5" ); riSetActiveCellProperty( ActivePropData3, 1, "PropertyName6", [1,3]); riSetActiveCellProperty( ActivePropData3, 1, "PropertyName7", [1,3], "Matrix"); -##riSetActiveCellProperty( ActivePropData1, 1, "PropertyName8", "Matrix"); +riSetActiveCellProperty( ActivePropData1, 1, "PropertyName8", "Matrix"); ### riSetGridProperty( Matrix[numI][numJ][numK][numTimeSteps], [CaseId], GridIndex, PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) printf ("===== Testing ====> riSetGridProperty\n"); riSetGridProperty( GridProps1, 0, "PropertyName11" ); riSetGridProperty( GridProps2, 0, "PropertyName12", [1,3]); riSetGridProperty( GridProps2, 0, "PropertyName13", [1,3], "Matrix"); -##riSetGridProperty( GridProps1, 0, "PropertyName14", "Matrix"); +riSetGridProperty( GridProps1, 0, "PropertyName14", "Matrix"); riSetGridProperty( GridProps1, 1, 0, "PropertyName15" ); riSetGridProperty( GridProps2, 1, 0, "PropertyName16", [1,3]); riSetGridProperty( GridProps2, 1, 0, "PropertyName17", [1,3], "Matrix"); -##riSetGridProperty( GridProps1, 1, 0, "PropertyName18", "Matrix"); +riSetGridProperty( GridProps1, 1, 0, "PropertyName18", "Matrix"); ### Matrix[numI][numJ][numK][3] riGetCellCenters([CaseId], GridIndex) diff --git a/OctavePlugin/riGetActiveCellProperty.cpp b/OctavePlugin/riGetActiveCellProperty.cpp index de2816dd5d..a936b82d96 100644 --- a/OctavePlugin/riGetActiveCellProperty.cpp +++ b/OctavePlugin/riGetActiveCellProperty.cpp @@ -168,8 +168,8 @@ DEFUN_DLD (riGetActiveCellProperty, args, nargout, } // Check if we have a Requested TimeSteps - - if (!(nargin > argIndices[2] && args(argIndices[2]).is_matrix_type())) + + if (!(nargin > argIndices[2] && args(argIndices[2]).is_matrix_type() && !args(argIndices[2]).is_string())) { argIndices[2] = -1; for (size_t aIdx = 3; aIdx < argIndices.size(); ++aIdx) diff --git a/OctavePlugin/riGetGridProperty.cpp b/OctavePlugin/riGetGridProperty.cpp index 8621722af6..3771341644 100644 --- a/OctavePlugin/riGetGridProperty.cpp +++ b/OctavePlugin/riGetGridProperty.cpp @@ -168,7 +168,7 @@ DEFUN_DLD (riGetGridProperty, args, nargout, // Check if we have a Requested TimeSteps - if (!(nargin > argIndices[3] && args(argIndices[3]).is_matrix_type())) + if (!(nargin > argIndices[3] && args(argIndices[3]).is_matrix_type() && !args(argIndices[3]).is_string())) { argIndices[3] = -1; for (size_t aIdx = 3; aIdx < argIndices.size(); ++aIdx) diff --git a/OctavePlugin/riSetActiveCellProperty.cpp b/OctavePlugin/riSetActiveCellProperty.cpp index 9f142b2253..463add131a 100644 --- a/OctavePlugin/riSetActiveCellProperty.cpp +++ b/OctavePlugin/riSetActiveCellProperty.cpp @@ -146,7 +146,7 @@ DEFUN_DLD (riSetActiveCellProperty, args, nargout, // Check if we have a Requested TimeSteps - if (!(nargin > argIndices[3] && args(argIndices[3]).is_matrix_type())) + if (!(nargin > argIndices[3] && args(argIndices[3]).is_matrix_type() && !args(argIndices[3]).is_string())) { argIndices[3] = -1; for (size_t aIdx = 4; aIdx < argIndices.size(); ++aIdx) diff --git a/OctavePlugin/riSetGridProperty.cpp b/OctavePlugin/riSetGridProperty.cpp index f4bf54f05f..769eafb05c 100644 --- a/OctavePlugin/riSetGridProperty.cpp +++ b/OctavePlugin/riSetGridProperty.cpp @@ -176,7 +176,7 @@ DEFUN_DLD (riSetGridProperty, args, nargout, // Check if we have a Requested TimeSteps - if (!(nargin > argIndices[4] && args(argIndices[4]).is_matrix_type())) + if (!(nargin > argIndices[4] && args(argIndices[4]).is_matrix_type() && !args(argIndices[4]).is_string())) { argIndices[4] = -1; for (size_t aIdx = 5; aIdx < argIndices.size(); ++aIdx)