diff --git a/Common/Options.cpp b/Common/Options.cpp index b413d9370e6016c9f7f3caa26e724b7609783a69..de59be40af421271cc786496b832f10eaf94fe29 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -8011,7 +8011,7 @@ double opt_view_tensor_type(OPT_ARGS_NUM) GET_VIEW(0.); if(action & GMSH_SET) { opt->tensorType = (int)val; - if(opt->tensorType != 1) + if(opt->tensorType > 4) opt->tensorType = 1; if(view) view->setChanged(true); } diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 3a079b2dea84984fddab8da625afe44f9e602bd5..aabaf00e198b906e9687a375471acaf7ae48ec4f 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -3128,6 +3128,9 @@ optionWindow::optionWindow(int deltaFontSize) static Fl_Menu_Item menu_tensor[] = { {"Von-Mises", 0, 0, 0}, + {"Maximum eigen value", 0, 0, 0}, + {"Minimum eigen value", 0, 0, 0}, + {"Eigen vectors", 0, 0, 0}, {0} }; view.choice[4] = new Fl_Choice diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h index febec84dc13c47ea2fbd27c5a4c4883e600dff7f..795b3002512f406df24807a6944957f3d32000bc 100644 --- a/Post/PViewOptions.h +++ b/Post/PViewOptions.h @@ -34,7 +34,10 @@ class PViewOptions { Displacement = 5 }; enum TensorType { - VonMises = 1 + VonMises = 1, + MaxEigenValue = 2, + MinEigenValue = 3, + EigenVectors = 4 }; enum GlyphLocation { COG = 1, diff --git a/Post/PViewVertexArrays.cpp b/Post/PViewVertexArrays.cpp index b5eee4f1b75c37921083b7ae639dfd1a2fd5c38c..139cc9736d4f45b1c597b3dee0d0079b5788edc5 100644 --- a/Post/PViewVertexArrays.cpp +++ b/Post/PViewVertexArrays.cpp @@ -944,16 +944,60 @@ static void addVectorElement(PView *p, int ient, int iele, int numNodes, } } -static void addTensorElement(PView *p, int numNodes, int type, +static void addTensorElement(PView *p, int iEnt, int iEle, int numNodes, int type, double xyz[PVIEW_NMAX][3], double val[PVIEW_NMAX][9], bool pre) { PViewOptions *opt = p->getOptions(); + fullMatrix <double> tensor(3,3); + fullVector<double> S(3), imS (3); + fullMatrix<double> V(3,3); + fullMatrix <double> rightV(3,3); if(opt->tensorType == PViewOptions::VonMises){ for(int i = 0; i < numNodes; i++) val[i][0] = ComputeVonMises(val[i]); addScalarElement(p, type, xyz, val, pre, numNodes); + } else if (opt->tensorType == PViewOptions::MinEigenValue) { + for(int i = 0; i < numNodes; i++) { + for (int j = 0; j < 3; j++) { + tensor(j,0) = val [i][0+j*3]; + tensor(j,1) = val [i][1+j*3]; + tensor(j,2) = val [i][2+j*3]; + } + tensor.eig(S, imS, V, rightV, true); + val[i][0] = S(0); + } + addScalarElement(p, type, xyz, val, pre, numNodes); + } else if (opt->tensorType == PViewOptions::MaxEigenValue) { + for(int i = 0; i < numNodes; i++) { + for (int j = 0; j < 3; j++) { + tensor(j,0) = val [i][0+j*3]; + tensor(j,1) = val [i][1+j*3]; + tensor(j,2) = val [i][2+j*3]; + } + tensor.eig(S, imS, V, rightV, true); + val[i][0] = S(2); + } + addScalarElement(p, type, xyz, val, pre, numNodes); + } else if (opt->tensorType == PViewOptions::EigenVectors) { + double vval[3][PVIEW_NMAX][9]; + for(int i = 0; i < numNodes; i++) { + for (int j = 0; j < 3; j++) { + tensor(j,0) = val [i][0+j*3]; + tensor(j,1) = val [i][1+j*3]; + tensor(j,2) = val [i][2+j*3]; + } + tensor.eig(S, imS, V, rightV, false); + for (int j = 0; j < 3; j++) { + vval[j][i][0] = V(j,0)*S(j); + vval[j][i][1] = V(j,1)*S(j); + vval[j][i][2] = V(j,2)*S(j); + } + } + addVectorElement(p, iEnt, iEle, numNodes, type, xyz, vval[0], pre); + addVectorElement(p, iEnt, iEle, numNodes, type, xyz, vval[1], pre); + addVectorElement(p, iEnt, iEle, numNodes, type, xyz, vval[2], pre); } } @@ -1034,7 +1078,7 @@ static void addElementsInArrays(PView *p, bool preprocessNormalsOnly) else if(numComp == 3 && opt->drawVectors) addVectorElement(p, ent, i, 1, TYPE_PNT, xyz2, val2, preprocessNormalsOnly); else if(numComp == 9 && opt->drawTensors) - addTensorElement(p, 1, TYPE_PNT, xyz2, val2, preprocessNormalsOnly); + addTensorElement(p, ent, i, 1, TYPE_PNT, xyz2, val2, preprocessNormalsOnly); } } else if(numComp == 1 && opt->drawScalars) @@ -1042,7 +1086,7 @@ static void addElementsInArrays(PView *p, bool preprocessNormalsOnly) else if(numComp == 3 && opt->drawVectors) addVectorElement(p, ent, i, numNodes, type, xyz, val, preprocessNormalsOnly); else if(numComp == 9 && opt->drawTensors) - addTensorElement(p, numNodes, type, xyz, val, preprocessNormalsOnly); + addTensorElement(p, ent, i, numNodes, type, xyz, val, preprocessNormalsOnly); } } }