14 static const int exn[13][12][2] = {
18 {{0, 1}, {0, 2}, {1, 2}},
19 {{0, 1}, {0, 3}, {1, 2}, {2, 3}},
21 {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}},
23 {{0, 1}, {0, 3}, {0, 4}, {1, 2}, {1, 4}, {2, 3}, {2, 4}, {3, 4}},
60 static void getSimplexDec(
int numNodes,
int numEdges,
int type,
int i,
int &n0,
61 int &n1,
int &n2,
int &n3,
int &nn,
int &ne)
63 static const int qua[2][3] = {{0, 1, 2}, {0, 2, 3}};
64 static const int hex[6][4] = {{0, 1, 3, 7}, {0, 4, 1, 7}, {1, 4, 5, 7},
65 {1, 2, 3, 7}, {1, 6, 2, 7}, {1, 5, 6, 7}};
66 static const int pri[3][4] = {{0, 1, 2, 4}, {0, 2, 4, 5}, {0, 3, 4, 5}};
67 static const int pyr[2][4] = {{0, 1, 3, 4}, {1, 2, 3, 4}};
111 static void affect(
double *xpi,
double *ypi,
double *zpi,
double valpi[12][9],
112 int epi[12],
int i,
double *xp,
double *yp,
double *zp,
113 double valp[12][9],
int ep[12],
int j,
int nb)
118 for(
int k = 0; k < nb; k++) valpi[i][k] = valp[j][k];
123 double yp[12],
double zp[12],
124 double valp[12][9],
int ep[12])
126 double xpi[12], ypi[12], zpi[12], valpi[12][9];
129 affect(xpi, ypi, zpi, valpi, epi, 0, xp, yp, zp, valp, ep, 0, numComp);
131 for(
int j = 1; j < *np; j++) {
132 for(
int i = 0; i < npi; i++) {
133 if(fabs(xp[j] - xpi[i]) < 1.e-12 && fabs(yp[j] - ypi[i]) < 1.e-12 &&
134 fabs(zp[j] - zpi[i]) < 1.e-12) {
138 affect(xpi, ypi, zpi, valpi, epi, npi, xp, yp, zp, valp, ep, j,
145 for(
int i = 0; i < npi; i++)
146 affect(xp, yp, zp, valp, ep, i, xpi, ypi, zpi, valpi, epi, i, numComp);
150 static void reorderQuad(
int numComp,
double xp[12],
double yp[12],
151 double zp[12],
double valp[12][9],
int ep[12])
153 double xpi[1], ypi[1], zpi[1], valpi[1][9];
155 affect(xpi, ypi, zpi, valpi, epi, 0, xp, yp, zp, valp, ep, 3, numComp);
156 affect(xp, yp, zp, valp, ep, 3, xp, yp, zp, valp, ep, 2, numComp);
157 affect(xp, yp, zp, valp, ep, 2, xpi, ypi, zpi, valpi, epi, 0, numComp);
161 double zp[12],
double valp[12][9],
int ep[12],
164 double xpi[6], ypi[6], zpi[6], valpi[6][9];
170 affect(xpi, ypi, zpi, valpi, epi, 0, xp, yp, zp, valp, ep, 3, numComp);
171 affect(xpi, ypi, zpi, valpi, epi, 1, xp, yp, zp, valp, ep, 4, numComp);
172 affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 5, numComp);
173 for(
int i = 0; i < 3; i++) {
174 int edgecut = ep[i] - 1;
175 for(
int j = 0; j < 3; j++) {
177 if(
exn[9][edgecut][0] == p ||
exn[9][edgecut][1] == p)
178 affect(xp, yp, zp, valp, ep, 3 + i, xpi, ypi, zpi, valpi, epi, j,
183 else if(nbCut == 4) {
185 affect(xpi, ypi, zpi, valpi, epi, 0, xp, yp, zp, valp, ep, 0, numComp);
186 int edgecut = ep[0] - 1;
189 if(
exn[9][edgecut][0] == p0 ||
exn[9][edgecut][1] == p0) {
190 affect(xpi, ypi, zpi, valpi, epi, 1, xp, yp, zp, valp, ep, 4, numComp);
191 if(
exn[9][ep[1] - 1][0] == p0 ||
exn[9][ep[1] - 1][1] == p0) {
192 affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 1, numComp);
193 affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 3, numComp);
194 affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 5, numComp);
195 affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp);
198 affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 3, numComp);
199 affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 1, numComp);
200 affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 5, numComp);
201 affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp);
205 affect(xpi, ypi, zpi, valpi, epi, 1, xp, yp, zp, valp, ep, 5, numComp);
206 if(
exn[9][ep[1] - 1][0] == p0 ||
exn[9][ep[1] - 1][1] == p0) {
207 affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 1, numComp);
208 affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 3, numComp);
209 affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 4, numComp);
210 affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp);
213 affect(xpi, ypi, zpi, valpi, epi, 2, xp, yp, zp, valp, ep, 3, numComp);
214 affect(xpi, ypi, zpi, valpi, epi, 3, xp, yp, zp, valp, ep, 1, numComp);
215 affect(xpi, ypi, zpi, valpi, epi, 4, xp, yp, zp, valp, ep, 4, numComp);
216 affect(xpi, ypi, zpi, valpi, epi, 5, xp, yp, zp, valp, ep, 2, numComp);
219 for(
int i = 0; i < 6; i++)
220 affect(xp, yp, zp, valp, ep, i, xpi, ypi, zpi, valpi, epi, i, numComp);
239 double xp[12],
double yp[12],
240 double zp[12],
double valp[12][9],
243 std::vector<double> *list;
251 else if(numComp == 3) {
265 else if(numComp == 3) {
279 else if(numComp == 3) {
294 else if(numComp == 3) {
308 else if(numComp == 3) {
323 else if(numComp == 3) {
337 else if(numComp == 3) {
351 else if(numComp == 3) {
365 for(
int k = 0; k < np; k++) list->push_back(xp[k]);
366 for(
int k = 0; k < np; k++) list->push_back(yp[k]);
367 for(
int k = 0; k < np; k++) list->push_back(zp[k]);
370 for(
int k = 0; k < np; k++)
371 for(
int l = 0; l < numComp; l++) list->push_back(valp[k][l]);
376 double x[8],
double y[8],
double z[8],
double levels[8],
379 int stepmin = vstep, stepmax = vstep + 1, otherstep = wstep;
386 int numNodes = vdata->
getNumNodes(stepmin, ent, ele);
387 int numEdges = vdata->
getNumEdges(stepmin, ent, ele);
389 int type = vdata->
getType(stepmin, ent, ele);
392 for(
int simplex = 0; simplex <
numSimplexDec(type); simplex++) {
393 int n[4], ep[12], nsn, nse;
394 getSimplexDec(numNodes, numEdges, type, simplex, n[0], n[1], n[2], n[3],
398 for(
int step = stepmin; step < stepmax; step++) {
400 if(wstep < 0) otherstep = step;
405 double xp[12], yp[12], zp[12], valp[12][9];
406 for(
int i = 0; i < nse; i++) {
407 int n0 =
exn[nse][i][0], n1 =
exn[nse][i][1];
408 if(levels[n[n0]] * levels[n[n1]] <= 0.) {
411 for(
int comp = 0; comp < numComp; comp++) {
413 wdata->
getValue(otherstep, ent, ele, n[n0], comp, v0);
414 wdata->
getValue(otherstep, ent, ele, n[n1], comp, v1);
415 valp[np][comp] = v0 +
c * (v1 - v0);
429 for(
int nod = 0; nod < nsn; nod++) {
437 for(
int nod = 0; nod < nsn; nod++) {
441 for(
int comp = 0; comp < numComp; comp++)
442 wdata->
getValue(otherstep, ent, ele, n[nod], comp,
445 _addElement(nsn, nse, numComp, xp, yp, zp, valp, out,
452 if(numEdges > 4 && np < 3)
454 else if(numEdges > 1 && np < 2)
456 else if(np < 1 || np > 4)
460 if(np == 4)
reorderQuad(numComp, xp, yp, zp, valp, ep);
466 double v1[3] = {xp[2] - xp[0], yp[2] - yp[0], zp[2] - zp[0]};
467 double v2[3] = {xp[1] - xp[0], yp[1] - yp[0], zp[1] - zp[0]};
468 double gr[3], normal[3];
477 gr[0] = xp[0] -
_ref[0];
478 gr[1] = yp[0] -
_ref[1];
479 gr[2] = zp[0] -
_ref[2];
486 double xpi[12], ypi[12], zpi[12], valpi[12][9];
488 for(
int k = 0; k < np; k++)
489 affect(xpi, ypi, zpi, valpi, epi, k, xp, yp, zp, valp, ep, k,
491 for(
int k = 0; k < np; k++)
492 affect(xp, yp, zp, valp, ep, k, xpi, ypi, zpi, valpi, epi,
493 np - k - 1, numComp);
502 for(
int nod = 0; nod < nsn; nod++) {
508 for(
int comp = 0; comp < numComp; comp++)
509 wdata->
getValue(otherstep, ent, ele, n[nod], comp,
516 if(np == 4 && numEdges <= 4)
reorderQuad(numComp, xp, yp, zp, valp, ep);
517 if(np == 6)
reorderPrism(numComp, xp, yp, zp, valp, ep, nbCut);
523 _addElement(np, numEdges, numComp, xp, yp, zp, valp, out,
529 if(vstep < 0 && (stepmax - stepmin) > (
int)out->
Time.size()) {
531 for(
int i = stepmin; i < stepmax; i++) {
572 double x[8], y[8],
z[8], levels[8];
573 double scalarValues[8] = {0., 0., 0., 0., 0., 0., 0., 0.};
581 for(
int ent = 0; ent < vdata->
getNumEntities(firstNonEmptyStep); ent++) {
582 for(
int ele = 0; ele < vdata->
getNumElements(firstNonEmptyStep, ent);
584 if(vdata->
skipElement(firstNonEmptyStep, ent, ele))
continue;
585 for(
int nod = 0; nod < vdata->
getNumNodes(firstNonEmptyStep, ent, ele);
587 vdata->
getNode(firstNonEmptyStep, ent, ele, nod, x[nod], y[nod],
589 levels[nod] =
levelset(x[nod], y[nod],
z[nod], 0.);
592 levels, scalarValues, out);
608 for(
int nod = 0; nod < vdata->
getNumNodes(step, ent, ele); nod++) {
609 vdata->
getNode(step, ent, ele, nod, x[nod], y[nod],
z[nod]);
611 levels[nod] =
levelset(x[nod], y[nod],
z[nod], scalarValues[nod]);
615 levels, scalarValues, out);
619 sprintf(tmp,
"_Levelset_%d", step);
642 if(v1 * v2 > 0 && v1 * v3 > 0)
653 if(sc1 || sc2 || sc3 || sc4) {
677 if(v1 * v2 > 0 && v1 * v3 > 0 && v1 * v4 > 0)
688 if(sc1 || sc2 || sc3 || sc4) {
712 if(v1 * v2 > 0 && v1 * v3 > 0 && v1 * v4 > 0)
727 if(sc1 || sc2 || sc3 || sc4 || sc5 || sc6 || sc7 || sc8) {
763 if(v1 * v2 > 0 && v1 * v3 > 0 && v1 * v4 > 0 && v1 * v5 > 0 &&
764 v1 * v6 > 0 && v1 * v7 > 0 && v1 * v8 > 0)
779 if(sc1 || sc2 || sc3 || sc4 || sc5 || sc6 || sc7 || sc8) {
810 if(v1 * v2 > 0 && v1 * v3 > 0 && v1 * v4 > 0 && v1 * v5 > 0 && v1 * v6 > 0)
825 if(sc1 || sc2 || sc3 || sc4 || sc5 || sc6 || sc7 || sc8) {
855 if(v1 * v2 > 0 && v1 * v3 > 0 && v1 * v4 > 0 && v1 * v5 > 0)
872 if(sc1 || sc2 || sc3 || sc4 || sc5 || sc6 || sc7 || sc8 || sc9 || sc10) {