Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
VerdictWrapper.cpp
Go to the documentation of this file.
00001 /*
00002  * VerdictWrapper.cpp
00003  *
00004  *  Created on: Nov 18, 2014
00005  *
00006  */
00007 
00008 #include "moab/Interface.hpp"
00009 #include "moab/verdict/VerdictWrapper.hpp"
00010 #include "Internals.hpp"
00011 #include "moab/verdict.h"
00012 
00013 namespace moab
00014 {
00015 VerdictWrapper::VerdictWrapper( Interface* mb ) : mbImpl( mb )
00016 {
00017     // TODO Auto-generated constructor stub
00018 }
00019 
00020 VerdictWrapper::~VerdictWrapper()
00021 {
00022     // TODO Auto-generated destructor stub
00023 }
00024 
00025 static int possibleQuality[MBMAXTYPE][MB_QUALITY_COUNT] = {
00026     /*
00027       MB_EDGE_RATIO = 0,  // 0
00028       |  MB_MAX_EDGE_RATIO , // 1
00029       |  |  MB_SKEW,            // 2
00030       |  |  |  MB_TAPER,           // 3
00031       |  |  |  |  MB_VOLUME,          // 4
00032       |  |  |  |  |  MB_STRETCH,         // 5
00033       |  |  |  |  |  |  MB_DIAGONAL,        // 6
00034       |  |  |  |  |  |  |  MB_DIMENSION,       // 7
00035       |  |  |  |  |  |  |  |  MB_ODDY,            // 8
00036       |  |  |  |  |  |  |  |  |  MB_MED_ASPECT_FROBENIUS,// 9
00037       |  |  |  |  |  |  |  |  |  |  MB_MAX_ASPECT_FROBENIUS, // 10
00038       |  |  |  |  |  |  |  |  |  |  |  MB_CONDITION,       // 11
00039       |  |  |  |  |  |  |  |  |  |  |  |  MB_JACOBIAN,        // 12
00040       |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SCALED_JACOBIAN, // 13
00041       |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SHEAR,           // 14
00042       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SHAPE,           // 15
00043       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_RELATIVE_SIZE_SQUARED, // 16
00044       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SHAPE_AND_SIZE,        // 17
00045       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SHEAR_AND_SIZE,        // 18
00046       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_DISTORTION,            // 19
00047       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_LENGTH,                // 20
00048       only for edge |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_RADIUS_RATIO
00049       // 21 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_ASPECT_BETA //
00050       22 tet (very similar to 21) |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00051       |  MB_ASPECT_RATIO   // 23 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00052       |  |  |  MB_ASPECT_GAMMA // 24 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00053       |  |  |  |  |  MB_MINIMUM_ANGLE // 25 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00054       |  |  |  |  |  |  |  |  MB_COLLAPSE_RATIO // 26 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |
00055       |  |  |  |  |  |  |  |  |  |  |  |  |  MB_WARPAGE     // 27 quad |  |  |  |  |  |  |  |  |  |
00056       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_AREA     // 28 quad |  |  |  |  |  |
00057       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_MAXIMUM_ANGLE // 29
00058       quad |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00059       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00060     */
00061     /*0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29*/
00062     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBVERTEX
00063     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBEDGE
00064     { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1 },  //  MBTRI
00065     { 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1 },  //  MBQUAD
00066     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBPOLYGON
00067     { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 },  //  MBTET
00068     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBPYRAMID
00069     { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBPRISM
00070     { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBKNIFE
00071     { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  // MBHEX
00072     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBPOLYHEDRON
00073     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }   //  MBENTITYSET
00074 };
00075 
00076 static int numQualities[MBMAXTYPE] = {
00077     0,   // "MBVERTEX"
00078     1,   // "MBEDGE", /**< Mesh Edge */
00079     13,  // "MBTRI", /**< Triangular element (including shells) */
00080     22,  // "MBQUAD", /**< Quadrilateral element (including shells) */
00081     0,   // "MBPOLYGON", /**< Polygon */
00082     14,  // "MBTET", /**< Tetrahedral element */
00083     0,   //"MBPYRAMID", /**< Pyramid element (where are the face ids for this defined?) */
00084     1,   // "MBPRISM", /**< Wedge element (Exodus has one, Cubit doesn't. Does Mesh need it?) */
00085     1,   // "MBKNIFE", /**< Knife element */
00086     20,  // "MBHEX", /**< Hexahedral element */
00087     0,   //"MBPOLYHEDRON", /**< Polyhedron */
00088     0,   // "MBENTITYSET", /**< MeshSet */
00089 };
00090 static char const* nameQuality[MB_QUALITY_COUNT] = {
00091     " edge ratio",                //  MB_EDGE_RATIO = 0,  // 0
00092     " maximum edge ratio",        //  MB_MAX_EDGE_RATIO , // 1
00093     " skew",                      //  MB_SKEW,            // 2
00094     " taper",                     //   MB_TAPER,            // 3
00095     " volume",                    //   MB_VOLUME,          // 4
00096     " stretch",                   //   MB_STRETCH,         // 5
00097     " diagonal",                  //   MB_DIAGONAL,        // 6
00098     " characteristic length",     //  MB_DIMENSION,       // 7
00099     " oddy",                      //   MB_ODDY,            // 8
00100     " average Frobenius aspect",  //  MB_MED_ASPECT_FROBENIUS,// 9
00101     " maximum Frobenius aspect",  //   MB_MAX_ASPECT_FROBENIUS, // 10
00102     " condition number",          //   MB_CONDITION,       // 11
00103     " jacobian",                  //   MB_JACOBIAN,        // 12
00104     " scaled jacobian",           //   MB_SCALED_JACOBIAN, // 13
00105     " shear",                     //   MB_SHEAR,           // 14
00106     " shape",                     //  MB_SHAPE,           // 15
00107     " relative size squared",     //    MB_RELATIVE_SIZE_SQUARED, // 16
00108     " shape and size",            //   MB_SHAPE_AND_SIZE,        // 17
00109     " shear and size",            //   MB_SHEAR_AND_SIZE,        // 18
00110     " distortion",                //   MB_DISTORTION,            // 19
00111                                   // next are QuadMetricVals that are not in hex metrics
00112                                   // length for edge:
00113     " length",                    //   MB_LENGTH,                // 20 only for edge
00114     " radius ratio",              //   MB_RADIUS_RATIO           // 21 tet
00115     " aspect beta",               // MB_ASPECT_BETA              // 22 tet
00116     " aspect ratio",              // MB_ASPECT_RATIO,            // 23 MBTET
00117     " aspect gamma",              // MB_ASPECT_GAMMA             // 24 tet
00118     " minimum angle",             //  MB_MINIMUM_ANGLE,         // 25  MBTET
00119     " collapse ratio",            // MB_COLLAPSE_RATIO,        // 26  MBTET
00120     " warpage",                   // MB_WARPAGE                // 27  MBQUAD
00121     " area",                      // MB_AREA                   // 28  MBQAD
00122     " maximum angle"              // MB_MAXIMUM_ANGLE          // 29  MBQUAD
00123 };
00124 
00125 static const char* nameType[MBMAXTYPE] = {
00126     "MBVERTEX",     /**< Mesh Vertex AKA node */
00127     "MBEDGE",       /**< Mesh Edge */
00128     "MBTRI",        /**< Triangular element (including shells) */
00129     "MBQUAD",       /**< Quadrilateral element (including shells) */
00130     "MBPOLYGON",    /**< Polygon */
00131     "MBTET",        /**< Tetrahedral element */
00132     "MBPYRAMID",    /**< Pyramid element (where are the face ids for this defined?) */
00133     "MBPRISM",      /**< Wedge element (Exodus has one, Cubit doesn't. Does Mesh need it?) */
00134     "MBKNIFE",      /**< Knife element */
00135     "MBHEX",        /**< Hexahedral element */
00136     "MBPOLYHEDRON", /**< Polyhedron */
00137     "MBENTITYSET",  /**< MeshSet */
00138 };
00139 
00140 ErrorCode VerdictWrapper::quality_measure( EntityHandle eh,
00141                                            QualityType q,
00142                                            double& quality,
00143                                            int num_nodes,
00144                                            EntityType etype,
00145                                            double* coords )
00146 {
00147     double coordinates[27][3];  // at most 27 nodes per element
00148 
00149     if( 0 == num_nodes && NULL == coords )
00150     {
00151         etype = TYPE_FROM_HANDLE( eh );
00152         if( possibleQuality[etype][q] == 0 ) return MB_NOT_IMPLEMENTED;
00153 
00154         // get coordinates of points, if not passed already
00155         const EntityHandle* conn = NULL;
00156         // int num_nodes;
00157         ErrorCode rval = mbImpl->get_connectivity( eh, conn, num_nodes );
00158         if( rval != MB_SUCCESS ) return rval;
00159         if( etype != MBPOLYHEDRON )
00160         {
00161             rval = mbImpl->get_coords( conn, num_nodes, &( coordinates[0][0] ) );
00162             if( rval != MB_SUCCESS ) return rval;
00163         }
00164     }
00165     else
00166     {
00167         if( num_nodes > 27 ) return MB_FAILURE;
00168         for( int i = 0; i < num_nodes; i++ )
00169         {
00170             for( int j = 0; j < 3; j++ )
00171                 coordinates[i][j] = coords[3 * i + j];
00172         }
00173     }
00174     VerdictFunction func = 0;
00175 
00176     switch( etype )
00177     {
00178         case MBHEX: {
00179             num_nodes = 8;
00180             switch( q )
00181             {
00182                 case MB_EDGE_RATIO:
00183                     func = v_hex_edge_ratio;
00184                     break;  // 0
00185                 case MB_MAX_EDGE_RATIO:
00186                     func = v_hex_max_edge_ratio;
00187                     break;  // 1
00188                 case MB_SKEW:
00189                     func = v_hex_skew;
00190                     break;  // 2
00191                 case MB_TAPER:
00192                     func = v_hex_taper;
00193                     break;  // 3
00194                 case MB_VOLUME:
00195                     func = v_hex_volume;
00196                     break;  // 4
00197                 case MB_STRETCH:
00198                     func = v_hex_stretch;
00199                     break;  // 5
00200                 case MB_DIAGONAL:
00201                     func = v_hex_diagonal;
00202                     break;  // 6
00203                 case MB_DIMENSION:
00204                     func = v_hex_dimension;
00205                     break;  // 7
00206                 case MB_ODDY:
00207                     func = v_hex_oddy;
00208                     break;  // 8
00209                 case MB_MED_ASPECT_FROBENIUS:
00210                     func = v_hex_med_aspect_frobenius;
00211                     break;  // 9
00212                 case MB_MAX_ASPECT_FROBENIUS:
00213                     func = v_hex_max_aspect_frobenius;
00214                     break;  // 10
00215                 case MB_CONDITION:
00216                     func = v_hex_condition;
00217                     break;  // 11
00218                 case MB_JACOBIAN:
00219                     func = v_hex_jacobian;
00220                     break;  // 12
00221                 case MB_SCALED_JACOBIAN:
00222                     func = v_hex_scaled_jacobian;
00223                     break;  // 13
00224                 case MB_SHEAR:
00225                     func = v_hex_shear;
00226                     break;  // 14
00227                 case MB_SHAPE:
00228                     func = v_hex_shape;
00229                     break;  // 15
00230                 case MB_RELATIVE_SIZE_SQUARED:
00231                     func = v_hex_relative_size_squared;
00232                     break;  // 16
00233                 case MB_SHAPE_AND_SIZE:
00234                     func = v_hex_shape_and_size;
00235                     break;  // 17
00236                 case MB_SHEAR_AND_SIZE:
00237                     func = v_hex_shear_and_size;
00238                     break;  // 18
00239                 case MB_DISTORTION:
00240                     func = v_hex_distortion;
00241                     break;  // 19
00242                 default:
00243                     return MB_FAILURE;
00244             }
00245             break;
00246         }
00247         case MBEDGE: {
00248             num_nodes = 2;
00249             switch( q )
00250             {
00251                 case MB_LENGTH:
00252                     func = v_edge_length;
00253                     break;  // 20
00254                 default:
00255                     return MB_FAILURE;
00256             }
00257             break;
00258         }
00259         case MBTET: {
00260             num_nodes = 4;
00261             switch( q )
00262             {
00263                 case MB_EDGE_RATIO:
00264                     func = v_tet_edge_ratio;
00265                     break;  // 0 //! Calculates tet edge ratio metric.
00266                 case MB_RADIUS_RATIO:
00267                     func = v_tet_radius_ratio;
00268                     break;  // 21
00269                 case MB_ASPECT_BETA:
00270                     func = v_tet_aspect_beta;
00271                     break;  // 22
00272                 case MB_ASPECT_RATIO:
00273                     func = v_tet_aspect_ratio;
00274                     break;  // 23
00275                 case MB_ASPECT_GAMMA:
00276                     func = v_tet_aspect_gamma;
00277                     break;  // 24
00278                 case MB_MAX_ASPECT_FROBENIUS:
00279                     func = v_tet_aspect_frobenius;
00280                     break;  // 10
00281                 case MB_MINIMUM_ANGLE:
00282                     func = v_tet_minimum_angle;
00283                     break;  // 25
00284                 case MB_COLLAPSE_RATIO:
00285                     func = v_tet_collapse_ratio;
00286                     break;  // 26
00287                 case MB_VOLUME:
00288                     func = v_tet_volume;
00289                     break;  // 4
00290                 case MB_CONDITION:
00291                     func = v_tet_condition;
00292                     break;  // 11
00293                 case MB_JACOBIAN:
00294                     func = v_tet_jacobian;
00295                     break;  // 12
00296                 case MB_SCALED_JACOBIAN:
00297                     func = v_tet_scaled_jacobian;
00298                     break;  // 13
00299                 case MB_SHAPE:
00300                     func = v_tet_shape;
00301                     break;  // 15
00302                 case MB_RELATIVE_SIZE_SQUARED:
00303                     func = v_tet_relative_size_squared;
00304                     break;  // 16
00305                 case MB_SHAPE_AND_SIZE:
00306                     func = v_tet_shape_and_size;
00307                     break;  // 17
00308                 case MB_DISTORTION:
00309                     func = v_tet_distortion;
00310                     break;  // 19
00311                 default:
00312                     return MB_FAILURE;
00313             }
00314             break;
00315         }
00316         case MBPRISM: {
00317             num_nodes = 6;
00318             switch( q )
00319             {
00320                 case MB_VOLUME:
00321                     func = v_wedge_volume;
00322                     break;  // 4
00323                 default:
00324                     return MB_FAILURE;
00325             }
00326             break;
00327         }
00328         case MBKNIFE: {
00329             num_nodes = 7;
00330             switch( q )
00331             {
00332                 case MB_VOLUME:
00333                     func = v_knife_volume;
00334                     break;  // 4
00335                 default:
00336                     return MB_FAILURE;
00337             }
00338             break;
00339         }
00340         case MBQUAD: {
00341             num_nodes = 4;
00342             switch( q )
00343             {
00344                 case MB_EDGE_RATIO:
00345                     func = v_quad_edge_ratio;
00346                     break;  // 0
00347                 case MB_MAX_EDGE_RATIO:
00348                     func = v_quad_max_edge_ratio;
00349                     break;  // 1
00350                 case MB_ASPECT_RATIO:
00351                     func = v_quad_aspect_ratio;
00352                     break;  // 23
00353                 case MB_RADIUS_RATIO:
00354                     func = v_quad_radius_ratio;
00355                     break;  // 21
00356                 case MB_MED_ASPECT_FROBENIUS:
00357                     func = v_quad_med_aspect_frobenius;
00358                     break;  // 9
00359                 case MB_MAX_ASPECT_FROBENIUS:
00360                     func = v_quad_max_aspect_frobenius;
00361                     break;  // 10
00362                 case MB_SKEW:
00363                     func = v_quad_skew;
00364                     break;  // 2
00365                 case MB_TAPER:
00366                     func = v_quad_taper;
00367                     break;  // 3
00368                 case MB_WARPAGE:
00369                     func = v_quad_warpage;
00370                     break;  // 27
00371                 case MB_AREA:
00372                     func = v_quad_area;
00373                     break;  // 28
00374                 case MB_STRETCH:
00375                     func = v_quad_stretch;
00376                     break;  // 5
00377                 case MB_MINIMUM_ANGLE:
00378                     func = v_quad_minimum_angle;
00379                     break;  // 25
00380                 case MB_MAXIMUM_ANGLE:
00381                     func = v_quad_maximum_angle;
00382                     break;  // 29
00383                 case MB_ODDY:
00384                     func = v_quad_oddy;
00385                     break;  // 8
00386                 case MB_CONDITION:
00387                     func = v_quad_condition;
00388                     break;  // 11
00389                 case MB_JACOBIAN:
00390                     func = v_quad_jacobian;
00391                     break;  // 12
00392                 case MB_SCALED_JACOBIAN:
00393                     func = v_quad_scaled_jacobian;
00394                     break;  // 13
00395                 case MB_SHEAR:
00396                     func = v_quad_shear;
00397                     break;  // 14
00398                 case MB_SHAPE:
00399                     func = v_quad_shape;
00400                     break;  // 15
00401                 case MB_RELATIVE_SIZE_SQUARED:
00402                     func = v_quad_relative_size_squared;
00403                     break;  // 16
00404                 case MB_SHAPE_AND_SIZE:
00405                     func = v_quad_shape_and_size;
00406                     break;  // 17
00407                 case MB_SHEAR_AND_SIZE:
00408                     func = v_quad_shear_and_size;
00409                     break;  // 18
00410                 case MB_DISTORTION:
00411                     func = v_quad_distortion;
00412                     break;  // 19
00413                 default:
00414                     return MB_FAILURE;
00415             }
00416             break;
00417         }
00418 
00419         case MBTRI: {
00420             num_nodes = 3;
00421             switch( q )
00422             {
00423                 case MB_EDGE_RATIO:
00424                     func = v_tri_edge_ratio;
00425                     break;  // 0
00426                 case MB_ASPECT_RATIO:
00427                     func = v_tri_aspect_ratio;
00428                     break;  // 23
00429                 case MB_RADIUS_RATIO:
00430                     func = v_tri_radius_ratio;
00431                     break;  // 21
00432                 case MB_MAX_ASPECT_FROBENIUS:
00433                     func = v_tri_aspect_frobenius;
00434                     break;  // 10
00435                 case MB_AREA:
00436                     func = v_tri_area;
00437                     break;  // 28
00438                 case MB_MINIMUM_ANGLE:
00439                     func = v_tri_minimum_angle;
00440                     break;  // 25
00441                 case MB_MAXIMUM_ANGLE:
00442                     func = v_tri_maximum_angle;
00443                     break;  // 29
00444                 case MB_CONDITION:
00445                     func = v_tri_condition;
00446                     break;  // 11
00447                 case MB_SCALED_JACOBIAN:
00448                     func = v_tri_scaled_jacobian;
00449                     break;  // 13
00450                 // does not exist, even though it was defined in verdict.h; remove it from there too
00451                 // case MB_SHEAR:                func = v_tri_shear; break;                  // 14
00452                 case MB_RELATIVE_SIZE_SQUARED:
00453                     func = v_tri_relative_size_squared;
00454                     break;  // 16
00455                 case MB_SHAPE:
00456                     func = v_tri_shape;
00457                     break;  // 15
00458                 case MB_SHAPE_AND_SIZE:
00459                     func = v_tri_shape_and_size;
00460                     break;  // 17
00461                 case MB_DISTORTION:
00462                     func = v_tri_distortion;
00463                     break;  // 19
00464                 default:
00465                     return MB_FAILURE;
00466             }
00467             break;
00468         }
00469         default:
00470             break;  // some have no measures
00471     }
00472 
00473     if( !func ) return MB_NOT_IMPLEMENTED;
00474     // actual computation happens here
00475     quality = ( *func )( num_nodes, coordinates );
00476 
00477     return MB_SUCCESS;
00478 }
00479 const char* VerdictWrapper::quality_name( QualityType q )
00480 {
00481     return nameQuality[q];
00482 }
00483 const char* VerdictWrapper::entity_type_name( EntityType etype )
00484 {
00485     return nameType[etype];
00486 }
00487 int VerdictWrapper::num_qualities( EntityType etype )
00488 {
00489     return numQualities[etype];
00490 }
00491 int VerdictWrapper::possible_quality( EntityType et, QualityType q )
00492 {
00493     return possibleQuality[et][q];
00494 }
00495 // relative size needs a base size, that is set at global level, one for each major type (hex, tet,
00496 // quad, tri)
00497 ErrorCode VerdictWrapper::set_size( double size )
00498 {
00499     // set the sizes for all of them; maybe we can set by type, this should be enough for simplicity
00500     v_set_hex_size( size );
00501     v_set_tet_size( size );
00502     v_set_quad_size( size );
00503     v_set_tri_size( size );
00504     return MB_SUCCESS;
00505 }
00506 
00507 ErrorCode VerdictWrapper::all_quality_measures( EntityHandle eh, std::map< QualityType, double >& qualities )
00508 {
00509     EntityType etype = TYPE_FROM_HANDLE( eh );
00510     if( etype == MBPOLYHEDRON || etype == MBVERTEX || etype == MBENTITYSET )
00511         return MB_SUCCESS;  // no quality for polyhedron or vertex or set
00512 
00513     double coordinates[27][3];  // at most 27 nodes per element
00514     // get coordinates of points, if not passed already
00515     const EntityHandle* conn = NULL;
00516     int num_nodes;
00517     ErrorCode rval = mbImpl->get_connectivity( eh, conn, num_nodes );
00518     if( rval != MB_SUCCESS ) return rval;
00519     rval = mbImpl->get_coords( conn, num_nodes, &( coordinates[0][0] ) );
00520     if( rval != MB_SUCCESS ) return rval;
00521 
00522     switch( etype )
00523     {
00524         case MBEDGE: {
00525             double leng          = v_edge_length( 2, coordinates );
00526             qualities[MB_LENGTH] = leng;
00527             break;
00528         }
00529         case MBHEX: {
00530             num_nodes = 8;
00531             HexMetricVals hexMetric;
00532             v_hex_quality( num_nodes, coordinates, V_HEX_ALL, &hexMetric );
00533             qualities[MB_EDGE_RATIO]           = hexMetric.edge_ratio;
00534             qualities[MB_MAX_EDGE_RATIO]       = hexMetric.max_edge_ratio;
00535             qualities[MB_SKEW]                 = hexMetric.skew;
00536             qualities[MB_TAPER]                = hexMetric.taper;
00537             qualities[MB_VOLUME]               = hexMetric.volume;
00538             qualities[MB_STRETCH]              = hexMetric.stretch;
00539             qualities[MB_DIAGONAL]             = hexMetric.diagonal;
00540             qualities[MB_DIMENSION]            = hexMetric.dimension;
00541             qualities[MB_ODDY]                 = hexMetric.oddy;
00542             qualities[MB_MED_ASPECT_FROBENIUS] = hexMetric.med_aspect_frobenius;
00543             // MB_CONDITION is the same as MB_MAX_ASPECT_FROBENIUS
00544             qualities[MB_MAX_ASPECT_FROBENIUS]  = hexMetric.condition;
00545             qualities[MB_CONDITION]             = hexMetric.condition;
00546             qualities[MB_JACOBIAN]              = hexMetric.jacobian;
00547             qualities[MB_SCALED_JACOBIAN]       = hexMetric.scaled_jacobian;
00548             qualities[MB_SHEAR]                 = hexMetric.shear;
00549             qualities[MB_SHAPE]                 = hexMetric.shape;
00550             qualities[MB_RELATIVE_SIZE_SQUARED] = hexMetric.relative_size_squared;
00551             qualities[MB_SHAPE_AND_SIZE]        = hexMetric.shape_and_size;
00552             qualities[MB_SHEAR_AND_SIZE]        = hexMetric.shear_and_size;
00553             qualities[MB_DISTORTION]            = hexMetric.distortion;
00554             break;
00555         }
00556 
00557         case MBTET: {
00558             num_nodes = 4;
00559             TetMetricVals tetMetrics;
00560             v_tet_quality( num_nodes, coordinates, V_TET_ALL, &tetMetrics );
00561             qualities[MB_EDGE_RATIO]            = tetMetrics.edge_ratio;
00562             qualities[MB_RADIUS_RATIO]          = tetMetrics.radius_ratio;
00563             qualities[MB_ASPECT_BETA]           = tetMetrics.aspect_beta;
00564             qualities[MB_ASPECT_RATIO]          = tetMetrics.aspect_ratio;
00565             qualities[MB_ASPECT_GAMMA]          = tetMetrics.aspect_gamma;
00566             qualities[MB_MAX_ASPECT_FROBENIUS]  = tetMetrics.aspect_frobenius;
00567             qualities[MB_MINIMUM_ANGLE]         = tetMetrics.minimum_angle;
00568             qualities[MB_COLLAPSE_RATIO]        = tetMetrics.collapse_ratio;
00569             qualities[MB_VOLUME]                = tetMetrics.volume;
00570             qualities[MB_CONDITION]             = tetMetrics.condition;
00571             qualities[MB_JACOBIAN]              = tetMetrics.jacobian;
00572             qualities[MB_SCALED_JACOBIAN]       = tetMetrics.scaled_jacobian;
00573             qualities[MB_SHAPE]                 = tetMetrics.shape;
00574             qualities[MB_RELATIVE_SIZE_SQUARED] = tetMetrics.relative_size_squared;
00575             qualities[MB_SHAPE_AND_SIZE]        = tetMetrics.shape_and_size;
00576             qualities[MB_DISTORTION]            = tetMetrics.distortion;
00577             break;
00578         }
00579         case MBPRISM: {
00580             num_nodes            = 6;
00581             double volu          = v_wedge_volume( num_nodes, coordinates );
00582             qualities[MB_VOLUME] = volu;
00583             break;
00584         }
00585         case MBKNIFE: {
00586             num_nodes            = 7;
00587             double volu          = v_knife_volume( num_nodes, coordinates );
00588             qualities[MB_VOLUME] = volu;
00589             break;
00590         }
00591         case MBQUAD: {
00592             num_nodes = 4;
00593             QuadMetricVals quadMetrics;
00594             v_quad_quality( num_nodes, coordinates, V_QUAD_ALL, &quadMetrics );
00595             qualities[MB_EDGE_RATIO]            = quadMetrics.edge_ratio;
00596             qualities[MB_MAX_EDGE_RATIO]        = quadMetrics.max_edge_ratio;
00597             qualities[MB_ASPECT_RATIO]          = quadMetrics.aspect_ratio;           // 23
00598             qualities[MB_RADIUS_RATIO]          = quadMetrics.radius_ratio;           // 21
00599             qualities[MB_MED_ASPECT_FROBENIUS]  = quadMetrics.med_aspect_frobenius;   // 9
00600             qualities[MB_MAX_ASPECT_FROBENIUS]  = quadMetrics.max_aspect_frobenius;   // 10
00601             qualities[MB_SKEW]                  = quadMetrics.skew;                   // 2
00602             qualities[MB_TAPER]                 = quadMetrics.taper;                  // 3
00603             qualities[MB_WARPAGE]               = quadMetrics.warpage;                // 27
00604             qualities[MB_AREA]                  = quadMetrics.area;                   // 28
00605             qualities[MB_STRETCH]               = quadMetrics.stretch;                // 5
00606             qualities[MB_MINIMUM_ANGLE]         = quadMetrics.minimum_angle;          // 25
00607             qualities[MB_MAXIMUM_ANGLE]         = quadMetrics.maximum_angle;          // 29
00608             qualities[MB_ODDY]                  = quadMetrics.oddy;                   // 8
00609             qualities[MB_CONDITION]             = quadMetrics.condition;              // 11
00610             qualities[MB_JACOBIAN]              = quadMetrics.jacobian;               // 12
00611             qualities[MB_SCALED_JACOBIAN]       = quadMetrics.scaled_jacobian;        // 13
00612             qualities[MB_SHEAR]                 = quadMetrics.shear;                  // 14
00613             qualities[MB_SHAPE]                 = quadMetrics.shape;                  // 15
00614             qualities[MB_RELATIVE_SIZE_SQUARED] = quadMetrics.relative_size_squared;  // 16
00615             qualities[MB_SHAPE_AND_SIZE]        = quadMetrics.shape_and_size;         // 17
00616             qualities[MB_SHEAR_AND_SIZE]        = quadMetrics.shear_and_size;         // 18
00617             qualities[MB_DISTORTION]            = quadMetrics.distortion;             // 19
00618             break;
00619         }
00620 
00621         case MBTRI: {
00622             num_nodes = 3;
00623             TriMetricVals triMetrics;
00624             v_tri_quality( num_nodes, coordinates, V_TRI_ALL, &triMetrics );
00625             qualities[MB_EDGE_RATIO]           = triMetrics.edge_ratio;        // 0
00626             qualities[MB_ASPECT_RATIO]         = triMetrics.aspect_ratio;      // 23
00627             qualities[MB_RADIUS_RATIO]         = triMetrics.radius_ratio;      // 21
00628             qualities[MB_MAX_ASPECT_FROBENIUS] = triMetrics.aspect_frobenius;  // 10
00629             qualities[MB_AREA]                 = triMetrics.area;              // 28
00630             qualities[MB_MINIMUM_ANGLE]        = triMetrics.minimum_angle;     // 25
00631             qualities[MB_MAXIMUM_ANGLE]        = triMetrics.maximum_angle;     // 29
00632             qualities[MB_CONDITION]            = triMetrics.condition;         // 11
00633             qualities[MB_SCALED_JACOBIAN]      = triMetrics.scaled_jacobian;   // 13
00634             // does not exist, even though it was defined in verdict.h; remove it from there too
00635             // case MB_SHEAR:                func = v_tri_shear; break;                  // 14
00636             qualities[MB_RELATIVE_SIZE_SQUARED] = triMetrics.relative_size_squared;  // 16
00637             qualities[MB_SHAPE]                 = triMetrics.shape;                  // 15
00638             qualities[MB_SHAPE_AND_SIZE]        = triMetrics.shape_and_size;         // 17
00639             qualities[MB_DISTORTION]            = triMetrics.distortion;             // 19
00640             break;
00641         }
00642         default:
00643             return MB_NOT_IMPLEMENTED;
00644     }
00645     return MB_SUCCESS;
00646 }
00647 
00648 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines