Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
V_KnifeMetric.cpp
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: V_KnifeMetric.cpp,v $
00004 
00005   Copyright (c) 2006 Sandia Corporation.
00006   All rights reserved.
00007   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 
00015 /*
00016  *
00017  * KnifeMetrics.cpp contains quality calculations for knives
00018  *
00019  * This file is part of VERDICT
00020  *
00021  */
00022 
00023 #define VERDICT_EXPORTS
00024 
00025 #include "moab/verdict.h"
00026 #include "VerdictVector.hpp"
00027 #include <memory.h>
00028 
00029 /*  a knife element
00030 
00031           3
00032          _/\_
00033        _/  | \_
00034    0 _/        \_ 2
00035     |\_    | ___/|
00036     |  \  __/    |
00037     |  1\/ |     |
00038     |    \       |
00039     |_____\|_____|
00040    4       5      6
00041 
00042 
00043     (edge 3,5  is is a hidden line if you will)
00044 
00045     if this is hard to visualize, consider a hex
00046     with nodes 5 and 7 becoming the same node
00047 
00048 
00049 */
00050 
00051 /*!
00052   calculates the volume of a knife element
00053 
00054   this is done by dividing the knife into 4 tets
00055   and summing the volumes of each.
00056 */
00057 
00058 C_FUNC_DEF double v_knife_volume( int num_nodes, double coordinates[][3] )
00059 {
00060     double volume = 0;
00061     VerdictVector side1, side2, side3;
00062 
00063     if( num_nodes == 7 )
00064     {
00065 
00066         // divide the knife into 4 tets and calculate the volume
00067 
00068         side1.set( coordinates[1][0] - coordinates[0][0], coordinates[1][1] - coordinates[0][1],
00069                    coordinates[1][2] - coordinates[0][2] );
00070         side2.set( coordinates[3][0] - coordinates[0][0], coordinates[3][1] - coordinates[0][1],
00071                    coordinates[3][2] - coordinates[0][2] );
00072         side3.set( coordinates[4][0] - coordinates[0][0], coordinates[4][1] - coordinates[0][1],
00073                    coordinates[4][2] - coordinates[0][2] );
00074 
00075         volume = side3 % ( side1 * side2 ) / 6;
00076 
00077         side1.set( coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
00078                    coordinates[5][2] - coordinates[1][2] );
00079         side2.set( coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
00080                    coordinates[3][2] - coordinates[1][2] );
00081         side3.set( coordinates[4][0] - coordinates[1][0], coordinates[4][1] - coordinates[1][1],
00082                    coordinates[4][2] - coordinates[1][2] );
00083 
00084         volume += side3 % ( side1 * side2 ) / 6;
00085 
00086         side1.set( coordinates[2][0] - coordinates[1][0], coordinates[2][1] - coordinates[1][1],
00087                    coordinates[2][2] - coordinates[1][2] );
00088         side2.set( coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
00089                    coordinates[3][2] - coordinates[1][2] );
00090         side3.set( coordinates[6][0] - coordinates[1][0], coordinates[6][1] - coordinates[1][1],
00091                    coordinates[6][2] - coordinates[1][2] );
00092 
00093         volume += side3 % ( side1 * side2 ) / 6;
00094 
00095         side1.set( coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
00096                    coordinates[3][2] - coordinates[1][2] );
00097         side2.set( coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
00098                    coordinates[5][2] - coordinates[1][2] );
00099         side3.set( coordinates[6][0] - coordinates[1][0], coordinates[6][1] - coordinates[1][1],
00100                    coordinates[6][2] - coordinates[1][2] );
00101 
00102         volume += side3 % ( side1 * side2 ) / 6;
00103     }
00104 
00105     return (double)volume;
00106 }
00107 
00108 /*!
00109 
00110   calculate the quality metrics of a knife element.
00111 
00112   There is only one, but we put this here to be consistent with
00113   functions for other element types.  Who knows if we'll add
00114   more metrics.
00115 */
00116 
00117 C_FUNC_DEF void v_knife_quality( int num_nodes,
00118                                  double coordinates[][3],
00119                                  unsigned int metrics_request_flag,
00120                                  KnifeMetricVals* metric_vals )
00121 {
00122     memset( metric_vals, 0, sizeof( KnifeMetricVals ) );
00123 
00124     if( metrics_request_flag & V_KNIFE_VOLUME ) metric_vals->volume = v_knife_volume( num_nodes, coordinates );
00125 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines