19 return "Plugin(Lambda2) computes the eigenvalues "
20 "Lambda(1,2,3) of the tensor (S_ik S_kj + "
21 "Om_ik Om_kj), where S_ij = 0.5 (ui,j + uj,i) "
22 "and Om_ij = 0.5 (ui,j - uj,i) are respectively "
23 "the symmetric and antisymmetric parts of the "
24 "velocity gradient tensor.\n\n"
25 "Vortices are well represented by regions where "
26 "Lambda(2) is negative.\n\n"
27 "If `View' contains tensor elements, the plugin "
28 "directly uses the tensors as the values of the "
29 "velocity gradient tensor; if `View' contains "
30 "vector elements, the plugin uses them as the "
31 "velocities from which to derive the velocity "
32 "gradient tensor.\n\n"
33 "If `View' < 0, the plugin is run on the current view.\n\n"
34 "Plugin(Lambda2) creates one new list-based view.";
47 static int inv3x3tran(
double mat[3][3],
double inv[3][3],
double *det)
53 if(*det == 0.0)
return (0);
57 inv[0][0] = ud * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]);
58 inv[0][1] = -ud * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]);
59 inv[0][2] = ud * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]);
60 inv[1][0] = -ud * (mat[0][1] * mat[2][2] - mat[0][2] * mat[2][1]);
61 inv[1][1] = ud * (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]);
62 inv[1][2] = -ud * (mat[0][0] * mat[2][1] - mat[0][1] * mat[2][0]);
63 inv[2][0] = ud * (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]);
64 inv[2][1] = -ud * (mat[0][0] * mat[1][2] - mat[0][2] * mat[1][0]);
65 inv[2][2] = ud * (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]);
69 static void eigen(std::vector<double> &inList,
int inNb,
70 std::vector<double> &outList,
int *outNb,
int nbTime,
71 int nbNod,
int nbComp,
int lam)
73 if(!inNb || (nbComp != 3 && nbComp != 9) || lam < 1 || lam > 3)
return;
76 int nb = inList.size() / inNb;
77 for(std::size_t i = 0; i < inList.size(); i += nb) {
79 for(
int j = 0; j < 3 * nbNod; j++) outList.push_back(inList[i + j]);
82 for(
int j = 0; j < nbTime; j++) {
83 double *x = &inList[i];
84 double *y = &inList[i + nbNod];
85 double *
z = &inList[i + 2 * nbNod];
92 double *v = &inList[i + 3 * nbNod + nbNod * nbComp * j + nbComp * 0];
100 GradVel[2][1] = v[7];
101 GradVel[2][2] = v[8];
103 else if(nbComp == 3) {
109 const int MAX_NOD = 4;
110 double val[3][MAX_NOD];
111 for(
int k = 0; k < nbNod; k++) {
112 double *v = &inList[i + 3 * nbNod + nbNod * nbComp * j + nbComp * k];
113 for(
int l = 0; l < 3; l++) { val[l][k] = v[l]; }
116 double GradPhi_x[MAX_NOD][3];
117 double GradPhi_ksi[MAX_NOD][3];
118 double dx_dksi[3][3];
119 double dksi_dx[3][3];
122 double a[3], b[3],
cross[3];
130 dx_dksi[0][0] = x[1] - x[0];
131 dx_dksi[0][1] = x[2] - x[0];
132 dx_dksi[0][2] =
cross[0];
133 dx_dksi[1][0] = y[1] - y[0];
134 dx_dksi[1][1] = y[2] - y[0];
135 dx_dksi[1][2] =
cross[1];
136 dx_dksi[2][0] =
z[1] -
z[0];
137 dx_dksi[2][1] =
z[2] -
z[0];
138 dx_dksi[2][2] =
cross[2];
140 GradPhi_ksi[0][0] = -1;
141 GradPhi_ksi[0][1] = -1;
142 GradPhi_ksi[0][2] = 0;
143 GradPhi_ksi[1][0] = 1;
144 GradPhi_ksi[1][1] = 0;
145 GradPhi_ksi[1][2] = 0;
146 GradPhi_ksi[2][0] = 0;
147 GradPhi_ksi[2][1] = 1;
148 GradPhi_ksi[2][2] = 0;
150 else if(nbNod == 4) {
151 dx_dksi[0][0] = x[1] - x[0];
152 dx_dksi[0][1] = x[2] - x[0];
153 dx_dksi[0][2] = x[3] - x[0];
154 dx_dksi[1][0] = y[1] - y[0];
155 dx_dksi[1][1] = y[2] - y[0];
156 dx_dksi[1][2] = y[3] - y[0];
157 dx_dksi[2][0] =
z[1] -
z[0];
158 dx_dksi[2][1] =
z[2] -
z[0];
159 dx_dksi[2][2] =
z[3] -
z[0];
161 GradPhi_ksi[0][0] = -1;
162 GradPhi_ksi[0][1] = -1;
163 GradPhi_ksi[0][2] = -1;
164 GradPhi_ksi[1][0] = 1;
165 GradPhi_ksi[1][1] = 0;
166 GradPhi_ksi[1][2] = 0;
167 GradPhi_ksi[2][0] = 0;
168 GradPhi_ksi[2][1] = 1;
169 GradPhi_ksi[2][2] = 0;
170 GradPhi_ksi[3][0] = 0;
171 GradPhi_ksi[3][1] = 0;
172 GradPhi_ksi[3][2] = 1;
175 Msg::Error(
"Lambda2 not ready for this type of element");
178 for(
int k = 0; k < nbNod; k++) {
179 for(
int l = 0; l < 3; l++) {
180 GradPhi_x[k][l] = 0.0;
181 for(
int m = 0; m < 3; m++) {
182 GradPhi_x[k][l] += GradPhi_ksi[k][m] * dksi_dx[l][m];
187 for(
int k = 0; k < 3; k++) {
188 for(
int l = 0; l < 3; l++) {
190 for(
int m = 0; m < nbNod; m++) {
191 GradVel[k][l] += val[k][m] * GradPhi_x[m][l];
197 for(
int k = 0; k < 3; k++)
198 for(
int l = 0; l < 3; l++) GradVel[k][l] = 0.0;
203 for(
int m = 0; m < 3; m++) {
204 for(
int n = 0; n < 3; n++) {
205 sym[m][n] = 0.5 * (GradVel[m][n] + GradVel[n][m]);
206 asym[m][n] = 0.5 * (GradVel[m][n] - GradVel[n][m]);
210 for(
int m = 0; m < 3; m++) {
211 for(
int n = 0; n < 3; n++) {
213 for(
int l = 0; l < 3; l++)
214 a[m][n] += sym[m][l] * sym[l][n] + asym[m][l] * asym[l][n];
221 for(
int k = 0; k < nbNod; k++) outList.push_back(lambda[lam - 1]);