Code covered by the BSD License

# FELICITY

### Shawn Walker (view profile)

21 Apr 2011 (Updated )

Finite ELement Implementation and Computational Interface Tool for You

```function [Points, Weights] = Quad_On_Tetra(Order)
%
%   This routine gives the quadrature rule for integrating on the unit
%   `logical' tetrahedron. i.e. the tet whose vertices are
%                   (0,0,0), (1,0,0), (0,1,0), (0,0,1).
%   Be careful with the input argument (see below).
%
%
%   OUTPUTS
%   -------
%   Points:
%       An N x 3 array, where N is the number of quadrature points.  Each row gives the
%       (x,y,z) coordinates of the point.  Note: N := Order.
%
%   Weights:
%       An N x 1 array, where N is the number of quadrature points.  Each row gives the
%       weight assigned to the point.  Note: N := Order.  WARNING: the quad weights are
%       scaled such that they sum to (1/6); this is the area of the reference
%       tetrahedron.
%
%   INPUTS
%   ------
%   Order:
%       A positive integer indicating the desired order of accuracy for the integration
%       method, i.e. (h^Order) accuracy.  Note: not all orders are available;  only these:
%       Order = [1,4,5,10,11,14,15,24,31,45].
%       If Order is not in the above list, then the next highest is chosen.

% Copyright (c) 11-03-2014,  Shawn W. Walker

% make sure it is an integer
Order = round(Order);
Ord_Vec = [1,4,5,10,11,14,15,24,31,45];

% choose an order at least as big as what was desired
Mask = (Ord_Vec - Order) >= 0;
if isempty(Subset_Ord_Vec)
% THEN, set a default value
Order = 5;
else
Order = min(Subset_Ord_Vec);
end

% BEGIN: define volume integration points and weights

switch Order

case  1 % O(h), degree of precision 0
Points  = [(1/4), (1/4), (1/4)];
Weights = (1/6);
case  4 % O(h^4), degree of precision 1
Points  = [0.5854101966249685  0.1381966011250105  0.1381966011250105;
0.1381966011250105  0.5854101966249685  0.1381966011250105;
0.1381966011250105  0.1381966011250105  0.5854101966249685;
0.1381966011250105  0.1381966011250105  0.1381966011250105];
Weights = (1/6) * [1; 1; 1; 1] / 4;

case  5 % O(h^5), degree of precision 2
Points = [ 0.2500000000000000  0.2500000000000000  0.2500000000000000;
0.5000000000000000  0.1666666666666667  0.1666666666666667;
0.1666666666666667  0.1666666666666667  0.1666666666666667;
0.1666666666666667  0.1666666666666667  0.5000000000000000;
0.1666666666666667  0.5000000000000000  0.1666666666666667];
Weights = [ -0.8000000000000000;
0.4500000000000000;
0.4500000000000000;
0.4500000000000000;
0.4500000000000000] * (1/6);
case  10  % O(h^10), degree of precision 3
Points = [    0.5684305841968444  0.1438564719343852  0.1438564719343852;
0.1438564719343852  0.1438564719343852  0.1438564719343852;
0.1438564719343852  0.1438564719343852  0.5684305841968444;
0.1438564719343852  0.5684305841968444  0.1438564719343852;
0.0000000000000000  0.5000000000000000  0.5000000000000000;
0.5000000000000000  0.0000000000000000  0.5000000000000000;
0.5000000000000000  0.5000000000000000  0.0000000000000000;
0.5000000000000000  0.0000000000000000  0.0000000000000000;
0.0000000000000000  0.5000000000000000  0.0000000000000000;
0.0000000000000000  0.0000000000000000  0.5000000000000000];
Weights = [ 0.2177650698804054;
0.2177650698804054;
0.2177650698804054;
0.2177650698804054;
0.0214899534130631;
0.0214899534130631;
0.0214899534130631;
0.0214899534130631;
0.0214899534130631;
0.0214899534130631] * (1/6);

case  11 % O(h^11), degree of precision 4
Points = [0.2500000000000000  0.2500000000000000  0.2500000000000000;
0.7857142857142857  0.0714285714285714  0.0714285714285714;
0.0714285714285714  0.0714285714285714  0.0714285714285714;
0.0714285714285714  0.0714285714285714  0.7857142857142857;
0.0714285714285714  0.7857142857142857  0.0714285714285714;
0.1005964238332008  0.3994035761667992  0.3994035761667992;
0.3994035761667992  0.1005964238332008  0.3994035761667992;
0.3994035761667992  0.3994035761667992  0.1005964238332008;
0.3994035761667992  0.1005964238332008  0.1005964238332008;
0.1005964238332008  0.3994035761667992  0.1005964238332008;
0.1005964238332008  0.1005964238332008  0.3994035761667992];
Weights = [  -0.0789333333333333;
0.0457333333333333;
0.0457333333333333;
0.0457333333333333;
0.0457333333333333;
0.1493333333333333;
0.1493333333333333;
0.1493333333333333;
0.1493333333333333;
0.1493333333333333;
0.1493333333333333] * (1/6);
case  14 % O(h^14), degree of precision 4
Points = [0.0000000000000000  0.5000000000000000  0.5000000000000000;
0.5000000000000000  0.0000000000000000  0.5000000000000000;
0.5000000000000000  0.5000000000000000  0.0000000000000000;
0.5000000000000000  0.0000000000000000  0.0000000000000000;
0.0000000000000000  0.5000000000000000  0.0000000000000000;
0.0000000000000000  0.0000000000000000  0.5000000000000000;
0.6984197043243866  0.1005267652252045  0.1005267652252045;
0.1005267652252045  0.1005267652252045  0.1005267652252045;
0.1005267652252045  0.1005267652252045  0.6984197043243866;
0.1005267652252045  0.6984197043243866  0.1005267652252045;
0.0568813795204234  0.3143728734931922  0.3143728734931922;
0.3143728734931922  0.3143728734931922  0.3143728734931922;
0.3143728734931922  0.3143728734931922  0.0568813795204234;
0.3143728734931922  0.0568813795204234  0.3143728734931922];
Weights = [0.0190476190476190;
0.0190476190476190;
0.0190476190476190;
0.0190476190476190;
0.0190476190476190;
0.0190476190476190;
0.0885898247429807;
0.0885898247429807;
0.0885898247429807;
0.0885898247429807;
0.1328387466855907;
0.1328387466855907;
0.1328387466855907;
0.1328387466855907] * (1/6);
case  15 % O(h^15), degree of precision 5
Points = [0.2500000000000000  0.2500000000000000  0.2500000000000000;
0.0000000000000000  0.3333333333333333  0.3333333333333333;
0.3333333333333333  0.3333333333333333  0.3333333333333333;
0.3333333333333333  0.3333333333333333  0.0000000000000000;
0.3333333333333333  0.0000000000000000  0.3333333333333333;
0.7272727272727273  0.0909090909090909  0.0909090909090909;
0.0909090909090909  0.0909090909090909  0.0909090909090909;
0.0909090909090909  0.0909090909090909  0.7272727272727273;
0.0909090909090909  0.7272727272727273  0.0909090909090909;
0.4334498464263357  0.0665501535736643  0.0665501535736643;
0.0665501535736643  0.4334498464263357  0.0665501535736643;
0.0665501535736643  0.0665501535736643  0.4334498464263357;
0.0665501535736643  0.4334498464263357  0.4334498464263357;
0.4334498464263357  0.0665501535736643  0.4334498464263357;
0.4334498464263357  0.4334498464263357  0.0665501535736643];
Weights = [ 0.1817020685825351;
0.0361607142857143;
0.0361607142857143;
0.0361607142857143;
0.0361607142857143;
0.0698714945161738;
0.0698714945161738;
0.0698714945161738;
0.0698714945161738;
0.0656948493683187;
0.0656948493683187;
0.0656948493683187;
0.0656948493683187;
0.0656948493683187;
0.0656948493683187] * (1/6);
case  24 % O(h^24), degree of precision 6
Points = [0.3561913862225449  0.2146028712591517  0.2146028712591517;
0.2146028712591517  0.2146028712591517  0.2146028712591517;
0.2146028712591517  0.2146028712591517  0.3561913862225449;
0.2146028712591517  0.3561913862225449  0.2146028712591517;
0.8779781243961660  0.0406739585346113  0.0406739585346113;
0.0406739585346113  0.0406739585346113  0.0406739585346113;
0.0406739585346113  0.0406739585346113  0.8779781243961660;
0.0406739585346113  0.8779781243961660  0.0406739585346113;
0.0329863295731731  0.3223378901422757  0.3223378901422757;
0.3223378901422757  0.3223378901422757  0.3223378901422757;
0.3223378901422757  0.3223378901422757  0.0329863295731731;
0.3223378901422757  0.0329863295731731  0.3223378901422757;
0.2696723314583159  0.0636610018750175  0.0636610018750175;
0.0636610018750175  0.2696723314583159  0.0636610018750175;
0.0636610018750175  0.0636610018750175  0.2696723314583159;
0.6030056647916491  0.0636610018750175  0.0636610018750175;
0.0636610018750175  0.6030056647916491  0.0636610018750175;
0.0636610018750175  0.0636610018750175  0.6030056647916491;
0.0636610018750175  0.2696723314583159  0.6030056647916491;
0.2696723314583159  0.6030056647916491  0.0636610018750175;
0.6030056647916491  0.0636610018750175  0.2696723314583159;
0.0636610018750175  0.6030056647916491  0.2696723314583159;
0.2696723314583159  0.0636610018750175  0.6030056647916491;
0.6030056647916491  0.2696723314583159  0.0636610018750175];
Weights = [   0.0399227502581679;
0.0399227502581679;
0.0399227502581679;
0.0399227502581679;
0.0100772110553207;
0.0100772110553207;
0.0100772110553207;
0.0100772110553207;
0.0553571815436544;
0.0553571815436544;
0.0553571815436544;
0.0553571815436544;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857;
0.0482142857142857] * (1/6);
case  31 % O(h^31), degree of precision 7
Points = [0.2500000000000000  0.2500000000000000  0.2500000000000000;
0.7653604230090441  0.0782131923303186  0.0782131923303186;
0.0782131923303186  0.0782131923303186  0.0782131923303186;
0.0782131923303186  0.0782131923303186  0.7653604230090441;
0.0782131923303186  0.7653604230090441  0.0782131923303186;
0.6344703500082868  0.1218432166639044  0.1218432166639044;
0.1218432166639044  0.1218432166639044  0.1218432166639044;
0.1218432166639044  0.1218432166639044  0.6344703500082868;
0.1218432166639044  0.6344703500082868  0.1218432166639044;
0.0023825066607383  0.3325391644464206  0.3325391644464206;
0.3325391644464206  0.3325391644464206  0.3325391644464206;
0.3325391644464206  0.3325391644464206  0.0023825066607383;
0.3325391644464206  0.0023825066607383  0.3325391644464206;
0.0000000000000000  0.5000000000000000  0.5000000000000000;
0.5000000000000000  0.0000000000000000  0.5000000000000000;
0.5000000000000000  0.5000000000000000  0.0000000000000000;
0.5000000000000000  0.0000000000000000  0.0000000000000000;
0.0000000000000000  0.5000000000000000  0.0000000000000000;
0.0000000000000000  0.0000000000000000  0.5000000000000000;
0.2000000000000000  0.1000000000000000  0.1000000000000000;
0.1000000000000000  0.2000000000000000  0.1000000000000000;
0.1000000000000000  0.1000000000000000  0.2000000000000000;
0.6000000000000000  0.1000000000000000  0.1000000000000000;
0.1000000000000000  0.6000000000000000  0.1000000000000000;
0.1000000000000000  0.1000000000000000  0.6000000000000000;
0.1000000000000000  0.2000000000000000  0.6000000000000000;
0.2000000000000000  0.6000000000000000  0.1000000000000000;
0.6000000000000000  0.1000000000000000  0.2000000000000000;
0.1000000000000000  0.6000000000000000  0.2000000000000000;
0.2000000000000000  0.1000000000000000  0.6000000000000000;
0.6000000000000000  0.2000000000000000  0.1000000000000000];
Weights = [   0.1095853407966528;
0.0635996491464850;
0.0635996491464850;
0.0635996491464850;
0.0635996491464850;
-0.3751064406859797;
-0.3751064406859797;
-0.3751064406859797;
-0.3751064406859797;
0.0293485515784412;
0.0293485515784412;
0.0293485515784412;
0.0293485515784412;
0.0058201058201058;
0.0058201058201058;
0.0058201058201058;
0.0058201058201058;
0.0058201058201058;
0.0058201058201058;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105;
0.1653439153439105] * (1/6);
case  45 % O(h^45), degree of precision 8
Points = [0.2500000000000000  0.2500000000000000  0.2500000000000000;
0.6175871903000830  0.1274709365666390  0.1274709365666390;
0.1274709365666390  0.1274709365666390  0.1274709365666390;
0.1274709365666390  0.1274709365666390  0.6175871903000830;
0.1274709365666390  0.6175871903000830  0.1274709365666390;
0.9037635088221031  0.0320788303926323  0.0320788303926323;
0.0320788303926323  0.0320788303926323  0.0320788303926323;
0.0320788303926323  0.0320788303926323  0.9037635088221031;
0.0320788303926323  0.9037635088221031  0.0320788303926323;
0.4502229043567190  0.0497770956432810  0.0497770956432810;
0.0497770956432810  0.4502229043567190  0.0497770956432810;
0.0497770956432810  0.0497770956432810  0.4502229043567190;
0.0497770956432810  0.4502229043567190  0.4502229043567190;
0.4502229043567190  0.0497770956432810  0.4502229043567190;
0.4502229043567190  0.4502229043567190  0.0497770956432810;
0.3162695526014501  0.1837304473985499  0.1837304473985499;
0.1837304473985499  0.3162695526014501  0.1837304473985499;
0.1837304473985499  0.1837304473985499  0.3162695526014501;
0.1837304473985499  0.3162695526014501  0.3162695526014501;
0.3162695526014501  0.1837304473985499  0.3162695526014501;
0.3162695526014501  0.3162695526014501  0.1837304473985499;
0.0229177878448171  0.2319010893971509  0.2319010893971509;
0.2319010893971509  0.0229177878448171  0.2319010893971509;
0.2319010893971509  0.2319010893971509  0.0229177878448171;
0.5132800333608811  0.2319010893971509  0.2319010893971509;
0.2319010893971509  0.5132800333608811  0.2319010893971509;
0.2319010893971509  0.2319010893971509  0.5132800333608811;
0.2319010893971509  0.0229177878448171  0.5132800333608811;
0.0229177878448171  0.5132800333608811  0.2319010893971509;
0.5132800333608811  0.2319010893971509  0.0229177878448171;
0.2319010893971509  0.5132800333608811  0.0229177878448171;
0.0229177878448171  0.2319010893971509  0.5132800333608811;
0.5132800333608811  0.0229177878448171  0.2319010893971509;
0.7303134278075384  0.0379700484718286  0.0379700484718286;
0.0379700484718286  0.7303134278075384  0.0379700484718286;
0.0379700484718286  0.0379700484718286  0.7303134278075384;
0.1937464752488044  0.0379700484718286  0.0379700484718286;
0.0379700484718286  0.1937464752488044  0.0379700484718286;
0.0379700484718286  0.0379700484718286  0.1937464752488044;
0.0379700484718286  0.7303134278075384  0.1937464752488044;
0.7303134278075384  0.1937464752488044  0.0379700484718286;
0.1937464752488044  0.0379700484718286  0.7303134278075384;
0.0379700484718286  0.1937464752488044  0.7303134278075384;
0.7303134278075384  0.0379700484718286  0.1937464752488044;
0.1937464752488044  0.7303134278075384  0.0379700484718286];
Weights = [  -0.2359620398477557;
0.0244878963560562;
0.0244878963560562;
0.0244878963560562;
0.0244878963560562;
0.0039485206398261;
0.0039485206398261;
0.0039485206398261;
0.0039485206398261;
0.0263055529507371;
0.0263055529507371;
0.0263055529507371;
0.0263055529507371;
0.0263055529507371;
0.0263055529507371;
0.0829803830550589;
0.0829803830550589;
0.0829803830550589;
0.0829803830550589;
0.0829803830550589;
0.0829803830550589;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0254426245481023;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852;
0.0134324384376852] * (1/6);
otherwise