7 QVector< double >& xvec )
10 double* x = xvec .data();
11 double* radi = C0.
radius .data();
13 int rsiz = C0.
radius .size();
15 for (
int j = 0; j < xvec.size(); j++ )
19 double xc = xs + 1.e-12;
21 for ( i = ja; i < rsiz; i++ )
22 if ( radi[ i ] > xc )
break;
29 C1[ j ] = conc[ i - 1 ];
33 double a = radi[ i - 1 ];
36 double tmp = ( xs - a ) / ( b - a );
40 C1[ j ] = conc[ ja ] * ( 1.0 - tmp ) +
51 double* C0radi = C0.
radius .data();
52 double* C1radi = C1.
radius .data();
55 int r0size = C0.
radius .size();
56 int r1size = C1.
radius .size();
58 for (
int j = 0; j < r1size; j++ )
61 double xs = C1radi[ j ];
62 double xc = xs + 1.e-12;
64 for ( i = ja; i < r0size; i++ )
65 if ( C0.
radius[ i ] > xc )
break;
69 C1conc[ j ] = C0conc[ 0 ];
71 else if ( i == r0size )
72 C1conc[ j ] = C0conc[ i - 1 ];
78 double a = C0radi[ ja ];
79 double b = C0radi[ i ];
81 double tmp = ( xs - a ) / ( b - a );
83 C1conc[ j ] = C0conc[ ja ] * ( 1.0 - tmp ) + C0conc[ i ] * tmp;
90 for (
int i = 0; i < val1; i++ )
91 for (
int j = 0; j < val2; j++ )
92 matrix[ i ][ j ] = 0.0;
97 *matrix =
new double* [ val1 ];
99 for (
int i = 0; i < val1; i++ )
101 (*matrix)[ i ] =
new double [ val2 ];
103 for (
int j = 0; j < val2; j++ )
104 (*matrix)[ i ][ j ] = 0.0;
111 for (
int i = 0; i < val1; i++ )
delete [] matrix[i];
118 const double* avalue = value.data();
119 double minimum = 1.0e300;
121 for (
int i = 0; i < value.size(); i++ )
122 minimum = qMin( minimum, avalue[ i ] );
129 double minimum = 1.0e300;
131 for (
int i = 0; i < value.size(); i++ )
132 minimum =
min( minimum, value[ i ].s );
139 const double* avalue = value.data();
140 double maximum = -1.0e300;
142 for (
int i = 0; i < value.size(); i++ )
143 maximum = qMax( maximum, avalue[ i ]);
150 double maximum = -1.0e300;
152 for (
int i = 0; i < value.size(); i++ )
153 maximum =
max( maximum, value[ i ].s );
159 int val1,
int val2,
int val3,
double**** matrix )
161 *matrix =
new double** [ val1 ];
163 for (
int i = 0; i < val1; i++ )
165 (*matrix)[ i ] =
new double *[ val2 ];
167 for (
int j = 0; j < val2; j++ )
169 (*matrix)[ i ][ j ] =
new double [ val3 ];
171 for (
int k = 0; k < val3; k++ )
173 (*matrix)[ i ][ j ][ k ] = 0.0;
181 for (
int i = 0; i < val1; i++ )
183 for (
int j = 0; j < val2; j++ )
185 delete [] matrix[ i ][ j ];
188 delete [] matrix[ i ];
195 double* r,
double* u,
int N )
199 static QVector< double > gamvec;
200 static int Nsave = 0;
208 QVector< double > gamvec( N );
210 double* gam = gamvec.data();
212 if ( bet == 0.0 ) qDebug() <<
"Error 1 in tridiag";
214 u[ 0 ] = r[ 0 ] / bet;
216 for (
int j = 1; j < N; j++ )
218 gam[ j ] = c[ j - 1 ] / bet;
219 bet = b[ j ] - a[ j ] * gam[ j ];
221 if ( bet == 0.0 ) qDebug() <<
"Error 2 in tridiag";
223 u[ j ] = ( r[ j ] - a[ j ] * u[ j - 1 ] ) / bet;
228 for (
int j = N - 2; j >= 0; j-- )
229 u[ j ] -= gam[ j + 1 ] * u[ j + 1 ];
244 double Q = ( 3.0 * a1 -
sq( a2 ) ) / 9.0;
245 double S = ( 9.0 * a1 * a2 - 27.0 * a0 - 2.0 * pow( a2, 3.0 ) ) / 54.0;
246 double D = pow( Q, 3.0 ) +
sq( S );
250 double theta = acos( S / sqrt( pow( -Q, 3.0 ) ) );
251 x = 2.0 * sqrt( -Q ) * cos( theta / 3.0) ;
256 double Dc = sqrt( D );
259 B = - pow( - ( S + Dc ), 1.0 / 3.0 ) - pow( Dc - S, 1.0 / 3.0 );
262 B = pow( S + Dc, 1.0 / 3.0) - pow( Dc - S, 1.0 / 3.0);
265 B = pow( S + Dc, 1.0 / 3.0 ) + pow( S - Dc, 1.0 / 3.0 );
267 double Dc2 = -3.0 * (pow(B, 2.0) + 4 * Q);
270 x =
max( B, 0.5 * ( -B + sqrt( Dc2 ) ) );
292 const int MaxNumIt = 1000;
295 if ( CT <= 0.0 )
return 0.0 ;
296 if ( CT <= 1.0e-12 )
return CT;
298 for ( i = 1; i < MaxNumIt; i++ )
300 x1 = ( K * ( n - 1.0 ) * pow( x0, (
double)n ) + CT ) /
301 ( 1.0 + K * n * pow( x0, n - 1.0 ) );
303 if ( fabs( x1 - x0 ) / ( 1.0 + fabs( x1 ) ) < 1.e-12 )
break;
309 qDebug() <<
"warning: Newton's method did not coonverges "
310 "in find_C1_mono_Nmer";
314 return 0.5 * ( x0 + x1 );
329 for (
int i = 0; i < n; i++ )
332 double amax = fabs( a[ i ][ i ] );
335 for (
int ip = i + 1; ip < n; ip++ )
337 if ( fabs( a[ ip ][ i ] ) > amax )
339 amax = fabs( a[ ip ][ i ]);
346 qDebug() <<
"Singular matrix in routine GaussElim";
355 double* ptmp = a[ i ];
367 for (
int j = i; j < n; j++ ) a[ i ][ j ] /= tmp;
371 for (
int ip = i + 1; ip < n; ip++ )
375 for (
int j = i + 1; j < n; j++ )
376 a[ ip ][ j ] -= tmp * a[ i ][ j ];
378 b[ ip ] -= tmp * b[ i ];
383 for (
int i = n - 2; i >= 0; i-- )
384 for (
int j = i + 1; j < n; j++ ) b[ i ] -= a[ i ][ j ] * b[ j ];
397 if ( expdata.
scan.size() == 0 || expdata.
scan[ 0 ].conc.size() == 0 ||
398 simdata.
scan.size() == 0 || simdata.
radius.size() == 0 )
406 int escans = expdata.
scan.size();
407 int sscans = simdata.
scan.size();
408 double e_omega = 0.0;
413 double s_time = simdata.
scan[ 0 ].time;
414 double l_time = simdata.
scan[ sscans - 1 ].time;
416 for (
int expscan = 0; expscan < escans; expscan++ )
418 e_time = expdata.
scan[ expscan ].time;
419 if ( fscan < 0 && e_time >= s_time )
421 if ( e_time > l_time )
428 qDebug() <<
"MATHi: s_time e_time" << s_time << e_time
429 <<
"fscan lscan" << fscan << lscan;
430 fscan = ( fscan < 0 ) ? 0 : fscan;
431 lscan = ( lscan < 0 ) ? escans : qMin( lscan, escans );
435 double s_omega = simdata.
scan[ 0 ].omega_s_t;
436 double l_omega = simdata.
scan[ sscans - 1 ].omega_s_t;
438 for (
int expscan = 0; expscan < escans; expscan++ )
440 e_omega = expdata.
scan[ expscan ].omega_s_t;
441 if ( fscan < 0 && e_omega >= s_omega )
443 if ( e_omega > l_omega )
450 fscan = ( fscan < 0 ) ? 0 : fscan;
451 lscan = ( lscan < 0 ) ? escans : qMin( lscan, escans );
456 if ( fscan < 0 || lscan < 0 )
460 interpolate( expdata, simdata, use_time, fscan, lscan );
467 bool use_time,
int fscan,
int lscan )
477 int nsscan = simdata.
scan.size();
478 int nsconc = simdata.
radius.size();
479 int nescan = expdata.
scan.size();
480 int neconc = expdata.
scan[ 0 ].conc.size();
482 if ( nescan == 0 || neconc == 0 || nsscan == 0 || nsconc == 0 )
493 tmp_data.
scan .clear();
495 tmp_data.
scan .reserve( nescan );
496 tmp_data.
radius.reserve( nsconc );
500 for (
int ii = 0; ii < nsconc; ii++ )
509 double e_omega = 0.0;
518 int eftime = (int)expdata.
scan[ 0 ].time;
519 int sltime = (
int)simdata.
scan[ nsscan - 1 ].time;
521 for (
int expscan = fscan; expscan < lscan; expscan++ )
528 e_time = escan->
time;
530 while ( simdata.
scan[ simscan ].time < e_time )
534 if ( simscan == nsscan )
536 if ( sltime >= eftime )
538 qDebug() <<
"simulation time scan[" << simscan <<
"]: "
539 << simdata.
scan[ simscan - 1 ].time
540 <<
", expdata scan time[" << expscan <<
"]: "
541 << expdata.
scan[ expscan ].time;
543 qDebug() <<
"The simulated data does not cover the entire "
544 "experimental time range and ends too early!\n"
550 MPI_Abort( MPI_COMM_WORLD, -1 );
560 int sscm = ( simscan > 0 ) ? ( simscan - 1 ) : 1;
561 sscan1 = &simdata.
scan[ sscm ];
562 sscan2 = &simdata.
scan[ simscan ];
564 s_time1 = sscan1->
time;
566 s_time2 = sscan2->
time;
569 if ( s_time2 == e_time )
572 tmp_data.
scan << simdata.
scan[ simscan ];
578 tmp_scan.
conc.clear();
579 tmp_scan.
conc.reserve( nsconc );
582 for (
int ii = 0; ii < nsconc; ii++ )
584 a = ( sscan2->
conc[ ii ] - sscan1->
conc[ ii ] ) /
585 ( s_time2 - s_time1 );
587 b = sscan2->
conc[ ii ] - a * s_time2;
589 tmp_scan.
conc << ( a * e_time + b );
594 a = ( s_omega2 - s_omega1 ) / ( s_time2 - s_time1 );
596 b = s_omega2 - a * s_time2;
600 tmp_data.
scan << tmp_scan;
606 for (
int expscan = fscan; expscan < lscan; expscan++ )
613 e_time = escan->
time;
617 while ( simdata.
scan[ simscan ].omega_s_t < e_omega )
621 if ( simscan == (
int) simdata.
scan.size() )
623 qDebug() <<
"simulation omega^2t scan[" << simscan <<
"]: "
624 << simdata.
scan[ simscan - 1 ].omega_s_t
625 <<
", expdata scan omega^2t[" << expscan <<
"]: "
626 << expdata.
scan[ expscan ].omega_s_t;
639 qDebug() <<
"The simulated data does not cover the entire "
640 "experimental time range and ends too early!\n"
648 int sscm = ( simscan > 0 ) ? ( simscan - 1 ) : 1;
649 sscan1 = &simdata.
scan[ sscm ];
650 sscan2 = &simdata.
scan[ simscan ];
652 s_time1 = sscan1->
time;
654 s_time2 = sscan2->
time;
657 if ( s_omega2 == e_omega )
660 tmp_data.
scan << simdata.
scan[ simscan ];
666 tmp_scan.
conc.clear();
667 tmp_scan.
conc.reserve( nsconc );
670 for (
int ii = 0; ii < nsconc; ii++ )
672 a = ( sscan2->
conc[ ii ] - sscan1->
conc[ ii ] ) /
673 ( s_omega2 - s_omega1 );
675 b = sscan2->
conc[ ii ] - a * s_omega2;
677 tmp_scan.
conc << ( a * e_omega + b );
682 a = ( s_time2 - s_time1 ) / ( s_omega2 - s_omega1 );
684 b = s_time2 - a * s_omega2;
686 escan->
time = a * e_omega + b;
689 tmp_data.
scan << tmp_scan;
698 qDebug() <<
"Radius comparison: " << tmp_data.
radius[ 0 ]
699 <<
" (simulated), " << expdata.
radius[ 0 ]
700 <<
" (experimental)";
702 qDebug() <<
"jj = " << 0 <<
", simdata radius: "
703 << tmp_data.
radius[ 0 ] <<
", expdata radius: "
707 qDebug() <<
"The simulated data radial range does not include the "
708 "beginning of the experimental data's radii!\n"
712 MPI_Abort( MPI_COMM_WORLD, -3 );
719 for (
int ii = 0; ii < neconc; ii++ )
725 if ( jj == tmp_data.
radius.size() )
727 qDebug() <<
"The simulated data does not have enough "
728 "radial points and ends too early!\n"
733 MPI_Abort( MPI_COMM_WORLD, -2 );
743 for (
int expscan = fscan; expscan < lscan; expscan++ )
744 expdata.
scan[ expscan ].conc[ ii ] +=
745 tmp_data.
scan[ ee++ ].conc[ jj ];
751 double radius1 = tmp_data.
radius[ mm ];
752 double radius2 = tmp_data.
radius[ jj ];
753 double eradius = expdata .
radius[ ii ];
754 double radrange = radius2 - radius1;
759 for (
int expscan = fscan; expscan < lscan; expscan++ )
763 double a = ( tscan->
conc[ jj ] - tscan->
conc[ mm ] ) / radrange;
765 double b = tscan->
conc[ jj ] - a * radius2;
767 expdata.
scan[ expscan ].conc[ ii ] += ( a * eradius + b );
781 double* di,
double* cr,
double* solu,
int N )
796 QVector< double > caVec( N );
797 QVector< double > cbVec( N );
798 QVector< double > ccVec( N );
799 QVector< double > cdVec( N );
800 double* ca = caVec.data();
801 double* cb = cbVec.data();
802 double* cc = ccVec.data();
803 double* cd = cdVec.data();
805 for (
int i = 0; i < N; i++ )
813 for (
int i = 1; i <= N - 2; i++ )
815 double tmp = ca[ i ] / cb[ i - 1 ];
817 cb[ i ] = cb[ i ] -cc [ i - 1] * tmp;
818 cc[ i ] = cc[ i ] -cd [ i - 1] * tmp;
819 cr[ i ] = cr[ i ] -cr [ i - 1] * tmp;
823 double tmp = ca[ i ] / cb[ i - 1 ];
825 cb[ i] = cb[ i ] - cc[ i - 1 ] * tmp;
826 cr[ i ] = cr[ i ] - cr[ i - 1 ] * tmp;
828 solu[ N - 1 ] = cr[ N - 1 ] / cb[ N - 1 ];
829 solu[ N - 2 ] = ( cr[ N - 2 ] - cc[ N - 2 ] * solu[ N - 1] ) / cb[ N - 2 ];
835 solu[ i ] = ( cr[ i ]
836 - cc[ i ] * solu[ i + 1 ]
837 - cd[ i ] * solu[ i + 2 ] ) /
847 double** Stif,
double dt )
852 double x_gauss, y_gauss, dval;
853 double hh, slope, xn1, phiC, phiCx;
854 double Lx[ 3 ], Ly[ 3 ];
856 double Qx[ 3 ], Qy[ 3 ];
857 double Tx[ 3 ], Ty[ 3 ];
886 hh = vx[ 3 ] - vx[ 2 ];
887 slope = ( vx[ 3 ] - vx[ 5 ] ) / dt;
903 for (k=0; k<npts; k++)
905 x_gauss = Lam[k][0] * Qx[0] + Lam[k][1] * Qx[1] + Lam[k][2] * Qx[2];
906 y_gauss = Lam[k][0] * Qy[0] + Lam[k][1] * Qy[1] + Lam[k][2] * Qy[2];
907 DJac = 2.0 *
AreaT( Qx, Qy );
910 xn1 = x_gauss + slope * ( dt - y_gauss );
916 BasisTR( Lx, Ly, x_gauss, y_gauss, phiL, phiLx, phiLy);
918 phiC = ( xn1 - vx[ 2 ] ) / hh;
923 dval =
Integrand(x_gauss, D, sw2, phiL[i], phiLx[i], phiLy[i],
925 StifL[i][0] += Lam[k][3] * DJac * dval;
927 dval =
Integrand(x_gauss, D, sw2, phiL[i], phiLx[i], phiLy[i],
929 StifL[i][1] += Lam[k][3] * DJac * dval;
944 for ( k = 0; k < npts; k++ )
946 x_gauss = Lam[k][0] * Tx[0] + Lam[k][1] * Tx[1] + Lam[k][2] * Tx[2];
947 y_gauss = Lam[k][0] * Ty[0] + Lam[k][1] * Ty[1] + Lam[k][2] * Ty[2];
948 DJac = 2.0 *
AreaT( Tx, Ty );
950 if( DJac < 1.e-22 )
break;
952 xn1 = x_gauss + slope * ( dt - y_gauss );
958 BasisQR( Rx, x_gauss, y_gauss, phiR, phiRx, phiRy, dt);
959 phiC = ( xn1 - vx[ 2 ] ) / hh;
963 for (i = 0; i < 4; i++ )
965 dval =
Integrand( x_gauss, D, sw2, phiR[ i ], phiRx[ i ],
966 phiRy[ i ], 1. - phiC, -phiCx );
967 StifR[ i ][ 0 ] += Lam[ k ][ 3 ] * DJac * dval;
969 dval =
Integrand( x_gauss, D, sw2, phiR[ i ], phiRx[ i ],
970 phiRy[ i ], phiC, phiCx );
971 StifR[ i ][ 1 ] += Lam[k][3] * DJac * dval;
977 for ( i = 0; i < 2; i++ )
979 Stif[ 0 ][ i ] = StifL[ 0 ][ i ] + StifR[ 0 ][ i ];
980 Stif[ 1 ][ i ] = StifR[ 1 ][ i ];
981 Stif[ 2 ][ i ] = StifL[ 2 ][ i ];
982 Stif[ 3 ][ i ] = StifL[ 1 ][ i ] + StifR[ 3 ][ i ];
983 Stif[ 4 ][ i ] = StifR[ 2 ][ i ];
991 double** Stif,
double dt )
996 double x_gauss, y_gauss, dval;
1000 double Qx[ 4 ], Qy[ 4 ];
1001 double Tx[ 3 ], Ty[ 3 ];
1057 for ( k = 0; k < npts; k++ )
1059 BasisQS( Gs[k][0], Gs[k][1], psi, psi1, psi2 );
1063 for ( i = 0; i < 4; i++ )
1067 for ( i = 0; i < 4; i++ )
1069 x_gauss += psi[ i ] * Qx[ i ];
1070 y_gauss += psi[ i ] * Qy[ i ];
1071 jac[ 0 ] += Qx[ i ] * psi1[ i ];
1072 jac[ 1 ] += Qx[ i ] * psi2[ i ];
1073 jac[ 2 ] += Qy[ i ] * psi1[ i ];
1074 jac[ 3 ] += Qy[ i ] * psi2[ i ];
1077 DJac = jac[ 0 ] * jac[ 3 ] - jac[ 1 ] * jac[ 2 ];
1083 BasisQR( Lx, x_gauss, y_gauss, phiL, phiLx, phiLy, dt );
1084 BasisQR( Cx, x_gauss, y_gauss, phiC, phiCx, phiCy, dt );
1086 for ( i = 0; i < 4; i++ )
1088 dval =
Integrand( x_gauss, D, sw2, phiL[ i ], phiLx[ i ], phiLy[ i ],
1089 phiC[ 0 ] + phiC[ 3 ], phiCx[ 0 ] + phiCx[ 3 ] );
1090 StifL[ i ][ 0 ] += Gs[ k ][ 2 ] * DJac * dval;
1092 dval =
Integrand( x_gauss, D, sw2, phiL[i], phiLx[i], phiLy[i],
1093 phiC[ 1 ] + phiC[ 2 ], phiCx[ 1 ] + phiCx[ 2 ] );
1094 StifL[ i ][ 1 ] += Gs[ k ][ 2 ] * DJac * dval;
1115 for ( k = 0; k < npts; k++ )
1117 x_gauss = Lam[ k ][ 0 ] * Tx[ 0 ] + Lam[ k ][ 1 ] * Tx[ 1 ] +
1118 Lam[ k ][ 2 ] * Tx[ 2 ];
1119 y_gauss = Lam[ k ][ 0 ] * Ty[ 0 ] + Lam[ k ][ 1 ] * Ty[ 1 ] +
1120 Lam[ k ][ 2 ] * Ty[ 2 ];
1121 DJac = 2.0 *
AreaT( Tx, Ty );
1123 if ( DJac < 1.e-22 )
break;
1129 BasisQR( Rx, x_gauss, y_gauss, phiR, phiRx, phiRy, dt );
1130 BasisQR( Cx, x_gauss, y_gauss, phiC, phiCx, phiCy, dt );
1132 for (i = 0; i < 4; i++ )
1134 dval =
Integrand( x_gauss, D, sw2, phiR[ i ], phiRx[ i ], phiRy[ i ],
1135 phiC[ 0 ] + phiC[ 3 ], phiCx[ 0 ] + phiCx[ 3 ] );
1136 StifR[ i ][ 0 ] += Lam[ k ][ 3 ] * DJac * dval;
1138 dval =
Integrand( x_gauss, D, sw2, phiR[ i ], phiRx[ i ], phiRy[ i ],
1139 phiC[ 1 ] + phiC[ 2 ], phiCx[ 1 ] + phiCx[ 2 ] );
1140 StifR[ i ][ 1 ] += Lam[ k ][ 3 ] * DJac * dval;
1146 for ( i = 0; i < 2; i++ )
1148 Stif[ 0 ][ i ] = StifL[ 0 ][ i ];
1149 Stif[ 1 ][ i ] = StifL[ 1 ][ i ] + StifR[ 0 ][ i ];
1150 Stif[ 2 ][ i ] = StifR[ 1 ][ i ];
1151 Stif[ 3 ][ i ] = StifL[ 3 ][ i ];
1152 Stif[ 4 ][ i ] = StifL[ 2 ][ i ] + StifR[ 3 ][ i ];
1153 Stif[ 5 ][ i ] = StifR[ 2 ][ i ];
1162 double** Stif,
double dt )
1167 double x_gauss, y_gauss, dval;
1170 double Rx[ 3 ], Ry[ 3 ];
1171 double Qx[ 4 ], Qy[ 4 ];
1172 double Tx[ 3 ], Ty[ 3 ];
1226 double psi[ 4 ], psi1[ 4 ], psi2[ 4 ], jac[ 4 ];
1228 for ( k = 0; k < npts; k++ )
1230 BasisQS( Gs[ k ][ 0 ], Gs[ k ][ 1 ], psi, psi1, psi2 );
1235 for ( i = 0; i < 4; i++ )
1240 for ( i = 0; i < 4; i++ )
1242 x_gauss += psi[ i ] * Qx[ i ];
1243 y_gauss += psi[ i ] * Qy[ i ];
1244 jac[ 0 ] += Qx[ i ] * psi1[ i ];
1245 jac[ 1 ] += Qx[ i ] * psi2[ i ];
1246 jac[ 2 ] += Qy[ i ] * psi1[ i ];
1247 jac[ 3 ] += Qy[ i ] * psi2[ i ];
1250 DJac = jac[ 0 ] * jac[ 3 ] - jac[ 1] * jac[ 2 ];
1256 BasisQR( Lx, x_gauss, y_gauss, phiL, phiLx, phiLy, dt );
1257 BasisQR( Cx, x_gauss, y_gauss, phiC, phiCx, phiCy, dt );
1259 for ( i = 0; i < 4; i++ )
1261 dval =
Integrand( x_gauss, D, sw2, phiL[ i ], phiLx[ i ], phiLy[ i ],
1262 phiC[ 0 ] + phiC[ 3 ], phiCx[ 0 ] + phiCx[ 3 ] );
1263 StifL[ i ][ 0 ] += Gs[ k ][ 2 ] * DJac * dval;
1265 dval =
Integrand( x_gauss, D, sw2, phiL[ i ], phiLx[ i ], phiLy[ i ],
1266 phiC[ 1 ] + phiC[ 2 ], phiCx[ 1 ] + phiCx[ 2 ] );
1267 StifL[ i ][ 1 ] += Gs[ k ][ 2 ] * DJac * dval;
1288 for ( k = 0; k < npts; k++ )
1290 x_gauss = Lam[ k ][ 0 ] * Tx[ 0 ] + Lam[ k ][ 1 ] *
1291 Tx[ 1 ] + Lam[ k ][ 2 ] * Tx[ 2 ];
1292 y_gauss = Lam[ k ][ 0 ] * Ty[ 0 ] + Lam[ k ][ 1 ] *
1293 Ty[ 1 ] + Lam[ k ][ 2 ] * Ty[ 2 ];
1294 DJac = 2.0 *
AreaT( Tx, Ty );
1296 if ( DJac < 1.e-22 )
break;
1302 BasisQR( Cx, x_gauss, y_gauss, phiC, phiCx, phiCy, dt );
1303 BasisTR( Rx, Ry, x_gauss, y_gauss, phiR, phiRx, phiRy );
1305 for ( i = 0; i < 3; i++ )
1307 dval =
Integrand( x_gauss, D, sw2, phiR[ i ], phiRx[ i ], phiRy[ i ],
1308 phiC[ 0 ] + phiC[ 3 ], phiCx[ 0 ] + phiCx[ 3 ] );
1309 StifR[ i ][ 0 ] += Lam[ k ][ 3 ] * DJac * dval;
1311 dval =
Integrand( x_gauss, D, sw2, phiR[ i ], phiRx[ i ], phiRy[ i ],
1312 phiC[ 1 ] + phiC[ 2 ], phiCx[ 1 ] + phiCx[ 2 ] );
1313 StifR[ i ][ 1 ] += Lam[ k ][ 3 ] * DJac * dval;
1319 for ( i = 0; i < 2; i++ )
1321 Stif[ 0 ][ i ] = StifL[ 0 ][ i ];
1322 Stif[ 1 ][ i ] = StifL[ 1 ][ i ] + StifR[ 0 ][ i ] ;
1323 Stif[ 2 ][ i ] = StifR[ 1 ][ i ];
1324 Stif[ 3 ][ i ] = StifL[ 3 ][ i ];
1325 Stif[ 4 ][ i ] = StifL[ 2 ][ i ] + StifR[ 2 ][ i ];
1333 double** Stif,
double dt )
1338 double x_gauss, y_gauss, dval;
1339 double Lx[ 3 ], Ly[ 3 ];
1340 double Tx[ 3 ], Ty[ 3 ];
1373 for ( k = 0; k < npts; k++ )
1375 x_gauss = Lam[ k ][ 0 ] * Tx[ 0 ] + Lam[ k ][ 1 ] *
1376 Tx[ 1 ] + Lam[ k ][ 2 ] * Tx[ 2 ];
1377 y_gauss = Lam[ k ][ 0 ] * Ty[ 0 ] + Lam[ k ][ 1 ] *
1378 Ty[ 1 ] + Lam[ k ][ 2 ] * Ty[ 2 ];
1379 DJac = 2.0 *
AreaT( Tx, Ty );
1381 if ( DJac < 1.e-22 )
break;
1386 BasisTR( Lx, Ly, x_gauss, y_gauss, phiL, phiLx, phiLy );
1388 for ( i = 0; i < 3; i++ )
1390 dval =
Integrand( x_gauss, D, sw2, phiL[ i ], phiLx[ i ], phiLy[ i ],
1392 StifR[ i ][ 0 ] += Lam[ k ][ 3 ] * DJac * dval;
1396 for ( i = 0; i < 2; i++ )
1398 Stif[ 0 ][ i ] = StifR[ 0 ][ i ];
1399 Stif[ 1 ][ i ] = StifR[ 1 ][ i ];
1400 Stif[ 2 ][ i ] = StifR[ 2 ][ i ];
1417 Lam[ 0 ][ 0 ] = 0.873821971016996;
1418 Lam[ 1 ][ 0 ] = 0.063089014491502;
1419 Lam[ 2 ][ 0 ] = 0.063089014491502;
1420 Lam[ 3 ][ 0 ] = 0.501426509658179;
1421 Lam[ 4 ][ 0 ] = 0.249286745170910;
1422 Lam[ 5 ][ 0 ] = 0.249286745170910;
1423 Lam[ 6 ][ 0 ] = 0.636502499121399;
1424 Lam[ 7 ][ 0 ] = 0.636502499121399;
1425 Lam[ 8 ][ 0 ] = 0.310352451033785;
1426 Lam[ 9 ][ 0 ] = 0.310352451033785;
1427 Lam[ 10 ][ 0 ] = 0.053145049844816;
1428 Lam[ 11 ][ 0 ] = 0.053145049844816;
1430 Lam[ 0 ][ 1 ] = 0.063089014491502;
1431 Lam[ 1 ][ 1 ] = 0.873821971016996;
1432 Lam[ 2 ][ 1 ] = 0.063089014491502;
1433 Lam[ 3 ][ 1 ] = 0.249286745170910;
1434 Lam[ 4 ][ 1 ] = 0.501426509658179;
1435 Lam[ 5 ][ 1 ] = 0.249286745170910;
1436 Lam[ 6 ][ 1 ] = 0.310352451033785;
1437 Lam[ 7 ][ 1 ] = 0.053145049844816;
1438 Lam[ 8 ][ 1 ] = 0.636502499121399;
1439 Lam[ 9 ][ 1 ] = 0.053145049844816;
1440 Lam[ 10 ][ 1 ] = 0.636502499121399;
1441 Lam[ 11 ][ 1 ] = 0.310352451033785;
1443 Lam[ 0 ][ 3 ] = 0.050844906370207;
1444 Lam[ 1 ][ 3 ] = 0.050844906370207;
1445 Lam[ 2 ][ 3 ] = 0.050844906370207;
1446 Lam[ 3 ][ 3 ] = 0.116786275726379;
1447 Lam[ 4 ][ 3 ] = 0.116786275726379;
1448 Lam[ 5 ][ 3 ] = 0.116786275726379;
1449 Lam[ 6 ][ 3 ] = 0.082851075618374;
1450 Lam[ 7 ][ 3 ] = 0.082851075618374;
1451 Lam[ 8 ][ 3 ] = 0.082851075618374;
1452 Lam[ 9 ][ 3 ] = 0.082851075618374;
1453 Lam[ 10 ][ 3 ] = 0.082851075618374;
1454 Lam[ 11 ][ 3 ] = 0.082851075618374;
1461 Lam[ 0 ][ 0 ] = 0.33333333333333333;
1462 Lam[ 1 ][ 0 ] = 0.9480217181434233;
1463 Lam[ 2 ][ 0 ] = 0.02598914092828833;
1464 Lam[ 3 ][ 0 ] = 0.02598914092828833;
1465 Lam[ 4 ][ 0 ] = 0.8114249947041546;
1466 Lam[ 5 ][ 0 ] = 0.09428750264792270;
1467 Lam[ 6 ][ 0 ] = 0.09428750264792270;
1468 Lam[ 7 ][ 0 ] = 0.01072644996557060;
1469 Lam[ 8 ][ 0 ] = 0.4946367750172147;
1470 Lam[ 9 ][ 0 ] = 0.4946367750172147;
1471 Lam[ 10 ][ 0 ] = 0.5853132347709715;
1472 Lam[ 11 ][ 0 ] = 0.2073433826145142;
1473 Lam[ 12 ][ 0 ] = 0.2073433826145142;
1474 Lam[ 13 ][ 0 ] = 0.1221843885990187;
1475 Lam[ 14 ][ 0 ] = 0.4389078057004907;
1476 Lam[ 15 ][ 0 ] = 0.4389078057004907;
1477 Lam[ 16 ][ 0 ] = 0.6779376548825902;
1478 Lam[ 17 ][ 0 ] = 0.6779376548825902;
1479 Lam[ 18 ][ 0 ] = 0.04484167758913055;
1480 Lam[ 19 ][ 0 ] = 0.04484167758913055;
1481 Lam[ 20 ][ 0 ] = 0.27722066752827925;
1482 Lam[ 21 ][ 0 ] = 0.27722066752827925;
1483 Lam[ 22 ][ 0 ] = 0.8588702812826364;
1484 Lam[ 23 ][ 0 ] = 0.8588702812826364;
1485 Lam[ 24 ][ 0 ] = 0.0000000000000000;
1486 Lam[ 25 ][ 0 ] = 0.0000000000000000;
1487 Lam[ 26 ][ 0 ] = 0.1411297187173636;
1488 Lam[ 27 ][ 0 ] = 0.1411297187173636;
1490 Lam[ 0 ][ 1 ] = 0.333333333333333333;
1491 Lam[ 1 ][ 1 ] = 0.02598914092828833;
1492 Lam[ 2 ][ 1 ] = 0.9480217181434233;
1493 Lam[ 3 ][ 1 ] = 0.02598914092828833;
1494 Lam[ 4 ][ 1 ] = 0.09428750264792270;
1495 Lam[ 5 ][ 1 ] = 0.8114249947041546;
1496 Lam[ 6 ][ 1 ] = 0.09428750264792270;
1497 Lam[ 7 ][ 1 ] = 0.4946367750172147;
1498 Lam[ 8 ][ 1 ] = 0.01072644996557060;
1499 Lam[ 9 ][ 1 ] = 0.4946367750172147;
1500 Lam[ 10 ][ 1 ] = 0.2073433826145142;
1501 Lam[ 11 ][ 1 ] = 0.5853132347709715;
1502 Lam[ 12 ][ 1 ] = 0.2073433826145142;
1503 Lam[ 13 ][ 1 ] = 0.4389078057004907;
1504 Lam[ 14 ][ 1 ] = 0.1221843885990187;
1505 Lam[ 15 ][ 1 ] = 0.4389078057004907;
1506 Lam[ 16 ][ 1 ] = 0.04484167758913055;
1507 Lam[ 17 ][ 1 ] = 0.27722066752827925;
1508 Lam[ 18 ][ 1 ] = 0.6779376548825902;
1509 Lam[ 19 ][ 1 ] = 0.27722066752827925;
1510 Lam[ 20 ][ 1 ] = 0.6779376548825902;
1511 Lam[ 21 ][ 1 ] = 0.04484167758913055;
1512 Lam[ 22 ][ 1 ] = 0.00000000000000000;
1513 Lam[ 23 ][ 1 ] = 0.1411297187173636;
1514 Lam[ 24 ][ 1 ] = 0.8588702812826364;
1515 Lam[ 25 ][ 1 ] = 0.1411297187173636;
1516 Lam[ 26 ][ 1 ] = 0.8588702812826364;
1517 Lam[ 27 ][ 1 ] = 0.0000000000000000;
1519 Lam[ 0 ][ 3 ] = 0.08797730116222190;
1520 Lam[ 1 ][ 3 ] = 0.008744311553736190;
1521 Lam[ 2 ][ 3 ] = 0.008744311553736190;
1522 Lam[ 3 ][ 3 ] = 0.008744311553736190;
1523 Lam[ 4 ][ 3 ] = 0.03808157199393533;
1524 Lam[ 5 ][ 3 ] = 0.03808157199393533;
1525 Lam[ 6 ][ 3 ] = 0.03808157199393533;
1526 Lam[ 7 ][ 3 ] = 0.01885544805613125;
1527 Lam[ 8 ][ 3 ] = 0.01885544805613125;
1528 Lam[ 9 ][ 3 ] = 0.01885544805613125;
1529 Lam[ 10 ][ 3 ] = 0.07215969754474100;
1530 Lam[ 11 ][ 3 ] = 0.07215969754474100;
1531 Lam[ 12 ][ 3 ] = 0.07215969754474100;
1532 Lam[ 13 ][ 3 ] = 0.06932913870553720;
1533 Lam[ 14 ][ 3 ] = 0.06932913870553720;
1534 Lam[ 15 ][ 3 ] = 0.06932913870553720;
1535 Lam[ 16 ][ 3 ] = 0.04105631542928860;
1536 Lam[ 17 ][ 3 ] = 0.04105631542928860;
1537 Lam[ 18 ][ 3 ] = 0.04105631542928860;
1538 Lam[ 19 ][ 3 ] = 0.04105631542928860;
1539 Lam[ 20 ][ 3 ] = 0.04105631542928860;
1540 Lam[ 21 ][ 3 ] = 0.04105631542928860;
1541 Lam[ 22 ][ 3 ] = 0.007362383783300573;
1542 Lam[ 23 ][ 3 ] = 0.007362383783300573;
1543 Lam[ 24 ][ 3 ] = 0.007362383783300573;
1544 Lam[ 25 ][ 3 ] = 0.007362383783300573;
1545 Lam[ 26 ][ 3 ] = 0.007362383783300573;
1546 Lam[ 27 ][ 3 ] = 0.007362383783300573;
1552 Lam[ 0 ][ 0 ] = 0.333333333333333333333333333333;
1553 Lam[ 1 ][ 0 ] = 0.950275662924105565450352089520;
1554 Lam[ 2 ][ 0 ] = 0.024862168537947217274823955239;
1555 Lam[ 3 ][ 0 ] = 0.024862168537947217274823955239;
1556 Lam[ 4 ][ 0 ] = 0.171614914923835347556304795551;
1557 Lam[ 5 ][ 0 ] = 0.414192542538082326221847602214;
1558 Lam[ 6 ][ 0 ] = 0.414192542538082326221847602214;
1559 Lam[ 7 ][ 0 ] = 0.539412243677190440263092985511;
1560 Lam[ 8 ][ 0 ] = 0.230293878161404779868453507244;
1561 Lam[ 9 ][ 0 ] = 0.230293878161404779868453507244;
1562 Lam[ 10 ][ 0 ] = 0.772160036676532561750285570113;
1563 Lam[ 11 ][ 0 ] = 0.113919981661733719124857214943;
1564 Lam[ 12 ][ 0 ] = 0.113919981661733719124857214943;
1565 Lam[ 13 ][ 0 ] = 0.009085399949835353883572964740;
1566 Lam[ 14 ][ 0 ] = 0.495457300025082323058213517632;
1567 Lam[ 15 ][ 0 ] = 0.495457300025082323058213517632;
1568 Lam[ 16 ][ 0 ] = 0.062277290305886993497083640527;
1569 Lam[ 17 ][ 0 ] = 0.468861354847056503251458179727;
1570 Lam[ 18 ][ 0 ] = 0.468861354847056503251458179727;
1571 Lam[ 19 ][ 0 ] = 0.022076289653624405142446876931;
1572 Lam[ 20 ][ 0 ] = 0.022076289653624405142446876931;
1573 Lam[ 21 ][ 0 ] = 0.851306504174348550389457672223;
1574 Lam[ 22 ][ 0 ] = 0.851306504174348550389457672223;
1575 Lam[ 23 ][ 0 ] = 0.126617206172027096933163647918;
1576 Lam[ 24 ][ 0 ] = 0.126617206172027096933163647918;
1577 Lam[ 25 ][ 0 ] = 0.018620522802520968955913511549;
1578 Lam[ 26 ][ 0 ] = 0.018620522802520968955913511549;
1579 Lam[ 27 ][ 0 ] = 0.689441970728591295496647976487;
1580 Lam[ 28 ][ 0 ] = 0.689441970728591295496647976487;
1581 Lam[ 29 ][ 0 ] = 0.291937506468887771754472382212;
1582 Lam[ 30 ][ 0 ] = 0.291937506468887771754472382212;
1583 Lam[ 31 ][ 0 ] = 0.096506481292159228736516560903;
1584 Lam[ 32 ][ 0 ] = 0.096506481292159228736516560903;
1585 Lam[ 33 ][ 0 ] = 0.635867859433872768286976979827;
1586 Lam[ 34 ][ 0 ] = 0.635867859433872768286976979827;
1587 Lam[ 35 ][ 0 ] = 0.267625659273967961282458816185;
1588 Lam[ 36 ][ 0 ] = 0.267625659273967961282458816185;
1590 Lam[ 0 ][ 1 ] = 0.333333333333333333333333333333;
1591 Lam[ 1 ][ 1 ] = 0.024862168537947217274823955239;
1592 Lam[ 2 ][ 1 ] = 0.950275662924105565450352089520;
1593 Lam[ 3 ][ 1 ] = 0.024862168537947217274823955239;
1594 Lam[ 4 ][ 1 ] = 0.414192542538082326221847602214;
1595 Lam[ 5 ][ 1 ] = 0.171614914923835347556304795551;
1596 Lam[ 6 ][ 1 ] = 0.414192542538082326221847602214;
1597 Lam[ 7 ][ 1 ] = 0.230293878161404779868453507244;
1598 Lam[ 8 ][ 1 ] = 0.539412243677190440263092985511;
1599 Lam[ 9 ][ 1 ] = 0.230293878161404779868453507244;
1600 Lam[ 10 ][ 1 ] = 0.113919981661733719124857214943;
1601 Lam[ 11 ][ 1 ] = 0.772160036676532561750285570113;
1602 Lam[ 12 ][ 1 ] = 0.113919981661733719124857214943;
1603 Lam[ 13 ][ 1 ] = 0.495457300025082323058213517632;
1604 Lam[ 14 ][ 1 ] = 0.009085399949835353883572964740;
1605 Lam[ 15 ][ 1 ] = 0.495457300025082323058213517632;
1606 Lam[ 16 ][ 1 ] = 0.468861354847056503251458179727;
1607 Lam[ 17 ][ 1 ] = 0.062277290305886993497083640527;
1608 Lam[ 18 ][ 1 ] = 0.468861354847056503251458179727;
1609 Lam[ 19 ][ 1 ] = 0.851306504174348550389457672223;
1610 Lam[ 20 ][ 1 ] = 0.126617206172027096933163647918;
1611 Lam[ 21 ][ 1 ] = 0.022076289653624405142446876931;
1612 Lam[ 22 ][ 1 ] = 0.126617206172027096933163647918;
1613 Lam[ 23 ][ 1 ] = 0.022076289653624405142446876931;
1614 Lam[ 24 ][ 1 ] = 0.851306504174348550389457672223;
1615 Lam[ 25 ][ 1 ] = 0.689441970728591295496647976487;
1616 Lam[ 26 ][ 1 ] = 0.291937506468887771754472382212;
1617 Lam[ 27 ][ 1 ] = 0.018620522802520968955913511549;
1618 Lam[ 28 ][ 1 ] = 0.291937506468887771754472382212;
1619 Lam[ 29 ][ 1 ] = 0.018620522802520968955913511549;
1620 Lam[ 30 ][ 1 ] = 0.689441970728591295496647976487;
1621 Lam[ 31 ][ 1 ] = 0.635867859433872768286976979827;
1622 Lam[ 32 ][ 1 ] = 0.267625659273967961282458816185;
1623 Lam[ 33 ][ 1 ] = 0.096506481292159228736516560903;
1624 Lam[ 34 ][ 1 ] = 0.267625659273967961282458816185;
1625 Lam[ 35 ][ 1 ] = 0.096506481292159228736516560903;
1626 Lam[ 36 ][ 1 ] = 0.635867859433872768286976979827;
1628 Lam[ 0 ][ 3 ] = 0.051739766065744133555179145422;
1629 Lam[ 1 ][ 3 ] = 0.008007799555564801597804123460;
1630 Lam[ 2 ][ 3 ] = 0.008007799555564801597804123460;
1631 Lam[ 3 ][ 3 ] = 0.008007799555564801597804123460;
1632 Lam[ 4 ][ 3 ] = 0.046868898981821644823226732071;
1633 Lam[ 5 ][ 3 ] = 0.046868898981821644823226732071;
1634 Lam[ 6 ][ 3 ] = 0.046868898981821644823226732071;
1635 Lam[ 7 ][ 3 ] = 0.046590940183976487960361770070;
1636 Lam[ 8 ][ 3 ] = 0.046590940183976487960361770070;
1637 Lam[ 9 ][ 3 ] = 0.046590940183976487960361770070;
1638 Lam[ 10 ][ 3 ] = 0.031016943313796381407646220131;
1639 Lam[ 11 ][ 3 ] = 0.031016943313796381407646220131;
1640 Lam[ 12 ][ 3 ] = 0.031016943313796381407646220131;
1641 Lam[ 13 ][ 3 ] = 0.010791612736631273623178240136;
1642 Lam[ 14 ][ 3 ] = 0.010791612736631273623178240136;
1643 Lam[ 15 ][ 3 ] = 0.010791612736631273623178240136;
1644 Lam[ 16 ][ 3 ] = 0.032195534242431618819414482205;
1645 Lam[ 17 ][ 3 ] = 0.032195534242431618819414482205;
1646 Lam[ 18 ][ 3 ] = 0.032195534242431618819414482205;
1647 Lam[ 19 ][ 3 ] = 0.015445834210701583817692900053;
1648 Lam[ 20 ][ 3 ] = 0.015445834210701583817692900053;
1649 Lam[ 21 ][ 3 ] = 0.015445834210701583817692900053;
1650 Lam[ 22 ][ 3 ] = 0.015445834210701583817692900053;
1651 Lam[ 23 ][ 3 ] = 0.015445834210701583817692900053;
1652 Lam[ 24 ][ 3 ] = 0.015445834210701583817692900053;
1653 Lam[ 25 ][ 3 ] = 0.017822989923178661888748319485;
1654 Lam[ 26 ][ 3 ] = 0.017822989923178661888748319485;
1655 Lam[ 27 ][ 3 ] = 0.017822989923178661888748319485;
1656 Lam[ 28 ][ 3 ] = 0.017822989923178661888748319485;
1657 Lam[ 29 ][ 3 ] = 0.017822989923178661888748319485;
1658 Lam[ 30 ][ 3 ] = 0.017822989923178661888748319485;
1659 Lam[ 31 ][ 3 ] = 0.037038683681384627918546472190;
1660 Lam[ 32 ][ 3 ] = 0.037038683681384627918546472190;
1661 Lam[ 33 ][ 3 ] = 0.037038683681384627918546472190;
1662 Lam[ 34 ][ 3 ] = 0.037038683681384627918546472190;
1663 Lam[ 35 ][ 3 ] = 0.037038683681384627918546472190;
1664 Lam[ 36 ][ 3 ] = 0.037038683681384627918546472190;
1674 for(
int i = 0; i < npts; i++ )
1676 Lam[ i ][ 2 ] = 1. - Lam[ i ][ 0 ] - Lam[ i ][ 1 ];
1678 Lam[ i ][ 3 ] /= 2.;
1686 return ( 0.5 * ( ( xv[ 1 ] - xv[ 0 ] ) * ( yv[ 2 ] - yv[ 0 ] )
1687 - ( xv[ 2 ] - xv[ 0 ] ) * ( yv[ 1 ] - yv[ 0 ] ) ) );
1693 double* phi1,
double* phi2 )
1697 phi [ 0 ] = 1.0 - xi - et;
1713 double* phi1,
double* phi2 )
1716 phi [ 0 ] = ( 1.0 - xi ) * ( 1.0 - et );
1717 phi1[ 0 ] = -1.0 * ( 1.0 - et );
1718 phi2[ 0 ] = -1.0 * ( 1.0 - xi );
1720 phi [ 1 ] = xi * ( 1.0 - et );
1721 phi1[ 1 ] = 1.0 - et;
1724 phi [ 2 ] = xi * et;
1728 phi [ 3 ] = ( 1.0 - xi ) * et;
1730 phi2[ 3 ] = 1.0 - xi;
1738 double xs,
double ys,
double* phi,
double* phix,
double* phiy )
1743 double tempv1[ 3 ], tempv2[ 3 ];
1746 tempv1[ 1 ] = vx[ 2 ];
1747 tempv1[ 2 ] = vx[ 0 ];
1749 tempv2[ 1 ] = vy[ 2 ];
1750 tempv2[ 2 ] = vy[ 0 ];
1752 double AreaK =
AreaT( vx, vy );
1753 double xi =
AreaT( tempv1, tempv2 ) / AreaK;
1756 tempv1[ 1 ] = vx[ 0 ];
1757 tempv1[ 2 ] = vx[ 1 ];
1759 tempv2[ 1 ] = vy[ 0 ];
1760 tempv2[ 2 ] = vy[ 1 ];
1762 double et =
AreaT( tempv1, tempv2 ) / AreaK;
1767 BasisTS( xi, et, phi, phi1, phi2 );
1769 double Jac[ 4 ], JacN[ 4 ], det;
1771 Jac[ 0 ] = vx[ 0 ] * phi1[ 0 ] + vx[ 1 ] * phi1[ 1 ] + vx[ 2 ] * phi1[ 2 ];
1772 Jac[ 1 ] = vx[ 0 ] * phi2[ 0 ] + vx[ 1 ] * phi2[ 1 ] + vx[ 2 ] * phi2[ 2 ];
1773 Jac[ 2 ] = vy[ 0 ] * phi1[ 0 ] + vy[ 1 ] * phi1[ 1 ] + vy[ 2 ] * phi1[ 2 ];
1774 Jac[ 3 ] = vy[ 0 ] * phi2[ 0 ] + vy[ 1 ] * phi2[ 1 ] + vy[ 2 ] * phi2[ 2 ];
1776 det = Jac[ 0 ] * Jac[ 3 ] - Jac[ 1 ] * Jac [ 2 ];
1778 JacN[ 0 ] = Jac[3]/det;
1779 JacN[ 1 ] = -Jac[1]/det;
1780 JacN[ 2 ] = -Jac[2]/det;
1781 JacN[ 3 ] = Jac[0]/det;
1783 for ( i = 0; i < 3; i++ )
1785 phix[ i ] = JacN[ 0 ] * phi1[ i ] + JacN[ 2 ] * phi2[ i ];
1786 phiy[ i ] = JacN[ 1 ] * phi1[ i ] + JacN[ 3 ] * phi2[ i ];
1791 double* phi,
double* phix,
double* phiy,
double dt )
1796 double et = ts / dt;
1797 double A = vx[ 0 ] * ( 1.0 - et ) + vx[ 3 ] * et;
1798 double B = vx[ 1 ] * ( 1.0 - et ) + vx[ 2 ] * et;
1799 double xi = ( xs - A ) / ( B - A );
1804 BasisQS( xi, et, phi, phi1, phi2 );
1806 double Jac[ 4 ], JacN[ 4 ], det;
1808 Jac[ 0] = vx[ 0 ] * phi1[ 0 ] + vx[ 1 ] * phi1[ 1 ] + vx[ 2 ] *
1809 phi1[ 2 ] + vx[ 3 ] * phi1[ 3 ];
1810 Jac[ 1] = vx[ 0 ] * phi2[ 0 ] + vx[ 1 ] * phi2[ 1 ] + vx[ 2 ] *
1811 phi2[ 2 ] + vx[ 3 ] * phi2[ 3 ];
1812 Jac[ 2] = dt * phi1[ 2 ] + dt * phi1[ 3 ];
1813 Jac[ 3] = dt * phi2[ 2 ] + dt * phi2[ 3 ];
1815 det = Jac[0] * Jac[3] - Jac[1] * Jac [2];
1817 JacN[ 0 ] = Jac[ 3 ] / det;
1818 JacN[ 1 ] = -Jac[ 1 ] / det;
1819 JacN[ 2 ] = -Jac[ 2 ] / det;
1820 JacN[ 3 ] = Jac[ 0 ] / det;
1822 for ( i = 0; i < 4; i++ )
1824 phix[ i ] = JacN[ 0 ] * phi1[ i ] + JacN[ 2 ] * phi2[ i ];
1825 phiy[ i ] = JacN[ 1 ] * phi1[ i ] + JacN[ 3 ] * phi2[ i ];
1832 double u,
double ux,
double ut,
double v,
double vx )
1834 return ( x_gauss * ut * v + D * x_gauss * ux * vx -
1835 sw2 *
sq( x_gauss ) * u * vx );
1842 double* Gs1 =
new double [ nGauss ];
1843 double* w =
new double [ nGauss ];
1849 Gs1[ 0 ] = -0.774596669241483; w[ 0 ] = 5.0 / 9.0;
1850 Gs1[ 1 ] = 0.0; w[ 1 ] = 8.0 / 9.0;
1851 Gs1[ 2 ] = 0.774596669241483; w[ 2 ] = 5.0 / 9.0;
1856 Gs1[ 0 ] = 0.906179845938664 ; w[ 0 ] = 0.236926885056189;
1857 Gs1[ 1 ] = 0.538469310105683 ; w[ 1 ] = 0.478628670499366;
1858 Gs1[ 2 ] = 0.000000000000000 ; w[ 2 ] = 0.568888888888889;
1859 Gs1[ 3 ] = -Gs1[ 1 ]; w[ 3 ] = w[ 1 ];
1860 Gs1[ 4 ] = -Gs1[ 0 ]; w[ 4 ] = w[ 0 ];
1865 Gs1[ 0 ] = 0.949107912342759 ; w[ 0 ] = 0.129484966168870;
1866 Gs1[ 1 ] = 0.741531185599394 ; w[ 1 ] = 0.279705391489277;
1867 Gs1[ 2 ] = 0.405845151377397 ; w[ 2 ] = 0.381830050505119;
1868 Gs1[ 3 ] = 0.000000000000000 ; w[ 3 ] = 0.417959183673469;
1869 Gs1[ 4 ] = -Gs1[ 2 ]; w[ 4 ] = w[ 2 ];
1870 Gs1[ 5 ] = -Gs1[ 1 ]; w[ 5 ] = w[ 1 ];
1871 Gs1[ 6 ] = -Gs1[ 0 ]; w[ 6 ] = w[ 0 ];
1876 Gs1[ 0 ] = 0.973906528517172 ; w[ 0 ] = 0.066671344308688;
1877 Gs1[ 1 ] = 0.865063366688985 ; w[ 1 ] = 0.149451349150581;
1878 Gs1[ 2 ] = 0.679409568299024 ; w[ 2 ] = 0.219086362515982;
1879 Gs1[ 3 ] = 0.433395394129247 ; w[ 3 ] = 0.269266719309996;
1880 Gs1[ 4 ] = 0.148874338981631 ; w[ 4 ] = 0.295524224714753;
1881 Gs1[ 5 ] = -Gs1[ 4 ]; w[ 5 ] = w[ 4 ];
1882 Gs1[ 6 ] = -Gs1[ 3 ]; w[ 6 ] = w[ 3 ];
1883 Gs1[ 7 ] = -Gs1[ 2 ]; w[ 7 ] = w[ 2 ];
1884 Gs1[ 8 ] = -Gs1[ 1 ]; w[ 8 ] = w[ 1 ];
1885 Gs1[ 9 ] = -Gs1[ 0 ]; w[ 9 ] = w[ 0 ];
1894 for (
int i = 0; i < nGauss; i++ )
1896 for (
int j = 0; j < nGauss; j++ )
1898 int k = j + i * nGauss;
1900 Gs2[ k ][ 0 ] = ( Gs1[ i ] + 1.0 ) / 2.0;
1901 Gs2[ k ][ 1 ] = ( Gs1[ j ] + 1.0 ) / 2.0;
1903 Gs2[ k ][ 2 ] = w[ i ] * w[ j ] / 4.0;
1921 simdata.
type[ 0 ] =
' ';
1922 simdata.
type[ 1 ] =
' ';
1924 for (
int jj = 0; jj < 16; jj++ )
1927 simdata.
cell = editdata.
cell.toInt();
1933 double rvalue = concval1;
1935 for (
int ii = 0; ii < nscan; ii++ )
1949 sscan.
rvalues.fill( rvalue, nconc );
1967 return variance( simdata, editdata, escns );
1974 QList< int > exclScans )
1982 if ( nscan != kscan )
1984 qDebug() <<
"*WARNING* variance(): sim/exp scan counts differ";
1985 nscan = ( nscan < kscan ) ? nscan : kscan;
1988 if ( nconc != kconc )
1990 qDebug() <<
"*WARNING* variance(): sim/exp readings counts differ";
1991 nconc = ( nconc < kconc ) ? nconc : kconc;
1996 for (
int ii = 0; ii < nscan; ii++ )
1999 if ( exclScans.contains( ii ) )
continue;
2003 for (
int jj = 0; jj < nconc; jj++ )
2005 vari +=
sq( simdata.
value( ii, jj ) - editdata.
value( ii, jj ) );
2009 vari /= (double)( kscan * nconc );
2016 double* rotorcoefs )
2018 return ( bottom_chan
2019 + rotorcoefs[ 0 ] * rpm
2020 + rotorcoefs[ 1 ] *
sq( rpm ) );
2025 #if defined(DEBUG_ALLOC)
2027 struct _created_matrices {
2033 static list <_created_matrices> created_matrices;
2035 void init_matrices_alloc()
2037 created_matrices.clear();
2038 puts(
"init_matrices_alloc()" );
2041 void list_matrices_alloc()
2043 if ( created_matrices.size() )
2045 printf(
"allocated matrices:\n" 0 );
2048 list<_created_matrices>::iterator Li;
2050 for ( Li = created_matrices.begin(); Li != created_matrices.end(); Li++ )
2052 printf(
"addr %lx val1 %u val2 %u\n", Li->addr, Li->val1, Li->val2 );
2056 static list<_created_matrices>::iterator find_matrices_alloc(
long addr )
2058 list<_created_matrices>::iterator Li;
2060 for ( Li = created_matrices.begin(); Li != created_matrices.end(); Li++ )
2062 if ( Li->addr == addr )
2083 void IntQT1_ellam(QVector <double> vx,
double D,
double sw2,
double **Stif,
double dt)
2088 double x_gauss, y_gauss, dval;
2089 QVector <double> Rx, Ry, Qx, Qy;
2090 double **StifR=NULL, DJac;
2091 double hh, slope, xn1, phiC, phiCx;
2098 Rx.push_back(vx[0]);
2099 Rx.push_back(vx[1]);
2100 Rx.push_back(vx[3]);
2101 Rx.push_back(vx[2]);
2108 initialize_2d(4, 2, &StifR);
2110 slope = (vx[3] - vx[4])/dt;
2115 if( (vx[1]-vx[4])/(vx[1]-vx[0]) <1.e-3 )
2121 Qx.push_back(vx[0]);
2122 Qx.push_back(vx[3]);
2123 Qx.push_back(vx[2]);
2130 initialize_2d(npts, 4, &Lam);
2131 DefineFkp(npts, Lam);
2133 for (k=0; k<npts; k++)
2135 x_gauss = Lam[k][0] * Qx[0] + Lam[k][1] * Qx[1] + Lam[k][2] * Qx[2];
2136 y_gauss = Lam[k][0] * Qy[0] + Lam[k][1] * Qy[1] + Lam[k][2] * Qy[2];
2137 DJac = 2.0 * AreaT(&Qx, &Qy);
2143 BasisQR( Rx, x_gauss, y_gauss, phiR, phiRx, phiRy, dt );
2145 xn1 = x_gauss + slope * ( dt - y_gauss );
2146 phiC = ( xn1 - vx[2] )/hh;
2151 dval = Integrand(x_gauss, D, sw2, phiR[i], phiRx[i], phiRy[i], 1.-phiC, -phiCx);
2152 StifR[i][0] += Lam[k][3] * DJac * dval;
2154 dval = Integrand(x_gauss, D, sw2, phiR[i], phiRx[i], phiRy[i], phiC, phiCx);
2155 StifR[i][1] += Lam[k][3] * DJac * dval;
2158 clear_2d(npts, Lam);
2167 Qx.push_back(vx[0]);
2168 Qx.push_back(vx[4]);
2169 Qx.push_back(vx[3]);
2170 Qx.push_back(vx[2]);
2179 initialize_2d(npts, 3, &Gs);
2180 DefineGaussian(5, Gs);
2182 double psi[4], psi1[4], psi2[4], jac[4];
2183 for (k=0; k<npts; k++)
2185 BasisQS(Gs[k][0], Gs[k][1], psi, psi1, psi2);
2194 x_gauss += psi[i] * Qx[i];
2195 y_gauss += psi[i] * Qy[i];
2196 jac[0] += Qx[i] * psi1[i];
2197 jac[1] += Qx[i] * psi2[i];
2198 jac[2] += Qy[i] * psi1[i];
2199 jac[3] += Qy[i] * psi2[i];
2201 DJac = jac[0] * jac[3] - jac[1] * jac[2];
2205 BasisQR( Rx, x_gauss, y_gauss, phiR, phiRx, phiRy, dt );
2206 xn1 = x_gauss + slope * ( dt - y_gauss );
2207 phiC = ( xn1 - vx[2] )/hh;
2211 dval = Integrand(x_gauss, D, sw2, phiR[i], phiRx[i], phiRy[i], 1.-phiC, -phiCx);
2212 StifR[i][0] += Gs[k][2] * DJac * dval;
2213 dval = Integrand(x_gauss, D, sw2, phiR[i], phiRx[i], phiRy[i], phiC, phiCx);
2214 StifR[i][1] += Gs[k][2] * DJac * dval;
2221 Stif[0][i] = StifR[0][i];
2222 Stif[1][i] = StifR[1][i];
2223 Stif[2][i] = StifR[3][i];
2224 Stif[3][i] = StifR[2][i];
2230 void IntQTm_ellam(QVector <double> vx,
double D,
double sw2,
double **Stif,
double dt)
2235 double x_gauss, y_gauss, dval;
2236 QVector <double> Lx, Ly, Cx, Cy, Rx, Ry, Qx, Qy, Tx, Ty;
2237 double *phiR, *phiRx, *phiRy;
2238 double **StifL=NULL, **StifR=NULL, **Lam=NULL, DJac;
2239 double *phiL, *phiLx, *phiLy, *phiCx, *phiCy, *phiC;
2261 Lx.push_back(vx[0]);
2262 Lx.push_back(vx[1]);
2263 Lx.push_back(vx[4]);
2264 Lx.push_back(vx[3]);
2271 Cx.push_back(vx[6]);
2272 Cx.push_back(vx[7]);
2273 Cx.push_back(vx[5]);
2274 Cx.push_back(vx[4]);
2281 Rx.push_back(vx[1]);
2282 Rx.push_back(vx[2]);
2283 Rx.push_back(vx[5]);
2284 Rx.push_back(vx[4]);
2292 initialize_2d(4, 2, &StifL);
2293 initialize_2d(4, 2, &StifR);
2298 Tx.push_back(vx[6]);
2299 Tx.push_back(vx[1]);
2300 Tx.push_back(vx[4]);
2307 initialize_2d(npts, 4, &Lam);
2308 DefineFkp(npts, Lam);
2310 for (k=0; k<npts; k++)
2312 x_gauss = Lam[k][0] * Tx[0] + Lam[k][1] * Tx[1] + Lam[k][2] * Tx[2];
2313 y_gauss = Lam[k][0] * Ty[0] + Lam[k][1] * Ty[1] + Lam[k][2] * Ty[2];
2314 DJac = 2.0 * AreaT(&Tx, &Ty);
2316 if(DJac<1.e-22)
break;
2322 BasisQR( Lx, x_gauss, y_gauss, phiL, phiLx, phiLy, dt );
2323 BasisQR( Cx, x_gauss, y_gauss, phiC, phiCx, phiCy, dt );
2327 dval = Integrand(x_gauss, D, sw2, phiL[i], phiLx[i], phiLy[i],
2328 phiC[0] + phiC[3], phiCx[0] + phiCx[3]);
2329 StifL[i][0] += Lam[k][3] * DJac * dval;
2331 dval = Integrand(x_gauss, D, sw2, phiL[i], phiLx[i], phiLy[i],
2332 phiC[1] + phiC[2], phiCx[1] + phiCx[2]);
2333 StifL[i][1] += Lam[k][3] * DJac * dval;
2336 clear_2d(npts, Lam);
2341 if( (vx[7]-vx[1])/(vx[2]-vx[1]) <1.e-3 )
2343 Qx.push_back(vx[1]);
2344 Qx.push_back(vx[5]);
2345 Qx.push_back(vx[4]);
2351 initialize_2d(npts, 4, &Lam);
2352 DefineFkp(npts, Lam);
2354 for (k=0; k<npts; k++)
2356 x_gauss = Lam[k][0] * Qx[0] + Lam[k][1] * Qx[1] + Lam[k][2] * Qx[2];
2357 y_gauss = Lam[k][0] * Qy[0] + Lam[k][1] * Qy[1] + Lam[k][2] * Qy[2];
2358 DJac = 2.0 * AreaT(&Qx, &Qy);
2364 BasisQR( Rx, x_gauss, y_gauss, phiR, phiRx, phiRy, dt );
2365 BasisQR( Cx, x_gauss, y_gauss, phiC, phiCx, phiCy, dt );
2368 dval = Integrand(x_gauss, D, sw2, phiR[i], phiRx[i], phiRy[i],
2369 phiC[0] + phiC[3], phiCx[0] + phiCx[3]);
2370 StifR[i][0] += Lam[k][3] * DJac * dval;
2372 dval = Integrand(x_gauss, D, sw2, phiR[i], phiRx[i], phiRy[i],
2373 phiC[1] + phiC[2], phiCx[1] + phiCx[2]);
2374 StifR[i][1] += Lam[k][3] * DJac * dval;
2377 clear_2d(npts, Lam);
2381 Qx.push_back(vx[1]);
2382 Qx.push_back(vx[7]);
2383 Qx.push_back(vx[5]);
2384 Qx.push_back(vx[4]);
2392 initialize_2d(npts, 3, &Gs);
2393 DefineGaussian(5, Gs);
2395 double psi[4], psi1[4], psi2[4], jac[4];
2396 for (k=0; k<npts; k++)
2398 BasisQS(Gs[k][0], Gs[k][1], psi, psi1, psi2);
2408 x_gauss += psi[i] * Qx[i];
2409 y_gauss += psi[i] * Qy[i];
2410 jac[0] += Qx[i] * psi1[i];
2411 jac[1] += Qx[i] * psi2[i];
2412 jac[2] += Qy[i] * psi1[i];
2413 jac[3] += Qy[i] * psi2[i];
2416 DJac = jac[0] * jac[3] - jac[1] * jac[2];
2422 BasisQR( Rx, x_gauss, y_gauss, phiR, phiRx, phiRy, dt );
2423 BasisQR( Cx, x_gauss, y_gauss, phiC, phiCx, phiCy, dt );
2426 dval = Integrand(x_gauss, D, sw2, phiR[i], phiRx[i], phiRy[i],
2427 phiC[0] + phiC[3], phiCx[0] + phiCx[3]);
2428 StifR[i][0] += Gs[k][2] * DJac * dval;
2430 dval = Integrand(x_gauss, D, sw2, phiR[i], phiRx[i], phiRy[i],
2431 phiC[1] + phiC[2], phiCx[1] + phiCx[2]);
2432 StifR[i][1] += Gs[k][2] * DJac * dval;
2440 Stif[0][i] = StifL[0][i];
2441 Stif[1][i] = StifL[1][i] + StifR[0][i];
2442 Stif[2][i] = StifR[1][i];
2443 Stif[3][i] = StifL[3][i];
2444 Stif[4][i] = StifL[2][i] + StifR[3][i];
2445 Stif[5][i] = StifR[2][i];
2453 void IntQTn1_ellam(QVector <double> vx,
double D,
double sw2,
double **Stif,
double dt)
2458 double x_gauss, y_gauss, dval;
2459 QVector <double> Lx, Ly, Tx, Ty;
2460 double **StifL=NULL, **Lam=NULL, DJac;
2469 Lx.push_back(vx[0]);
2470 Lx.push_back(vx[1]);
2471 Lx.push_back(vx[3]);
2472 Lx.push_back(vx[2]);
2479 initialize_2d(4, 2, &StifL);
2485 Tx.push_back(vx[4]);
2486 Tx.push_back(vx[1]);
2487 Tx.push_back(vx[3]);
2494 initialize_2d(npts, 4, &Lam);
2495 DefineFkp(npts, Lam);
2497 for (k=0; k<npts; k++)
2499 x_gauss = Lam[k][0] * Tx[0] + Lam[k][1] * Tx[1] + Lam[k][2] * Tx[2];
2500 y_gauss = Lam[k][0] * Ty[0] + Lam[k][1] * Ty[1] + Lam[k][2] * Ty[2];
2501 DJac = 2.0 * AreaT(&Tx, &Ty);
2503 if(DJac<1.e-22)
break;
2508 BasisQR( Lx, x_gauss, y_gauss, phiL, phiLx, phiLy, dt );
2512 dval = Integrand(x_gauss, D, sw2, phiL[i], phiLx[i], phiLy[i], 1.0, 0.0);
2513 StifL[i][0] += Lam[k][3] * DJac * dval;
2516 clear_2d(npts, Lam);
2521 Stif[0][i] = StifL[0][i];
2522 Stif[1][i] = StifL[1][i];
2523 Stif[2][i] = StifL[3][i];
2524 Stif[3][i] = StifL[2][i];
2531 void QuadSolver_ellam(
double *ai,
double *bi,
double *ci,
double *di,
double *cr,
double *solu,
int N)
2540 QVector<double> ca, cb, cc, cd;
2547 ca.push_back( ai[i] );
2548 cb.push_back( bi[i] );
2549 cc.push_back( ci[i] );
2550 cd.push_back( di[i] );
2553 for (i=N-2; i>=1; i--)
2555 tmp = cd[i]/cc[i+1];
2556 cc[i] = cc[i]-cb[i+1]*tmp;
2557 cb[i] = cb[i]-ca[i+1]*tmp;
2558 cr[i] = cr[i]-cr[i+1]*tmp;
2561 tmp = cd[i]/cc[i+1];
2562 cc[i] = cc[i]-cb[i+1]*tmp;
2563 cr[i] = cr[i]-cr[i+1]*tmp;
2564 solu[0] = cr[0] / cc[0];
2565 solu[1] = (cr[1] - cb[1] * solu[0]) / cc[1];
2570 solu[i] = (cr[i] - ca[i] * solu[i-2] - cb[i] * solu[i-1]) / cc[i];
2582 double IntConcentration(QVector<double> r,
double *u)
2586 for (
int j=0; j<r.size()-1; j++)
2588 T += (r[j+1] - r[j]) * ((r[j+1] - r[j]) * (u[j+1]/3.0 + u[j]/6.0)
2589 + r[j] * (u[j] + u[j+1])/2.0);
2596 void DefInitCond(
double **C0,
int N)
2606 int interpolate( MfemData *simdata,
int scans,
int points,
2607 float *scantimes,
double *radius,
double **c )
2623 double slope, intercept;
2625 ip_array =
new double* [scans];
2626 for (i=0; i<scans; i++)
2628 ip_array[i] =
new double [(*simdata).radius.size()];
2631 for (i=0; i<scans; i++)
2633 while (count < (*simdata).scan.size()-1
2634 && scantimes[i] >= (*simdata).scan[count].time)
2638 if (scantimes[i] == (*simdata).scan[count].time)
2640 for (j=0; j<(*simdata).radius.size(); j++)
2642 ip_array[i][j] = (*simdata).scan[count].conc[j];
2647 for (j=0; j<(*simdata).radius.size(); j++)
2649 slope = ((*simdata).scan[count].conc[j] - (*simdata).scan[count-1].conc[j])
2650 /((*simdata).scan[count].time - (*simdata).scan[count-1].time);
2651 intercept = (*simdata).scan[count].conc[j] - slope * (*simdata).scan[count].time;
2652 ip_array[i][j] = slope * scantimes[i] + intercept;
2657 for (i=0; i<scans; i++)
2659 c[i][0] += ip_array[i][0];
2662 for (i=0; i<scans; i++)
2665 for (j=1; j<(int) points; j++)
2667 while (radius[j] > (*simdata).radius[count] && count < (*simdata).radius.size()-1)
2671 if (radius[j] == (*simdata).radius[count])
2673 c[i][j] += ip_array[i][count];
2677 slope = (ip_array[i][count] - ip_array[i][count-1])/((*simdata).radius[count] - (*simdata).radius[count-1]);
2678 intercept = ip_array[i][count] - (*simdata).radius[count] * slope;
2679 c[i][j] += slope * radius[j] + intercept;
2683 for (i=0; i<scans; i++)
2685 delete [] ip_array[i];
2692 void interpolate_Cfinal( MfemInitial *C0,
double *cfinal, QVector <double> *x )
2708 for(j=0; j<(*C0).radius.size(); j++)
2710 xs = (*C0).radius[j];
2711 for (i=ja; i<(*x).size(); i++)
2713 if( (*x)[i] > xs + 1.e-12)
2721 (*C0).concentration[j] = cfinal[0];
2723 else if ( i == (*x).size() )
2725 (*C0).concentration[j] = cfinal[ i-1 ];
2732 (*C0).concentration[j] = cfinal[i-1] * (1. - tmp) + cfinal[i] * tmp;