forked from sandialabs/verdict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathV_KnifeMetric.cpp
153 lines (114 loc) · 3.52 KB
/
V_KnifeMetric.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*=========================================================================
Module: V_KnifeMetric.cpp
Copyright 2006 National Technology & Engineering Solutions of Sandia,
LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS,
the U.S. Government retains certain rights in this software.
See LICENSE for details.
=========================================================================*/
/*
*
* KnifeMetrics.cpp contains quality calculations for knives
*
* This file is part of VERDICT
*
*/
#include "verdict.h"
#include "VerdictVector.hpp"
#include <memory.h>
namespace VERDICT_NAMESPACE
{
/* a knife element
3
_/\_
_/ | \_
0 _/ \_ 2
|\_ | ___/|
| \ __/ |
| 1\/ | |
| \ |
|_____\|_____|
4 5 6
(edge 3,5 is is a hidden line if you will)
if this is hard to visualize, consider a hex
with nodes 5 and 7 becoming the same node
*/
/*!
calculates the volume of a knife element
this is done by dividing the knife into 4 tets
and summing the volumes of each.
*/
double knife_volume( int num_nodes, double coordinates[][3] )
{
double volume = 0;
VerdictVector side1, side2, side3;
if (num_nodes == 7)
{
// divide the knife into 4 tets and calculate the volume
side1.set(
coordinates[1][0] - coordinates[0][0],
coordinates[1][1] - coordinates[0][1],
coordinates[1][2] - coordinates[0][2]
);
side2.set(
coordinates[3][0] - coordinates[0][0],
coordinates[3][1] - coordinates[0][1],
coordinates[3][2] - coordinates[0][2]
);
side3.set(
coordinates[4][0] - coordinates[0][0],
coordinates[4][1] - coordinates[0][1],
coordinates[4][2] - coordinates[0][2]
);
volume = side3 % (side1 * side2) / 6;
side1.set(
coordinates[5][0] - coordinates[1][0],
coordinates[5][1] - coordinates[1][1],
coordinates[5][2] - coordinates[1][2]
);
side2.set(
coordinates[3][0] - coordinates[1][0],
coordinates[3][1] - coordinates[1][1],
coordinates[3][2] - coordinates[1][2]
);
side3.set(
coordinates[4][0] - coordinates[1][0],
coordinates[4][1] - coordinates[1][1],
coordinates[4][2] - coordinates[1][2]
);
volume += side3 % (side1 * side2) / 6;
side1.set(
coordinates[2][0] - coordinates[1][0],
coordinates[2][1] - coordinates[1][1],
coordinates[2][2] - coordinates[1][2]
);
side2.set(
coordinates[3][0] - coordinates[1][0],
coordinates[3][1] - coordinates[1][1],
coordinates[3][2] - coordinates[1][2]
);
side3.set(
coordinates[6][0] - coordinates[1][0],
coordinates[6][1] - coordinates[1][1],
coordinates[6][2] - coordinates[1][2]
);
volume += side3 % (side1 * side2) / 6;
side1.set(
coordinates[3][0] - coordinates[1][0],
coordinates[3][1] - coordinates[1][1],
coordinates[3][2] - coordinates[1][2]
);
side2.set(
coordinates[5][0] - coordinates[1][0],
coordinates[5][1] - coordinates[1][1],
coordinates[5][2] - coordinates[1][2]
);
side3.set(
coordinates[6][0] - coordinates[1][0],
coordinates[6][1] - coordinates[1][1],
coordinates[6][2] - coordinates[1][2]
);
volume += side3 % (side1 * side2) / 6;
}
return (double)volume;
}
} // namespace verdict