Skip to content
Snippets Groups Projects
Commit cc627e5d authored by Laurent Stainier's avatar Laurent Stainier
Browse files

In tensor display, min/max values are now consistent with the scalar

Von Mises value displayed.
parent 48d33ad3
No related branches found
No related tags found
No related merge requests found
// $Id: Views.cpp,v 1.94 2003-04-14 22:55:56 geuzaine Exp $ // $Id: Views.cpp,v 1.95 2003-05-14 13:35:50 stainier Exp $
// //
// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
// //
...@@ -157,6 +157,27 @@ Post_View *BeginView(int allocate) ...@@ -157,6 +157,27 @@ Post_View *BeginView(int allocate)
return v; return v;
} }
// utility function
double ComputeVonMises(double*); // prototype
double ComputeVonMises(double *V) {
static const double THIRD = 1.e0 / 3.e0;
double tr = (V[0] + V[4] + V[8]) * THIRD;
double v11 = V[0] - tr;
double v12 = V[1];
double v13 = V[2];
double v21 = V[3];
double v22 = V[4] - tr;
double v23 = V[5];
double v31 = V[6];
double v32 = V[7];
double v33 = V[8] - tr;
return sqrt(1.5 * (v11 * v11 + v12 * v12 + v13 * v13 +
v21 * v21 + v22 * v22 + v23 * v23 +
v31 * v31 + v32 * v32 + v33 * v33));
}
void Stat_Element(Post_View * v, int type, int nbnod, int N, void Stat_Element(Post_View * v, int type, int nbnod, int N,
double *X, double *Y, double *Z, double *V) double *X, double *Y, double *Z, double *V)
{ {
...@@ -202,9 +223,12 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N, ...@@ -202,9 +223,12 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N,
v->ScalarOnly = 0; v->ScalarOnly = 0;
break; break;
case 2: // tensor - TODO! case 2: // tensor
// by lack of any current better solution,
// tensors are displayed as their Von Mises
// invariant (J2 invariant)
if(v->Min == VAL_INF || v->Max == -VAL_INF) { if(v->Min == VAL_INF || v->Max == -VAL_INF) {
l0 = sqrt(DSQR(V[0]) + DSQR(V[4]) + DSQR(V[8])); l0 = ComputeVonMises(V);
v->Min = l0; v->Min = l0;
v->Max = l0; v->Max = l0;
v->NbTimeStep = N / (9 * nbnod); v->NbTimeStep = N / (9 * nbnod);
...@@ -213,7 +237,7 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N, ...@@ -213,7 +237,7 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N,
v->NbTimeStep = N / (9 * nbnod); v->NbTimeStep = N / (9 * nbnod);
for(i = 0; i < N; i += 9) { for(i = 0; i < N; i += 9) {
l0 = sqrt(DSQR(V[i]) + DSQR(V[i + 4]) + DSQR(V[i + 8])); l0 = ComputeVonMises(V+i);
if(l0 < v->Min) if(l0 < v->Min)
v->Min = l0; v->Min = l0;
if(l0 > v->Max) if(l0 > v->Max)
... ...
......
// $Id: PostElement.cpp,v 1.14 2003-03-21 00:52:39 geuzaine Exp $ // $Id: PostElement.cpp,v 1.15 2003-05-14 13:35:50 stainier Exp $
// //
// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
// //
...@@ -1009,6 +1009,8 @@ void Draw_VectorPyramid(ARGS) ...@@ -1009,6 +1009,8 @@ void Draw_VectorPyramid(ARGS)
// Tensor Elements // Tensor Elements
extern double ComputeVonMises(double*);
void Draw_TensorElement(int type, Post_View * View, void Draw_TensorElement(int type, Post_View * View,
double ValMin, double ValMax, double Raise[3][8], double ValMin, double ValMax, double Raise[3][8],
double *X, double *Y, double *Z, double *V) double *X, double *Y, double *Z, double *V)
...@@ -1042,26 +1044,16 @@ void Draw_TensorElement(int type, Post_View * View, ...@@ -1042,26 +1044,16 @@ void Draw_TensorElement(int type, Post_View * View,
break; break;
} }
/// we want to compute "von mises" value i.e. max eigenvalue /// by lack of any current better solution,
/// tensors are displayed as their Von Mises
/// invariant (J2 invariant)
/// this will simply call the scalar function /// this will simply call the scalar function
if(View->TensorType == DRAW_POST_VONMISES) { if(View->TensorType == DRAW_POST_VONMISES) {
static const double THIRD = 1.e0 / 3.e0;
double V_VonMises[8]; double V_VonMises[8];
for(int i = 0; i < nbnod; i++) { for(int i = 0; i < nbnod; i++)
double tr = (V[0 + 9 * i] + V[4 + 9 * i] + V[8 + 9 * i]) * THIRD; V_VonMises[i] = ComputeVonMises(V + 9*i);
double v11 = V[0 + 9 * i] - tr;
double v12 = V[1 + 9 * i];
double v13 = V[2 + 9 * i];
double v21 = V[3 + 9 * i];
double v22 = V[4 + 9 * i] - tr;
double v23 = V[5 + 9 * i];
double v31 = V[6 + 9 * i];
double v32 = V[7 + 9 * i];
double v33 = V[8 + 9 * i] - tr;
V_VonMises[i] = sqrt(1.5 * (v11 * v11 + v12 * v12 + v13 * v13 +
v21 * v21 + v22 * v22 + v23 * v23 +
v31 * v31 + v32 * v32 + v33 * v33));
}
switch (type) { switch (type) {
case POINT: case POINT:
Draw_ScalarPoint(View, 0, ValMin, ValMax, Raise, X, Y, Z, V_VonMises); Draw_ScalarPoint(View, 0, ValMin, ValMax, Raise, X, Y, Z, V_VonMises);
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment