![]() |
Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 /*=========================================================================
00002
00003 Module: $RCSfile: V_WedgeMetric.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 * WedgeMetric.cpp contains quality calculations for wedges
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
00028
00029 /*
00030 the wedge element
00031
00032
00033 5
00034 ^
00035 / \
00036 / | \
00037 / /2\ \
00038 6/_______\4
00039 | / \ |
00040 |/_____\|
00041 3 1
00042
00043 */
00044
00045 /*!
00046
00047 calculate the volume of a wedge
00048
00049 this is done by dividing the wedge into 3 tets
00050 and summing the volume of each tet
00051
00052 */
00053
00054 C_FUNC_DEF double v_wedge_volume( int num_nodes, double coordinates[][3] )
00055 {
00056
00057 double volume = 0;
00058 VerdictVector side1, side2, side3;
00059
00060 if( num_nodes == 6 )
00061 {
00062
00063 // divide the wedge into 3 tets and calculate each volume
00064
00065 side1.set( coordinates[1][0] - coordinates[0][0], coordinates[1][1] - coordinates[0][1],
00066 coordinates[1][2] - coordinates[0][2] );
00067
00068 side2.set( coordinates[2][0] - coordinates[0][0], coordinates[2][1] - coordinates[0][1],
00069 coordinates[2][2] - coordinates[0][2] );
00070
00071 side3.set( coordinates[3][0] - coordinates[0][0], coordinates[3][1] - coordinates[0][1],
00072 coordinates[3][2] - coordinates[0][2] );
00073
00074 volume = side3 % ( side1 * side2 ) / 6;
00075
00076 side1.set( coordinates[4][0] - coordinates[1][0], coordinates[4][1] - coordinates[1][1],
00077 coordinates[4][2] - coordinates[1][2] );
00078
00079 side2.set( coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
00080 coordinates[5][2] - coordinates[1][2] );
00081
00082 side3.set( coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
00083 coordinates[3][2] - coordinates[1][2] );
00084
00085 volume += side3 % ( side1 * side2 ) / 6;
00086
00087 side1.set( coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
00088 coordinates[5][2] - coordinates[1][2] );
00089
00090 side2.set( coordinates[2][0] - coordinates[1][0], coordinates[2][1] - coordinates[1][1],
00091 coordinates[2][2] - coordinates[1][2] );
00092
00093 side3.set( coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
00094 coordinates[3][2] - coordinates[1][2] );
00095
00096 volume += side3 % ( side1 * side2 ) / 6;
00097 }
00098
00099 return (double)volume;
00100 }
00101
00102 C_FUNC_DEF void v_wedge_quality( int num_nodes,
00103 double coordinates[][3],
00104 unsigned int metrics_request_flag,
00105 WedgeMetricVals* metric_vals )
00106 {
00107 memset( metric_vals, 0, sizeof( WedgeMetricVals ) );
00108
00109 if( metrics_request_flag & V_WEDGE_VOLUME ) metric_vals->volume = v_wedge_volume( num_nodes, coordinates );
00110 }