[cig-commits] r4141 - in long/3D/Gale/trunk/src/StGermain: . Discretisation/Geometry/src Discretisation/Geometry/tests

walter at geodynamics.org walter at geodynamics.org
Tue Aug 1 01:53:25 PDT 2006


Author: walter
Date: 2006-08-01 01:53:25 -0700 (Tue, 01 Aug 2006)
New Revision: 4141

Modified:
   long/3D/Gale/trunk/src/StGermain/
   long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/FullTensorMath.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/FullTensorMath.h
   long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testFullTensorMath.0of1.FullTensorMath.txt.expected
   long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testFullTensorMath.c
Log:
 r2607 at earth:  boo | 2006-08-01 01:50:36 -0700
  r2586 at earth (orig r3709):  KathleenHumble | 2006-07-26 19:54:09 -0700
  For FullTensorMath.c:
  -Added in a SymmetricTensor_TensorMap function
  which works exactly the same as the function
  TensorArray_TensorMap except that it gives the symmetric tensor
  index number.
  -Added in more substantial comments to many functions, 
  and added a /** instead of /* for important comments 
  so that they will be read by Doxygen.
  
  For FullTensorMath.h
  -Added in comments on how TensorMap enumerated types work in the code
  
  For testFullTensorMath.c
  -Added in test at beginning to check TensorMap functions
  and enumerated types for symmetric and full tensor arrays.
  
  For expected file:
  patched file so that it has results for new test added to it.
  
  
 



Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
   - 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2606
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3708
   + 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2607
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3709

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/FullTensorMath.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/FullTensorMath.c	2006-08-01 08:53:20 UTC (rev 4140)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/FullTensorMath.c	2006-08-01 08:53:25 UTC (rev 4141)
@@ -26,7 +26,7 @@
 **  License along with this library; if not, write to the Free Software
 **  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 **
-** $Id: TensorMath.c 3479 2006-03-09 03:15:29Z DavidMay $
+** $Id: FullTensorMath.c  $
 **
 **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
@@ -49,13 +49,21 @@
 
 #define STG_TENSOR_ERROR 1.0e-05;
 
-/* Mappings from enumerated types to arrays*/
+/** Mappings from enumerated types to arrays
+This gives the user the option to use:
+References instead of enumerated types.
+TensorMapFT2D[0][0] = FT2D_00
+etc.
+*/
 const unsigned int TensorMapFT2D[2][2] = {{FT2D_00, FT2D_01},{FT2D_10, FT2D_11}};
 const unsigned int TensorMapST2D[2][2] = {{ST2D_00, ST2D_01},{ST2D_01, ST2D_11}};
 const unsigned int TensorMapFT3D[3][3] ={{FT3D_00, FT3D_01, FT3D_02},{FT3D_10, FT3D_11, FT3D_12},{FT3D_20, FT3D_21, FT3D_22}};
 const unsigned int TensorMapST3D[3][3] ={{ST3D_00, ST3D_01, ST3D_02},{ST3D_01, ST3D_11, ST3D_12},{ST3D_02, ST3D_12, ST3D_22}};
 
-
+/** This is a wrapper that converts a row/col index and a dimension
+into the correct number to reference the correct address of the value
+in the tensorArray function.
+*/
 int TensorArray_TensorMap(Dimension_Index row_I, Dimension_Index col_I, Dimension_Index dim) {
 	switch (dim) {
 		case 3: {
@@ -75,7 +83,32 @@
 	return 0;
 }
 
+/** This is a wrapper that converts a row/col index and a dimension
+into the correct number to reference the correct address of the value
+in the symmetricTensor function.
+*/
+int SymmetricTensor_TensorMap(Dimension_Index row_I, Dimension_Index col_I, Dimension_Index dim) {
+	switch (dim) {
+		case 3: {
+			return TensorMapST3D[ row_I ][ col_I ];
+		}
+		case 2: {
+			return TensorMapST2D[ row_I ][ col_I ];
+		}
+		default: {
+			Stream* error = Journal_Register( ErrorStream_Type, "FullTensorMath" );
+			Journal_Printf( error, "Cannot get tensor value for dimension %d in %s.\n", dim, __func__);
+			Journal_Firewall( dim, Journal_Register( Error_Type, "FullTensorMath" ),
+				"In func '%s' don't understand dim = %u\n", __func__, dim );
+		}
+		
+	}
+	return 0;
+}
 
+
+
+/** Converts a symmetric tensor to a full tensor */
 void StGermain_SymmetricTensor_ToTensorArray(SymmetricTensor symTensor, Dimension_Index dim, TensorArray fullTensor) {
 	switch (dim) {
 		case 3:
@@ -90,9 +123,9 @@
 		}
 	}
 }
+/** This function uses enumerated types to convert symmetric tensors to full tensors */
+void StGermain_SymmetricTensor_ToTensorArray2D(SymmetricTensor symTensor, TensorArray fullTensor) {
 
-void StGermain_SymmetricTensor_ToTensorArray2D(SymmetricTensor symTensor, TensorArray fullTensor) {
-	/*Using enumerated types to convert symmetric tensors to full tensors */
 	fullTensor[FT2D_00] = symTensor[ST2D_00];
 	fullTensor[FT2D_01] = symTensor[ST2D_01];
 	fullTensor[FT2D_10] = symTensor[ST2D_01];
@@ -100,6 +133,9 @@
 	
 
 }
+
+/** This function uses enumerated types to convert symmetric tensors to full tensors */
+
 void StGermain_SymmetricTensor_ToTensorArray3D(SymmetricTensor symTensor, TensorArray fullTensor) {
 	/*Using enumerated types to convert symmetric tensors to full tensors */
 	fullTensor[FT3D_00] = symTensor[ST3D_00];
@@ -115,7 +151,7 @@
 
 }
 
-
+/** This function converts TensorArray's to square Matrixes */
 void TensorArray_ToMatrix( TensorArray tensor, Dimension_Index dim, double** matrix ) {
 	if (dim == 2) {
 		matrix[0][0] = tensor[FT2D_00] ; matrix[0][1] = tensor[FT2D_01] ;
@@ -132,7 +168,7 @@
 	}
 }
 
-
+/** This function converts TensorArray's to ComplexTensorArray's */
 void TensorArray_ToComplexTensorArray(TensorArray tensorArray, ComplexTensorArray complexTensorArray, Dimension_Index dim) {
 	Dimension_Index index_I;
 
@@ -149,7 +185,9 @@
 	}
 	return;			
 }
-
+/** This function converts ComplexTensorArrays back into TensorArrays.
+If there are any non-zero entries for complex components,
+this function will JournalFirewall and exit */
 void ComplexTensorArray_ToTensorArray(ComplexTensorArray complexTensorArray, TensorArray tensorArray, Dimension_Index dim) {
 	Dimension_Index index_I;
 	Stream* error = Journal_Register( ErrorStream_Type, "FullTensorMath" );
@@ -177,7 +215,7 @@
 	
 	return;		
 }
-
+/** This function converts ComplexTensorArrays to Complex Square Matrices */
 void ComplexTensorArray_ToComplexMatrix(ComplexTensorArray complexTensor, Dimension_Index dim, Cmplx** complexMatrix ) {
 	if (dim == 2) {
 		Cmplx_Copy(complexTensor[FT2D_00], complexMatrix[0][0]); 			
@@ -204,17 +242,20 @@
 	}
 }
 
+/** This function calculates only the eigenvalues of a given TensorArray */
 void TensorArray_CalcAllEigenvalues( TensorArray tensor, Dimension_Index dim, ComplexEigenvector* eigenvectorList ) {
 	/* False flag means Eigenvectors are not written to eigenvectorList */
 	TensorArray_CalcAllEigenFunctions(tensor, dim, False, eigenvectorList);
 	
 }
+/** This function calculates only the eigenvalues of a given 2D TensorArray */
 
 void TensorArray_CalcAllEigenvalues2D( TensorArray tensor, ComplexEigenvector* eigenvectorList ) {
 	/* False flag means Eigenvectors are not written to eigenvectorList */
 	TensorArray_CalcAllEigenFunctions(tensor, 2, False, eigenvectorList);
 	
 }
+/** This function calculates only the eigenvalues of a given 3D TensorArray */
 
 void TensorArray_CalcAllEigenvalues3D( TensorArray tensor, ComplexEigenvector* eigenvectorList ) {
 	/* False flag means Eigenvectors are not written to eigenvectorList */
@@ -222,7 +263,7 @@
 	
 }
 
-
+/** This function is a wrapper to calculate all eigenvalues and vectors for 2 or 3D TensorArray's */
 void TensorArray_CalcAllEigenvectors(TensorArray tensor, Dimension_Index dim, ComplexEigenvector* eigenvectorList){
 	/* True flag means eigenvalues and vectors are calculated */
 	TensorArray_CalcAllEigenFunctions(tensor, dim, True, eigenvectorList);
@@ -230,6 +271,7 @@
 	ComplexEigenvectorList_Sort( eigenvectorList, dim );
 }
 
+/** This function is a wrapper to calculate all eigenvalues and vectors for 2D TensorArray's */
 
 void TensorArray_CalcAllEigenvectors2D( TensorArray tensor, ComplexEigenvector* eigenvectorList ) {
 	
@@ -241,6 +283,7 @@
 	
 
 }
+/** This function is a wrapper to calculate all eigenvalues and vectors for 3D TensorArray's */
 
 void TensorArray_CalcAllEigenvectors3D( TensorArray tensor, ComplexEigenvector* eigenvectorList ) {
 	
@@ -251,11 +294,13 @@
 	ComplexEigenvectorList_Sort( eigenvectorList, 3 );
 	
 
-}	
+}
 
+/** This function will call the blas-lapack library and calculate the eigenvalues and eigenvectors
+For a given tensorArray and return the answers in a ComplexEigenvector structure.*/
 void TensorArray_CalcAllEigenFunctions(TensorArray tensor, Dimension_Index dim, Bool eigenFlag, ComplexEigenvector* eigenvectorList) {
-/*This function will call the blas-lapack library and calculate the eigenvalues and eigenvectors */
-	/* Define functions needed to pass to blaslapack library function */
+/**This function will call the blas-lapack library and calculate the eigenvalues and eigenvectors */
+	/** Define functions needed to pass to blaslapack library function */
 	char jobVecLeft='V';
 	char jobVecRight='N';
 	
@@ -272,52 +317,52 @@
 	//char* 	errorStringValues;
 	Stream* errorStream = Journal_Register( ErrorStream_Type, "FullTensorMath" );
 	
-	/* Set size of workspace to pass to function */
+	/** Set size of workspace to pass to function */
 	dimWorkSpace = 10*dim;
 
-	/* define array size */
+	/** define array size */
 	arrayA = Memory_Alloc_Array( double, dim * dim, "ArrayA" );				
 
-	/* define output eigenvalue matrices */
+	/** define output eigenvalue matrices */
 	outputReal = Memory_Alloc_Array( double, dim, "OutputReal" );				
 	outputImag = Memory_Alloc_Array( double, dim, "OutputImag" );
 	for (row_I = 0; row_I < dim; row_I++) {
 		outputReal[row_I] = 0;
 		outputImag[row_I] = 0;
 	}
-	/* Define workspace */
+	/** Define workspace */
 	workSpace = Memory_Alloc_Array( double, dimWorkSpace, "DimWorkSpace" );
 	
-	/* Transpose array so that it is in Fortran-style indexing */
+	/** Transpose array so that it is in Fortran-style indexing */
 	for( row_I = 0 ; row_I < dim ; row_I++ ) {
 		 for( col_I = 0 ; col_I < dim ; col_I++ ) {
 			arrayA[ ( row_I * dim ) + col_I ] = tensor[TensorArray_TensorMap(row_I, col_I, dim)];
 		 }
 	}
-	 /* Turn off eigenvector calculations if eigenvector flag is not set */
+	 /** Turn off eigenvector calculations if eigenvector flag is not set */
 	if (eigenFlag == False) {
 		 jobVecLeft = 'N';
 	}
-	/* Set sizes for eigenvectors */
+	/** Set sizes for eigenvectors */
 	if (jobVecLeft=='V') {
-		/* times 2 to account for complex eigenvectors */
+		/** times size by 2 to account for complex eigenvectors */
 		leadDimVL = 2*dim;
 	}
 	else {
 		leadDimVL = 1;
 	}
-	/* Set sizes for alternate eigenvectors
+	/** Set sizes for alternate eigenvectors
 	This is currently always turned off since calculating right eigenvectors
 	as well is redundant */
 	if (jobVecRight=='V') {
-		/* times 2 to account for complex eigenvectors */
+		/** times 2 to account for complex eigenvectors */
 		leadDimVR = 2*dim;
 	}
 	else {
 		leadDimVR = 1;
 	}
 	
-	/* set size of eigenvector arrays */
+	/** set size of eigenvector arrays */
 	leftEigenVec = Memory_Alloc_Array( double, leadDimVL * dim, "LeftEigenVec" );				
 	rightEigenVec = Memory_Alloc_Array( double, leadDimVR * dim, "RightEigenVec" );
 	for (row_I = 0; row_I < leadDimVL * dim; row_I++) {
@@ -327,7 +372,7 @@
 		rightEigenVec[row_I] = 0;
 	}
 	
-	/* Definitions of laplac inputs (from dgeev man page):
+	/** Definitions of lapack call inputs (from dgeev man page):
 
 		JOBVL   (input) CHARACTER*1
 				  = 'N': left eigenvectors of A are not computed;
@@ -395,7 +440,7 @@
 	*/	 
 
 
-	/* Passes into blaslapack function:
+	/** Passes into blaslapack function:
 		 From Man page:
 		 	1.  JOBVL			2.	JOBVR 			3.	N 
 			4.	A 				5.	LDA 			6.	WR 
@@ -411,13 +456,14 @@
 			13. &dimWorkSpace	14. &INFO		 
 		 */
 		 
-	/* Call blas-lapack function */	 
+	/** Call blas-lapack function, dgeev through stg_lapack header file substitution
+	to take account of dirrerent Fortran compilers	*/	 
 	stg_dgeev( &jobVecLeft, &jobVecRight, &dim, arrayA, &dim, 
 	 		outputReal, outputImag, leftEigenVec, &leadDimVL, 
 	 		rightEigenVec, &leadDimVR, workSpace, &dimWorkSpace, &INFO );
 
 
-	/* Check flag for succesful calculation */
+	/** Check flag for succesful calculation */
 
 	if (INFO < 0) {
 		Journal_Printf( errorStream, "Error in %s, Blas-Lapack failed at %f-th argument for tensor:", 
@@ -433,9 +479,9 @@
 	}
 	
 
-/*Pass values back */
+/**Pass values back */
 	errorValue = STG_TENSOR_ERROR;	
-	/* Assign eigenvalues */
+	/** Assign eigenvalues */
 	for (col_I=0; col_I < dim; col_I++) {
 		
 		eigenvectorList[col_I].eigenvalue[REAL_PART] = outputReal[col_I];
@@ -448,12 +494,12 @@
 		}	
 	}
 	
-	/* If eigenvectors have been calculated */
+	/** If eigenvectors have been calculated */
 	if (eigenFlag == True ) {
 		int index_K;
 		int numSign;
 		
-		/* Assign eigenvectors - see format for VL in comments for lapack pass above*/
+		/** Assign eigenvectors - see format for VL in comments for lapack pass above*/
 		for (col_I=0; col_I < dim; col_I++) {
 			
 			if (outputImag[col_I] == 0.0) {
@@ -465,7 +511,7 @@
 			else {
 				for (index_K = col_I; index_K <= col_I + 1; index_K++) {
 					
-					/* set sign of complex vector components */
+					/** set sign of complex vector components */
 					if (index_K == col_I) {
 						numSign = -1;
 					}
@@ -474,7 +520,7 @@
 					}	
 					for (row_I = 0; row_I < dim; row_I++) {
 					
-						/* u(index_J, index_I) = v(index_I, index_J) 
+						/** u(index_J, index_I) = v(index_I, index_J) 
 											     -/+ i *v(index_I, index_J+1) */
 						eigenvectorList[index_K].vector[row_I][REAL_PART] = 
 							leftEigenVec[col_I * leadDimVL + row_I];
@@ -489,7 +535,7 @@
 			}
 		}
 	}
-	/* Round up values that are less than the error bar */
+	/** Round up values that are less than the error bar */
 	for (row_I = 0; row_I < dim; row_I++) {
 		for (col_I = 0; col_I <dim; col_I++) {
 			
@@ -504,7 +550,7 @@
 	
 	
 				
-	
+	/** Free memory and exit function */
 	Memory_Free( arrayA );
 	Memory_Free( outputReal );
 	Memory_Free( outputImag );
@@ -512,7 +558,8 @@
 	Memory_Free( rightEigenVec );
 	Memory_Free( workSpace );	
 }
-
+/** This function checks eigenvalues to find which of
+the two has the biggest modulus*/
 int _QsortComplexEigenvalue( const void* _a, const void* _b ) {
 	ComplexEigenvector* a = (ComplexEigenvector*) _a;
 	ComplexEigenvector* b = (ComplexEigenvector*) _b;
@@ -525,12 +572,15 @@
 		return -1;
 }
 
-/* Sorts the eigenvectors according to the value of the eigenvalue - from smallest to greatest */
+/** Sorts the eigenvectors and eigenvalues according to the value of the modulus of the 
+eigenvalue - from smallest to greatest */
 void ComplexEigenvectorList_Sort( ComplexEigenvector* eigenvectorList, Index count ) {
 	qsort( eigenvectorList, count, sizeof( ComplexEigenvector ), _QsortComplexEigenvalue );
 
 }
-
+/** This function prints a ComplexTensorArray 
+At present, it only shows %7.5g as the format.
+TODO: It would be nice in future to make this variable.*/
 void Journal_PrintComplexTensorArray_Unnamed( Stream* stream, ComplexTensorArray tensor, Dimension_Index dim ) {
 	Dimension_Index row_I, col_I;
 
@@ -546,7 +596,7 @@
 		Journal_Printf( stream, "\n" );
 	}
 }
-
+/** This function prints a Complex Square matrix */
 void Journal_PrintComplexMatrix_Unnamed( Stream* stream, Cmplx** complexMatrix, Dimension_Index dim ) {
 	Dimension_Index row_I, col_I;
 

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/FullTensorMath.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/FullTensorMath.h	2006-08-01 08:53:20 UTC (rev 4140)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/FullTensorMath.h	2006-08-01 08:53:25 UTC (rev 4141)
@@ -33,7 +33,7 @@
 **
 ** Comments:
 **
-** $Id: TensorMath.h 3480 2006-03-09 03:20:09Z DavidMay $
+** $Id: FullTensorMath.h  $
 **
 **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
@@ -44,7 +44,7 @@
 #include "ComplexVectorMath.h"
 #include "TensorMath.h"
 
-	/* TensorArray - Tensor (t_{ij}) here is defined in 2D as
+	/** TensorArray - Tensor (t_{ij}) here is defined in 2D as
 	 * t_{00} = tensor[0] t_{01} = tensor[1]
 	 * t_{10} = tensor[2] t_{11} = tensor[3] 
 	 *
@@ -69,7 +69,12 @@
 	 * tensor[4] = u_{02} = u_{20}
 	 * tensor[5] = u_{12} = u_{21}
 	 */
-/*Create complex eigenvalue and vector */
+/** Create complex eigenvalue and vector:
+	This creates a Cmplx tuple to represent the vector
+	And a Complex value to represent the eigenvalue.
+	These can be referenced by:
+	{eigenvectorName}.vector[{indexNumber}], or {eigenvectorName}.eigenvalue
+	*/
 	 
 typedef struct {
 	XYZC    vector;
@@ -77,20 +82,43 @@
 } ComplexEigenvector;
 
 
-/*Tensor indices for referencing */
+/** TensorIndex creates an enumerated type that can be used as 
+Tensor indices for referencing:
+These indexes are defined as: 
+	ST ~ symmetric tensorArray
+	FT ~ full tensorArray
+	2D ~ in 2 dimensions
+	3D ~ in 3 dimensions
+For example, tensorArray[FT2D_00]
+
+And the indexes follow this naming scheme (for full tensors):
+For 2D:
+\left{ 	a_{00},	a_{01}
+		a_{10},	a_{11} \right}
+For 3D:		
+\left{ 	a_{00},	a_{01},	a_{02}
+		a_{10},	a_{11},	a_{12}
+		a_{20}, a_{21}, a_{22} \right}
+
+Symmetric tensors only use the upper triangle indicee definitions.
+
+*/
  typedef enum TensorIndexST2D { ST2D_00=0, ST2D_11=1, ST2D_01=2 } TensorIndexST2D;
  typedef enum TensorIndexFT2D { FT2D_00=0, FT2D_11=3, FT2D_01=1, FT2D_10=2 } TensorIndexFT2D;
  typedef enum TensorIndexST3D { ST3D_00=0, ST3D_11=1, ST3D_22=2, ST3D_01=3, ST3D_02=4, ST3D_12=5} TensorIndexST3D;
  typedef enum TensorIndexFT3D { FT3D_00=0, FT3D_11=4, FT3D_22=8, FT3D_01=1, FT3D_02=2, FT3D_10=3, FT3D_12=5, FT3D_20=6, FT3D_21=7} TensorIndexFT3D;
 
-/*Define mapping function for enum types to arrays */
+/*Define mapping function for enumerated types to arrays */
+ 
 extern const unsigned int TensorMapFT2D[2][2];
 extern const unsigned int TensorMapST2D[2][2];
 extern const unsigned int TensorMapFT3D[3][3];
 extern const unsigned int TensorMapST3D[3][3];
 
 /*Define TensorArray mapping functions */
+ 
 int TensorArray_TensorMap(Dimension_Index row_I, Dimension_Index col_I, Dimension_Index dim);
+int SymmetricTensor_TensorMap(Dimension_Index row_I, Dimension_Index col_I, Dimension_Index dim);
 	
 void StGermain_SymmetricTensor_ToTensorArray(SymmetricTensor symTensor, Dimension_Index dim, TensorArray fullTensor);
 	
@@ -127,6 +155,7 @@
 
 
 /* Define print statements */
+
 #define Journal_PrintComplexTensorArray(stream, tensor, dim) \
 	do {	\
 		Journal_Printf( stream, #tensor " - \n" ); \

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testFullTensorMath.0of1.FullTensorMath.txt.expected
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testFullTensorMath.0of1.FullTensorMath.txt.expected	2006-08-01 08:53:20 UTC (rev 4140)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testFullTensorMath.0of1.FullTensorMath.txt.expected	2006-08-01 08:53:25 UTC (rev 4141)
@@ -1,4 +1,78 @@
 
+/*******************    Test 0   ************************/
+Test Mapping functions
+
+2-D
+The full tensor:
+tensorArray - 
+    0.5          10     
+     20          30     
+The tensor Mapping using enumerated types:
+tensorArray[FT2D_00] = 0.5
+tensorArray[FT2D_01] = 10
+ ---
+tensorArray[FT2D_10] = 20
+tensorArray[FT2D_11] = 30
+The symmetric tensor:
+symmTensor - 
+     40          60     
+     60          50     
+The symmetric tensor Mapping using enumerated types:
+symmTensor[ST2D_00] = 40
+symmTensor[ST2D_01] = 60
+ ---
+symmTensor[ST2D_11] = 50
+Test Mapping functions for Full Tensor using TensorArray_TensorMap
+
+(0,0): 0  = 0	(0,1): 1  = 1
+(1,0): 2  = 2	(1,1): 3  = 3
+Test Mapping functions for Symmetric Tensor using SymmetricTensor_TensorMap
+
+(0,0): 0  = 0	(0,1): 2  = 2
+(1,0): 2  = 2	(1,1): 1  = 1
+3-D
+The full tensor:
+tensorArray - 
+      0           1           2     
+      3           4           5     
+      6           7           8     
+The tensor Mapping using enumerated types:
+tensorArray[FT3D_00] = 0
+tensorArray[FT3D_01] = 1
+tensorArray[FT3D_02] = 2
+ ---
+tensorArray[FT3D_10] = 3
+tensorArray[FT3D_11] = 4
+tensorArray[FT3D_12] = 5
+ ---
+tensorArray[FT3D_20] = 6
+tensorArray[FT3D_21] = 7
+tensorArray[FT3D_22] = 8
+The symmetric tensor:
+symmTensor - 
+     90         120         130     
+    120         100         140     
+    130         140         110     
+The symmetric tensor Mapping using enumerated types:
+symmTensor[ST3D_00] = 90
+symmTensor[ST3D_01] = 120
+symmTensor[ST3D_02] = 130
+ ---
+symmTensor[ST3D_11] = 100
+symmTensor[ST3D_12] = 140
+ ---
+symmTensor[ST3D_22] = 110
+Test Mapping functions for Full Tensor using TensorArray_TensorMap
+
+(0,0): 0  = 0	(0,1): 1  = 1	(0,2): 2  = 2
+(1,0): 3  = 3	(1,1): 4  = 4	(1,2): 5  = 5
+(2,0): 6  = 6	(2,1): 7  = 7	(2,2): 8  = 8
+Test Mapping functions for Symmetric Tensor using SymmetricTensor_TensorMap
+
+(0,0): 0  = 0	(0,1): 3  = 3	(0,2): 4  = 4
+(1,0): 3  = 3	(1,1): 1  = 1	(1,2): 5  = 5
+(2,0): 4  = 4	(2,1): 5  = 5	(2,2): 2  = 2
+
 /*******************    Test Eigenvector 1   ************************/
 Symmetric 2D Case from Kresig, p. 371f
 
@@ -194,13 +268,13 @@
 
 2-D
 complexTensorArray - 
-      4 +       0 i	       4 +       1 i	 
-      3 +    0.33 i	       5 +     100 i	 
+      4 +       0 i      4 +       1 i
+      3 +    0.33 i      5 +     100 i
 3-D
 complexTensorArray - 
-      1 +     0.5 i	       2 +       0 i	       3 +       0 i	 
-      4 +       0 i	       5 +       1 i	       6 +       2 i	 
-      7 +       0 i	       8 +       0 i	       9 +      30 i	 
+      1 +     0.5 i      2 +       0 i      3 +       0 i
+      4 +       0 i      5 +       1 i      6 +       2 i
+      7 +       0 i      8 +       0 i      9 +      30 i
 
 /*******************    Test  11  ************************/
 Test print ComplexMatrix function
@@ -223,33 +297,33 @@
       1           3     
       4           5     
 complexTensorArray - 
-      1 +       0 i	       3 +       0 i	 
-      4 +       0 i	       5 +       0 i	 
+      1 +       0 i      3 +       0 i
+      4 +       0 i      5 +       0 i
 3-D conversion
 tensorArray - 
       1           3           4     
       5           7           8     
       9          11          12     
 complexTensorArray - 
-      1 +       0 i	       3 +       0 i	       4 +       0 i	 
-      5 +       0 i	       7 +       0 i	       8 +       0 i	 
-      9 +       0 i	      11 +       0 i	      12 +       0 i	 
+      1 +       0 i      3 +       0 i      4 +       0 i
+      5 +       0 i      7 +       0 i      8 +       0 i
+      9 +       0 i     11 +       0 i     12 +       0 i
 
 /*******************    Test  13  ************************/
 Test ComplexTensorArray to ComplexMatrix conversion function
 
 2-D conversion
 complexTensorArray - 
-      1 +     0.5 i	       2 +       0 i	 
-      3 +       0 i	       4 +       0 i	 
+      1 +     0.5 i      2 +       0 i
+      3 +       0 i      4 +       0 i
 complexMatrix - 
       1 +     0.5 i      2 +       0 i
       3 +       0 i      4 +       0 i
 3-D conversion
 complexTensorArray - 
-      1 +     0.5 i	       2 +       0 i	       3 +       0 i	 
-      4 +       0 i	       5 +       1 i	       6 +       2 i	 
-      7 +       0 i	       8 +       0 i	       9 +      30 i	 
+      1 +     0.5 i      2 +       0 i      3 +       0 i
+      4 +       0 i      5 +       1 i      6 +       2 i
+      7 +       0 i      8 +       0 i      9 +      30 i
 complexMatrix - 
       1 +     0.5 i      2 +       0 i      3 +       0 i
       4 +       0 i      5 +       1 i      6 +       2 i
@@ -260,29 +334,29 @@
 
 2-D conversion
 complexTensorArray - 
-      1 +       0 i	       2 +       0 i	 
-      3 +       0 i	       4 +       0 i	 
+      1 +       0 i      2 +       0 i
+      3 +       0 i      4 +       0 i
 tensorArray - 
       1           2     
       3           4     
 3-D conversion
 complexTensorArray - 
-      1 +       0 i	       2 +       0 i	       3 +       0 i	 
-      4 +       0 i	       5 +       0 i	       6 +       0 i	 
-      7 +       0 i	      88 +       0 i	     9.5 +       0 i	 
+      1 +       0 i      2 +       0 i      3 +       0 i
+      4 +       0 i      5 +       0 i      6 +       0 i
+      7 +       0 i     88 +       0 i    9.5 +       0 i
 tensorArray - 
       1           2           3     
       4           5           6     
       7          88         9.5     
 Failing conversion
 complexTensorArray - 
-      1 +       1 i	       2 +       0 i	       3 +       0 i	 
-      4 +       0 i	       5 +       0 i	       6 +       0 i	 
-      7 +       0 i	      88 +       0 i	     9.5 +       0 i	 
+      1 +       1 i      2 +       0 i      3 +       0 i
+      4 +       0 i      5 +       0 i      6 +       0 i
+      7 +       0 i     88 +       0 i    9.5 +       0 i
 Cannot convert to real matrix:
 Indicee 0 in complexTensorArray is complex value.
 complexTensorArray - 
-      1 +       1 i	       2 +       0 i	       3 +       0 i	 
-      4 +       0 i	       5 +       0 i	       6 +       0 i	 
-      7 +       0 i	      88 +       0 i	     9.5 +       0 i	 
+      1 +       1 i      2 +       0 i      3 +       0 i
+      4 +       0 i      5 +       0 i      6 +       0 i
+      7 +       0 i     88 +       0 i    9.5 +       0 i
 In func 'ComplexTensorArray_ToTensorArray'. Cannot convert ComplexTensor to Real Tensor 

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testFullTensorMath.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testFullTensorMath.c	2006-08-01 08:53:20 UTC (rev 4140)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/tests/testFullTensorMath.c	2006-08-01 08:53:25 UTC (rev 4141)
@@ -89,7 +89,126 @@
 		tensor[2][0] = 2;  tensor[2][1] = 2;    tensor[2][2] = -7; tensor[2][3] = 2  ; tensor[2][4] = 3.1;
 		tensor[3][0] = -4; tensor[3][1] = 9;    tensor[3][2] = 3 ; tensor[3][3] = 8  ; tensor[3][4] = 6;
 		tensor[4][0] = 3;  tensor[4][1] = 1;    tensor[4][2] = 9 ; tensor[4][3] = 2  ; tensor[4][4] = 12;
+		/*Test mapping functions */
+		Journal_Printf(stream, "\n/*******************    Test 0   ************************/\n");		
+		Journal_Printf( stream, "Test Mapping functions\n\n");
+		Journal_Printf( stream, "2-D\n");
+		tensorArray[0] =  0.5;
+		tensorArray[1] =  10;
+		tensorArray[2] =  20;
+		tensorArray[3] =  30;
+		symmTensor[0] = 40;
+		symmTensor[1] = 50;
+		symmTensor[2] = 60;
+		
+		Journal_Printf( stream, "The full tensor:\n");
+		Journal_PrintTensorArray( stream, tensorArray, 2 );
+		
+		Journal_Printf( stream, "The tensor Mapping using enumerated types:\n");
+		Journal_PrintValue( stream, tensorArray[FT2D_00]);
+		Journal_PrintValue( stream, tensorArray[FT2D_01]);
+		Journal_Printf( stream, " ---\n");		
+		Journal_PrintValue( stream, tensorArray[FT2D_10]);
+		Journal_PrintValue( stream, tensorArray[FT2D_11]);
 
+		Journal_Printf( stream, "The symmetric tensor:\n");
+		Journal_PrintSymmetricTensor( stream, symmTensor, 2 );
+		
+		Journal_Printf( stream, "The symmetric tensor Mapping using enumerated types:\n");
+		Journal_PrintValue( stream, symmTensor[ST2D_00]);
+		Journal_PrintValue( stream, symmTensor[ST2D_01]);
+		Journal_Printf( stream, " ---\n");		
+		Journal_PrintValue( stream, symmTensor[ST2D_11]);
+		
+		Journal_Printf( stream, "Test Mapping functions for Full Tensor ");
+		Journal_Printf( stream, "using TensorArray_TensorMap\n\n");
+		Journal_Printf( stream, "(0,0): %d  = %d	",	FT2D_00, TensorArray_TensorMap(0,0,2));
+		Journal_Printf( stream, "(0,1): %d  = %d\n", 	FT2D_01, TensorArray_TensorMap(0,1,2));
+		Journal_Printf( stream, "(1,0): %d  = %d	",	FT2D_10, TensorArray_TensorMap(1,0,2));
+		Journal_Printf( stream, "(1,1): %d  = %d\n", 	FT2D_11, TensorArray_TensorMap(1,1,2));
+		
+		Journal_Printf( stream, "Test Mapping functions for Symmetric Tensor ");
+		Journal_Printf( stream, "using SymmetricTensor_TensorMap\n\n");
+		Journal_Printf( stream, "(0,0): %d  = %d	",	ST2D_00, SymmetricTensor_TensorMap(0,0,2));
+		Journal_Printf( stream, "(0,1): %d  = %d\n", 	ST2D_01, SymmetricTensor_TensorMap(0,1,2));
+		Journal_Printf( stream, "(1,0): %d  = %d	", 	ST2D_01, SymmetricTensor_TensorMap(1,0,2));
+		Journal_Printf( stream, "(1,1): %d  = %d\n", 	ST2D_11, SymmetricTensor_TensorMap(1,1,2));
+		
+		Journal_Printf( stream, "3-D\n");
+		tensorArray[0] =  0;
+		tensorArray[1] =  1;
+		tensorArray[2] =  2;
+		tensorArray[3] =  3;
+		tensorArray[4] =  4;
+		tensorArray[5] =  5;
+		tensorArray[6] =  6;
+		tensorArray[7] =  7;
+		tensorArray[8] =  8;
+		
+		symmTensor[0] = 90;
+		symmTensor[1] = 100;
+		symmTensor[2] = 110;
+		symmTensor[3] = 120;
+		symmTensor[4] = 130;
+		symmTensor[5] = 140;
+		
+		Journal_Printf( stream, "The full tensor:\n");
+		Journal_PrintTensorArray( stream, tensorArray, 3 );
+		
+		Journal_Printf( stream, "The tensor Mapping using enumerated types:\n");
+		Journal_PrintValue( stream, tensorArray[FT3D_00]);
+		Journal_PrintValue( stream, tensorArray[FT3D_01]);
+		Journal_PrintValue( stream, tensorArray[FT3D_02]);
+		Journal_Printf( stream, " ---\n");
+		Journal_PrintValue( stream, tensorArray[FT3D_10]);
+		Journal_PrintValue( stream, tensorArray[FT3D_11]);
+		Journal_PrintValue( stream, tensorArray[FT3D_12]);
+		Journal_Printf( stream, " ---\n");
+		Journal_PrintValue( stream, tensorArray[FT3D_20]);
+		Journal_PrintValue( stream, tensorArray[FT3D_21]);
+		Journal_PrintValue( stream, tensorArray[FT3D_22]);		
+
+		Journal_Printf( stream, "The symmetric tensor:\n");
+		Journal_PrintSymmetricTensor( stream, symmTensor, 3 );
+		
+		Journal_Printf( stream, "The symmetric tensor Mapping using enumerated types:\n");
+		Journal_PrintValue( stream, symmTensor[ST3D_00]);
+		Journal_PrintValue( stream, symmTensor[ST3D_01]);
+		Journal_PrintValue( stream, symmTensor[ST3D_02]);
+		Journal_Printf( stream, " ---\n");
+		Journal_PrintValue( stream, symmTensor[ST3D_11]);
+		Journal_PrintValue( stream, symmTensor[ST3D_12]);
+		Journal_Printf( stream, " ---\n");
+		Journal_PrintValue( stream, symmTensor[ST3D_22]);
+
+		Journal_Printf( stream, "Test Mapping functions for Full Tensor ");
+		Journal_Printf( stream, "using TensorArray_TensorMap\n\n");
+		Journal_Printf( stream, "(0,0): %d  = %d	",	FT3D_00, TensorArray_TensorMap(0,0,3));
+		Journal_Printf( stream, "(0,1): %d  = %d	",	FT3D_01, TensorArray_TensorMap(0,1,3));
+		Journal_Printf( stream, "(0,2): %d  = %d\n", 	FT3D_02, TensorArray_TensorMap(0,2,3));
+
+		Journal_Printf( stream, "(1,0): %d  = %d	", 	FT3D_10, TensorArray_TensorMap(1,0,3));
+		Journal_Printf( stream, "(1,1): %d  = %d	", 	FT3D_11, TensorArray_TensorMap(1,1,3));
+		Journal_Printf( stream, "(1,2): %d  = %d\n", 	FT3D_12, TensorArray_TensorMap(1,2,3));
+
+		Journal_Printf( stream, "(2,0): %d  = %d	", 	FT3D_20, TensorArray_TensorMap(2,0,3));
+		Journal_Printf( stream, "(2,1): %d  = %d	", 	FT3D_21, TensorArray_TensorMap(2,1,3));
+		Journal_Printf( stream, "(2,2): %d  = %d\n", 	FT3D_22, TensorArray_TensorMap(2,2,3));
+
+		Journal_Printf( stream, "Test Mapping functions for Symmetric Tensor ");
+		Journal_Printf( stream, "using SymmetricTensor_TensorMap\n\n");
+		Journal_Printf( stream, "(0,0): %d  = %d	",	ST3D_00, SymmetricTensor_TensorMap(0,0,3));
+		Journal_Printf( stream, "(0,1): %d  = %d	", 	ST3D_01, SymmetricTensor_TensorMap(0,1,3));
+		Journal_Printf( stream, "(0,2): %d  = %d\n", 	ST3D_02, SymmetricTensor_TensorMap(0,2,3));
+		
+		Journal_Printf( stream, "(1,0): %d  = %d	",	ST3D_01, SymmetricTensor_TensorMap(1,0,3));
+		Journal_Printf( stream, "(1,1): %d  = %d	", 	ST3D_11, SymmetricTensor_TensorMap(1,1,3));
+		Journal_Printf( stream, "(1,2): %d  = %d\n", 	ST3D_12, SymmetricTensor_TensorMap(1,2,3));
+
+		Journal_Printf( stream, "(2,0): %d  = %d	", 	ST3D_02, SymmetricTensor_TensorMap(2,0,3));
+		Journal_Printf( stream, "(2,1): %d  = %d	", 	ST3D_12, SymmetricTensor_TensorMap(2,1,3));
+		Journal_Printf( stream, "(2,2): %d  = %d\n", 	ST3D_22, SymmetricTensor_TensorMap(2,2,3));
+		
 		Journal_Printf(stream, "\n/*******************    Test Eigenvector 1   ************************/\n");
 		Journal_Printf( stream, "Symmetric 2D Case from Kresig, p. 371f\n\n");
 		tensorArray[FT2D_00] = -5;



More information about the cig-commits mailing list