Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
V_WedgeMetric.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: V_WedgeMetric.cpp,v $
4 
5  Copyright (c) 2006 Sandia Corporation.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 
15 /*
16  *
17  * WedgeMetric.cpp contains quality calculations for wedges
18  *
19  * This file is part of VERDICT
20  *
21  */
22 
23 #define VERDICT_EXPORTS
24 
25 #include "moab/verdict.h"
26 #include "VerdictVector.hpp"
27 #include <memory.h>
28 
29 /*
30  the wedge element
31 
32 
33  5
34  ^
35  / \
36  / | \
37  / /2\ \
38  6/_______\4
39  | / \ |
40  |/_____\|
41  3 1
42 
43 */
44 
45 /*!
46 
47  calculate the volume of a wedge
48 
49  this is done by dividing the wedge into 3 tets
50  and summing the volume of each tet
51 
52 */
53 
54 C_FUNC_DEF double v_wedge_volume( int num_nodes, double coordinates[][3] )
55 {
56 
57  double volume = 0;
58  VerdictVector side1, side2, side3;
59 
60  if( num_nodes == 6 )
61  {
62 
63  // divide the wedge into 3 tets and calculate each volume
64 
65  side1.set( coordinates[1][0] - coordinates[0][0], coordinates[1][1] - coordinates[0][1],
66  coordinates[1][2] - coordinates[0][2] );
67 
68  side2.set( coordinates[2][0] - coordinates[0][0], coordinates[2][1] - coordinates[0][1],
69  coordinates[2][2] - coordinates[0][2] );
70 
71  side3.set( coordinates[3][0] - coordinates[0][0], coordinates[3][1] - coordinates[0][1],
72  coordinates[3][2] - coordinates[0][2] );
73 
74  volume = side3 % ( side1 * side2 ) / 6;
75 
76  side1.set( coordinates[4][0] - coordinates[1][0], coordinates[4][1] - coordinates[1][1],
77  coordinates[4][2] - coordinates[1][2] );
78 
79  side2.set( coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
80  coordinates[5][2] - coordinates[1][2] );
81 
82  side3.set( coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
83  coordinates[3][2] - coordinates[1][2] );
84 
85  volume += side3 % ( side1 * side2 ) / 6;
86 
87  side1.set( coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
88  coordinates[5][2] - coordinates[1][2] );
89 
90  side2.set( coordinates[2][0] - coordinates[1][0], coordinates[2][1] - coordinates[1][1],
91  coordinates[2][2] - coordinates[1][2] );
92 
93  side3.set( coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
94  coordinates[3][2] - coordinates[1][2] );
95 
96  volume += side3 % ( side1 * side2 ) / 6;
97  }
98 
99  return (double)volume;
100 }
101 
102 C_FUNC_DEF void v_wedge_quality( int num_nodes,
103  double coordinates[][3],
104  unsigned int metrics_request_flag,
105  WedgeMetricVals* metric_vals )
106 {
107  memset( metric_vals, 0, sizeof( WedgeMetricVals ) );
108 
109  if( metrics_request_flag & V_WEDGE_VOLUME ) metric_vals->volume = v_wedge_volume( num_nodes, coordinates );
110 }