00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef QUADRATURE_FORMULA_HPP
00021 #define QUADRATURE_FORMULA_HPP
00022
00023 #include <TinyVector.hpp>
00024 #include <ThreadStaticBase.hpp>
00025
00026 #include <ErrorHandler.hpp>
00027
00028 class QuadratureFormulaP0Triangle3D
00029 : public ThreadStaticBase<QuadratureFormulaP0Triangle3D>
00030 {
00031 public:
00032 enum {
00033 numberOfQuadraturePoints = 1
00034 };
00035
00036 private:
00037 TinyVector<numberOfQuadraturePoints,
00038 TinyVector<3> > __integrationVertices;
00039
00040 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00041
00042 public:
00043 const TinyVector<3, real_t>& operator[](const size_t& i) const
00044 {
00045 return __integrationVertices[i];
00046 }
00047
00048 const TinyVector<numberOfQuadraturePoints, TinyVector<3> >& vertices() const
00049 {
00050 return __integrationVertices;
00051 }
00052
00053 size_t numberOfVertices() const
00054 {
00055 return numberOfQuadraturePoints;
00056 }
00057
00058 real_t weight(const size_t& i) const
00059 {
00060 return __weight[i];
00061 }
00062
00063 QuadratureFormulaP0Triangle3D()
00064 : __weight(0)
00065 {
00066 __integrationVertices[0] = TinyVector<3,real_t>(1./3.,1./3.,0);
00067 }
00068 };
00069
00070 class QuadratureFormulaP1Triangle3D
00071 : public ThreadStaticBase<QuadratureFormulaP1Triangle3D>
00072 {
00073 public:
00074 enum {
00075 numberOfQuadraturePoints = 3
00076 };
00077
00078 private:
00079 TinyVector<numberOfQuadraturePoints,
00080 TinyVector<3> > __integrationVertices;
00081
00082 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00083
00084 public:
00085 const TinyVector<3, real_t>& operator[](const size_t& i) const
00086 {
00087 return __integrationVertices[i];
00088 }
00089
00090 const TinyVector<numberOfQuadraturePoints, TinyVector<3> >& vertices() const
00091 {
00092 return __integrationVertices;
00093 }
00094
00095 size_t numberOfVertices() const
00096 {
00097 return numberOfQuadraturePoints;
00098 }
00099
00100 real_t weight(const size_t& i) const
00101 {
00102 return __weight[i];
00103 }
00104
00105 QuadratureFormulaP1Triangle3D()
00106 {
00107 this->__setQuadratureVertices();
00108 }
00109 private:
00110 void __setQuadratureVertices()
00111 {
00112 __weight = 1./(2.*numberOfQuadraturePoints);
00113
00114 __integrationVertices[0][0] = 0;
00115 __integrationVertices[0][1] = 0.5;
00116 __integrationVertices[0][2] = 0;
00117
00118 __integrationVertices[1][0] = 0.5;
00119 __integrationVertices[1][1] = 0;
00120 __integrationVertices[1][2] = 0;
00121
00122 __integrationVertices[2][0] = 0.5;
00123 __integrationVertices[2][1] = 0.5;
00124 __integrationVertices[2][2] = 0;
00125 }
00126 };
00127
00128 class QuadratureFormulaP2Triangle3D
00129 : public ThreadStaticBase<QuadratureFormulaP2Triangle3D>
00130 {
00131 public:
00132 enum {
00133 numberOfQuadraturePoints = 6
00134 };
00135
00136 private:
00137 TinyVector<numberOfQuadraturePoints,
00138 TinyVector<3, real_t> > __integrationVertices;
00139
00140 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00141
00142 public:
00143 const TinyVector<3>& operator[](const size_t& i) const
00144 {
00145 return __integrationVertices[i];
00146 }
00147
00148 const TinyVector<numberOfQuadraturePoints,
00149 TinyVector<3, real_t> >&
00150 vertices() const
00151 {
00152 return __integrationVertices;
00153 }
00154
00155 size_t numberOfVertices() const
00156 {
00157 return numberOfQuadraturePoints;
00158 }
00159
00160
00161 real_t weight(const size_t& i) const
00162 {
00163 return __weight[i];
00164 }
00165
00166 QuadratureFormulaP2Triangle3D()
00167 {
00168 this->__setQuadratureVertices();
00169 }
00170 private:
00171 void __setQuadratureVertices()
00172 {
00173
00174 const real_t a = 0.445948490915965;
00175 const real_t b = 0.091576213509771;
00176 const real_t c = 0.111690794839005;
00177 const real_t d = 0.054975871827661;
00178 __integrationVertices[0] = TinyVector<3, real_t>( a, a,0);
00179 __weight[0] = c;
00180 __integrationVertices[1] = TinyVector<3, real_t>(1-2*a, a,0);
00181 __weight[1] = c;
00182 __integrationVertices[2] = TinyVector<3, real_t>( a,1-2*a,0);
00183 __weight[2] = c;
00184 __integrationVertices[3] = TinyVector<3, real_t>( b, b,0);
00185 __weight[3] = d;
00186 __integrationVertices[4] = TinyVector<3, real_t>(1-2*b, b,0);
00187 __weight[4] = d;
00188 __integrationVertices[5] = TinyVector<3, real_t>( b,1-2*b,0);
00189 __weight[5] = d;
00190 }
00191 };
00192
00193 class QuadratureFormulaQ0Quadrangle3D
00194 : public ThreadStaticBase<QuadratureFormulaQ0Quadrangle3D>
00195 {
00196 public:
00197 enum {
00198 numberOfQuadraturePoints = 1
00199 };
00200
00201 private:
00202 TinyVector<numberOfQuadraturePoints,
00203 TinyVector<3> > __integrationVertices;
00204
00205 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00206
00207 public:
00208 const TinyVector<3>& operator[](const size_t& i) const
00209 {
00210 return __integrationVertices[i];
00211 }
00212
00213 const TinyVector<numberOfQuadraturePoints, TinyVector<3> >& vertices() const
00214 {
00215 return __integrationVertices;
00216 }
00217
00218 size_t numberOfVertices() const
00219 {
00220 return numberOfQuadraturePoints;
00221 }
00222
00223 real_t weight(const size_t& i) const
00224 {
00225 return __weight[i];
00226 }
00227
00228 QuadratureFormulaQ0Quadrangle3D()
00229 : __weight(1)
00230 {
00231 __integrationVertices[0] = TinyVector<3,real_t>(0.5,0.5,0);
00232 }
00233 };
00234
00235 class QuadratureFormulaQ1Quadrangle3D
00236 : public ThreadStaticBase<QuadratureFormulaQ1Quadrangle3D>
00237 {
00238 public:
00239 enum {
00240 numberOfQuadraturePoints = 4
00241 };
00242
00243 private:
00244 TinyVector<numberOfQuadraturePoints,
00245 TinyVector<3> > __integrationVertices;
00246
00247 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00248
00249 public:
00250 const TinyVector<3>& operator[](const size_t& i) const
00251 {
00252 return __integrationVertices[i];
00253 }
00254
00255 const TinyVector<numberOfQuadraturePoints, TinyVector<3> >& vertices() const
00256 {
00257 return __integrationVertices;
00258 }
00259
00260 size_t numberOfVertices() const
00261 {
00262 return numberOfQuadraturePoints;
00263 }
00264
00265 real_t weight(const size_t& i) const
00266 {
00267 return __weight[i];
00268 }
00269
00270 QuadratureFormulaQ1Quadrangle3D()
00271 {
00272 this->__setQuadratureVertices();
00273 }
00274
00275 private:
00276 void __setQuadratureVertices()
00277 {
00278 __weight = 1./numberOfQuadraturePoints;
00279
00280 TinyVector<2, real_t> X;
00281
00282 X[0] = 0.5 - std::sqrt(3.)/6.;
00283 X[1] = 0.5 + std::sqrt(3.)/6.;
00284
00285 for (size_t i=0; i<numberOfQuadraturePoints; ++i) {
00286 __integrationVertices[i][0] = X[i%2];
00287 __integrationVertices[i][1] = X[(i/2)%2];
00288 __integrationVertices[i][2] = 0;
00289 }
00290 }
00291 };
00292
00293 class QuadratureFormulaQ2Quadrangle3D
00294 : public ThreadStaticBase<QuadratureFormulaQ2Quadrangle3D>
00295 {
00296 public:
00297 enum {
00298 numberOfQuadraturePoints = 9
00299 };
00300
00301 private:
00302 TinyVector<numberOfQuadraturePoints, TinyVector<3> > __integrationVertices;
00303
00304 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00305
00306 public:
00307 const TinyVector<3>& operator[](const size_t& i) const
00308 {
00309 return __integrationVertices[i];
00310 }
00311
00312 const TinyVector<numberOfQuadraturePoints, TinyVector<3> >& vertices() const
00313 {
00314 return __integrationVertices;
00315 }
00316
00317 size_t numberOfVertices() const
00318 {
00319 return numberOfQuadraturePoints;
00320 }
00321
00322 real_t weight(const size_t& i) const
00323 {
00324 return __weight[i];
00325 }
00326
00327 QuadratureFormulaQ2Quadrangle3D()
00328 {
00329 this->__setQuadratureVertices();
00330 }
00331
00332 private:
00333 void __setQuadratureVertices()
00334 {
00335 TinyVector<3, real_t> weight1D(5./18.,8./18.,5./18.);
00336
00337 TinyVector<3, real_t> X;
00338
00339 X[0] = 0.5 - std::sqrt(15.)/10.;
00340 X[1] = 0.5;
00341 X[2] = 0.5 + std::sqrt(15.)/10.;
00342
00343 for (size_t i=0; i<numberOfQuadraturePoints; ++i) {
00344
00345 __weight[i] = weight1D[i%3]*weight1D[(i/3)%3];
00346
00347 __integrationVertices[i][0] = X[i%3];
00348 __integrationVertices[i][1] = X[(i/3)%3];
00349 __integrationVertices[i][2] = 0;
00350 }
00351 }
00352 };
00353
00354 class QuadratureFormulaQ0Hexahedron
00355 : public ThreadStaticBase<QuadratureFormulaQ0Hexahedron>
00356 {
00357 public:
00358 enum {
00359 numberOfQuadraturePoints = 1
00360 };
00361
00362 private:
00363 TinyVector<numberOfQuadraturePoints,TinyVector<3> > __integrationVertices;
00364
00365 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00366
00367 public:
00368 const TinyVector<3>& operator[](const size_t& i) const
00369 {
00370 return __integrationVertices[i];
00371 }
00372
00373 const TinyVector<numberOfQuadraturePoints,TinyVector<3> >& vertices() const
00374 {
00375 return __integrationVertices;
00376 }
00377
00378 size_t numberOfVertices() const
00379 {
00380 return numberOfQuadraturePoints;
00381 }
00382
00383 real_t weight(const size_t& i) const
00384 {
00385 return __weight[i];
00386 }
00387
00388 QuadratureFormulaQ0Hexahedron()
00389 : __weight(1.)
00390 {
00391 __integrationVertices[0] = TinyVector<3,real_t>(0.5,0.5,0.5);
00392 }
00393 };
00394
00395 class QuadratureFormulaQ1Hexahedron
00396 : public ThreadStaticBase<QuadratureFormulaQ1Hexahedron>
00397 {
00398 public:
00399 enum {
00400 numberOfQuadraturePoints = 8
00401 };
00402
00403 private:
00404 TinyVector<numberOfQuadraturePoints,TinyVector<3> > __integrationVertices;
00405
00406 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00407
00408 public:
00409 const TinyVector<3>& operator[](const size_t& i) const
00410 {
00411 return __integrationVertices[i];
00412 }
00413
00414 const TinyVector<numberOfQuadraturePoints,TinyVector<3> >& vertices() const
00415 {
00416 return __integrationVertices;
00417 }
00418
00419 size_t numberOfVertices() const
00420 {
00421 return numberOfQuadraturePoints;
00422 }
00423
00424 real_t weight(const size_t& i) const
00425 {
00426 return __weight[i];
00427 }
00428
00429 QuadratureFormulaQ1Hexahedron()
00430 {
00431 this->__setQuadratureVertices();
00432 }
00433
00434 private:
00435 void __setQuadratureVertices()
00436 {
00437 __weight = 1./numberOfQuadraturePoints;
00438
00439 TinyVector<2, real_t> X;
00440
00441 X[0] = 0.5 - std::sqrt(3.)/6.;
00442 X[1] = 0.5 + std::sqrt(3.)/6.;
00443
00444 for (size_t i=0; i<numberOfQuadraturePoints; ++i) {
00445 __integrationVertices[i][0] = X[i%2];
00446 __integrationVertices[i][1] = X[(i/2)%2];
00447 __integrationVertices[i][2] = X[(i/4)%2];
00448 }
00449 }
00450 };
00451
00452 class QuadratureFormulaQ2Hexahedron
00453 : public ThreadStaticBase<QuadratureFormulaQ2Hexahedron>
00454 {
00455 public:
00456 enum {
00457 numberOfQuadraturePoints = 27
00458 };
00459 private:
00460 TinyVector<numberOfQuadraturePoints,TinyVector<3> > __integrationVertices;
00461
00462 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00463
00464 public:
00465 const TinyVector<3>& operator[](const size_t& i) const
00466 {
00467 return __integrationVertices[i];
00468 }
00469
00470 const TinyVector<numberOfQuadraturePoints,TinyVector<3> >& vertices() const
00471 {
00472 return __integrationVertices;
00473 }
00474
00475 size_t numberOfVertices() const
00476 {
00477 return numberOfQuadraturePoints;
00478 }
00479
00480 real_t weight(const size_t& i) const
00481 {
00482 return __weight[i];
00483 }
00484
00485 QuadratureFormulaQ2Hexahedron()
00486 {
00487 this->__setQuadratureVertices();
00488 }
00489
00490 private:
00491 void __setQuadratureVertices()
00492 {
00493 TinyVector<3, real_t> weight1D(5./18.,8./18.,5./18.);
00494
00495 TinyVector<3, real_t> X;
00496
00497 X[0] = 0.5 - std::sqrt(15.)/10.;
00498 X[1] = 0.5;
00499 X[2] = 0.5 + std::sqrt(15.)/10.;
00500
00501 for (size_t i=0; i<numberOfQuadraturePoints; ++i) {
00502
00503 __weight[i] = weight1D[i%3]*weight1D[(i/3)%3]*weight1D[(i/9)%3];
00504
00505 __integrationVertices[i][0] = X[i%3];
00506 __integrationVertices[i][1] = X[(i/3)%3];
00507 __integrationVertices[i][2] = X[(i/9)%3];
00508 }
00509 }
00510 };
00511
00512
00513 class QuadratureFormulaP0Tetrahedron
00514 : public ThreadStaticBase<QuadratureFormulaP0Tetrahedron>
00515 {
00516 public:
00517 enum {
00518 numberOfQuadraturePoints = 1
00519 };
00520
00521 private:
00522 TinyVector<numberOfQuadraturePoints, TinyVector<3> > __integrationVertices;
00523
00524 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00525
00526 public:
00527 const TinyVector<3>& operator[](const size_t& i) const
00528 {
00529 return __integrationVertices[i];
00530 }
00531
00532 const TinyVector<numberOfQuadraturePoints,TinyVector<3> >& vertices() const
00533 {
00534 return __integrationVertices;
00535 }
00536
00537 size_t numberOfVertices() const
00538 {
00539 return numberOfQuadraturePoints;
00540 }
00541
00542 real_t weight(const size_t& i) const
00543 {
00544 return __weight[i];
00545 }
00546
00547 QuadratureFormulaP0Tetrahedron()
00548 :__weight(1./6.)
00549 {
00550 __integrationVertices[0] = TinyVector<3, real_t>(0.25, 0.25, 0.25);
00551 }
00552 };
00553
00554 class QuadratureFormulaP1Tetrahedron
00555 : public ThreadStaticBase<QuadratureFormulaP1Tetrahedron>
00556 {
00557 public:
00558 enum {
00559 numberOfQuadraturePoints = 4
00560 };
00561
00562 private:
00563 TinyVector<numberOfQuadraturePoints, TinyVector<3> > __integrationVertices;
00564
00565 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00566
00567 public:
00568 const TinyVector<3>& operator[](const size_t& i) const
00569 {
00570 return __integrationVertices[i];
00571 }
00572
00573 const TinyVector<numberOfQuadraturePoints,TinyVector<3> >& vertices() const
00574 {
00575 return __integrationVertices;
00576 }
00577
00578 size_t numberOfVertices() const
00579 {
00580 return numberOfQuadraturePoints;
00581 }
00582
00583 real_t weight(const size_t& i) const
00584 {
00585 return __weight[i];
00586 }
00587
00588 QuadratureFormulaP1Tetrahedron()
00589 {
00590 this->__setQuadratureVertices();
00591 }
00592 private:
00593 void __setQuadratureVertices()
00594 {
00595 __weight = 1./(6.*numberOfQuadraturePoints);
00596
00597 TinyVector<4, real_t> mu;
00598 mu[0] = 0.585410196624969;
00599 mu[1] = 0.138196601125011;
00600 mu[2] = 0.138196601125011;
00601 mu[3] = 0.138196601125011;
00602
00603 TinyVector<4, TinyVector<3,real_t> > vertex;
00604 vertex[0] = TinyVector<3, real_t>(0,0,0);
00605 vertex[1] = TinyVector<3, real_t>(1,0,0);
00606 vertex[2] = TinyVector<3, real_t>(0,1,0);
00607 vertex[3] = TinyVector<3, real_t>(0,0,1);
00608
00609 for (size_t i=0; i<4; ++i) {
00610 __integrationVertices[i] = 0;
00611 for (size_t j=0; j<4; ++j) {
00612 __integrationVertices[i] += mu[(i-j)%4]*vertex[j];
00613 }
00614 }
00615 }
00616 };
00617
00618 class QuadratureFormulaP2Tetrahedron
00619 : public ThreadStaticBase<QuadratureFormulaP2Tetrahedron>
00620 {
00621 public:
00622 enum {
00623 numberOfQuadraturePoints = 15
00624 };
00625
00626 private:
00627 TinyVector<numberOfQuadraturePoints, TinyVector<3> > __integrationVertices;
00628
00629 TinyVector<numberOfQuadraturePoints, real_t> __weight;
00630
00631 public:
00632 const TinyVector<3>& operator[](const size_t& i) const
00633 {
00634 return __integrationVertices[i];
00635 }
00636
00637 const TinyVector<numberOfQuadraturePoints,TinyVector<3> >& vertices() const
00638 {
00639 return __integrationVertices;
00640 }
00641
00642 size_t numberOfVertices() const
00643 {
00644 return numberOfQuadraturePoints;
00645 }
00646
00647 real_t weight(const size_t& i) const
00648 {
00649 return __weight[i];
00650 }
00651
00652 QuadratureFormulaP2Tetrahedron()
00653 {
00654 this->__setQuadratureVertices();
00655 }
00656 private:
00657 void __setQuadratureVertices()
00658 {
00659 const real_t a = (7.+std::sqrt(15))/34.;
00660 const real_t b = (7.-std::sqrt(15))/34.;
00661 const real_t c = (13.-3*std::sqrt(15))/34.;
00662 const real_t d = (13.+3*std::sqrt(15))/34.;
00663 const real_t e = (5.-std::sqrt(15))/20.;
00664 const real_t f = (5.+std::sqrt(15))/20.;
00665 const real_t h = (2665-14*std::sqrt(15))/226800.;
00666 const real_t i = (2665+14*std::sqrt(15))/226800.;
00667
00668 __integrationVertices[0] = TinyVector<3, real_t>(1./4., 1./4., 1./4.);
00669 __weight[ 0] = 8./405.;
00670 __integrationVertices[ 1] = TinyVector<3, real_t>(a,a,a);
00671 __weight[ 1] = h;
00672 __integrationVertices[ 2] = TinyVector<3, real_t>(a,a,c);
00673 __weight[ 2] = h;
00674 __integrationVertices[ 3] = TinyVector<3, real_t>(a,c,a);
00675 __weight[ 3] = h;
00676 __integrationVertices[ 4] = TinyVector<3, real_t>(c,a,a);
00677 __weight[ 4] = h;
00678 __integrationVertices[ 5] = TinyVector<3, real_t>(b,b,b);
00679 __weight[ 5] = i;
00680 __integrationVertices[ 6] = TinyVector<3, real_t>(b,b,d);
00681 __weight[ 6] = i;
00682 __integrationVertices[ 7] = TinyVector<3, real_t>(b,d,b);
00683 __weight[ 7] = i;
00684 __integrationVertices[ 8] = TinyVector<3, real_t>(d,b,b);
00685 __weight[ 8] = i;
00686 __integrationVertices[ 9] = TinyVector<3, real_t>(e,e,f);
00687 __weight[ 9] = 5./567.;
00688 __integrationVertices[10] = TinyVector<3, real_t>(e,f,e);
00689 __weight[10] = 5./567.;
00690 __integrationVertices[11] = TinyVector<3, real_t>(f,e,e);
00691 __weight[11] = 5./567.;
00692 __integrationVertices[12] = TinyVector<3, real_t>(e,f,f);
00693 __weight[12] = 5./567.;
00694 __integrationVertices[13] = TinyVector<3, real_t>(f,e,f);
00695 __weight[13] = 5./567.;
00696 __integrationVertices[14] = TinyVector<3, real_t>(f,f,e);
00697 __weight[14] = 5./567.;
00698 }
00699 };
00700
00701 #endif // QUADRATURE_FORMULA_HPP
00702