42 #define OPTIMIZED_VERSION_A4dot4 52 double sum = 0.0, val;
53 int count, c = 1, ind, indx, uind, vind, tind;
54 std :: vector< FloatArray >
N;
59 for (
int i = 0; i <
nsd; i++ ) {
64 for (
int i = 0; i <
nsd; i++ ) {
72 uind = span(0) -
degree [ 0 ];
74 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
78 }
else if ( nsd == 2 ) {
79 uind = span(0) -
degree [ 0 ];
80 vind = span(1) -
degree [ 1 ];
82 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
83 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
90 }
else if ( nsd == 3 ) {
91 uind = span(0) -
degree [ 0 ];
92 vind = span(1) -
degree [ 1 ];
93 tind = span(2) -
degree [ 2 ];
95 for (
int m = 0; m <=
degree [ 2 ]; m++ ) {
97 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
98 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
113 answer.
at(count--) /= sum;
124 double Jacob = 0., product, w, weight;
125 int count, cnt, ind, indx, uind, vind, tind;
126 std :: vector< FloatArray >
N(
nsd);
127 std :: vector< FloatMatrix > ders(
nsd);
132 for (
int i = 0; i <
nsd; i++ ) {
137 for (
int i = 0; i <
nsd; i++ ) {
142 answer.
resize(count, nsd);
144 #if 0 // code according NURBS book (too general allowing higher derivatives) 149 #ifndef OPTIMIZED_VERSION_A4dot4 161 for (
int i = 0; i <
nsd; i++ ) {
164 #ifndef OPTIMIZED_VERSION_A4dot4 174 uind = span(0) -
degree [ 0 ];
175 vind = span(1) -
degree [ 1 ];
177 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
180 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
182 w = vertexCoordsPtr->
at(3);
184 tmp1(0) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(1) * w;
185 tmp1(1) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(2) * w;
186 tmp1(2) += ders [ 0 ](0, k) * w;
188 tmp2(0) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(1) * w;
189 tmp2(1) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(2) * w;
190 tmp2(2) += ders [ 0 ](1, k) * w;
195 Aders [ 0 ](0, 0) += ders [ 1 ](0, l) * tmp1(0);
196 Aders [ 1 ](0, 0) += ders [ 1 ](0, l) * tmp1(1);
197 wders(0, 0) += ders [ 1 ](0, l) * tmp1(2);
199 Aders [ 0 ](0, 1) += ders [ 1 ](1, l) * tmp1(0);
200 Aders [ 1 ](0, 1) += ders [ 1 ](1, l) * tmp1(1);
201 wders(0, 1) += ders [ 1 ](1, l) * tmp1(2);
203 Aders [ 0 ](1, 0) += ders [ 1 ](0, l) * tmp2(0);
204 Aders [ 1 ](1, 0) += ders [ 1 ](0, l) * tmp2(1);
205 wders(1, 0) += ders [ 1 ](0, l) * tmp2(2);
208 weight = wders(0, 0);
210 #ifndef OPTIMIZED_VERSION_A4dot4 214 for (
int k = 0; k <= d; k++ ) {
215 for (
int l = 0; l <= d - k; l++ ) {
216 tmp1(0) = Aders [ 0 ](k, l);
217 tmp1(1) = Aders [ 1 ](k, l);
218 for ( j = 1; j <= l; j++ ) {
219 tmp1(0) -= wders(0, j) * Sders [ 0 ](k, l - j);
220 tmp1(1) -= wders(0, j) * Sders [ 1 ](k, l - j);
223 for (
int i = 1; i <= k; i++ ) {
224 tmp1(0) -= wders(i, 0) * Sders [ 0 ](k - i, l);
225 tmp1(1) -= wders(i, 0) * Sders [ 1 ](k - i, l);
227 for (
int j = 1; j <= l; j++ ) {
228 tmp2(0) += wders(i, j) * Sders [ 0 ](k - i, l - j);
229 tmp2(1) += wders(i, j) * Sders [ 1 ](k - i, l - j);
236 Sders [ 0 ](k, l) = tmp1(0) / weight;
237 Sders [ 1 ](k, l) = tmp1(1) / weight;
241 jacobian(0, 0) = Sders [ 0 ](1, 0);
242 jacobian(0, 1) = Sders [ 1 ](1, 0);
243 jacobian(1, 0) = Sders [ 0 ](0, 1);
244 jacobian(1, 1) = Sders [ 1 ](0, 1);
266 tmp1(0) = Aders [ 0 ](0, 0) / weight;
267 tmp1(1) = Aders [ 1 ](0, 0) / weight;
269 jacobian(0, 0) = ( Aders [ 0 ](1, 0) - wders(1, 0) * tmp1(0) ) / weight;
270 jacobian(0, 1) = ( Aders [ 1 ](1, 0) - wders(1, 0) * tmp1(1) ) / weight;
272 jacobian(1, 0) = ( Aders [ 0 ](0, 1) - wders(0, 1) * tmp1(0) ) / weight;
273 jacobian(1, 1) = ( Aders [ 1 ](0, 1) - wders(0, 1) * tmp1(1) ) / weight;
279 product = Jacob * weight * weight;
282 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
283 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
286 tmp1(0) = ders [ 0 ](1, k) * ders [ 1 ](0, l) * w * weight - ders [ 0 ](0, k) * ders [ 1 ](0, l) * w * wders(1, 0);
288 tmp1(1) = ders [ 0 ](0, k) * ders [ 1 ](1, l) * w * weight - ders [ 0 ](0, k) * ders [ 1 ](0, l) * w * wders(0, 1);
290 answer(cnt, 0) = ( +jacobian(1, 1) * tmp1(0) - jacobian(0, 1) * tmp1(1) ) / product;
291 answer(cnt, 1) = ( -jacobian(1, 0) * tmp1(0) + jacobian(0, 0) * tmp1(1) ) / product;
302 std :: vector< FloatArray > Aders(nsd);
305 for (
int i = 0; i <
nsd; i++ ) {
306 Aders [ i ].
resize(nsd + 1);
315 uind = span(0) -
degree [ 0 ];
317 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
319 w = vertexCoordsPtr->
at(2);
321 Aders [ 0 ](0) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(1) * w;
322 wders(0) += ders [ 0 ](0, k) * w;
324 Aders [ 0 ](1) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(1) * w;
325 wders(1) += ders [ 0 ](1, k) * w;
331 jacobian(0, 0) = ( Aders [ 0 ](1) - wders(1) * Aders [ 0 ](0) / weight ) / weight;
336 product = Jacob * weight * weight;
339 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
342 answer(cnt, 0) = ders [ 0 ](1, k) * w * weight - ders [ 0 ](0, k) * w * wders(1) / product;
345 }
else if ( nsd == 2 ) {
349 uind = span(0) -
degree [ 0 ];
350 vind = span(1) -
degree [ 1 ];
352 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
355 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
357 w = vertexCoordsPtr->
at(3);
359 tmp1(0) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(1) * w;
360 tmp1(1) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(2) * w;
361 tmp1(2) += ders [ 0 ](0, k) * w;
363 tmp2(0) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(1) * w;
364 tmp2(1) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(2) * w;
365 tmp2(2) += ders [ 0 ](1, k) * w;
370 Aders [ 0 ](0) += ders [ 1 ](0, l) * tmp1(0);
371 Aders [ 1 ](0) += ders [ 1 ](0, l) * tmp1(1);
372 wders(0) += ders [ 1 ](0, l) * tmp1(2);
374 Aders [ 0 ](1) += ders [ 1 ](0, l) * tmp2(0);
375 Aders [ 1 ](1) += ders [ 1 ](0, l) * tmp2(1);
376 wders(1) += ders [ 1 ](0, l) * tmp2(2);
378 Aders [ 0 ](2) += ders [ 1 ](1, l) * tmp1(0);
379 Aders [ 1 ](2) += ders [ 1 ](1, l) * tmp1(1);
380 wders(2) += ders [ 1 ](1, l) * tmp1(2);
386 tmp1(0) = Aders [ 0 ](0) / weight;
387 tmp1(1) = Aders [ 1 ](0) / weight;
388 jacobian(0, 0) = ( Aders [ 0 ](1) - wders(1) * tmp1(0) ) / weight;
389 jacobian(0, 1) = ( Aders [ 1 ](1) - wders(1) * tmp1(1) ) / weight;
390 jacobian(1, 0) = ( Aders [ 0 ](2) - wders(2) * tmp1(0) ) / weight;
391 jacobian(1, 1) = ( Aders [ 1 ](2) - wders(2) * tmp1(1) ) / weight;
396 product = Jacob * weight * weight;
399 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
400 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
403 tmp1(0) = ders [ 0 ](1, k) * ders [ 1 ](0, l) * w * weight - ders [ 0 ](0, k) * ders [ 1 ](0, l) * w * wders(1);
405 tmp1(1) = ders [ 0 ](0, k) * ders [ 1 ](1, l) * w * weight - ders [ 0 ](0, k) * ders [ 1 ](0, l) * w * wders(2);
407 answer(cnt, 0) = ( +jacobian(1, 1) * tmp1(0) - jacobian(0, 1) * tmp1(1) ) / product;
408 answer(cnt, 1) = ( -jacobian(1, 0) * tmp1(0) + jacobian(0, 0) * tmp1(1) ) / product;
414 }
else if ( nsd == 3 ) {
416 FloatArray temp1(nsd + 1), temp2(nsd + 1), temp3(nsd + 1);
419 uind = span(0) -
degree [ 0 ];
420 vind = span(1) -
degree [ 1 ];
421 tind = span(2) -
degree [ 2 ];
423 for (
int m = 0; m <=
degree [ 2 ]; m++ ) {
428 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
431 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
433 w = vertexCoordsPtr->
at(4);
435 tmp1(0) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(1) * w;
436 tmp1(1) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(2) * w;
437 tmp1(2) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(3) * w;
438 tmp1(3) += ders [ 0 ](0, k) * w;
440 tmp2(0) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(1) * w;
441 tmp2(1) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(2) * w;
442 tmp2(2) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(3) * w;
443 tmp2(3) += ders [ 0 ](1, k) * w;
448 temp1(0) += ders [ 1 ](0, l) * tmp1(0);
449 temp1(1) += ders [ 1 ](0, l) * tmp1(1);
450 temp1(2) += ders [ 1 ](0, l) * tmp1(2);
451 temp1(3) += ders [ 1 ](0, l) * tmp1(3);
453 temp2(0) += ders [ 1 ](0, l) * tmp2(0);
454 temp2(1) += ders [ 1 ](0, l) * tmp2(1);
455 temp2(2) += ders [ 1 ](0, l) * tmp2(2);
456 temp2(3) += ders [ 1 ](0, l) * tmp2(3);
458 temp3(0) += ders [ 1 ](1, l) * tmp1(0);
459 temp3(1) += ders [ 1 ](1, l) * tmp1(1);
460 temp3(2) += ders [ 1 ](1, l) * tmp1(2);
461 temp3(3) += ders [ 1 ](1, l) * tmp1(3);
466 Aders [ 0 ](0) += ders [ 2 ](0, m) * temp1(0);
467 Aders [ 1 ](0) += ders [ 2 ](0, m) * temp1(1);
468 Aders [ 2 ](0) += ders [ 2 ](0, m) * temp1(2);
469 wders(0) += ders [ 2 ](0, m) * temp1(3);
471 Aders [ 0 ](1) += ders [ 2 ](0, m) * temp2(0);
472 Aders [ 1 ](1) += ders [ 2 ](0, m) * temp2(1);
473 Aders [ 2 ](1) += ders [ 2 ](0, m) * temp2(2);
474 wders(1) += ders [ 2 ](0, m) * temp2(3);
476 Aders [ 0 ](2) += ders [ 2 ](0, m) * temp3(0);
477 Aders [ 1 ](2) += ders [ 2 ](0, m) * temp3(1);
478 Aders [ 2 ](2) += ders [ 2 ](0, m) * temp3(2);
479 wders(2) += ders [ 2 ](0, m) * temp3(3);
481 Aders [ 0 ](3) += ders [ 2 ](1, m) * temp1(0);
482 Aders [ 1 ](3) += ders [ 2 ](1, m) * temp1(1);
483 Aders [ 2 ](3) += ders [ 2 ](1, m) * temp1(2);
484 wders(3) += ders [ 2 ](1, m) * temp1(3);
490 tmp1(0) = Aders [ 0 ](0) / weight;
491 tmp1(1) = Aders [ 1 ](0) / weight;
492 tmp1(2) = Aders [ 2 ](0) / weight;
493 jacobian(0, 0) = ( Aders [ 0 ](1) - wders(1) * tmp1(0) ) / weight;
494 jacobian(0, 1) = ( Aders [ 1 ](1) - wders(1) * tmp1(1) ) / weight;
495 jacobian(0, 2) = ( Aders [ 2 ](1) - wders(1) * tmp1(2) ) / weight;
496 jacobian(1, 0) = ( Aders [ 0 ](2) - wders(2) * tmp1(0) ) / weight;
497 jacobian(1, 1) = ( Aders [ 1 ](2) - wders(2) * tmp1(1) ) / weight;
498 jacobian(1, 2) = ( Aders [ 2 ](2) - wders(2) * tmp1(2) ) / weight;
499 jacobian(2, 0) = ( Aders [ 0 ](3) - wders(3) * tmp1(0) ) / weight;
500 jacobian(2, 1) = ( Aders [ 1 ](3) - wders(3) * tmp1(1) ) / weight;
501 jacobian(2, 2) = ( Aders [ 2 ](3) - wders(3) * tmp1(2) ) / weight;
506 product = Jacob * weight * weight;
509 for (
int m = 0; m <=
degree [ 2 ]; m++ ) {
511 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
512 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
515 tmp1(0) = ders [ 0 ](1, k) * ders [ 1 ](0, l) * ders [ 2 ](0, m) * w * weight - ders [ 0 ](0, k) * ders [ 1 ](0, l) * ders [ 2 ](0, m) * w * wders(1);
517 tmp1(1) = ders [ 0 ](0, k) * ders [ 1 ](1, l) * ders [ 2 ](0, m) * w * weight - ders [ 0 ](0, k) * ders [ 1 ](0, l) * ders [ 2 ](0, m) * w * wders(2);
519 tmp1(2) = ders [ 0 ](0, k) * ders [ 1 ](0, l) * ders [ 2 ](1, m) * w * weight - ders [ 0 ](0, k) * ders [ 1 ](0, l) * ders [ 2 ](0, m) * w * wders(3);
521 answer(cnt, 0) = ( ( jacobian(1, 1) * jacobian(2, 2) - jacobian(1, 2) * jacobian(2, 1) ) * tmp1(0) +
522 ( jacobian(0, 2) * jacobian(2, 1) - jacobian(0, 1) * jacobian(2, 2) ) * tmp1(1) +
523 ( jacobian(0, 1) * jacobian(1, 2) - jacobian(0, 2) * jacobian(1, 1) ) * tmp1(2) ) / product;
524 answer(cnt, 1) = ( ( jacobian(1, 2) * jacobian(2, 0) - jacobian(1, 0) * jacobian(2, 2) ) * tmp1(0) +
525 ( jacobian(0, 0) * jacobian(2, 2) - jacobian(0, 2) * jacobian(2, 0) ) * tmp1(1) +
526 ( jacobian(0, 2) * jacobian(1, 0) - jacobian(0, 0) * jacobian(1, 2) ) * tmp1(2) ) / product;
527 answer(cnt, 2) = ( ( jacobian(1, 0) * jacobian(2, 1) - jacobian(1, 1) * jacobian(2, 0) ) * tmp1(0) +
528 ( jacobian(0, 1) * jacobian(2, 0) - jacobian(0, 0) * jacobian(2, 1) ) * tmp1(1) +
529 ( jacobian(0, 0) * jacobian(1, 1) - jacobian(0, 1) * jacobian(1, 0) ) * tmp1(2) ) / product;
554 double w, weight = 0.0;
555 int ind, indx, uind, vind, tind;
556 std :: vector< FloatArray >
N(
nsd);
561 for (
int i = 0; i <
nsd; i++ ) {
566 for (
int i = 0; i <
nsd; i++ ) {
574 uind = span(0) -
degree [ 0 ];
576 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
578 w = vertexCoordsPtr->
at(2);
579 answer(0) += N [ 0 ](k) * vertexCoordsPtr->
at(1) * w;
580 weight += N [ 0 ](k) * w;
582 }
else if ( nsd == 2 ) {
585 uind = span(0) -
degree [ 0 ];
586 vind = span(1) -
degree [ 1 ];
588 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
590 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
592 w = vertexCoordsPtr->
at(3);
593 tmp(0) += N [ 0 ](k) * vertexCoordsPtr->
at(1) * w;
594 tmp(1) += N [ 0 ](k) * vertexCoordsPtr->
at(2) * w;
595 tmp(2) += N [ 0 ](k) * w;
599 answer(0) += N [ 1 ](l) * tmp(0);
600 answer(1) += N [ 1 ](l) * tmp(1);
601 weight += N [ 1 ](l) * tmp(2);
603 }
else if ( nsd == 3 ) {
606 uind = span(0) -
degree [ 0 ];
607 vind = span(1) -
degree [ 1 ];
608 tind = span(2) -
degree [ 2 ];
610 for (
int m = 0; m <=
degree [ 2 ]; m++ ) {
613 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
615 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
617 w = vertexCoordsPtr->
at(4);
618 tmp(0) += N [ 0 ](k) * vertexCoordsPtr->
at(1) * w;
619 tmp(1) += N [ 0 ](k) * vertexCoordsPtr->
at(2) * w;
620 tmp(2) += N [ 0 ](k) * vertexCoordsPtr->
at(3) * w;
621 tmp(3) += N [ 0 ](k) * w;
626 temp(0) += N [ 1 ](l) * tmp(0);
627 temp(1) += N [ 1 ](l) * tmp(1);
628 temp(2) += N [ 1 ](l) * tmp(2);
629 temp(3) += N [ 1 ](l) * tmp(3);
634 answer(0) += N [ 2 ](m) * temp(0);
635 answer(1) += N [ 2 ](m) * temp(1);
636 answer(2) += N [ 2 ](m) * temp(2);
637 weight += N [ 2 ](m) * temp(3);
643 answer.
times(1.0 / weight);
656 int ind, indx, uind, vind, tind;
657 std :: vector< FloatMatrix > ders(
nsd);
663 for (
int i = 0; i <
nsd; i++ ) {
668 for (
int i = 0; i <
nsd; i++ ) {
672 #if 0 // code according NURBS book (too general allowing higher derivatives) 677 #ifndef OPTIMIZED_VERSION_A4dot4 689 for (
int i = 0; i <
nsd; i++ ) {
692 #ifndef OPTIMIZED_VERSION_A4dot4 702 uind = span(0) -
degree [ 0 ];
703 vind = span(1) -
degree [ 1 ];
705 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
708 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
710 w = vertexCoordsPtr->
at(3);
712 tmp1(0) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(1) * w;
713 tmp1(1) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(2) * w;
714 tmp1(2) += ders [ 0 ](0, k) * w;
716 tmp2(0) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(1) * w;
717 tmp2(1) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(2) * w;
718 tmp2(2) += ders [ 0 ](1, k) * w;
723 Aders [ 0 ](0, 0) += ders [ 1 ](0, l) * tmp1(0);
724 Aders [ 1 ](0, 0) += ders [ 1 ](0, l) * tmp1(1);
725 wders(0, 0) += ders [ 1 ](0, l) * tmp1(2);
727 Aders [ 0 ](0, 1) += ders [ 1 ](1, l) * tmp1(0);
728 Aders [ 1 ](0, 1) += ders [ 1 ](1, l) * tmp1(1);
729 wders(0, 1) += ders [ 1 ](1, l) * tmp1(2);
731 Aders [ 0 ](1, 0) += ders [ 1 ](0, l) * tmp2(0);
732 Aders [ 1 ](1, 0) += ders [ 1 ](0, l) * tmp2(1);
733 wders(1, 0) += ders [ 1 ](0, l) * tmp2(2);
736 weight = wders(0, 0);
738 #ifndef OPTIMIZED_VERSION_A4dot4 742 for (
int k = 0; k <= d; k++ ) {
743 for (
int l = 0; l <= d - k; l++ ) {
744 tmp1(0) = Aders [ 0 ](k, l);
745 tmp1(1) = Aders [ 1 ](k, l);
746 for ( j = 1; j <= l; j++ ) {
747 tmp1(0) -= wders(0, j) * Sders [ 0 ](k, l - j);
748 tmp1(1) -= wders(0, j) * Sders [ 1 ](k, l - j);
751 for (
int i = 1; i <= k; i++ ) {
752 tmp1(0) -= wders(i, 0) * Sders [ 0 ](k - i, l);
753 tmp1(1) -= wders(i, 0) * Sders [ 1 ](k - i, l);
755 for (
int j = 1; j <= l; j++ ) {
756 tmp2(0) += wders(i, j) * Sders [ 0 ](k - i, l - j);
757 tmp2(1) += wders(i, j) * Sders [ 1 ](k - i, l - j);
764 Sders [ 0 ](k, l) = tmp1(0) / weight;
765 Sders [ 1 ](k, l) = tmp1(1) / weight;
769 jacobian(0, 0) = Sders [ 0 ](1, 0);
770 jacobian(0, 1) = Sders [ 1 ](1, 0);
771 jacobian(1, 0) = Sders [ 0 ](0, 1);
772 jacobian(1, 1) = Sders [ 1 ](0, 1);
794 tmp1(0) = Aders [ 0 ](0, 0) / weight;
795 tmp1(1) = Aders [ 1 ](0, 0) / weight;
797 jacobian(0, 0) = ( Aders [ 0 ](1, 0) - wders(1, 0) * tmp1(0) ) / weight;
798 jacobian(0, 1) = ( Aders [ 1 ](1, 0) - wders(1, 0) * tmp1(1) ) / weight;
800 jacobian(1, 0) = ( Aders [ 0 ](0, 1) - wders(0, 1) * tmp1(0) ) / weight;
801 jacobian(1, 1) = ( Aders [ 1 ](0, 1) - wders(0, 1) * tmp1(1) ) / weight;
808 std :: vector< FloatArray > Aders(nsd);
811 for (
int i = 0; i <
nsd; i++ ) {
812 Aders [ i ].
resize(nsd + 1);
821 uind = span(0) -
degree [ 0 ];
823 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
825 w = vertexCoordsPtr->
at(2);
827 Aders [ 0 ](0) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(1) * w;
828 wders(0) += ders [ 0 ](0, k) * w;
830 Aders [ 0 ](1) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(1) * w;
831 wders(1) += ders [ 0 ](1, k) * w;
837 jacobian(0, 0) = ( Aders [ 0 ](1) - wders(1) * Aders [ 0 ](0) / weight ) / weight;
838 }
else if ( nsd == 2 ) {
842 uind = span(0) -
degree [ 0 ];
843 vind = span(1) -
degree [ 1 ];
845 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
848 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
850 w = vertexCoordsPtr->
at(3);
852 tmp1(0) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(1) * w;
853 tmp1(1) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(2) * w;
854 tmp1(2) += ders [ 0 ](0, k) * w;
856 tmp2(0) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(1) * w;
857 tmp2(1) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(2) * w;
858 tmp2(2) += ders [ 0 ](1, k) * w;
863 Aders [ 0 ](0) += ders [ 1 ](0, l) * tmp1(0);
864 Aders [ 1 ](0) += ders [ 1 ](0, l) * tmp1(1);
865 wders(0) += ders [ 1 ](0, l) * tmp1(2);
867 Aders [ 0 ](1) += ders [ 1 ](0, l) * tmp2(0);
868 Aders [ 1 ](1) += ders [ 1 ](0, l) * tmp2(1);
869 wders(1) += ders [ 1 ](0, l) * tmp2(2);
871 Aders [ 0 ](2) += ders [ 1 ](1, l) * tmp1(0);
872 Aders [ 1 ](2) += ders [ 1 ](1, l) * tmp1(1);
873 wders(2) += ders [ 1 ](1, l) * tmp1(2);
879 tmp1(0) = Aders [ 0 ](0) / weight;
880 tmp1(1) = Aders [ 1 ](0) / weight;
881 jacobian(0, 0) = ( Aders [ 0 ](1) - wders(1) * tmp1(0) ) / weight;
882 jacobian(0, 1) = ( Aders [ 1 ](1) - wders(1) * tmp1(1) ) / weight;
883 jacobian(1, 0) = ( Aders [ 0 ](2) - wders(2) * tmp1(0) ) / weight;
884 jacobian(1, 1) = ( Aders [ 1 ](2) - wders(2) * tmp1(1) ) / weight;
885 }
else if ( nsd == 3 ) {
887 FloatArray temp1(nsd + 1), temp2(nsd + 1), temp3(nsd + 1);
890 uind = span(0) -
degree [ 0 ];
891 vind = span(1) -
degree [ 1 ];
892 tind = span(2) -
degree [ 2 ];
894 for (
int m = 0; m <=
degree [ 2 ]; m++ ) {
899 for (
int l = 0; l <=
degree [ 1 ]; l++ ) {
902 for (
int k = 0; k <=
degree [ 0 ]; k++ ) {
904 w = vertexCoordsPtr->
at(4);
906 tmp1(0) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(1) * w;
907 tmp1(1) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(2) * w;
908 tmp1(2) += ders [ 0 ](0, k) * vertexCoordsPtr->
at(3) * w;
909 tmp1(3) += ders [ 0 ](0, k) * w;
911 tmp2(0) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(1) * w;
912 tmp2(1) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(2) * w;
913 tmp2(2) += ders [ 0 ](1, k) * vertexCoordsPtr->
at(3) * w;
914 tmp2(3) += ders [ 0 ](1, k) * w;
919 temp1(0) += ders [ 1 ](0, l) * tmp1(0);
920 temp1(1) += ders [ 1 ](0, l) * tmp1(1);
921 temp1(2) += ders [ 1 ](0, l) * tmp1(2);
922 temp1(3) += ders [ 1 ](0, l) * tmp1(3);
924 temp2(0) += ders [ 1 ](0, l) * tmp2(0);
925 temp2(1) += ders [ 1 ](0, l) * tmp2(1);
926 temp2(2) += ders [ 1 ](0, l) * tmp2(2);
927 temp2(3) += ders [ 1 ](0, l) * tmp2(3);
929 temp3(0) += ders [ 1 ](1, l) * tmp1(0);
930 temp3(1) += ders [ 1 ](1, l) * tmp1(1);
931 temp3(2) += ders [ 1 ](1, l) * tmp1(2);
932 temp3(3) += ders [ 1 ](1, l) * tmp1(3);
937 Aders [ 0 ](0) += ders [ 2 ](0, m) * temp1(0);
938 Aders [ 1 ](0) += ders [ 2 ](0, m) * temp1(1);
939 Aders [ 2 ](0) += ders [ 2 ](0, m) * temp1(2);
940 wders(0) += ders [ 2 ](0, m) * temp1(3);
942 Aders [ 0 ](1) += ders [ 2 ](0, m) * temp2(0);
943 Aders [ 1 ](1) += ders [ 2 ](0, m) * temp2(1);
944 Aders [ 2 ](1) += ders [ 2 ](0, m) * temp2(2);
945 wders(1) += ders [ 2 ](0, m) * temp2(3);
947 Aders [ 0 ](2) += ders [ 2 ](0, m) * temp3(0);
948 Aders [ 1 ](2) += ders [ 2 ](0, m) * temp3(1);
949 Aders [ 2 ](2) += ders [ 2 ](0, m) * temp3(2);
950 wders(2) += ders [ 2 ](0, m) * temp3(3);
952 Aders [ 0 ](3) += ders [ 2 ](1, m) * temp1(0);
953 Aders [ 1 ](3) += ders [ 2 ](1, m) * temp1(1);
954 Aders [ 2 ](3) += ders [ 2 ](1, m) * temp1(2);
955 wders(3) += ders [ 2 ](1, m) * temp1(3);
961 tmp1(0) = Aders [ 0 ](0) / weight;
962 tmp1(1) = Aders [ 1 ](0) / weight;
963 tmp1(2) = Aders [ 2 ](0) / weight;
964 jacobian(0, 0) = ( Aders [ 0 ](1) - wders(1) * tmp1(0) ) / weight;
965 jacobian(0, 1) = ( Aders [ 1 ](1) - wders(1) * tmp1(1) ) / weight;
966 jacobian(0, 2) = ( Aders [ 2 ](1) - wders(1) * tmp1(2) ) / weight;
967 jacobian(1, 0) = ( Aders [ 0 ](2) - wders(2) * tmp1(0) ) / weight;
968 jacobian(1, 1) = ( Aders [ 1 ](2) - wders(2) * tmp1(1) ) / weight;
969 jacobian(1, 2) = ( Aders [ 2 ](2) - wders(2) * tmp1(2) ) / weight;
970 jacobian(2, 0) = ( Aders [ 0 ](3) - wders(3) * tmp1(0) ) / weight;
971 jacobian(2, 1) = ( Aders [ 1 ](3) - wders(3) * tmp1(1) ) / weight;
972 jacobian(2, 2) = ( Aders [ 2 ](3) - wders(3) * tmp1(2) ) / weight;
double giveDeterminant() const
Returns the trace (sum of diagonal components) of the receiver.
virtual double evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the matrix of derivatives of interpolation functions (shape functions) at given point...
const IntArray * knotSpan
double & at(int i)
Coefficient access function.
virtual const FloatArray * giveVertexCoordinates(int i) const =0
int findSpan(int n, int p, double u, const double *U) const
Determines the knot span index (Algorithm A2.1 from the NURBS book)
int * degree
Degree in each direction.
Class representing a general abstraction for cell geometry.
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the array of interpolation functions (shape functions) at given point.
Class implementing an array of integers.
virtual void giveJacobianMatrixAt(FloatMatrix &jacobianMatrix, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Gives the jacobian matrix at the local coordinates.
double ** knotVector
Knot vectors [nsd][knot_vector_size].
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates global coordinates from given local ones.
Class representing vector of real numbers.
Implementation of matrix containing floating point numbers.
virtual int giveNumberOfKnotSpanBasisFunctions(const IntArray &knotSpan)
Returns the number of nonzero basis functions at individual knot span,.
void dersBasisFuns(int n, double u, int span, int p, double *const U, FloatMatrix &ders)
Computes nonzero basis functions and their derivatives at u.
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
void zero()
Zeroes all coefficients of receiver.
void times(double s)
Multiplies receiver with scalar.
void zero()
Zeroes all coefficient of receiver.
Geometry wrapper for IGA elements.
int * numberOfControlPoints
numberOfControlPoints[nsd]
the oofem namespace is to define a context or scope in which all oofem names are defined.
virtual ~NURBSInterpolation()
void basisFuns(FloatArray &N, int span, double u, int p, const double *U)
Evaluates the nonvanishing basis functions of 1d BSpline (algorithm A2.2 from NURBS book) ...
int nsd
Number of spatial directions.
void resize(int s)
Resizes receiver towards requested size.