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

I have added plotting of J2 invariant of tensors for all elements.

Previously, it was only available for 2D tensors in triangles.
Now, the 'Von Mises' option plots the J2 invariant of the full 3D tensor.
The J2 invariant is the second invariant (A_ij*A_ij) of the deviator.
In practice, what is actually plotted is sqrt(1.5*A_ij*A_ij).
parent f577eca0
No related branches found
No related tags found
No related merge requests found
// $Id: PostElement.cpp,v 1.8 2003-02-14 04:02:30 geuzaine Exp $
// $Id: PostElement.cpp,v 1.9 2003-02-14 09:32:31 stainier Exp $
//
// Copyright (C) 1997 - 2003 C. Geuzaine, J.-F. Remacle
//
......@@ -834,12 +834,58 @@ void Draw_VectorPyramid(ARGS){
void Draw_TensorElement(int type, Post_View *View,
double ValMin, double ValMax, double Raise[3][8],
double *X, double *Y, double *Z, double *V){
static int error=0 ;
if(!error){
error = 1;
Msg(GERROR, "Tensor field visualization is not implemented");
Msg(GERROR, "We *need* some ideas on how to implement this!");
Msg(GERROR, "Send your ideas to <gmsh@geuz.org>!");
int nbnod ;
switch(type){
case POINT : nbnod = 1; break;
case LINE : nbnod = 2; break;
case TRIANGLE : nbnod = 3; break;
case QUADRANGLE : nbnod = 4; break;
case TETRAHEDRON : nbnod = 4; break;
case HEXAHEDRON : nbnod = 8; break;
case PRISM : nbnod = 6; break;
case PYRAMID : nbnod = 5; break;
}
/// we want to compute "von mises" value i.e. max eigenvalue
/// this will simply call the scalar function
if(View->TensorType == DRAW_POST_VONMISES){
static const double THIRD = 1.e0/3.e0;
double V_VonMises [8];
for(int i=0;i<nbnod;i++){
double tr = (V[0+9*i]+V[4+9*i]+V[8+9*i])*THIRD;
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){
case POINT : Draw_ScalarPoint(View, 0, ValMin, ValMax, Raise, X,Y,Z,V_VonMises); break;
case LINE : Draw_ScalarLine(View, 0, ValMin, ValMax, Raise, X,Y,Z,V_VonMises); break;
case TRIANGLE : Draw_ScalarTriangle(View, 0, ValMin, ValMax, Raise, X,Y,Z,V_VonMises); break;
case QUADRANGLE : Draw_ScalarQuadrangle(View, 0, ValMin, ValMax, Raise, X,Y,Z,V_VonMises); break;
case TETRAHEDRON : Draw_ScalarTetrahedron(View, 0, ValMin, ValMax, Raise, X,Y,Z,V_VonMises); break;
case HEXAHEDRON : Draw_ScalarHexahedron(View, 0, ValMin, ValMax, Raise, X,Y,Z,V_VonMises); break;
case PRISM : Draw_ScalarPrism(View, 0, ValMin, ValMax, Raise, X,Y,Z,V_VonMises); break;
case PYRAMID : Draw_ScalarPyramid(View, 0, ValMin, ValMax, Raise, X,Y,Z,V_VonMises); break;
}
}
else {
static int error=0 ;
if(!error){
error = 1;
Msg(GERROR, "Tensor field visualization is not implemented");
Msg(GERROR, "We *need* some ideas on how to implement this!");
Msg(GERROR, "Send your ideas to <gmsh@geuz.org>!");
}
}
}
......@@ -852,6 +898,7 @@ void Draw_TensorPoint(ARGS){
void Draw_TensorLine(ARGS){
Draw_TensorElement(LINE, View, ValMin, ValMax, Raise, X, Y, Z, V); }
void Draw_TensorTriangle(ARGS){
/*
/// we want to compute "von mises" value i.e. max eigenvalue
/// this will simply call the scalar function
if(View->TensorType == DRAW_POST_VONMISES){
......@@ -866,7 +913,8 @@ void Draw_TensorTriangle(ARGS){
}
Draw_ScalarTriangle(View, 0, ValMin, ValMax, Raise, X,Y,Z,V_VonMises);
}
}
*/
Draw_TensorElement(TRIANGLE, View, ValMin, ValMax, Raise, X, Y, Z, V); }
void Draw_TensorTetrahedron(ARGS){
Draw_TensorElement(TETRAHEDRON, View, ValMin, ValMax, Raise, X, Y, Z, V); }
void Draw_TensorQuadrangle(ARGS){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment