6 #beginMacro getSphereEigenmode(evalSolution,U,ERR,X,t,I1,I2,I3)
8 const int v1c = parameters.dbase.get<
int >(
"v1c");
9 const int v2c = parameters.dbase.get<
int >(
"v2c");
10 const int v3c = parameters.dbase.get<
int >(
"v3c");
13 const int s11c = parameters.dbase.get<
int >(
"s11c");
14 const int s12c = parameters.dbase.get<
int >(
"s12c");
15 const int s13c = parameters.dbase.get<
int >(
"s13c");
16 const int s21c = parameters.dbase.get<
int >(
"s21c");
17 const int s22c = parameters.dbase.get<
int >(
"s22c");
18 const int s23c = parameters.dbase.get<
int >(
"s23c");
19 const int s31c = parameters.dbase.get<
int >(
"s31c");
20 const int s32c = parameters.dbase.get<
int >(
"s32c");
21 const int s33c = parameters.dbase.get<
int >(
"s33c");
23 const int pc = parameters.dbase.get<
int >(
"pc");
25 const real &
rho=parameters.dbase.get<real>(
"rho");
26 const real &
mu = parameters.dbase.get<real>(
"mu");
27 const real &
lambda = parameters.dbase.get<real>(
"lambda");
28 const RealArray &
muGrid = parameters.dbase.get<RealArray>(
"muGrid");
29 const RealArray &
lambdaGrid = parameters.dbase.get<RealArray>(
"lambdaGrid");
36 printF(
"\n\n **************** FIX ME: getSphereEigenmode: finish me for HEMP **********\n\n");
40 assert(
mg.numberOfDimensions()==3 );
43 std::vector<real> &
data = parameters.dbase.get<std::vector<real> >(
"sphereEigenmodeData");
46 const int n = (int)data[1];
47 const int m = (int)data[2];
48 const real
rad = data[3];
50 const real
cp =sqrt( (lambda+2.*mu)/rho );
51 const real
cs = sqrt( mu/rho );
68 if( vibrationClass==1 )
71 real radialEigenvalue;
75 radialEigenvalue = 1.83456604098843*Pi;
77 radialEigenvalue = 2.89503202144422*Pi;
80 OV_ABORT(
"getSphereEigenmode: invalid value for m");
88 radialEigenvalue = 7.96135239733083e-01*Pi;
90 radialEigenvalue = 2.27146214644857*Pi;
93 OV_ABORT(
"getSphereEigenmode: invalid value for m");
96 omega = (radialEigenvalue/
rad)*cs;
99 else if( vibrationClass==2 )
107 real radialEigenvalue;
112 8.15966436697752e-01,
113 1.92853458475813e+00,
114 2.95387153514092e+00,
120 radialEigenvalue = eig[m-1]*Pi;
124 printF(
"sphereEigenmode: ERROR: n=%i m=%i not available\n",n,m);
128 omega = (radialEigenvalue/
rad)*cp;
150 8.40296489389027e-01,
151 1.54866444711667e+00,
152 2.65126525857435e+00,
156 -3.75375159272393e-01,
157 -7.98905931500425e-02,
158 4.64019111586348e-02,
159 -1.61929174684121e-02
165 radialEigenvalue=eig[m-1]*Pi;
170 printF(
"sphereEigenmode: ERROR: n=%i m=%i not available\n",n,m);
173 omega = (radialEigenvalue/
rad)*cs;
179 OV_ABORT(
"finish me for vibrationClass==2");
200 printF(
"**** getSphereEigenmode: t=%8.2e class=%i n=%i m=%i radius=%9.3e omega=%9.3e cp=%8.2e cs=%8.2e"
201 " h*a/pi=%9.3e kappa*a/pi=%9.3e\n",
202 t,vibrationClass,n,m,rad,omega,cp,cs,h*rad/Pi,kappa*rad/Pi);
206 real
cost = cos(omega*t);
207 real
sint = sin(omega*t);
212 if( vibrationClass==1 )
221 #define U1(x,y,z) (amp*cost*psi*( a0xy*(y) -a0zx*(z) ))
222 #define V1(x,y,z) (amp*cost*psi*(-a0xy*(x)+a0yz*(z) ))
223 #define W1(x,y,z) (amp*cost*psi*( -a0yz*(y)+a0zx*(x) ))
226 real psi0, psi1= 1./(2.*(2.*n+3.));
233 psi0 = 1./(1.*3.*5.);
241 const real rEps = pow(REAL_EPSILON,.25);
245 real x0,y0,z0,
r,kr,psi,u1,u2,u3;
253 r = sqrt( x0*x0 + y0*y0 + z0*z0 );
260 psi = psi0*( 1. - psi1*kr*kr );
262 psi = (kr*cos(kr)-sin(kr))/(kr*kr*kr);
270 #define U2(x,y,z) (amp*cost*psi*( a0xy*(y)*(z) -a0zx*(z)*(y) ))
271 #define V2(x,y,z) (amp*cost*psi*(-a0xy*(x)*(z)+a0yz*(z)*(x) ))
272 #define W2(x,y,z) (amp*cost*psi*( -a0yz*(y)*(x) +a0zx*(x)*(y) ))
276 psi = psi0*( 1. - psi1*kr*kr );
278 psi = ( 3.*kr*cos(kr)+ (kr*kr-3.)*sin(kr) )/(kr*kr*kr*kr*kr);
286 OV_ABORT(
"un-implemented value for n");
298 ERR(i1,i2,i3,uc) =
U(i1,i2,i3,uc) - u1;
299 ERR(i1,i2,i3,vc) =
U(i1,i2,i3,vc) - u2;
300 ERR(i1,i2,i3,
wc) =
U(i1,i2,i3,
wc) - u3;
305 if( assignVelocities )
308 OV_ABORT(
"getSphereEigenmode: finish me");
324 OV_ABORT(
"getSphereEigenmode: finish me");
337 else if( vibrationClass==2 )
339 const real amp=50./
rad;
341 const real rEps = pow(REAL_EPSILON,.25);
346 const real psi10 = -1./(1.*3.);
347 const real psi20 = 1./(1.*3.*5.);
348 const real psi30 = -1./(1.*3.*5.*7.);
349 const real psi40 = 1./(1.*3.*5.*7.*9.);
351 const real psi11 = 1./(2.*(2.*1.+3.));
352 const real psi21 = 1./(2.*(2.*2.+3.));
353 const real psi31 = 1./(2.*(2.*3.+3.));
354 const real psi41 = 1./(2.*(2.*4.+3.));
359 const real n2p1 = 2.*n+1.;
363 real kr,kr2,kr3,kr4,kr5,kr7,kr9;
364 real hr,hr2,hr3,hr4,hr5,hr7,hr9;
367 real u1x,u1y,u1z, u2x,u2y,u2z, u3x,u3y,u3z,div;
368 real s11,s12,s13,s21,s22,s23,s31,s32,s33;
369 real psi1hr, psi2hr, psi3hr, psi4hr;
370 real psi1kr, psi2kr, psi3kr, psi4kr;
378 r = sqrt( x0*x0 + y0*y0 + z0*z0 );
385 real coskr = cos(kr);
386 real sinkr = sin(kr);
393 real coshr = cos(hr);
394 real sinhr = sin(hr);
402 psi1hr = psi10*( 1. - psi11*hr2 );
406 psi1hr = ( hr *coshr - sinhr )/hr3;
409 u1 = amp*cost*( x0*psi1hr );
410 u2 = amp*cost*( y0*psi1hr );
411 u3 = amp*cost*( z0*psi1hr );
412 if( assignVelocities )
414 v1 = -amp*omega*sint*( x0*psi1hr );
415 v2 = -amp*omega*sint*( y0*psi1hr );
416 v3 = -amp*omega*sint*( z0*psi1hr );
421 psi2hr = psi20*( 1. - psi21*hr2 );
423 psi2hr = - ( hr2*sinhr + 3.*hr*coshr - 3.*sinhr)/hr5;
427 u1x = amp*cost*( psi1hr + h*h*x0*x0*psi2hr );
428 u1y = amp*cost*( h*h*x0*y0*psi2hr );
429 u1z = amp*cost*( h*h*x0*z0*psi2hr );
431 u2x = amp*cost*( h*h*y0*x0*psi2hr );
432 u2y = amp*cost*( psi1hr + h*h*y0*y0*psi2hr );
433 u2z = amp*cost*( h*h*y0*z0*psi2hr );
435 u3x = amp*cost*( h*h*z0*x0*psi2hr );
436 u3y = amp*cost*( h*h*z0*y0*psi2hr );
437 u3z = amp*cost*( psi1hr + h*h*z0*z0*psi2hr );
457 psi2hr = psi20*( 1. - psi21*hr2 );
458 psi3hr = psi30*( 1. - psi31*hr2 );
462 psi2hr = - ( hr2*sinhr + 3.*hr*coshr - 3.*sinhr)/hr5;
463 psi3hr = - ( hr3*coshr - 6.*hr2*sinhr - 15.*hr*coshr +15.*sinhr)/hr7;
468 psi1kr = psi10*( 1. - psi11*kr2 );
469 psi3kr = psi30*( 1. - psi31*kr2 );
473 psi1kr = ( kr *coskr - sinkr )/kr3;
474 psi3kr = - ( kr3*coskr - 6.*kr2*sinkr - 15.*kr*coskr +15.*sinkr )/kr7;
481 real wxx,wxy,wxz, wyy,wyz,wzz;
485 w = 2.*z0*z0 - x0*x0 - y0*y0;
489 wxx = -2.; wxy=0.; wxz=0.;
531 real pxx,pxy,pxz, pyy,pyz,pzz;
534 p = cPhi*(2.*z0*z0 - x0*x0 - y0*y0);
535 px = cPhi*( -2.*x0 );
536 py = cPhi*( -2.*y0 );
539 pxx = cPhi*(-2. ); pxy=0.; pxz=0.;
540 pyy = cPhi*(-2. ); pyz=0.;
556 #define VB2A(xa,wxa,pxa) \
557 ( (-1./(h*h))*( psi2hr + (hr2/n2p1)*psi3hr )*(wxa) \
558 + (1./n2p1)*psi3hr*( r*r*(wxa) - n2p1*(xa)*w ) \
559 + psi1kr*(pxa) - (n/(n+1.))*psi3kr*kappa*kappa*( r*r*(pxa) - n2p1*(xa)*p ) )
562 #define VB2(xa,wxa,pxa) \
563 ( (-1./(h*h))*( psi2hr*(wxa) + h*h*(xa)*psi3hr*w ) \
564 + psi1kr*(pxa) - (n/(n+1.))*psi3kr*kappa*kappa*( r*r*(pxa) - n2p1*(xa)*p ) )
566 real vb2x =
VB2(x0,wx,px);
567 real vb2y =
VB2(y0,wy,py);
568 real vb2z =
VB2(z0,wz,pz);
574 if( assignVelocities )
576 v1 = -amp*omega*sint*vb2x;
577 v2 = -amp*omega*sint*vb2y;
578 v3 = -amp*omega*sint*vb2z;
592 psi4hr = psi40*( 1. - psi41*hr2 );
594 psi4hr = ( (hr4-45.*hr2+105.)*sinhr + (10.*hr3-105.*hr)*coshr )/hr9;
598 psi2kr = psi20*( 1. - psi21*kr2 );
599 psi4kr = psi40*( 1. - psi41*kr2 );
603 psi2kr = - ( kr2*sinkr + 3.*kr*coskr - 3.*sinkr )/kr5;
604 psi4kr = ( (kr4-45.*kr2+105.)*sinkr + (10.*kr3-105.*kr)*coskr )/kr9;
608 #define VB2X(xj,wj,pj, xa,wa,pa, wja,pja, deltaja )\
609 ( (-1./(h2))*( h2*xa*psi3hr*wj + psi2hr*wja + h2*deltaja*psi3hr*w + h4*xj*xa*psi4hr*w + h2*xj*psi3hr*wa )\
610 + kappa2*xa*psi2kr*pj + psi1kr*pja \
611 - (n/(n+1.))*kappa4*xa*psi4kr*( r*r*pj - n2p1*xj*p )\
612 - (n/(n+1.))*kappa2*psi3kr*( 2.*xa*pj - n2p1*(deltaja)*p + r*r*pja - n2p1*xj*pa ) )
614 u1x = amp*cost*(
VB2X(x0,wx,px, x0,wx,px, wxx,pxx, 1. ) );
615 u1y = amp*cost*(
VB2X(x0,wx,px, y0,wy,py, wxy,pxy, 0. ) );
616 u1z = amp*cost*(
VB2X(x0,wx,px, z0,wz,pz, wxz,pxz, 0. ) );
618 u2x = amp*cost*(
VB2X(y0,wy,py, x0,wx,px, wxy,pxy, 0. ) );
619 u2y = amp*cost*(
VB2X(y0,wy,py, y0,wy,py, wyy,pyy, 1. ) );
620 u2z = amp*cost*(
VB2X(y0,wy,py, z0,wz,pz, wyz,pyz, 0. ) );
622 u3x = amp*cost*(
VB2X(z0,wz,pz, x0,wx,px, wxz,pxz, 0. ) );
623 u3y = amp*cost*(
VB2X(z0,wz,pz, y0,wy,py, wyz,pyz, 0. ) );
624 u3z = amp*cost*(
VB2X(z0,wz,pz, z0,wz,pz, wzz,pzz, 1. ) );
645 ERR(i1,i2,i3,uc) =
U(i1,i2,i3,uc) - u1;
646 ERR(i1,i2,i3,vc) =
U(i1,i2,i3,vc) - u2;
647 ERR(i1,i2,i3,
wc) =
U(i1,i2,i3,
wc) - u3;
650 if( assignVelocities )
660 ERR(i1,i2,i3,v1c) =
U(i1,i2,i3,v1c) - v1;
661 ERR(i1,i2,i3,v2c) =
U(i1,i2,i3,v2c) - v2;
662 ERR(i1,i2,i3,v3c) =
U(i1,i2,i3,v3c) - v3;
670 s11 = lambda*div + 2.*mu*u1x;
671 s12 = mu*( u1y+u2x );
672 s13 = mu*( u1z+u3x );
674 s22 = lambda*div + 2.*mu*u2y;
675 s23 = mu*( u2z + u3y );
678 s33 = lambda*div + 2.*mu*u3z;
683 U(i1,i2,i3,s11c) =s11;
684 U(i1,i2,i3,s12c) =s12;
685 U(i1,i2,i3,s13c) =s13;
686 U(i1,i2,i3,s21c) =s21;
687 U(i1,i2,i3,s22c) =s22;
688 U(i1,i2,i3,s23c) =s23;
689 U(i1,i2,i3,s31c) =s31;
690 U(i1,i2,i3,s32c) =s32;
691 U(i1,i2,i3,s33c) =s33;
695 ERR(i1,i2,i3,s11c) =
U(i1,i2,i3,s11c) - s11;
696 ERR(i1,i2,i3,s12c) =
U(i1,i2,i3,s12c) - s12;
697 ERR(i1,i2,i3,s13c) =
U(i1,i2,i3,s13c) - s13;
698 ERR(i1,i2,i3,s21c) =
U(i1,i2,i3,s21c) - s21;
699 ERR(i1,i2,i3,s22c) =
U(i1,i2,i3,s22c) - s22;
700 ERR(i1,i2,i3,s23c) =
U(i1,i2,i3,s23c) - s23;
701 ERR(i1,i2,i3,s31c) =
U(i1,i2,i3,s31c) - s31;
702 ERR(i1,i2,i3,s32c) =
U(i1,i2,i3,s32c) - s32;
703 ERR(i1,i2,i3,s33c) =
U(i1,i2,i3,s33c) - s33;
714 OV_ABORT(
"ERROR: unexpected vibrationClass");