Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
metric_demo.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: metric_demo.C,v 1.5 2008/12/06 08:45:25 mtcampbe Exp $
24 
25 #include "Algebraic_Metrics_2.h"
26 #include "Algebraic_Metrics_3.h"
27 #include "Geometric_Metrics_2.h"
28 #include "Geometric_Metrics_3.h"
29 #include "Connectivity.h"
30 #include <iostream>
31 
32 using namespace std;
34 
35 int main (){
36  // Build the reference tetrahedron and triangle
37  Vector_3<double> v0, v1, v2 , v3;
38  v0[0] = 0.0; v0[1] = 0.0; v0[2] = 0.0;
39  v1[0] = 1.0; v1[1] = 0.0; v1[2] = 0.0;
40  v2[0] = 0.5; v2[1] = .866025; v2[2] = 0.0;
41  v3[0] = 0.5; v3[1] = .288675; v3[2] = .816497;
42  Vector_3<double> ref_tet[4] = {v0,v1,v2,v3};
43  Vector_3<double> ref_tri[3] = {v0,v1,v2};
44 
45  // Build the logical tetrahedron and triangle (nodes are at position 1 or 0 along each axis)
46  Vector_3<double> p0, p1, p2 , p3;
47  p0[0] = 0.0; p0[1] = 0.0; p0[2] = 0.0;
48  p1[0] = 1.0; p1[1] = 0.0; p1[2] = 0.0;
49  p2[0] = 0.0; p2[1] = 1.0; p2[2] = 0.0;
50  p3[0] = 0.0; p3[1] = 0.0; p3[2] = 1.0;
51  Vector_3<double> log_tet[4] = {p0,p1,p2,p3};
52  Vector_3<double> log_tri[3] = {p0,p1,p2,};
53 
54  double tet_shape[1];
55  double tet_size[1];
56  double tet_skew[1];
57  double tet_angles[2];
58  double tet_aspects[2];
59 
60  double tri_shape[1];
61  double tri_size[1];
62  double tri_skew[1];
63  double tri_angles[2];
64  double tri_aspects[2];
65 
66  // For the reference volume I used the volume of a regular tetrahedron with
67  // edges of length 1.
68 
69  Shape_Metric_3 Shape3;
70  Size_Metric_3 Size3(.1178511);
71  Skew_Metric_3 Skew3;
72  Angle_Metric_3 Angle3;
73  Aspect_Metric_3 Aspect3;
74 
75  Shape_Metric_2 Shape2;
76  Size_Metric_2 Size2(.4330127);
77  Skew_Metric_2 Skew2;
78  Angle_Metric_2 Angle2;
79  Aspect_Metric_2 Aspect2;
80 
81  // Initialize the metrics
82 
83  Shape3.initialize(ref_tet,COM::Connectivity::TET4);
84  Size3.initialize(ref_tet,COM::Connectivity::TET4);
85  Skew3.initialize(ref_tet,COM::Connectivity::TET4);
86  Angle3.initialize(ref_tet,COM::Connectivity::TET4);
87  Aspect3.initialize(ref_tet,COM::Connectivity::TET4);
88 
89  Shape2.initialize(ref_tet,COM::Connectivity::TRI3);
90  Size2.initialize(ref_tet,COM::Connectivity::TRI3);
91  Skew2.initialize(ref_tet,COM::Connectivity::TRI3);
92  Angle2.initialize(ref_tri,COM::Connectivity::TRI3);
93  Aspect2.initialize(ref_tri,COM::Connectivity::TRI3);
94 
95  // Compute the metric values
96 
97  Shape3.compute(tet_shape);
98  Size3.compute(tet_size);
99  Skew3.compute(tet_skew);
100  Angle3.compute(tet_angles);
101  Aspect3.compute(tet_aspects);
102 
103  Shape2.compute(tri_shape);
104  Size2.compute(tri_size);
105  Skew2.compute(tri_skew);
106  Angle2.compute(tri_angles);
107  Aspect2.compute(tri_aspects);
108 
109  // Spit out some junk
110  cout << "For the regular tetrahedron, metric values are: " << endl;
111  cout << " Algebraic Metrics: " << endl;
112  cout << " shape = " << tet_shape[0] << endl;
113  cout << " size = " << tet_size[0] << endl;
114  cout << " skew = " << tet_skew[0] << endl;
115  cout << " Geometric Metrics: " << endl;
116  cout << " min angle = " << tet_angles[0] << endl;
117  cout << " max angle = " << tet_angles[1] << endl;
118  cout << " R/r = " << tet_aspects[0] << endl;
119  cout << " R/l = " << tet_aspects[1] << endl;
120  cout << "The range of values for the metrics are: " << endl;
121  cout << " shape = [" << Shape3.minValue() << "," << Shape3.maxValue() << "]" << endl;
122  cout << " size = [" << Size3.minValue() << "," << Size3.maxValue() << "]" << endl;
123  cout << " skew = [" << Skew3.minValue() << "," << Skew3.maxValue() << "]" << endl;
124  cout << " angles = [" << Angle3.minValue() << "," << Angle3.maxValue() << "]" << endl;
125  cout << " a. ratios = [" << Aspect3.minValue() << "," << Aspect3.maxValue() << "]" << endl << endl;
126 
127  cout << "For the equilateral triangle, metric values are: " << endl;
128  cout << " Algebraic Metrics: " << endl;
129  cout << " shape = " << tri_shape[0] << endl;
130  cout << " size = " << tri_size[0] << endl;
131  cout << " skew = " << tri_skew[0] << endl;
132  cout << " Geometric Metrics: " << endl;
133  cout << " min angle = " << tri_angles[0] << endl;
134  cout << " max angle = " << tri_angles[1] << endl;
135  cout << " R/r = " << tri_aspects[0] << endl;
136  cout << " R/l = " << tri_aspects[1] << endl;
137  cout << "The range of values for the metrics are: " << endl;
138  cout << " shape = [" << Shape3.minValue() << "," << Shape3.maxValue() << "]" << endl;
139  cout << " size = [" << Size3.minValue() << "," << Size3.maxValue() << "]" << endl;
140  cout << " skew = [" << Skew3.minValue() << "," << Skew3.maxValue() << "]" << endl;
141  cout << " angles = [" << Angle3.minValue() << "," << Angle3.maxValue() << "]" << endl;
142  cout << " a. ratios = [" << Aspect3.minValue() << "," << Aspect3.maxValue() << "]" << endl << endl;
143 
144  // Initialize the metrics
145 
146  Shape3.initialize(log_tet,COM::Connectivity::TET4);
147  Size3.initialize(log_tet,COM::Connectivity::TET4);
148  Skew3.initialize(log_tet,COM::Connectivity::TET4);
149  Angle3.initialize(log_tet,COM::Connectivity::TET4);
150  Aspect3.initialize(log_tet,COM::Connectivity::TET4);
151 
152  Shape2.initialize(log_tet,COM::Connectivity::TRI3);
153  Size2.initialize(log_tet,COM::Connectivity::TRI3);
154  Skew2.initialize(log_tet,COM::Connectivity::TRI3);
155  Angle2.initialize(log_tri,COM::Connectivity::TRI3);
156  Aspect2.initialize(log_tri,COM::Connectivity::TRI3);
157 
158  // Compute the metric values
159 
160  Shape3.compute(tet_shape);
161  Size3.compute(tet_size);
162  Skew3.compute(tet_skew);
163  Angle3.compute(tet_angles);
164  Aspect3.compute(tet_aspects);
165 
166  Shape2.compute(tri_shape);
167  Size2.compute(tri_size);
168  Skew2.compute(tri_skew);
169  Angle2.compute(tri_angles);
170  Aspect2.compute(tri_aspects);
171 
172  // Spit out more junk
173  cout << "For the logical tetrahedron, metric values are: " << endl;
174  cout << " Algebraic Metrics: " << endl;
175  cout << " shape = " << tet_shape[0] << endl;
176  cout << " size = " << tet_size[0] << endl;
177  cout << " skew = " << tet_skew[0] << endl;
178  cout << " Geometric Metrics: " << endl;
179  cout << " min angle = " << tet_angles[0] << endl;
180  cout << " max angle = " << tet_angles[1] << endl;
181  cout << " R/r = " << tet_aspects[0] << endl;
182  cout << " R/l = " << tet_aspects[1] << endl;
183  cout << "The range of values for the metrics are: " << endl;
184  cout << " shape = [" << Shape3.minValue() << "," << Shape3.maxValue() << "]" << endl;
185  cout << " size = [" << Size3.minValue() << "," << Size3.maxValue() << "]" << endl;
186  cout << " skew = [" << Skew3.minValue() << "," << Skew3.maxValue() << "]" << endl;
187  cout << " angles = [" << Angle3.minValue() << "," << Angle3.maxValue() << "]" << endl;
188  cout << " a. ratios = [" << Aspect3.minValue() << "," << Aspect3.maxValue() << "]" << endl << endl;
189 
190  cout << "For the logical triangle, metric values are: " << endl;
191  cout << " Algebraic Metrics: " << endl;
192  cout << " shape = " << tri_shape[0] << endl;
193  cout << " size = " << tri_size[0] << endl;
194  cout << " skew = " << tri_skew[0] << endl;
195  cout << " Geometric Metrics: " << endl;
196  cout << " min angle = " << tri_angles[0] << endl;
197  cout << " max angle = " << tri_angles[1] << endl;
198  cout << " R/r = " << tri_aspects[0] << endl;
199  cout << " R/l = " << tri_aspects[1] << endl;
200  cout << "The range of values for the metrics are: " << endl;
201  cout << " shape = [" << Shape3.minValue() << "," << Shape3.maxValue() << "]" << endl;
202  cout << " size = [" << Size3.minValue() << "," << Size3.maxValue() << "]" << endl;
203  cout << " skew = [" << Skew3.minValue() << "," << Skew3.maxValue() << "]" << endl;
204  cout << " angles = [" << Angle3.minValue() << "," << Angle3.maxValue() << "]" << endl;
205  cout << " a. ratios = [" << Aspect3.minValue() << "," << Aspect3.maxValue() << "]" << endl << endl;
206 
207 
208  // Build the reference/logical hexahedron=
209  Vector_3<double> v2_0, v2_1, v2_2 ,v2_3, v2_4, v2_5, v2_6, v2_7;
210  v2_0[0] = 0.0; v2_0[1] = 0.0; v2_0[2] = 0.0;
211  v2_1[0] = 1.0; v2_1[1] = 0.0; v2_1[2] = 0.0;
212  v2_2[0] = 1.0; v2_2[1] = 1.0; v2_2[2] = 0.0;
213  v2_3[0] = 0.0; v2_3[1] = 1.0; v2_3[2] = 0.0;
214  v2_4[0] = 0.0; v2_4[1] = 0.0; v2_4[2] = 1.0;
215  v2_5[0] = 1.0; v2_5[1] = 0.0; v2_5[2] = 1.0;
216  v2_6[0] = 1.0; v2_6[1] = 1.0; v2_6[2] = 1.0;
217  v2_7[0] = 0.0; v2_7[1] = 1.0; v2_7[2] = 1.0;
218 
219  Vector_3<double> ref_hex[8] = {v2_0,v2_1,v2_2,v2_3,v2_4,v2_5,v2_6,v2_7};
220  Vector_3<double> ref_quad[4] = {v2_0,v2_1,v2_2,v2_3};
221 
222  Size_Metric_3 Size_3(1.0);
223  Size_Metric_2 Size_2(1.0);
224 
225  double hex_shape[1];
226  double hex_size[1];
227  double hex_skew[1];
228  double hex_angles[2];
229  double hex_aspects[2];
230 
231  double quad_shape[1];
232  double quad_size[1];
233  double quad_skew[1];
234  double quad_angles[2];
235  double quad_aspects[2];
236 
237  // Initialize the metrics
238  Shape3.initialize(ref_hex,COM::Connectivity::HEX8);
239  Size_3.initialize(ref_hex,COM::Connectivity::HEX8);
240  Skew3.initialize(ref_hex,COM::Connectivity::HEX8);
241  Angle3.initialize(ref_hex,COM::Connectivity::HEX8);
242  Aspect3.initialize(ref_hex,COM::Connectivity::HEX8);
243 
244  Shape2.initialize(ref_quad,COM::Connectivity::QUAD4);
245  Size_2.initialize(ref_quad,COM::Connectivity::QUAD4);
246  Skew2.initialize(ref_quad,COM::Connectivity::QUAD4);
247  Angle2.initialize(ref_quad,COM::Connectivity::QUAD4);
248  Aspect2.initialize(ref_quad,COM::Connectivity::QUAD4);
249 
250  // Compute values
251  Shape3.compute(hex_shape);
252  Size_3.compute(hex_size);
253  Skew3.compute(hex_skew);
254  Angle3.compute(hex_angles);
255  Aspect3.compute(hex_aspects);
256 
257  Shape2.compute(quad_shape);
258  Size_2.compute(quad_size);
259  Skew2.compute(quad_skew);
260  Angle2.compute(quad_angles);
261  Aspect2.compute(quad_aspects);
262 
263  // Spit out junk
264  cout << "For the regular hexahedron, metric values are: " << endl;
265  cout << " Algebraic Metrics: " << endl;
266  cout << " shape = " << hex_shape[0] << endl;
267  cout << " size = " << hex_size[0] << endl;
268  cout << " skew = " << hex_skew[0] << endl;
269  cout << " Geometric Metrics: " << endl;
270  cout << " min angle = " << hex_angles[0] << endl;
271  cout << " max angle = " << hex_angles[1] << endl;
272  cout << " R/r = " << hex_aspects[0] << endl;
273  cout << " R/l = " << hex_aspects[1] << endl;
274  cout << "The range of values for the metrics are: " << endl;
275  cout << " shape = [" << Shape3.minValue() << "," << Shape3.maxValue() << "]" << endl;
276  cout << " size = [" << Size_3.minValue() << "," << Size_3.maxValue() << "]" << endl;
277  cout << " skew = [" << Skew3.minValue() << "," << Skew3.maxValue() << "]" << endl;
278  cout << " angles = [" << Angle3.minValue() << "," << Angle3.maxValue() << "]" << endl;
279  cout << " a. ratios = [" << Aspect3.minValue() << "," << Aspect3.maxValue() << "]" << endl << endl;
280 
281  cout << "For the square, metric values are: " << endl;
282  cout << " Algebraic Metrics: " << endl;
283  cout << " shape = " << quad_shape[0] << endl;
284  cout << " size = " << quad_size[0] << endl;
285  cout << " skew = " << quad_skew[0] << endl;
286  cout << " Geometric Metrics: " << endl;
287  cout << " min angle = " << quad_angles[0] << endl;
288  cout << " max angle = " << quad_angles[1] << endl;
289  cout << " R/r = " << quad_aspects[0] << endl;
290  cout << " r/l = " << quad_aspects[1] << endl;
291  cout << "The range of values for the metrics are: " << endl;
292  cout << " shape = [" << Shape2.minValue() << "," << Shape2.maxValue() << "]" << endl;
293  cout << " size = [" << Size2.minValue() << "," << Size2.maxValue() << "]" << endl;
294  cout << " skew = [" << Skew2.minValue() << "," << Skew2.maxValue() << "]" << endl;
295  cout << " angles = [" << Angle2.minValue() << "," << Angle2.maxValue() << "]" << endl;
296  cout << " a. ratios = [" << Aspect2.minValue() << "," << Aspect2.maxValue() << "]" << endl << endl;
297 
298 // Build a non-ideal hexahedron and square
299  Vector_3<double> p2_0, p2_1, p2_2 ,p2_3, p2_4, p2_5, p2_6, p2_7;
300  p2_0[0] = 0.0; p2_0[1] = 0.0; p2_0[2] = 0.0;
301  p2_1[0] = .9; p2_1[1] = 0.0; p2_1[2] = 0.1;
302  p2_2[0] = 1.0; p2_2[1] = 1.1; p2_2[2] = 0.0;
303  p2_3[0] = 0.2; p2_3[1] = .85; p2_3[2] = 0.0;
304  p2_4[0] = 0.0; p2_4[1] = 0.0; p2_4[2] = 1.1;
305  p2_5[0] = 1.0; p2_5[1] = 0.0; p2_5[2] = 1.0;
306  p2_6[0] = 1.2; p2_6[1] = .9; p2_6[2] = 1.0;
307  p2_7[0] = 0.2; p2_7[1] = 1.0; p2_7[2] = 1.2;
308 
309  Vector_3<double> misc_hex[8] = {p2_0,p2_1,p2_2,p2_3,p2_4,p2_5,p2_6,p2_7};
310  Vector_3<double> misc_quad[4] = {p2_0,p2_1,p2_2,p2_3};
311 
312  // And so on, and so forth...
313  Shape3.initialize(misc_hex,COM::Connectivity::HEX8);
314  Size_3.initialize(misc_hex,COM::Connectivity::HEX8);
315  Skew3.initialize(misc_hex,COM::Connectivity::HEX8);
316  Angle3.initialize(misc_hex,COM::Connectivity::HEX8);
317  Aspect3.initialize(misc_hex,COM::Connectivity::HEX8);
318 
319  Shape2.initialize(misc_quad,COM::Connectivity::QUAD4);
320  Size_2.initialize(misc_quad,COM::Connectivity::QUAD4);
321  Skew2.initialize(misc_quad,COM::Connectivity::QUAD4);
322  Angle2.initialize(misc_quad,COM::Connectivity::QUAD4);
323  Aspect2.initialize(misc_quad,COM::Connectivity::QUAD4);
324 
325  Shape3.compute(hex_shape);
326  Size_3.compute(hex_size);
327  Skew3.compute(hex_skew);
328  Angle3.compute(hex_angles);
329  Aspect3.compute(hex_aspects);
330 
331  Shape2.compute(quad_shape);
332  Size_2.compute(quad_size);
333  Skew2.compute(quad_skew);
334  Angle2.compute(quad_angles);
335  Aspect2.compute(quad_aspects);
336 
337  cout << "For the non-regular hexahedron, metric values are: " << endl;
338  cout << " Algebraic Metrics: " << endl;
339  cout << " shape = " << hex_shape[0] << endl;
340  cout << " size = " << hex_size[0] << endl;
341  cout << " skew = " << hex_skew[0] << endl;
342  cout << " Geometric Metrics: " << endl;
343  cout << " min angle = " << hex_angles[0] << endl;
344  cout << " max angle = " << hex_angles[1] << endl;
345  cout << " R/r = " << hex_aspects[0] << endl;
346  cout << " R/l = " << hex_aspects[1] << endl;
347  cout << "The range of values for the metrics are: " << endl;
348  cout << " shape = [" << Shape3.minValue() << "," << Shape3.maxValue() << "]" << endl;
349  cout << " size = [" << Size_3.minValue() << "," << Size_3.maxValue() << "]" << endl;
350  cout << " skew = [" << Skew3.minValue() << "," << Skew3.maxValue() << "]" << endl;
351  cout << " angles = [" << Angle3.minValue() << "," << Angle3.maxValue() << "]" << endl;
352  cout << " a. ratios = [" << Aspect3.minValue() << "," << Aspect3.maxValue() << "]" << endl << endl;
353 
354  cout << "For the non-regular quadrilateral, metric values are: " << endl;
355  cout << " Algebraic Metrics: " << endl;
356  cout << " shape = " << quad_shape[0] << endl;
357  cout << " size = " << quad_size[0] << endl;
358  cout << " skew = " << quad_skew[0] << endl;
359  cout << " Geometric Metrics: " << endl;
360  cout << " min angle = " << quad_angles[0] << endl;
361  cout << " max angle = " << quad_angles[1] << endl;
362  cout << " R/r = " << quad_aspects[0] << endl;
363  cout << " r/l = " << quad_aspects[1] << endl;
364  cout << "The range of values for the metrics are: " << endl;
365  cout << " shape = [" << Shape2.minValue() << "," << Shape2.maxValue() << "]" << endl;
366  cout << " size = [" << Size2.minValue() << "," << Size2.maxValue() << "]" << endl;
367  cout << " skew = [" << Skew2.minValue() << "," << Skew2.maxValue() << "]" << endl;
368  cout << " angles = [" << Angle2.minValue() << "," << Angle2.maxValue() << "]" << endl;
369  cout << " a. ratios = [" << Aspect2.minValue() << "," << Aspect2.maxValue() << "]" << endl << endl;
370 
371  return 0;
372 }
373 
374 
375 
376 
377 
378 
2D Skew Metric Class
3D Aspect Ratios Metric Class
virtual double maxValue() const
The maximum value for this metric.
virtual void compute(double atts[]) const
Calculate the metric value on this element.
double maxValue() const
Get the maximum value for this metric.
double minValue() const
Get the minimum value for this metric.
2D Aspect Ratios Metric Class
virtual void compute(double atts[]) const
Calculate the metric value on this element.
virtual void compute(double atts[]) const
Calculate the metric value on this element.
virtual void compute(double atts[]) const
Calculate scaled R/r and R/l.
NT p1
virtual void compute(double atts[]) const
Calculate the shape metric value.
3D geometric quality Metric declarations.
double minValue() const
Get the minimum value for this metric.
double maxValue() const
The maximum value for this metric.
double minValue() const
The minimum value for this metric.
virtual void initialize(Vector_3< double > n[], int type)
Initialize a 2D Algebraic Metric.
NT p0
3D Shape Metric Class
2D Max and Min Angle Metric Class
double maxValue() const
Get the maximum value for this metric.
virtual void compute(double atts[]) const
Calculate the metric value on this element.
virtual void compute(double atts[]) const
Calculate the metric value.
virtual void initialize(Vector_3< double > n[], int type)
Initialize a 3D Algebraic Metric.
3D Size Metric Class
double minValue() const
The minimum value for this metric.
virtual void compute(double atts[]) const
Calculate max and min angles.
virtual void initialize(Vector_3< double > n[], int type)
Initialize a 2D Geometric Metric.
virtual void initialize(Vector_3< double > n[], int type)
Initialize a 3D Geometric Metric by nodal coords and element type.
3D Skew Metric Class
Contains the prototype of Connectivity.
2D geometric quality Metric declarations.
3d algebraic quality Metric declarations.
int main(int argc, char *argv[])
Definition: blastest.C:94
2D algebraic quality Metric declaration..
2D Size Metric Class
virtual void compute(double atts[]) const
Calculate the metric value on this element.
double maxValue() const
The maximum value for this metric.
2D Shape Metric Class
3D Max and Min Angle Metric Class
virtual double minValue() const
The minimum value for this metric.
virtual void compute(double atts[]) const
Calculate the shape metric value.
virtual double maxValue() const
The maximum value for this metric.
virtual double minValue() const
The minimum value for this metric.
USE_MOP_NAMESPACE
Definition: metric_demo.C:33