Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

LSMDD_Utilities.h

Go to the documentation of this file.
00001 /*
00002  * File:        LSMDD_Utilities.h
00003  * Copyright:   (c) 2005-2007 Princeton University
00004  * Author(s):   Kevin T. Chu
00005  * Revision:    $Revision: 398 $
00006  * Modified:    $Date: 2007-08-07 15:24:02 -0400 (Tue, 07 Aug 2007) $
00007  * Description: Header file for the LSMDD_Utilities class
00008  */
00009 
00019 #ifndef included_LSMDD_Utilities_h
00020 #define included_LSMDD_Utilities_h
00021 
00031 // LSMDD Headers
00032 #include "LSMDD_config.h"
00033 
00034 
00035 /******************************************************************
00036  *
00037  * LSMDD_Utilities Class Definition
00038  *
00039  ******************************************************************/
00040 
00041 namespace LSMDD {
00042 
00043 class LSMDD_Utilities
00044 {
00045 public:
00046 
00047 
00048 private:
00049 
00050   /*
00051    * Private default constructor to prevent use.
00052    *
00053    * Arguments:  none
00054    *
00055    */
00056   LSMDD_Utilities(){}
00057 
00058   /*
00059    * Private copy constructor to prevent use.
00060    *
00061    * Arguments:
00062    *  - rhs (in):  LSMDD_Utilities object to copy
00063    *
00064    */
00065   LSMDD_Utilities(const LSMDD_Utilities& rhs){}
00066 
00067   /*
00068    * Private assignment operator to prevent use.
00069    *
00070    * Arguments:
00071    *  - rhs (in):   LSMDD_Utilities object to copy
00072    *
00073    * Return value:  *this
00074    *
00075    */
00076   const LSMDD_Utilities& operator=(
00077     const LSMDD_Utilities& rhs){ return *this; }
00078 
00079 };
00080 
00081 } // end LSMDD namespace
00082 
00083 
00084 // LSMDD_Utilities Macros 
00085 // NOTE:  These are written as macros to ensure performance because
00086 //        the "inline" keyword is only a suggestion to the compiler.
00087 
00128 #define GET_TETRAHEDRON(x1, x2, x3, x4, phi_tet, psi_tet,                    \
00129                         tet_num, i, j, k,                                    \
00130                         X, dX, phi, psi, idx_phi, idx_psi,                   \
00131                         phi_ghostbox_dims, psi_ghostbox_dims)                \
00132 {                                                                            \
00133   if ( (i+j)%2 == 0 ) {                                                      \
00134     switch(tet_num) {                                                        \
00135       case 0: {                                                              \
00136         x1[0]  = X[0];                                                       \
00137         x1[1]  = X[1];                                                       \
00138         x1[2]  = X[2];                                                       \
00139         phi_tet[0] = phi[idx_phi];                                           \
00140         psi_tet[0] = psi[idx_psi];                                           \
00141                                                                              \
00142         x2[0] = X[0] + dX[0];                                                \
00143         x2[1] = X[1] + dX[1];                                                \
00144         x2[2] = X[2];                                                        \
00145         phi_tet[1] = phi[idx_phi + 1 + phi_ghostbox_dims(0)];                \
00146         psi_tet[1] = psi[idx_psi + 1 + psi_ghostbox_dims(0)];                \
00147                                                                              \
00148         x3[0] = X[0] + dX[0];                                                \
00149         x3[1] = X[1];                                                        \
00150         x3[2] = X[2];                                                        \
00151         phi_tet[2] = phi[idx_phi + 1];                                       \
00152         psi_tet[2] = psi[idx_psi + 1];                                       \
00153                                                                              \
00154         x4[0] = X[0];                                                        \
00155         x4[1] = X[1];                                                        \
00156         x4[2] = X[2] + dX[2];                                                \
00157         phi_tet[3] = phi[idx_phi +                                           \
00158                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00159         psi_tet[3] = psi[idx_psi +                                           \
00160                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00161                                                                              \
00162         break;                                                               \
00163       }                                                                      \
00164                                                                              \
00165       case 1: {                                                              \
00166         x1[0] = X[0] + dX[0];                                                \
00167         x1[1] = X[1];                                                        \
00168         x1[2] = X[2];                                                        \
00169         phi_tet[0] = phi[idx_phi + 1];                                       \
00170         psi_tet[0] = psi[idx_psi + 1];                                       \
00171                                                                              \
00172         x2[0] = X[0];                                                        \
00173         x2[1] = X[1];                                                        \
00174         x2[2] = X[2] + dX[2];                                                \
00175         phi_tet[1] = phi[idx_phi +                                           \
00176                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00177         psi_tet[1] = psi[idx_psi +                                           \
00178                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00179                                                                              \
00180         x3[0] = X[0] + dX[0];                                                \
00181         x3[1] = X[1] + dX[1];                                                \
00182         x3[2] = X[2] + dX[2];                                                \
00183         phi_tet[2] = phi[idx_phi + 1 + phi_ghostbox_dims(0) +                \
00184                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00185         psi_tet[2] = psi[idx_psi + 1 + psi_ghostbox_dims(0) +                \
00186                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00187                                                                              \
00188         x4[0] = X[0] + dX[0];                                                \
00189         x4[1] = X[1];                                                        \
00190         x4[2] = X[2] + dX[2];                                                \
00191         phi_tet[3] = phi[idx_phi + 1 +                                       \
00192                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00193         psi_tet[3] = psi[idx_psi + 1 +                                       \
00194                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00195                                                                              \
00196         break;                                                               \
00197       }                                                                      \
00198                                                                              \
00199       case 2: {                                                              \
00200         x1[0] = X[0] + dX[0];                                                \
00201         x1[1] = X[1] + dX[1];                                                \
00202         x1[2] = X[2];                                                        \
00203         phi_tet[0] = phi[idx_phi + 1 + phi_ghostbox_dims(0)];                \
00204         psi_tet[0] = psi[idx_psi + 1 + psi_ghostbox_dims(0)];                \
00205                                                                              \
00206         x2[0] = X[0] + dX[0];                                                \
00207         x2[1] = X[1];                                                        \
00208         x2[2] = X[2];                                                        \
00209         phi_tet[1] = phi[idx_phi + 1];                                       \
00210         psi_tet[1] = psi[idx_psi + 1];                                       \
00211                                                                              \
00212         x3[0] = X[0];                                                        \
00213         x3[1] = X[1];                                                        \
00214         x3[2] = X[2] + dX[2];                                                \
00215         phi_tet[2] = phi[idx_phi +                                           \
00216                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00217         psi_tet[2] = psi[idx_psi +                                           \
00218                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00219                                                                              \
00220         x4[0] = X[0] + dX[0];                                                \
00221         x4[1] = X[1] + dX[1];                                                \
00222         x4[2] = X[2] + dX[2];                                                \
00223         phi_tet[3] = phi[idx_phi + 1 + phi_ghostbox_dims(0) +                \
00224                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00225         psi_tet[3] = psi[idx_psi + 1 + psi_ghostbox_dims(0) +                \
00226                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00227                                                                              \
00228         break;                                                               \
00229       }                                                                      \
00230                                                                              \
00231       case 3: {                                                              \
00232         x1[0] = X[0];                                                        \
00233         x1[1] = X[1];                                                        \
00234         x1[2] = X[2];                                                        \
00235         phi_tet[0] = phi[idx_phi];                                           \
00236         psi_tet[0] = psi[idx_psi];                                           \
00237                                                                              \
00238         x2[0] = X[0] + dX[0];                                                \
00239         x2[1] = X[1] + dX[1];                                                \
00240         x2[2] = X[2];                                                        \
00241         phi_tet[1] = phi[idx_phi + 1 + phi_ghostbox_dims(0)];                \
00242         psi_tet[1] = psi[idx_psi + 1 + psi_ghostbox_dims(0)];                \
00243                                                                              \
00244         x3[0] = X[0];                                                        \
00245         x3[1] = X[1] + dX[1];                                                \
00246         x3[2] = X[2];                                                        \
00247         phi_tet[2] = phi[idx_phi + phi_ghostbox_dims(0)];                    \
00248         psi_tet[2] = psi[idx_psi + psi_ghostbox_dims(0)];                    \
00249                                                                              \
00250         x4[0] = X[0];                                                        \
00251         x4[1] = X[1];                                                        \
00252         x4[2] = X[2] + dX[2];                                                \
00253         phi_tet[3] = phi[idx_phi +                                           \
00254                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00255         psi_tet[3] = psi[idx_psi +                                           \
00256                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00257                                                                              \
00258         break;                                                               \
00259       }                                                                      \
00260                                                                              \
00261       case 4: {                                                              \
00262         x1[0] = X[0];                                                        \
00263         x1[1] = X[1] + dX[1];                                                \
00264         x1[2] = X[2];                                                        \
00265         phi_tet[0] = phi[idx_phi + phi_ghostbox_dims(0)];                    \
00266         psi_tet[0] = psi[idx_psi + psi_ghostbox_dims(0)];                    \
00267                                                                              \
00268         x2[0] = X[0];                                                        \
00269         x2[1] = X[1];                                                        \
00270         x2[2] = X[2] + dX[2];                                                \
00271         phi_tet[1] = phi[idx_phi +                                           \
00272                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00273         psi_tet[1] = psi[idx_psi +                                           \
00274                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00275                                                                              \
00276         x3[0] = X[0] + dX[0];                                                \
00277         x3[1] = X[1] + dX[1];                                                \
00278         x3[2] = X[2] + dX[2];                                                \
00279         phi_tet[2] = phi[idx_phi + 1 + phi_ghostbox_dims(0) +                \
00280                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00281         psi_tet[2] = psi[idx_psi + 1 + psi_ghostbox_dims(0) +                \
00282                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00283                                                                              \
00284         x4[0] = X[0];                                                        \
00285         x4[1] = X[1] + dX[1];                                                \
00286         x4[2] = X[2] + dX[2];                                                \
00287         phi_tet[3] = phi[idx_phi + phi_ghostbox_dims(0) +                    \
00288                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00289         psi_tet[3] = psi[idx_psi + psi_ghostbox_dims(0) +                    \
00290                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00291                                                                              \
00292         break;                                                               \
00293       }                                                                      \
00294                                                                              \
00295       case 5: {                                                              \
00296         x1[0] = X[0] + dX[0];                                                \
00297         x1[1] = X[1] + dX[1];                                                \
00298         x1[2] = X[2];                                                        \
00299         phi_tet[0] = phi[idx_phi + 1 + phi_ghostbox_dims(0)];                \
00300         psi_tet[0] = psi[idx_psi + 1 + psi_ghostbox_dims(0)];                \
00301                                                                              \
00302         x2[0] = X[0];                                                        \
00303         x2[1] = X[1] + dX[1];                                                \
00304         x2[2] = X[2];                                                        \
00305         phi_tet[1] = phi[idx_phi + phi_ghostbox_dims(0)];                    \
00306         psi_tet[1] = psi[idx_psi + psi_ghostbox_dims(0)];                    \
00307                                                                              \
00308         x3[0] = X[0];                                                        \
00309         x3[1] = X[1];                                                        \
00310         x3[2] = X[2] + dX[2];                                                \
00311         phi_tet[2] = phi[idx_phi +                                           \
00312                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00313         psi_tet[2] = psi[idx_psi +                                           \
00314                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00315                                                                              \
00316         x4[0] = X[0] + dX[0];                                                \
00317         x4[1] = X[1] + dX[1];                                                \
00318         x4[2] = X[2] + dX[2];                                                \
00319         phi_tet[3] = phi[idx_phi + 1 + phi_ghostbox_dims(0) +                \
00320                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00321         psi_tet[3] = psi[idx_psi + 1 + psi_ghostbox_dims(0) +                \
00322                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00323                                                                              \
00324         break;                                                               \
00325       }                                                                      \
00326                                                                              \
00327       default: {                                                             \
00328         TBOX_ERROR(  "LSMDD_Utilities::"                        \
00329                   << "GET_TETRAHEDRON_DATA(): "                              \
00330                   << "  tet_num OUT OF RANGE...SHOULD BE 0 <= tet_num <= 5!" \
00331                   << endl);                                                  \
00332       }                                                                      \
00333     }                                                                        \
00334   } else { /* case: (i+j) != 0) */                                           \
00335                                                                              \
00336     switch(tet_num) {                                                        \
00337                                                                              \
00338       case 0: {                                                              \
00339         x1[0] = X[0];                                                        \
00340         x1[1] = X[1] + dX[1];                                                \
00341         x1[2] = X[2];                                                        \
00342         phi_tet[0] = phi[idx_phi + phi_ghostbox_dims(0)];                    \
00343         psi_tet[0] = psi[idx_psi + psi_ghostbox_dims(0)];                    \
00344                                                                              \
00345         x2[0] = X[0] + dX[0];                                                \
00346         x2[1] = X[1];                                                        \
00347         x2[2] = X[2];                                                        \
00348         phi_tet[1] = phi[idx_phi + 1];                                       \
00349         psi_tet[1] = psi[idx_psi + 1];                                       \
00350                                                                              \
00351         x3[0] = X[0];                                                        \
00352         x3[1] = X[1];                                                        \
00353         x3[2] = X[2];                                                        \
00354         phi_tet[2] = phi[idx_phi];                                           \
00355         psi_tet[2] = psi[idx_psi];                                           \
00356                                                                              \
00357         x4[0] = X[0];                                                        \
00358         x4[1] = X[1] + dX[1];                                                \
00359         x4[2] = X[2] + dX[2];                                                \
00360         phi_tet[3] = phi[idx_phi + phi_ghostbox_dims(0) +                    \
00361                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00362         psi_tet[3] = psi[idx_psi + psi_ghostbox_dims(0) +                    \
00363                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00364                                                                              \
00365         break;                                                               \
00366       }                                                                      \
00367                                                                              \
00368       case 1: {                                                              \
00369         x1[0] = X[0];                                                        \
00370         x1[1] = X[1];                                                        \
00371         x1[2] = X[2];                                                        \
00372         phi_tet[0] = phi[idx_phi];                                           \
00373         psi_tet[0] = psi[idx_psi];                                           \
00374                                                                              \
00375         x2[0] = X[0];                                                        \
00376         x2[1] = X[1] + dX[1];                                                \
00377         x2[2] = X[2] + dX[2];                                                \
00378         phi_tet[1] = phi[idx_phi + phi_ghostbox_dims(0) +                    \
00379                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00380         psi_tet[1] = psi[idx_psi + psi_ghostbox_dims(0) +                    \
00381                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00382                                                                              \
00383         x3[0] = X[0] + dX[0];                                                \
00384         x3[1] = X[1];                                                        \
00385         x3[2] = X[2] + dX[2];                                                \
00386         phi_tet[2] = phi[idx_phi + 1 +                                       \
00387                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00388         psi_tet[2] = psi[idx_psi + 1 +                                       \
00389                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00390                                                                              \
00391         x4[0] = X[0];                                                        \
00392         x4[1] = X[1];                                                        \
00393         x4[2] = X[2] + dX[2];                                                \
00394         phi_tet[3] = phi[idx_phi +                                           \
00395                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00396         psi_tet[3] = psi[idx_psi +                                           \
00397                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00398                                                                              \
00399         break;                                                               \
00400       }                                                                      \
00401                                                                              \
00402       case 2: {                                                              \
00403         x1[0] = X[0] + dX[0];                                                \
00404         x1[1] = X[1];                                                        \
00405         x1[2] = X[2];                                                        \
00406         phi_tet[0] = phi[idx_phi + 1];                                       \
00407         psi_tet[0] = psi[idx_psi + 1];                                       \
00408                                                                              \
00409         x2[0] = X[0];                                                        \
00410         x2[1] = X[1];                                                        \
00411         x2[2] = X[2];                                                        \
00412         phi_tet[1] = phi[idx_phi];                                           \
00413         psi_tet[1] = psi[idx_psi];                                           \
00414                                                                              \
00415         x3[0] = X[0];                                                        \
00416         x3[1] = X[1] + dX[1];                                                \
00417         x3[2] = X[2] + dX[2];                                                \
00418         phi_tet[2] = phi[idx_phi + phi_ghostbox_dims(0) +                    \
00419                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00420         psi_tet[2] = psi[idx_psi + psi_ghostbox_dims(0) +                    \
00421                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00422                                                                              \
00423         x4[0] = X[0] + dX[0];                                                \
00424         x4[1] = X[1];                                                        \
00425         x4[2] = X[2] + dX[2];                                                \
00426         phi_tet[3] = phi[idx_phi + 1 +                                       \
00427                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00428         psi_tet[3] = psi[idx_psi + 1 +                                       \
00429                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00430                                                                              \
00431         break;                                                               \
00432       }                                                                      \
00433                                                                              \
00434       case 3: {                                                              \
00435         x1[0] = X[0];                                                        \
00436         x1[1] = X[1] + dX[1];                                                \
00437         x1[2] = X[2];                                                        \
00438         phi_tet[0] = phi[idx_phi + phi_ghostbox_dims(0)];                    \
00439         psi_tet[0] = psi[idx_psi + psi_ghostbox_dims(0)];                    \
00440                                                                              \
00441         x2[0] = X[0] + dX[0];                                                \
00442         x2[1] = X[1];                                                        \
00443         x2[2] = X[2];                                                        \
00444         phi_tet[1] = phi[idx_phi + 1];                                       \
00445         psi_tet[1] = psi[idx_psi + 1];                                       \
00446                                                                              \
00447         x3[0] = X[0] + dX[0];                                                \
00448         x3[1] = X[1] + dX[1];                                                \
00449         x3[2] = X[2];                                                        \
00450         phi_tet[2] = phi[idx_phi + 1 + phi_ghostbox_dims(0)];                \
00451         psi_tet[2] = psi[idx_psi + 1 + psi_ghostbox_dims(0)];                \
00452                                                                              \
00453         x4[0] = X[0];                                                        \
00454         x4[1] = X[1] + dX[1];                                                \
00455         x4[2] = X[2] + dX[2];                                                \
00456         phi_tet[3] = phi[idx_phi + phi_ghostbox_dims(0) +                    \
00457                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00458         psi_tet[3] = psi[idx_psi + psi_ghostbox_dims(0) +                    \
00459                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00460                                                                              \
00461         break;                                                               \
00462       }                                                                      \
00463                                                                              \
00464       case 4: {                                                              \
00465         x1[0] = X[0] + dX[0];                                                \
00466         x1[1] = X[1] + dX[1];                                                \
00467         x1[2] = X[2];                                                        \
00468         phi_tet[0] = phi[idx_phi + 1 + phi_ghostbox_dims(0)];                \
00469         psi_tet[0] = psi[idx_psi + 1 + psi_ghostbox_dims(0)];                \
00470                                                                              \
00471         x2[0] = X[0];                                                        \
00472         x2[1] = X[1] + dX[1];                                                \
00473         x2[2] = X[2] + dX[2];                                                \
00474         phi_tet[1] = phi[idx_phi + phi_ghostbox_dims(0) +                    \
00475                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00476         psi_tet[1] = psi[idx_psi + psi_ghostbox_dims(0) +                    \
00477                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00478                                                                              \
00479         x3[0] = X[0] + dX[0];                                                \
00480         x3[1] = X[1];                                                        \
00481         x3[2] = X[2] + dX[2];                                                \
00482         phi_tet[2] = phi[idx_phi + 1 +                                       \
00483                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00484         psi_tet[2] = psi[idx_psi + 1 +                                       \
00485                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00486                                                                              \
00487         x4[0] = X[0] + dX[0];                                                \
00488         x4[1] = X[1] + dX[1];                                                \
00489         x4[2] = X[2] + dX[2];                                                \
00490         phi_tet[3] = phi[idx_phi + 1 + phi_ghostbox_dims(0) +                \
00491                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00492         psi_tet[3] = psi[idx_psi + 1 + psi_ghostbox_dims(0) +                \
00493                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00494                                                                              \
00495         break;                                                               \
00496       }                                                                      \
00497                                                                              \
00498       case 5: {                                                              \
00499         x1[0] = X[0] + dX[0];                                                \
00500         x1[1] = X[1];                                                        \
00501         x1[2] = X[2];                                                        \
00502         phi_tet[0] = phi[idx_phi + 1];                                       \
00503         psi_tet[0] = psi[idx_psi + 1];                                       \
00504                                                                              \
00505         x2[0] = X[0] + dX[0];                                                \
00506         x2[1] = X[1] + dX[1];                                                \
00507         x2[2] = X[2];                                                        \
00508         phi_tet[1] = phi[idx_phi + 1 + phi_ghostbox_dims(0)];                \
00509         psi_tet[1] = psi[idx_psi + 1 + psi_ghostbox_dims(0)];                \
00510                                                                              \
00511         x3[0] = X[0];                                                        \
00512         x3[1] = X[1] + dX[1];                                                \
00513         x3[2] = X[2] + dX[2];                                                \
00514         phi_tet[2] = phi[idx_phi + phi_ghostbox_dims(0) +                    \
00515                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00516         psi_tet[2] = psi[idx_psi + psi_ghostbox_dims(0) +                    \
00517                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00518                                                                              \
00519         x4[0] = X[0] + dX[0];                                                \
00520         x4[1] = X[1];                                                        \
00521         x4[2] = X[2] + dX[2];                                                \
00522         phi_tet[3] = phi[idx_phi + 1 +                                       \
00523                          phi_ghostbox_dims(0)*phi_ghostbox_dims(1)];         \
00524         psi_tet[3] = psi[idx_psi + 1 +                                       \
00525                          psi_ghostbox_dims(0)*psi_ghostbox_dims(1)];         \
00526                                                                              \
00527         break;                                                               \
00528       }                                                                      \
00529                                                                              \
00530       default: {                                                             \
00531         TBOX_ERROR(  "LSMDD_Utilities::"                        \
00532                   << "GET_TETRAHEDRON_DATA(): "                              \
00533                   << "  tet_num OUT OF RANGE...SHOULD BE 0 <= tet_num <= 5!" \
00534                   << endl);                                                  \
00535       }                                                                      \
00536     } /* end switch statement */                                             \
00537   }                                                                          \
00538 }
00539 
00569 #define INTERPOLATE_FORCE(force_x_pt, force_y_pt, force_z_pt,              \
00570                           pt,                                              \
00571                           force_x, force_y, force_z,                       \
00572                           X, dX,                                           \
00573                           idx_force, force_ghostbox_dims)                  \
00574 {                                                                          \
00575   const double inv_dx = 1.0/dX[0];                                         \
00576   const double inv_dy = 1.0/dX[1];                                         \
00577   const double inv_dz = 1.0/dX[2];                                         \
00578   double x_weight_minus, x_weight_plus;                                    \
00579   double y_weight_minus, y_weight_plus;                                    \
00580   double z_weight_minus, z_weight_plus;                                    \
00581                                                                            \
00582   x_weight_plus = (pt[0] - X[0])*inv_dx;                                   \
00583   x_weight_minus = 1 - x_weight_plus;                                      \
00584   y_weight_plus = (pt[1] - X[1])*inv_dy;                                   \
00585   y_weight_minus = 1 - y_weight_plus;                                      \
00586   z_weight_plus = (pt[2] - X[2])*inv_dz;                                   \
00587   z_weight_minus = 1 - z_weight_plus;                                      \
00588                                                                            \
00589   force_x_pt =                                                             \
00590     x_weight_minus * y_weight_minus * z_weight_minus *                     \
00591     force_x[idx_force]                                                     \
00592   + x_weight_plus * y_weight_minus * z_weight_minus *                      \
00593     force_x[idx_force + 1]                                                 \
00594   + x_weight_minus * y_weight_plus * z_weight_minus *                      \
00595     force_x[idx_force + force_ghostbox_dims(0)]                            \
00596   + x_weight_plus * y_weight_plus * z_weight_minus *                       \
00597     force_x[idx_force + 1 + force_ghostbox_dims(0)]                        \
00598   + x_weight_minus * y_weight_minus * z_weight_plus *                      \
00599     force_x[idx_force +                                                    \
00600             force_ghostbox_dims(0)*force_ghostbox_dims(1)]                 \
00601   + x_weight_plus * y_weight_minus * z_weight_plus *                       \
00602     force_x[idx_force + 1 +                                                \
00603             force_ghostbox_dims(0)*force_ghostbox_dims(1)]                 \
00604   + x_weight_minus * y_weight_plus * z_weight_plus *                       \
00605     force_x[idx_force + force_ghostbox_dims(0) +                           \
00606             force_ghostbox_dims(0)*force_ghostbox_dims(1)]                 \
00607   + x_weight_plus * y_weight_plus * z_weight_plus *                        \
00608     force_x[idx_force + 1 + force_ghostbox_dims(0) +                       \
00609             force_ghostbox_dims(0)*force_ghostbox_dims(1)];                \
00610                                                                            \
00611   force_y_pt =                                                             \
00612     x_weight_minus * y_weight_minus * z_weight_minus *                     \
00613     force_y[idx_force]                                                     \
00614   + x_weight_plus * y_weight_minus * z_weight_minus *                      \
00615     force_y[idx_force + 1]                                                 \
00616   + x_weight_minus * y_weight_plus * z_weight_minus *                      \
00617     force_y[idx_force + force_ghostbox_dims(0)]                            \
00618   + x_weight_plus * y_weight_plus * z_weight_minus *                       \
00619     force_y[idx_force + 1 + force_ghostbox_dims(0)]                        \
00620   + x_weight_minus * y_weight_minus * z_weight_plus *                      \
00621     force_y[idx_force +                                                    \
00622             force_ghostbox_dims(0)*force_ghostbox_dims(1)]                 \
00623   + x_weight_plus * y_weight_minus * z_weight_plus *                       \
00624     force_y[idx_force + 1 +                                                \
00625             force_ghostbox_dims(0)*force_ghostbox_dims(1)]                 \
00626   + x_weight_minus * y_weight_plus * z_weight_plus *                       \
00627     force_y[idx_force + force_ghostbox_dims(0) +                           \
00628             force_ghostbox_dims(0)*force_ghostbox_dims(1)]                 \
00629   + x_weight_plus * y_weight_plus * z_weight_plus *                        \
00630     force_y[idx_force + 1 + force_ghostbox_dims(0) +                       \
00631             force_ghostbox_dims(0)*force_ghostbox_dims(1)];                \
00632                                                                            \
00633   force_z_pt =                                                             \
00634     x_weight_minus * y_weight_minus * z_weight_minus *                     \
00635     force_z[idx_force]                                                     \
00636   + x_weight_plus * y_weight_minus * z_weight_minus *                      \
00637     force_z[idx_force + 1]                                                 \
00638   + x_weight_minus * y_weight_plus * z_weight_minus *                      \
00639     force_z[idx_force + force_ghostbox_dims(0)]                            \
00640   + x_weight_plus * y_weight_plus * z_weight_minus *                       \
00641     force_z[idx_force + 1 + force_ghostbox_dims(0)]                        \
00642   + x_weight_minus * y_weight_minus * z_weight_plus *                      \
00643     force_z[idx_force +                                                    \
00644             force_ghostbox_dims(0)*force_ghostbox_dims(1)]                 \
00645   + x_weight_plus * y_weight_minus * z_weight_plus *                       \
00646     force_z[idx_force + 1 +                                                \
00647             force_ghostbox_dims(0)*force_ghostbox_dims(1)]                 \
00648   + x_weight_minus * y_weight_plus * z_weight_plus *                       \
00649     force_z[idx_force + force_ghostbox_dims(0) +                           \
00650             force_ghostbox_dims(0)*force_ghostbox_dims(1)]                 \
00651   + x_weight_plus * y_weight_plus * z_weight_plus *                        \
00652     force_z[idx_force + 1 + force_ghostbox_dims(0) +                       \
00653             force_ghostbox_dims(0)*force_ghostbox_dims(1)];                \
00654 }
00655 
00656 
00706 #define CHECK_IF_CELL_NEEDS_VELOCITY_UPDATE(                               \
00707   update_cell, force_x_closest, force_y_closest, force_z_closest,          \
00708   tangent_x, tangent_y, tangent_z,                                         \
00709   dislocation_segment_length, min_segment_length,                          \
00710   X, dX, endpt1, endpt2,                                                   \
00711   force_x_endpt1, force_y_endpt1, force_z_endpt1,                          \
00712   force_x_endpt2, force_y_endpt2, force_z_endpt2,                          \
00713   distance, idx_neighbor_distance)                                         \
00714 {                                                                          \
00715   update_current_cell = false;                                             \
00716                                                                            \
00717   if ( dislocation_segment_length > min_segment_length ) {                 \
00718                                                                            \
00719     /* case: dislocation segment long enough to avoid  */                  \
00720     /*       significant round-off error               */                  \
00721                                                                            \
00722     /* compute 1/dislocation_segment_length and */                         \
00723     /* unit tangent vector                      */                         \
00724     double inv_dislocation_segment_length = 0.0;                           \
00725     inv_dislocation_segment_length =                                       \
00726       1.0/(dislocation_segment_length);                                    \
00727     double unit_tangent_x = tangent_x*inv_dislocation_segment_length;      \
00728     double unit_tangent_y = tangent_y*inv_dislocation_segment_length;      \
00729     double unit_tangent_z = tangent_z*inv_dislocation_segment_length;      \
00730                                                                            \
00731     /* find point on dislocation line segment closest to X */              \
00732     double p_minus_endpt1_dot_dislocation =                                \
00733         (X[0] - endpt1[0])*unit_tangent_x                                  \
00734       + (X[1] - endpt1[1])*unit_tangent_y                                  \
00735       + (X[2] - endpt1[2])*unit_tangent_z;                                 \
00736     double p_minus_endpt2_dot_dislocation =                                \
00737       - (X[0] - endpt2[0])*unit_tangent_x                                  \
00738       - (X[1] - endpt2[1])*unit_tangent_y                                  \
00739       - (X[2] - endpt2[2])*unit_tangent_z;                                 \
00740                                                                            \
00741     if (p_minus_endpt1_dot_dislocation <= 0) {                             \
00742       distance_to_dislocation_segment =                                    \
00743         sqrt( (X[0] - endpt1[0])*(X[0] - endpt1[0])                        \
00744             + (X[1] - endpt1[1])*(X[1] - endpt1[1])                        \
00745             + (X[2] - endpt1[2])*(X[2] - endpt1[2]) );                     \
00746                                                                            \
00747       /* artificially set p_minus_endpt1_dot_dislocation */                \
00748       /* to 0.0 so that the interpolation weights below  */                \
00749       /* are correctly computed                          */                \
00750       p_minus_endpt1_dot_dislocation = 0.0;                                \
00751                                                                            \
00752     } else if (p_minus_endpt2_dot_dislocation <= 0) {                      \
00753                                                                            \
00754       distance_to_dislocation_segment =                                    \
00755         sqrt( (X[0] - endpt2[0])*(X[0] - endpt2[0])                        \
00756             + (X[1] - endpt2[1])*(X[1] - endpt2[1])                        \
00757             + (X[2] - endpt2[2])*(X[2] - endpt2[2]) );                     \
00758                                                                            \
00759       /* artificially set p_minus_endpt1_dot_dislocation     */            \
00760       /* to dislocation_segment_length so that the           */            \
00761       /* interpolation weights below are correctly computed  */            \
00762       p_minus_endpt1_dot_dislocation =                                     \
00763         dislocation_segment_length;                                        \
00764                                                                            \
00765     } else {                                                               \
00766                                                                            \
00767       double x_closest = endpt1[0] +                                       \
00768          p_minus_endpt1_dot_dislocation*unit_tangent_x;                    \
00769       double y_closest = endpt1[1] +                                       \
00770          p_minus_endpt1_dot_dislocation*unit_tangent_y;                    \
00771       double z_closest = endpt1[2] +                                       \
00772          p_minus_endpt1_dot_dislocation*unit_tangent_z;                    \
00773                                                                            \
00774       distance_to_dislocation_segment =                                    \
00775         sqrt( (X[0] - x_closest)*(X[0] - x_closest)                        \
00776             + (X[1] - y_closest)*(X[1] - y_closest)                        \
00777             + (X[2] - z_closest)*(X[2] - z_closest) );                     \
00778                                                                            \
00779     }                                                                      \
00780                                                                            \
00781     /* if distance to current dislocation line segment        */           \
00782     /* is smaller than previous closest dislocation           */           \
00783     /* line segment, compute force and unit tangent           */           \
00784     /* vector at closest point                                */           \
00785     /* NOTE: we allow equality here in case the velocity      */           \
00786     /*       for the neighbor had previously been set with    */           \
00787     /*       a dislocation line segment that is numerically   */           \
00788     /*       just a "point."  In that situation, we would     */           \
00789     /*       rather use the value from a dislocation line     */           \
00790     /*       segment that has a nonzero numerical length.     */           \
00791     if ( distance_to_dislocation_segment <=                                \
00792          distance[idx_neighbor_distance] ) {                               \
00793                                                                            \
00794       double weight_endpt1, weight_endpt2;                                 \
00795       weight_endpt2 = p_minus_endpt1_dot_dislocation                       \
00796         *inv_dislocation_segment_length;                                   \
00797       weight_endpt1 = 1 - weight_endpt2;                                   \
00798                                                                            \
00799       force_x_closest = force_x_endpt1*weight_endpt1                       \
00800                       + force_x_endpt2*weight_endpt2;                      \
00801       force_y_closest = force_y_endpt1*weight_endpt1                       \
00802                       + force_y_endpt2*weight_endpt2;                      \
00803       force_z_closest = force_z_endpt1*weight_endpt1                       \
00804                       + force_z_endpt2*weight_endpt2;                      \
00805                                                                            \
00806       update_current_cell = true;                                          \
00807                                                                            \
00808     }                                                                      \
00809   } else {                                                                 \
00810     /* case: dislocation segment too short too compute its  */             \
00811     /*       length accurately, so the dislocation segment  */             \
00812     /*       is treated as a single point and the           */             \
00813     /*       tangent vector of the dislocation segment      */             \
00814     /*       is taken to be the tangent vector at the       */             \
00815     /*       current grid point.                            */             \
00816                                                                            \
00817     distance_to_dislocation_segment =                                      \
00818       sqrt( (X[0] - endpt1[0])*(X[0] - endpt1[0])                          \
00819           + (X[1] - endpt1[1])*(X[1] - endpt1[1])                          \
00820           + (X[2] - endpt1[2])*(X[2] - endpt1[2]) );                       \
00821                                                                            \
00822     /* if distance to current dislocation line segment  */                 \
00823     /* is smaller than previous closest dislocation     */                 \
00824     /* line segment, compute force and unit tangent     */                 \
00825     /* vector at closest point                          */                 \
00826     if ( distance_to_dislocation_segment <                                 \
00827          distance[idx_neighbor_distance] ) {                               \
00828                                                                            \
00829       force_x_closest = force_x_endpt1;                                    \
00830       force_y_closest = force_y_endpt1;                                    \
00831       force_z_closest = force_z_endpt1;                                    \
00832                                                                            \
00833       update_current_cell = true;                                          \
00834                                                                            \
00835     }                                                                      \
00836   } /* end branch on length of dislocation line segment */                 \
00837 }
00838 
00879 #define CHECK_FOR_PURE_SCREW_SCREW_DISLOCATION(                             \
00880   segment_is_pure_screw,                                                    \
00881   max_angle_for_pure_screw,                                                 \
00882   b_x, b_y, b_z,                                                            \
00883   tangent_vector_x, tangent_vector_y, tangent_vector_z)                     \
00884 {                                                                           \
00885   /* compute square of norm of tangent vector */                            \
00886   double norm_sq_tangent_vector = tangent_vector_x*tangent_vector_x         \
00887                                 + tangent_vector_y*tangent_vector_y         \
00888                                 + tangent_vector_z*tangent_vector_z;        \
00889                                                                             \
00890   if (norm_sq_tangent_vector < 1.0e-20) {                                   \
00891     TBOX_WARNING("LSMDD_Utilities::"                           \
00892               << "CHECK_FOR_PURE_SCREW_SCREW_DISLOCATION(): "               \
00893               << "length of tangent vector too small to do computation..."  \
00894               << "returning true"                                           \
00895               << endl);                                                     \
00896     segment_is_pure_screw = true;                                           \
00897   }                                                                         \
00898                                                                             \
00899   /* compute square of norm of Burgers vector */                            \
00900   double norm_sq_burgers_vector = b_x*b_x                                   \
00901                                 + b_y*b_y                                   \
00902                                 + b_z*b_z;                                  \
00903                                                                             \
00904   if (norm_sq_burgers_vector < 1.0e-20) {                                   \
00905     TBOX_WARNING("LSMDD_Utilities::"                           \
00906               << "CHECK_FOR_PURE_SCREW_SCREW_DISLOCATION(): "               \
00907               << "length of Burgers vector too small to do computation..."  \
00908               << "returning true"                                           \
00909               << endl);                                                     \
00910     segment_is_pure_screw = true;                                           \
00911   }                                                                         \
00912                                                                             \
00913   /* compute dot product of Burgers vector and tangent vector */            \
00914   double b_dot_tangent = b_x*tangent_vector_x                               \
00915                        + b_y*tangent_vector_y                               \
00916                        + b_z*tangent_vector_z;                              \
00917                                                                             \
00918   /* estimate the square of the angle between Burgers vector and */         \
00919   /* tangent vector                                              */         \
00920   double theta_sq = 1 - b_dot_tangent*b_dot_tangent                         \
00921                       / norm_sq_burgers_vector/norm_sq_tangent_vector;      \
00922                                                                             \
00923   segment_is_pure_screw =                                                   \
00924     (theta_sq < max_angle_for_pure_screw*max_angle_for_pure_screw);         \
00925 }
00926 
00927 #endif

Generated on Tue Aug 7 15:43:41 2007 for LSMDD by doxygen 1.3.4