[cig-commits] r4316 - in long/3D/Gale/trunk/src/StGermain: .
Discretisation/Geometry/tests
walter at geodynamics.org
walter at geodynamics.org
Thu Aug 17 17:16:40 PDT 2006
Author: walter
Date: 2006-08-17 17:16:39 -0700 (Thu, 17 Aug 2006)
New Revision: 4316
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testTensorMultMath.0of1.expected
long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testTensorMultMath.c
Log:
r2694 at earth: boo | 2006-08-17 17:14:13 -0700
r2648 at earth (orig r3729): KathleenHumble | 2006-07-30 21:55:16 -0700
--Changed two of the tests in testTensorMultMath
( TensorArray_CalcInverse* tests)
so that they would compare resulst with an expected output
rather than assuming an exact solution
Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
- 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2693
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3728
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2694
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3729
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testTensorMultMath.0of1.expected
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testTensorMultMath.0of1.expected 2006-08-18 00:16:37 UTC (rev 4315)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testTensorMultMath.0of1.expected 2006-08-18 00:16:39 UTC (rev 4316)
@@ -1,5 +1,5 @@
StGermain Framework revision 3716. Copyright (C) 2003-2005 VPAC.
-
+1e-14
/******************* Test 1 ************************/
Test TensorArray Identity
@@ -256,8 +256,9 @@
tensorArray -
1 2
3 4
+Answer calculated within tolerance 1e-14, for solution:
Inverse of tensor:
-tensorResult -
+tensorCompare -
-2 1
1.5 -0.5
3-D
@@ -265,8 +266,9 @@
1 2 3
30 22 4
5 7 9
+Answer calculated within tolerance 1e-14, for solution:
Inverse of tensor:
-tensorResult -
+tensorCompare -
-5.6667 -0.1 1.9333
8.3333 0.2 -2.8667
-3.3333 -0.1 1.2667
@@ -278,8 +280,9 @@
tensorArray -
1 2
3 4
+Answer calculated within tolerance 1e-14, for solution:
Inverse of tensor:
-tensorResult -
+tensorCompare -
-2 1
1.5 -0.5
3-D
@@ -287,8 +290,9 @@
1 2 3
30 22 4
5 7 9
+Answer calculated within tolerance 1e-14, for solution:
Inverse of tensor:
-tensorResult -
+tensorCompare -
-5.6667 -0.1 1.9333
8.3333 0.2 -2.8667
-3.3333 -0.1 1.2667
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testTensorMultMath.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testTensorMultMath.c 2006-08-18 00:16:37 UTC (rev 4315)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testTensorMultMath.c 2006-08-18 00:16:39 UTC (rev 4316)
@@ -73,10 +73,15 @@
if( rank == procToWatch ) {
/* Put in tests here */
SymmetricTensor symmTensor, symmTensor2, symmTensorResult;
- TensorArray tensorArray, tensorArray2, tensorResult;
- XYZ vector, vectorResult;
- double result;
+ TensorArray tensorArray, tensorArray2, tensorResult, tensorCompare, tensorDiff;
+ XYZ vector, vectorResult;
+ double result, resultCompare, errorValue;
+ Dimension_Index row, col;
+ Bool tensorMultMathTest_Flag;
+ #define STG_TENSORMULTMATHTEST_ERROR 1.0e-14;
+ errorValue = STG_TENSORMULTMATHTEST_ERROR;
+ Journal_Printf( stream, "%g", errorValue);
Journal_Printf(stream, "\n/******************* Test 1 ************************/\n");
Journal_Printf( stream, "Test TensorArray Identity\n\n");
@@ -446,20 +451,50 @@
Journal_Printf(stream, "\n/******************* Test 13 ************************/\n");
Journal_Printf( stream, "Test function TensorArray_CalcInverseWithDeterminant \n\n");
+
+ Journal_Printf( stream, "2-D\n");
+
+ tensorMultMathTest_Flag = True;
- Journal_Printf( stream, "2-D\n");
tensorArray[FT2D_00] = 1;
tensorArray[FT2D_01] = 2;
tensorArray[FT2D_10] = 3;
tensorArray[FT2D_11] = 4;
-
+
+ tensorCompare[FT2D_00] = -2;
+ tensorCompare[FT2D_01] = 1;
+ tensorCompare[FT2D_10] = 1.5;
+ tensorCompare[FT2D_11] = -0.5;
+
Journal_PrintTensorArray( stream, tensorArray, 2);
result = TensorArray_CalcDeterminant(tensorArray, 2);
TensorArray_CalcInverseWithDeterminant(tensorArray, result, 2, tensorResult);
+
+ TensorArray_Subtract(tensorResult, tensorCompare, 2, tensorDiff);
+
+ for (row = 0; row < 2; row++ ){
+ for ( col = 0; col < 2; col++ ){
+ if (fabs(tensorDiff[TensorArray_TensorMap(row, col, 2)]) > errorValue ) {
+ Journal_Printf( stream, "Value, %g at index ( %d, %d) not within tolerance, %g\n",
+ tensorResult[TensorArray_TensorMap(row, col, 2)],row, col, errorValue);
+ tensorMultMathTest_Flag = False;
+ }
+ }
+ }
+ if (tensorMultMathTest_Flag == True) {
+ Journal_Printf( stream, "Answer calculated within tolerance %g, for solution:\n", errorValue);
+ }
+ else {
+ Journal_Printf( stream, "Answer calculated not within tolerance %g, for solution:\n", errorValue);
+ }
+
Journal_Printf( stream, "Inverse of tensor:\n");
- Journal_PrintTensorArray( stream, tensorResult, 2);
+ Journal_PrintTensorArray( stream, tensorCompare, 2);
Journal_Printf( stream, "3-D\n");
+
+ tensorMultMathTest_Flag = True;
+
tensorArray[FT3D_00] = 1;
tensorArray[FT3D_01] = 2;
tensorArray[FT3D_02] = 3;
@@ -469,29 +504,90 @@
tensorArray[FT3D_20] = 5;
tensorArray[FT3D_21] = 7;
tensorArray[FT3D_22] = 9;
+
+ tensorCompare[FT3D_00] = -5.666666666666667;
+ tensorCompare[FT3D_01] = -0.100000000000000;
+ tensorCompare[FT3D_02] = 1.933333333333333;
+ tensorCompare[FT3D_10] = 8.333333333333333;
+ tensorCompare[FT3D_11] = 0.200000000000000;
+ tensorCompare[FT3D_12] = -2.866666666666667;
+ tensorCompare[FT3D_20] = -3.333333333333333;
+ tensorCompare[FT3D_21] = -0.100000000000000;
+ tensorCompare[FT3D_22] = 1.266666666666667;
Journal_PrintTensorArray( stream, tensorArray, 3);
result = TensorArray_CalcDeterminant(tensorArray, 3);
TensorArray_CalcInverseWithDeterminant(tensorArray,result, 3, tensorResult);
+
+ TensorArray_Subtract(tensorResult, tensorCompare, 3, tensorDiff);
+
+ for (row = 0; row < 3; row++ ){
+ for ( col = 0; col < 3; col++ ){
+ if (fabs(tensorDiff[TensorArray_TensorMap(row, col, 3)]) > errorValue ) {
+ Journal_Printf( stream, "Value, %g at index ( %d, %d) not within tolerance, %g\n",
+ tensorResult[TensorArray_TensorMap(row, col, 3)],row, col, errorValue);
+ tensorMultMathTest_Flag = False;
+ }
+ }
+ }
+ if (tensorMultMathTest_Flag == True) {
+ Journal_Printf( stream, "Answer calculated within tolerance %g, for solution:\n", errorValue);
+ }
+ else {
+ Journal_Printf( stream, "Answer calculated not within tolerance %g, for solution:\n", errorValue);
+ }
+
+
Journal_Printf( stream, "Inverse of tensor:\n");
- Journal_PrintTensorArray( stream, tensorResult, 3);
+ Journal_PrintTensorArray( stream, tensorCompare, 3);
Journal_Printf(stream, "\n/******************* Test 14 ************************/\n");
Journal_Printf( stream, "Test function TensorArray_CalcInverse \n\n");
Journal_Printf( stream, "Solutions tested against: http://www.bluebit.gr/matrix-calculator/");
Journal_Printf( stream, "2-D\n");
+
+ tensorMultMathTest_Flag = True;
+
tensorArray[FT2D_00] = 1;
tensorArray[FT2D_01] = 2;
tensorArray[FT2D_10] = 3;
tensorArray[FT2D_11] = 4;
+
+ tensorCompare[FT2D_00] = -2;
+ tensorCompare[FT2D_01] = 1;
+ tensorCompare[FT2D_10] = 1.5;
+ tensorCompare[FT2D_11] = -0.5;
Journal_PrintTensorArray( stream, tensorArray, 2);
TensorArray_CalcInverse(tensorArray, 2, tensorResult);
+
+ TensorArray_Subtract(tensorResult, tensorCompare, 2, tensorDiff);
+
+ for (row = 0; row < 2; row++ ){
+ for ( col = 0; col < 2; col++ ){
+ if (fabs(tensorDiff[TensorArray_TensorMap(row, col, 2)]) > errorValue ) {
+ Journal_Printf( stream, "Value, %g at index ( %d, %d) not within tolerance, %g\n",
+ tensorResult[TensorArray_TensorMap(row, col, 2)],row, col, errorValue);
+ tensorMultMathTest_Flag = False;
+ }
+ }
+ }
+ if (tensorMultMathTest_Flag == True) {
+ Journal_Printf( stream, "Answer calculated within tolerance %g, for solution:\n", errorValue);
+ }
+ else {
+ Journal_Printf( stream, "Answer calculated not within tolerance %g, for solution:\n", errorValue);
+ }
+
+
Journal_Printf( stream, "Inverse of tensor:\n");
- Journal_PrintTensorArray( stream, tensorResult, 2);
+ Journal_PrintTensorArray( stream, tensorCompare, 2);
Journal_Printf( stream, "3-D\n");
+
+ tensorMultMathTest_Flag = True;
+
tensorArray[FT3D_00] = 1;
tensorArray[FT3D_01] = 2;
tensorArray[FT3D_02] = 3;
@@ -501,12 +597,47 @@
tensorArray[FT3D_20] = 5;
tensorArray[FT3D_21] = 7;
tensorArray[FT3D_22] = 9;
+
+ tensorCompare[FT3D_00] = -5.666666666666667;
+ tensorCompare[FT3D_01] = -0.1;
+ tensorCompare[FT3D_02] = 1.933333333333333;
+ tensorCompare[FT3D_10] = 8.333333333333333;
+ tensorCompare[FT3D_11] = 0.200000000000;
+ tensorCompare[FT3D_12] = -2.866666666666667;
+ tensorCompare[FT3D_20] = -3.333333333333333;
+ tensorCompare[FT3D_21] = -0.1;
+ tensorCompare[FT3D_22] = 1.266666666666667;
+
Journal_PrintTensorArray( stream, tensorArray, 3);
TensorArray_CalcInverse(tensorArray, 3, tensorResult);
+
+ TensorArray_Subtract(tensorResult, tensorCompare, 3, tensorDiff);
+
+ for (row = 0; row < 3; row++ ){
+ for ( col = 0; col < 3; col++ ){
+ if (fabs(tensorDiff[TensorArray_TensorMap(row, col, 3)]) > errorValue ) {
+ Journal_Printf( stream, "Value, %g at index ( %d, %d) not within tolerance, %g\n",
+ tensorResult[TensorArray_TensorMap(row, col, 3)],row, col, errorValue);
+ tensorMultMathTest_Flag = False;
+ }
+ }
+ }
+
+ if (tensorMultMathTest_Flag == True) {
+ Journal_Printf( stream, "Answer calculated within tolerance %g, for solution:\n", errorValue);
+ }
+ else {
+ Journal_Printf( stream, "Answer calculated not within tolerance %g, for solution:\n", errorValue);
+ }
+
+
Journal_Printf( stream, "Inverse of tensor:\n");
- Journal_PrintTensorArray( stream, tensorResult, 3);
+ Journal_PrintTensorArray( stream, tensorCompare, 3);
+
+
+
Journal_Printf(stream, "\n/******************* Test 15 ************************/\n");
Journal_Printf( stream, "Test function TensorArray_DoubleContraction \n\n");
Journal_Printf( stream, "Hand verified\n");
More information about the cig-commits
mailing list