Changeset 12475
- Timestamp:
- 06/20/12 12:10:48 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/shared
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/shared/Elements/Arrhenius.cpp
r7848 r12475 6 6 #include <math.h> 7 7 8 double Arrhenius(double temperature,double depth,double n){8 IssmDouble Arrhenius(IssmDouble temperature,IssmDouble depth,IssmDouble n){ 9 9 /*Use EISMINT Parameterization for the rheology: Payne2000 10 10 * … … 25 25 26 26 /*Some physical constants (Payne2000)*/ 27 double beta=8.66*pow(10.,-4.);28 double R=8.314;27 IssmDouble beta=8.66*pow(10.,-4.); 28 IssmDouble R=8.314; 29 29 30 30 /*Intermediaries*/ 31 double A,B,Tstar;31 IssmDouble A,B,Tstar; 32 32 33 33 /*convert temperature to absolute temperature*/ -
issm/trunk-jpl/src/c/shared/Elements/CoordinateSystemTransform.cpp
r12435 r12475 5 5 #include <math.h> 6 6 7 void CoordinateSystemTransform( double** ptransform,Node** nodes,int numnodes,int* cs_array){7 void CoordinateSystemTransform(IssmDouble** ptransform,Node** nodes,int numnodes,int* cs_array){ 8 8 9 9 int i,counter; 10 10 int numdofs = 0; 11 double norm;12 double *transform = NULL;13 double *values = NULL;14 double coord_system[3][3];11 IssmDouble norm; 12 IssmDouble *transform = NULL; 13 IssmDouble *values = NULL; 14 IssmDouble coord_system[3][3]; 15 15 16 16 /*Some checks in debugging mode*/ … … 27 27 28 28 /*Allocate and initialize transform matrix*/ 29 transform=xNew< double>(numdofs*numdofs);29 transform=xNew<IssmDouble>(numdofs*numdofs); 30 30 for(i=0;i<numdofs*numdofs;i++) transform[i]=0.0; 31 31 -
issm/trunk-jpl/src/c/shared/Elements/GetVerticesCoordinates.cpp
r11197 r12475 5 5 #include "./elements.h" 6 6 7 void GetVerticesCoordinates( double* xyz, Node** nodes, int numvertices){7 void GetVerticesCoordinates(IssmDouble* xyz, Node** nodes, int numvertices){ 8 8 9 9 /*In debugging mode, check that nodes is not a NULL pointer*/ -
issm/trunk-jpl/src/c/shared/Elements/Paterson.cpp
r6966 r12475 7 7 #include <math.h> 8 8 9 double Paterson(double temperature){ 9 #include "../../include/include.h" 10 11 IssmDouble Paterson(IssmDouble temperature){ 10 12 11 13 /*output: */ 12 double B;13 double T;14 IssmDouble B; 15 IssmDouble T; 14 16 15 17 /*Switch to celsius from Kelvin: */ … … 30 32 31 33 if(T<=-45.0){ 32 B=pow(( double)10,(double)8)*(-0.000292866376675*pow(T+50,3)+ 0.011672640664130*pow(T+50,2) -0.325004442485481*(T+50)+ 6.524779401948101);34 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000292866376675*pow(T+50,3)+ 0.011672640664130*pow(T+50,2) -0.325004442485481*(T+50)+ 6.524779401948101); 33 35 } 34 36 else if((T>=-45.0) && (T<=-40.0)){ 35 B=pow(( double)10,(double)8)*(-0.000292866376675*pow(T+45,3)+ 0.007279645014004*pow(T+45,2) -0.230243014094813*(T+45)+ 5.154964909039554);37 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000292866376675*pow(T+45,3)+ 0.007279645014004*pow(T+45,2) -0.230243014094813*(T+45)+ 5.154964909039554); 36 38 } 37 39 else if((T>=-40.0) && (T<=-35.0)){ 38 B=pow(( double)10,(double)8)*(0.000072737147457*pow(T+40,3)+ 0.002886649363879*pow(T+40,2) -0.179411542205399*(T+40)+ 4.149132666831214);40 B=pow((IssmPDouble)10,(IssmPDouble)8)*(0.000072737147457*pow(T+40,3)+ 0.002886649363879*pow(T+40,2) -0.179411542205399*(T+40)+ 4.149132666831214); 39 41 } 40 42 else if((T>=-35.0) && (T<=-30.0)){ 41 B=pow(( double)10,(double)8)*(-0.000086144770023*pow(T+35,3)+ 0.003977706575736*pow(T+35,2) -0.145089762507325*(T+35)+ 3.333333333333331);43 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000086144770023*pow(T+35,3)+ 0.003977706575736*pow(T+35,2) -0.145089762507325*(T+35)+ 3.333333333333331); 42 44 } 43 45 else if((T>=-30.0) && (T<=-25.0)){ 44 B=pow(( double)10,(double)8)*(-0.000043984685769*pow(T+30,3)+ 0.002685535025386*pow(T+30,2) -0.111773554501713*(T+30)+ 2.696559088937191);46 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000043984685769*pow(T+30,3)+ 0.002685535025386*pow(T+30,2) -0.111773554501713*(T+30)+ 2.696559088937191); 45 47 } 46 48 else if((T>=-25.0) && (T<=-20.0)){ 47 B=pow(( double)10,(double)8)*(-0.000029799523463*pow(T+25,3)+ 0.002025764738854*pow(T+25,2) -0.088217055680511*(T+25)+ 2.199331606342181);49 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000029799523463*pow(T+25,3)+ 0.002025764738854*pow(T+25,2) -0.088217055680511*(T+25)+ 2.199331606342181); 48 50 } 49 51 else if((T>=-20.0) && (T<=-15.0)){ 50 B=pow(( double)10,(double)8)*(0.000136920904777*pow(T+20,3)+ 0.001578771886910*pow(T+20,2) -0.070194372551690*(T+20)+ 1.805165505978111);52 B=pow((IssmPDouble)10,(IssmPDouble)8)*(0.000136920904777*pow(T+20,3)+ 0.001578771886910*pow(T+20,2) -0.070194372551690*(T+20)+ 1.805165505978111); 51 53 } 52 54 else if((T>=-15.0) && (T<=-10.0)){ 53 B=pow(( double)10,(double)8)*(-0.000899763781026*pow(T+15,3)+ 0.003632585458564*pow(T+15,2) -0.044137585824322*(T+15)+ 1.510778053489523);55 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000899763781026*pow(T+15,3)+ 0.003632585458564*pow(T+15,2) -0.044137585824322*(T+15)+ 1.510778053489523); 54 56 } 55 57 else if((T>=-10.0) && (T<=-5.0)){ 56 B=pow(( double)10,(double)8)*(0.001676964325070*pow(T+10,3)- 0.009863871256831*pow(T+10,2) -0.075294014815659*(T+10)+ 1.268434288203714);58 B=pow((IssmPDouble)10,(IssmPDouble)8)*(0.001676964325070*pow(T+10,3)- 0.009863871256831*pow(T+10,2) -0.075294014815659*(T+10)+ 1.268434288203714); 57 59 } 58 60 else if((T>=-5.0) && (T<=-2.0)){ 59 B=pow(( double)10,(double)8)*(-0.003748937622487*pow(T+5,3)+0.015290593619213*pow(T+5,2) -0.048160403003748*(T+5)+ 0.854987973338348);61 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622487*pow(T+5,3)+0.015290593619213*pow(T+5,2) -0.048160403003748*(T+5)+ 0.854987973338348); 60 62 } 61 63 else if(T>=-2.0){ 62 B=pow(( double)10,(double)8)*(-0.003748937622488*pow(T+2,3)-0.018449844983174*pow(T+2,2) -0.057638157095631*(T+2)+ 0.746900791092860);64 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622488*pow(T+2,3)-0.018449844983174*pow(T+2,2) -0.057638157095631*(T+2)+ 0.746900791092860); 63 65 } 64 66 65 67 /*B cannot be negative!*/ 66 if(B<0) B=pow(( double)10,(double)6);68 if(B<0) B=pow((IssmPDouble)10,(IssmPDouble)6); 67 69 68 70 return B; -
issm/trunk-jpl/src/c/shared/Elements/TransformInvStiffnessMatrixCoord.cpp
r12435 r12475 23 23 int i,j; 24 24 int numdofs = 0; 25 double *transform = NULL;26 double *values = NULL;25 IssmDouble *transform = NULL; 26 IssmDouble *values = NULL; 27 27 28 28 /*Get total number of dofs*/ … … 36 36 37 37 /*Copy current stiffness matrix*/ 38 values=xNew< double>(Ke->nrows*Ke->ncols);38 values=xNew<IssmDouble>(Ke->nrows*Ke->ncols); 39 39 for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j]; 40 40 … … 49 49 50 50 /*Free Matrix*/ 51 xDelete< double>(transform);52 xDelete< double>(values);51 xDelete<IssmDouble>(transform); 52 xDelete<IssmDouble>(values); 53 53 } -
issm/trunk-jpl/src/c/shared/Elements/TransformLoadVectorCoord.cpp
r12437 r12475 22 22 int i,j; 23 23 int numdofs = 0; 24 double *transform = NULL;25 double *values = NULL;24 IssmDouble *transform = NULL; 25 IssmDouble *values = NULL; 26 26 27 27 /*Get total number of dofs*/ … … 35 35 36 36 /*Copy current load vector*/ 37 values=xNew< double>(pe->nrows);37 values=xNew<IssmDouble>(pe->nrows); 38 38 for(i=0;i<pe->nrows;i++) values[i]=pe->values[i]; 39 39 … … 47 47 48 48 /*Free Matrices*/ 49 xDelete< double>(transform);50 xDelete< double>(values);49 xDelete<IssmDouble>(transform); 50 xDelete<IssmDouble>(values); 51 51 } -
issm/trunk-jpl/src/c/shared/Elements/TransformSolutionCoord.cpp
r12437 r12475 4 4 #include "./elements.h" 5 5 6 void TransformSolutionCoord( double* solution,Node** nodes,int numnodes,int cs_enum){6 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int cs_enum){ 7 7 8 8 int* cs_array=NULL; … … 19 19 } 20 20 21 void TransformSolutionCoord( double* solution,Node** nodes,int numnodes,int* cs_array){21 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array){ 22 22 23 23 int i,j; 24 24 int numdofs = 0; 25 double *transform = NULL;26 double *values = NULL;25 IssmDouble *transform = NULL; 26 IssmDouble *values = NULL; 27 27 28 28 /*Get total number of dofs*/ … … 36 36 37 37 /*Copy current solution vector*/ 38 values=xNew< double>(numdofs);38 values=xNew<IssmDouble>(numdofs); 39 39 for(i=0;i<numdofs;i++) values[i]=solution[i]; 40 40 … … 48 48 49 49 /*Free Matrices*/ 50 xDelete< double>(transform);51 xDelete< double>(values);50 xDelete<IssmDouble>(transform); 51 xDelete<IssmDouble>(values); 52 52 } -
issm/trunk-jpl/src/c/shared/Elements/TransformStiffnessMatrixCoord.cpp
r12435 r12475 23 23 int i,j; 24 24 int numdofs = 0; 25 double *transform = NULL;26 double *values = NULL;25 IssmDouble *transform = NULL; 26 IssmDouble *values = NULL; 27 27 28 28 /*Get total number of dofs*/ … … 36 36 37 37 /*Copy current stiffness matrix*/ 38 values=xNew< double>(Ke->nrows*Ke->ncols);38 values=xNew<IssmDouble>(Ke->nrows*Ke->ncols); 39 39 for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j]; 40 40 … … 49 49 50 50 /*Free Matrix*/ 51 xDelete< double>(transform);52 xDelete< double>(values);51 xDelete<IssmDouble>(transform); 52 xDelete<IssmDouble>(values); 53 53 } -
issm/trunk-jpl/src/c/shared/Elements/elements.h
r12248 r12475 11 11 class ElementVector; 12 12 13 double Paterson(double temperature);14 double Arrhenius(double temperature,double depth,double n);15 void GetVerticesCoordinates( double* xyz, Node** nodes, int numvertices);13 IssmDouble Paterson(IssmDouble temperature); 14 IssmDouble Arrhenius(IssmDouble temperature,IssmDouble depth,IssmDouble n); 15 void GetVerticesCoordinates(IssmDouble* xyz, Node** nodes, int numvertices); 16 16 int GetNumberOfDofs( Node** nodes,int numnodes,int setenum,int approximation_enum); 17 17 int* GetLocalDofList( Node** nodes,int numnodes,int setenum,int approximation_enum); 18 18 int* GetGlobalDofList(Node** nodes,int numnodes,int setenum,int approximation_enum); 19 19 #ifdef _HAVE_DIAGNOSTIC_ 20 void CoordinateSystemTransform( double** ptransform,Node** nodes,int numnodes,int* cs_array);20 void CoordinateSystemTransform(IssmDouble** ptransform,Node** nodes,int numnodes,int* cs_array); 21 21 void TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int cs_enum); 22 22 void TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int* cs_array); … … 25 25 void TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int cs_enum); 26 26 void TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int* cs_array); 27 void TransformSolutionCoord( double* solution,Node** nodes,int numnodes,int cs_enum);28 void TransformSolutionCoord( double* solution,Node** nodes,int numnodes,int* cs_array);27 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int cs_enum); 28 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array); 29 29 #endif 30 30 31 inline void printarray( double* array,int lines,int cols=1){31 inline void printarray(IssmDouble* array,int lines,int cols=1){ 32 32 printf("\n"); 33 33 for(int i=0;i<lines;i++){ -
issm/trunk-jpl/src/c/shared/Matrix/MatrixUtils.cpp
r12441 r12475 17 17 18 18 /*FUNCTION TripleMultiply {{{*/ 19 int TripleMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int nrowc, int ncolc, int itrnc, double* d, int iaddd){19 int TripleMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int nrowc, int ncolc, int itrnc, IssmDouble* d, int iaddd){ 20 20 /*TripleMultiply Perform triple matrix product a*b*c+d.*/ 21 21 22 22 int idima,idimb,idimc,idimd; 23 double* dtemp;23 IssmDouble* dtemp; 24 24 25 25 /* set up dimensions for triple product */ … … 62 62 /* perform the matrix triple product in the order that minimizes the 63 63 number of multiplies and the temporary space used, noting that 64 (a*b)*c requires ac(b+d) multiplies and ac doubles, and a*(b*c)65 requires bd(a+c) multiplies and bd doubles (both are the same for64 (a*b)*c requires ac(b+d) multiplies and ac IssmDoubles, and a*(b*c) 65 requires bd(a+c) multiplies and bd IssmDoubles (both are the same for 66 66 a symmetric triple product) */ 67 67 … … 69 69 70 70 if (idima*idimc*(idimb+idimd) <= idimb*idimd*(idima+idimc)) { 71 dtemp=xNew< double>(idima*idimc);71 dtemp=xNew<IssmDouble>(idima*idimc); 72 72 73 73 MatrixMultiply(a,nrowa,ncola,itrna,b,nrowb,ncolb,itrnb,dtemp,0); 74 74 MatrixMultiply(dtemp,idima,idimc,0,c,nrowc,ncolc,itrnc,d,iaddd); 75 xDelete< double>(dtemp);75 xDelete<IssmDouble>(dtemp); 76 76 } 77 77 … … 79 79 80 80 else { 81 dtemp=xNew< double>(idimb*idimd);81 dtemp=xNew<IssmDouble>(idimb*idimd); 82 82 83 83 MatrixMultiply(b,nrowb,ncolb,itrnb,c,nrowc,ncolc,itrnc,dtemp,0); 84 84 MatrixMultiply(a,nrowa,ncola,itrna,dtemp,idimb,idimd,0,d,iaddd); 85 xDelete< double>(dtemp);85 xDelete<IssmDouble>(dtemp); 86 86 } 87 87 … … 89 89 }/*}}}*/ 90 90 /*FUNCTION MatrixMuliply {{{*/ 91 int MatrixMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int iaddc ){91 int MatrixMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int iaddc ){ 92 92 /*MatrixMultiply Perform matrix multiplication a*b+c.*/ 93 93 int noerr=1; … … 158 158 }/*}}}*/ 159 159 /*FUNCTION MatrixInverse {{{*/ 160 int MatrixInverse( double* a, int ndim, int nrow, double* b, int nvec, double* pdet ){160 int MatrixInverse( IssmDouble* a, int ndim, int nrow, IssmDouble* b, int nvec, IssmDouble* pdet ){ 161 161 /* MatrixInverse Perform matrix inversion and linear equation solution. 162 162 … … 172 172 int i,j,k,ipt,jpt,irow,icol,ipiv,ncol; 173 173 int *pivrc1,*pivrc2,*pindx; 174 double pivot,det,dtemp;174 IssmDouble pivot,det,dtemp; 175 175 176 176 if (!b && nvec) { … … 333 333 return noerr; 334 334 }/*}}}*/ 335 /*FUNCTION Matrix2x2Determinant( double* Adet,double* A) {{{*/336 void Matrix2x2Determinant( double* Adet,double* A){335 /*FUNCTION Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A) {{{*/ 336 void Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A){ 337 337 /*Compute determinant of a 2x2 matrix*/ 338 338 … … 341 341 } 342 342 /*}}}*/ 343 /*FUNCTION Matrix2x2Invert( double* Ainv,double* A) {{{*/344 void Matrix2x2Invert( double* Ainv,double* A){343 /*FUNCTION Matrix2x2Invert(IssmDouble* Ainv,IssmDouble* A) {{{*/ 344 void Matrix2x2Invert(IssmDouble* Ainv,IssmDouble* A){ 345 345 346 346 /*Intermediaries*/ 347 double det;347 IssmDouble det; 348 348 349 349 /*Compute determinant*/ … … 358 358 359 359 }/*}}}*/ 360 /*FUNCTION Matrix3x3Determinant( double* Adet,double* A) {{{*/361 void Matrix3x3Determinant( double* Adet,double* A){360 /*FUNCTION Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A) {{{*/ 361 void Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A){ 362 362 /*Compute determinant of a 3x3 matrix*/ 363 363 … … 366 366 } 367 367 /*}}}*/ 368 /*FUNCTION Matrix3x3Invert( double* Ainv,double* A) {{{*/369 void Matrix3x3Invert( double* Ainv,double* A){368 /*FUNCTION Matrix3x3Invert(IssmDouble* Ainv,IssmDouble* A) {{{*/ 369 void Matrix3x3Invert(IssmDouble* Ainv,IssmDouble* A){ 370 370 371 371 /*Intermediaries*/ 372 double det;372 IssmDouble det; 373 373 374 374 /*Compute determinant*/ … … 388 388 389 389 }/*}}}*/ 390 /*FUNCTION MatrixTranspose( double* Adet,double* A) {{{*/391 void MatrixTranspose( double* tA,double* A, int nrows, int ncols){390 /*FUNCTION MatrixTranspose(IssmDouble* Adet,IssmDouble* A) {{{*/ 391 void MatrixTranspose(IssmDouble* tA,IssmDouble* A, int nrows, int ncols){ 392 392 /*Transpose a n*m matrix*/ 393 393 -
issm/trunk-jpl/src/c/shared/Matrix/matrix.h
r5371 r12475 6 6 #define _MATRIXUTILS_H_ 7 7 8 int TripleMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int nrowc, int ncolc, int itrnc, double* d, int iaddd); 9 int MatrixMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int iaddc ); 10 int MatrixInverse( double* a, int ndim, int nrow, double* b, int nvec, double* pdet ); 11 void Matrix2x2Invert(double* Ainv, double* A); 12 void Matrix2x2Determinant(double* Adet,double* A); 13 void Matrix3x3Invert(double* Ainv, double* A); 14 void Matrix3x3Determinant(double* Adet,double* A); 15 void MatrixTranspose(double* tA,double* A,int nrows, int ncols); 8 #include "../../include/include.h" 9 10 int TripleMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int nrowc, int ncolc, int itrnc, IssmDouble* d, int iaddd); 11 int MatrixMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int iaddc ); 12 int MatrixInverse( IssmDouble* a, int ndim, int nrow, IssmDouble* b, int nvec, IssmDouble* pdet ); 13 void Matrix2x2Invert(IssmDouble* Ainv, IssmDouble* A); 14 void Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A); 15 void Matrix3x3Invert(IssmDouble* Ainv, IssmDouble* A); 16 void Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A); 17 void MatrixTranspose(IssmDouble* tA,IssmDouble* A,int nrows, int ncols); 16 18 17 19 #endif //ifndef _MATRIXUTILS_H_
Note:
See TracChangeset
for help on using the changeset viewer.