KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HexahedronTriquadratic.m
Go to the documentation of this file.
1 namespace fem{
2 
3 
4 /* (Autoinserted by mtoc++)
5  * This source code has been filtered by the mtoc++ executable,
6  * which generates code that can be processed by the doxygen documentation tool.
7  *
8  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
9  * Except for the comments, the function bodies of your M-file functions are untouched.
10  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
11  * attached source files that are highly readable by humans.
12  *
13  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
14  * the correct locations in the source code browser.
15  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
16  */
17 
19  :public fem.BaseFEM {
27  public:
28 
30  if nargin < 1
31  geo = fem.geometry.Cube27Node;
32  end
33  this = this@fem.BaseFEM(geo);
34  }
35 
36 
37  function Nx = N(colvec<double> x) {
38  Nx = [((x(1,:)-1).*x(1,:) .* (x(2,:)-1).*x(2,:) .* (x(3,:)-1).*x(3,:))/8; ... /* 1 */
39 
40  ((1-x(1,:).^2) .* (x(2,:)-1).*x(2,:) .* (x(3,:)-1).*x(3,:))/4; ... /* 2 */
41 
42  ((1+x(1,:)).*x(1,:) .* (x(2,:)-1).*x(2,:) .* (x(3,:)-1).*x(3,:))/8; ... /* 3 */
43 
44  ((x(1,:)-1).*x(1,:) .* (1-x(2,:).^2) .* (x(3,:)-1).*x(3,:))/4; ... /* 4 */
45 
46  ((1-x(1,:).^2) .* (1-x(2,:).^2) .* (x(3,:)-1).*x(3,:))/2; ... /* 5 */
47 
48  ((1+x(1,:)).*x(1,:) .* (1-x(2,:).^2) .* (x(3,:)-1).*x(3,:))/4; ... /* 6 */
49 
50  ((x(1,:)-1).*x(1,:) .* (1+x(2,:)).*x(2,:) .* (x(3,:)-1).*x(3,:))/8; ... /* 7 */
51 
52  ((1-x(1,:).^2) .* (1+x(2,:)).*x(2,:) .* (x(3,:)-1).*x(3,:))/4; ... /* 8 */
53 
54  ((1+x(1,:)).*x(1,:) .* (1+x(2,:)).*x(2,:) .* (x(3,:)-1).*x(3,:))/8; ... /* 9 */
55 
56  ((x(1,:)-1).*x(1,:) .* (x(2,:)-1).*x(2,:) .* (1-x(3,:).^2))/4; ... /* 10 */
57 
58  ((1-x(1,:).^2) .* (x(2,:)-1).*x(2,:) .* (1-x(3,:).^2))/2; ... /* 11 */
59 
60  ((1+x(1,:)).*x(1,:) .* (x(2,:)-1).*x(2,:) .* (1-x(3,:).^2))/4; ... /* 12 */
61 
62  ((x(1,:)-1).*x(1,:) .* (1-x(2,:).^2) .* (1-x(3,:).^2))/2; ... /* 13 */
63 
64  ((1-x(1,:).^2) .* (1-x(2,:).^2) .* (1-x(3,:).^2))/1; ... /* 14 */
65 
66  ((1+x(1,:)).*x(1,:) .* (1-x(2,:).^2) .* (1-x(3,:).^2))/2; ... /* 15 */
67 
68  ((x(1,:)-1).*x(1,:) .* (1+x(2,:)).*x(2,:) .* (1-x(3,:).^2))/4; ... /* 16 */
69 
70  ((1-x(1,:).^2) .* (1+x(2,:)).*x(2,:) .* (1-x(3,:).^2))/2; ... /* 17 */
71 
72  ((1+x(1,:)).*x(1,:) .* (1+x(2,:)).*x(2,:) .* (1-x(3,:).^2))/4; ... /* 18 */
73 
74  ((x(1,:)-1).*x(1,:) .* (x(2,:)-1).*x(2,:) .* (1+x(3,:)).*x(3,:))/8; ... /* 19 */
75 
76  ((1-x(1,:).^2) .* (x(2,:)-1).*x(2,:) .* (1+x(3,:)).*x(3,:))/4; ... /* 20 */
77 
78  ((1+x(1,:)).*x(1,:) .* (x(2,:)-1).*x(2,:) .* (1+x(3,:)).*x(3,:))/8; ... /* 21 */
79 
80  ((x(1,:)-1).*x(1,:) .* (1-x(2,:).^2) .* (1+x(3,:)).*x(3,:))/4; ... /* 22 */
81 
82  ((1-x(1,:).^2) .* (1-x(2,:).^2) .* (1+x(3,:)).*x(3,:))/2; ... /* 23 */
83 
84  ((1+x(1,:)).*x(1,:) .* (1-x(2,:).^2) .* (1+x(3,:)).*x(3,:))/4; ... /* 24 */
85 
86  ((x(1,:)-1).*x(1,:) .* (1+x(2,:)).*x(2,:) .* (1+x(3,:)).*x(3,:))/8; ... /* 25 */
87 
88  ((1-x(1,:).^2) .* (1+x(2,:)).*x(2,:) .* (1+x(3,:)).*x(3,:))/4; ... /* 26 */
89 
90  ((1+x(1,:)).*x(1,:) .* (1+x(2,:)).*x(2,:) .* (1+x(3,:)).*x(3,:))/8]; /* 27; */
91 
92  }
102  function dNx = gradN(colvec<double> x) {
103  dNx = [[((2*x(1,:)-1).*(x(2,:)-1).*x(2,:).*(x(3,:)-1).*x(3,:)) ((x(1,:)-1).*x(1,:).*(2*x(2,:)-1).*(x(3,:)-1).*x(3,:)) ((x(1,:)-1).*x(1,:).*(x(2,:)-1).*x(2,:).*(2*x(3,:)-1))]/8; ...
104  [((-2*x(1,:)).*(x(2,:)-1).*x(2,:).*(x(3,:)-1).*x(3,:)) ((1-x(1,:).^2).*(2*x(2,:)-1).*(x(3,:)-1).*x(3,:)) ((1-x(1,:).^2).*(x(2,:)-1).*x(2,:).*(2*x(3,:)-1))]/4; ...
105  [((1+2*x(1,:)).*(x(2,:)-1).*x(2,:).*(x(3,:)-1).*x(3,:)) ((1+x(1,:)).*x(1,:).*(2*x(2,:)-1).*(x(3,:)-1).*x(3,:)) ((1+x(1,:)).*x(1,:).*(x(2,:)-1).*x(2,:).*(2*x(3,:)-1))]/8; ...
106  [((2*x(1,:)-1).*(1-x(2,:).^2).*(x(3,:)-1).*x(3,:)) ((x(1,:)-1).*x(1,:).*(-2*x(2,:)).*(x(3,:)-1).*x(3,:)) ((x(1,:)-1).*x(1,:).*(1-x(2,:).^2).*(2*x(3,:)-1))]/4; ...
107  [((-2*x(1,:)).*(1-x(2,:).^2).*(x(3,:)-1).*x(3,:)) ((1-x(1,:).^2).*(-2*x(2,:)).*(x(3,:)-1).*x(3,:)) ((1-x(1,:).^2).*(1-x(2,:).^2).*(2*x(3,:)-1))]/2; ...
108  [((1+2*x(1,:)).*(1-x(2,:).^2).*(x(3,:)-1).*x(3,:)) ((1+x(1,:)).*x(1,:).*(-2*x(2,:)).*(x(3,:)-1).*x(3,:)) ((1+x(1,:)).*x(1,:).*(1-x(2,:).^2).*(2*x(3,:)-1))]/4; ...
109  [((2*x(1,:)-1).*(1+x(2,:)).*x(2,:).*(x(3,:)-1).*x(3,:)) ((x(1,:)-1).*x(1,:).*(1+2*x(2,:)).*(x(3,:)-1).*x(3,:)) ((x(1,:)-1).*x(1,:).*(1+x(2,:)).*x(2,:).*(2*x(3,:)-1))]/8; ...
110  [((-2*x(1,:)).*(1+x(2,:)).*x(2,:).*(x(3,:)-1).*x(3,:)) ((1-x(1,:).^2).*(1+2*x(2,:)).*(x(3,:)-1).*x(3,:)) ((1-x(1,:).^2).*(1+x(2,:)).*x(2,:).*(2*x(3,:)-1))]/4; ...
111  [((1+2*x(1,:)).*(1+x(2,:)).*x(2,:).*(x(3,:)-1).*x(3,:)) ((1+x(1,:)).*x(1,:).*(1+2*x(2,:)).*(x(3,:)-1).*x(3,:)) ((1+x(1,:)).*x(1,:).*(1+x(2,:)).*x(2,:).*(2*x(3,:)-1))]/8; ...
112  [((2*x(1,:)-1).*(x(2,:)-1).*x(2,:).*(1-x(3,:).^2)) ((x(1,:)-1).*x(1,:).*(2*x(2,:)-1).*(1-x(3,:).^2)) ((x(1,:)-1).*x(1,:).*(x(2,:)-1).*x(2,:).*(-2*x(3,:)))]/4; ...
113  [((-2*x(1,:)).*(x(2,:)-1).*x(2,:).*(1-x(3,:).^2)) ((1-x(1,:).^2).*(2*x(2,:)-1).*(1-x(3,:).^2)) ((1-x(1,:).^2).*(x(2,:)-1).*x(2,:).*(-2*x(3,:)))]/2; ...
114  [((1+2*x(1,:)).*(x(2,:)-1).*x(2,:).*(1-x(3,:).^2)) ((1+x(1,:)).*x(1,:).*(2*x(2,:)-1).*(1-x(3,:).^2)) ((1+x(1,:)).*x(1,:).*(x(2,:)-1).*x(2,:).*(-2*x(3,:)))]/4; ...
115  [((2*x(1,:)-1).*(1-x(2,:).^2).*(1-x(3,:).^2)) ((x(1,:)-1).*x(1,:).*(-2*x(2,:)).*(1-x(3,:).^2)) ((x(1,:)-1).*x(1,:).*(1-x(2,:).^2).*(-2*x(3,:)))]/2; ...
116  [((-2*x(1,:)).*(1-x(2,:).^2).*(1-x(3,:).^2)) ((1-x(1,:).^2).*(-2*x(2,:)).*(1-x(3,:).^2)) ((1-x(1,:).^2).*(1-x(2,:).^2).*(-2*x(3,:)))]/1; ...
117  [((1+2*x(1,:)).*(1-x(2,:).^2).*(1-x(3,:).^2)) ((1+x(1,:)).*x(1,:).*(-2*x(2,:)).*(1-x(3,:).^2)) ((1+x(1,:)).*x(1,:).*(1-x(2,:).^2).*(-2*x(3,:)))]/2; ...
118  [((2*x(1,:)-1).*(1+x(2,:)).*x(2,:).*(1-x(3,:).^2)) ((x(1,:)-1).*x(1,:).*(1+2*x(2,:)).*(1-x(3,:).^2)) ((x(1,:)-1).*x(1,:).*(1+x(2,:)).*x(2,:).*(-2*x(3,:)))]/4; ...
119  [((-2*x(1,:)).*(1+x(2,:)).*x(2,:).*(1-x(3,:).^2)) ((1-x(1,:).^2).*(1+2*x(2,:)).*(1-x(3,:).^2)) ((1-x(1,:).^2).*(1+x(2,:)).*x(2,:).*(-2*x(3,:)))]/2; ...
120  [((1+2*x(1,:)).*(1+x(2,:)).*x(2,:).*(1-x(3,:).^2)) ((1+x(1,:)).*x(1,:).*(1+2*x(2,:)).*(1-x(3,:).^2)) ((1+x(1,:)).*x(1,:).*(1+x(2,:)).*x(2,:).*(-2*x(3,:)))]/4; ...
121  [((2*x(1,:)-1).*(x(2,:)-1).*x(2,:).*(1+x(3,:)).*x(3,:)) ((x(1,:)-1).*x(1,:).*(2*x(2,:)-1).*(1+x(3,:)).*x(3,:)) ((x(1,:)-1).*x(1,:).*(x(2,:)-1).*x(2,:).*(1+2*x(3,:)))]/8; ...
122  [((-2*x(1,:)).*(x(2,:)-1).*x(2,:).*(1+x(3,:)).*x(3,:)) ((1-x(1,:).^2).*(2*x(2,:)-1).*(1+x(3,:)).*x(3,:)) ((1-x(1,:).^2).*(x(2,:)-1).*x(2,:).*(1+2*x(3,:)))]/4; ...
123  [((1+2*x(1,:)).*(x(2,:)-1).*x(2,:).*(1+x(3,:)).*x(3,:)) ((1+x(1,:)).*x(1,:).*(2*x(2,:)-1).*(1+x(3,:)).*x(3,:)) ((1+x(1,:)).*x(1,:).*(x(2,:)-1).*x(2,:).*(1+2*x(3,:)))]/8; ...
124  [((2*x(1,:)-1).*(1-x(2,:).^2).*(1+x(3,:)).*x(3,:)) ((x(1,:)-1).*x(1,:).*(-2*x(2,:)).*(1+x(3,:)).*x(3,:)) ((x(1,:)-1).*x(1,:).*(1-x(2,:).^2).*(1+2*x(3,:)))]/4; ...
125  [((-2*x(1,:)).*(1-x(2,:).^2).*(1+x(3,:)).*x(3,:)) ((1-x(1,:).^2).*(-2*x(2,:)).*(1+x(3,:)).*x(3,:)) ((1-x(1,:).^2).*(1-x(2,:).^2).*(1+2*x(3,:)))]/2; ...
126  [((1+2*x(1,:)).*(1-x(2,:).^2).*(1+x(3,:)).*x(3,:)) ((1+x(1,:)).*x(1,:).*(-2*x(2,:)).*(1+x(3,:)).*x(3,:)) ((1+x(1,:)).*x(1,:).*(1-x(2,:).^2).*(1+2*x(3,:)))]/4; ...
127  [((2*x(1,:)-1).*(1+x(2,:)).*x(2,:).*(1+x(3,:)).*x(3,:)) ((x(1,:)-1).*x(1,:).*(1+2*x(2,:)).*(1+x(3,:)).*x(3,:)) ((x(1,:)-1).*x(1,:).*(1+x(2,:)).*x(2,:).*(1+2*x(3,:)))]/8; ...
128  [((-2*x(1,:)).*(1+x(2,:)).*x(2,:).*(1+x(3,:)).*x(3,:)) ((1-x(1,:).^2).*(1+2*x(2,:)).*(1+x(3,:)).*x(3,:)) ((1-x(1,:).^2).*(1+x(2,:)).*x(2,:).*(1+2*x(3,:)))]/4; ...
129  [((1+2*x(1,:)).*(1+x(2,:)).*x(2,:).*(1+x(3,:)).*x(3,:)) ((1+x(1,:)).*x(1,:).*(1+2*x(2,:)).*(1+x(3,:)).*x(3,:)) ((1+x(1,:)).*x(1,:).*(1+x(2,:)).*x(2,:).*(1+2*x(3,:)))]/8];
130  }
131 
132 
133  public: /* ( Static ) */
134 
135  static function res = test_QuadraticBasisFun() {
136  q = fem.HexahedronTriquadratic;
137  res = fem.BaseFEM.test_BasisFun(q);
138 
139  /* test for correct basis function values on nodes */
140  [X,Y,Z] = ndgrid(-1:1:1,-1:1:1,-1:1:1);
141  p = [X(:) Y(:) Z(:)]^t;
142  res = res && isequal(q.N(p),eye(27));
143  }
144 
145 
146  static function generateN_dN() {
147  N = [" (x(1,:)-1).*x(1,:) ", " (1-x(1,:).^2) ", " (1+x(1,:)).*x(1,:) "
148  " (x(2,:)-1).*x(2,:) ", " (1-x(2,:).^2) ", " (1+x(2,:)).*x(2,:) "
149  " (x(3,:)-1).*x(3,:) ", " (1-x(3,:).^2) ", " (1+x(3,:)).*x(3,:) "];
150 
151  dN = [" (2*x(1,:)-1) ", " (-2*x(1,:)) ", " (1+2*x(1,:)) "
152  " (2*x(2,:)-1) ", " (-2*x(2,:)) ", " (1+2*x(2,:)) "
153  " (2*x(3,:)-1) ", " (-2*x(3,:)) ", " (1+2*x(3,:)) "];
154 
155  [x,y,z] = ndgrid(1:3);
156  idx = [x(:) y(:) z(:)]^t;
157  fac = 2.^sum(idx ~= 2);
158  s = ;
159  ds = ;
160  for k = 1:27
161  s = [s sprintf(" (%s .* %s .* %s)/%d; ... %%%d\n ",N[1,idx(1,k)],N[2,idx(2,k)],N[3,idx(3,k)],fac(k),k)];/* #ok */
162 
163  dn1 = sprintf(" (%s.*%s.*%s) ",dN[1,idx(1,k)],N[2,idx(2,k)],N[3,idx(3,k)]);
164  dn2 = sprintf(" (%s.*%s.*%s) ",N[1,idx(1,k)],dN[2,idx(2,k)],N[3,idx(3,k)]);
165  dn3 = sprintf(" (%s.*%s.*%s) ",N[1,idx(1,k)],N[2,idx(2,k)],dN[3,idx(3,k)]);
166  ds = [ds sprintf(" [%s %s %s]/%d; ...\n ",dn1,dn2,dn3,fac(k))];/* #ok */
167 
168  end
169  disp(s);
170  disp(ds);
171  N = eval(sprintf(" @(x)[%s]; ",s(1:end-9)));
172  gradN = eval(sprintf(" @(x)[%s]; ",ds(1:end-6)));
173  [x,y,z] = ndgrid(-1:1);
174  pos = [x(:) y(:) z(:)]^t;
175  sum(N(pos))
176  sum(gradN(pos))
177  }
186 };
187 }
188 
189 
190 
FEMBASE Summary of this class goes here Detailed explanation goes here.
Definition: BaseFEM.m:18
Triquatratic: Quadratic ansatz functions on cube with 20 nodes per cube.
static function generateN_dN()
Little hack to generate the appropriate basis function expressions.
static function res = test_QuadraticBasisFun()
disp
Handle object disp method which is called by the display method. See the MATLAB disp function...
#define X(i, j)
function dNx = gradN(colvec< double > x)
#define Y(i, j)
function Nx = N(colvec< double > x)
Triquadratic basis functions.