146 this.initGaussPoints;
150 flat_el = flat_el(:)^
t;
153 idx = find(flat_el ==
k);
154 i = [i ones(size(idx))*
k];
159 this.
Sigma= sparse(i,j,ones(size(i)),np,g.NumElements*g.DofsPerElement);
172 Ngpval = zeros(eldofs,ngp,nel);
174 eljac = zeros(nel,ngp);
177 dtnall = zeros(eldofs,ngp*3,nel);
180 mass_gp = zeros(eldofs,eldofs);
181 damp_gp = zeros(eldofs,eldofs);
189 Ngpval(:,gi,m) = this.
N(xi);
192 dNxi = this.
gradN(xi);
194 Jac = g.Nodes(:,elem)*dNxi;
198 eljac(m,gi) = abs(det(Jac));
205 mass_gp = mass_gp + this.
GaussWeights(gi)*(Nxi*Nxi^
t)*eljac(m,gi);
208 damp_gp = damp_gp + this.
GaussWeights(gi)*(dNxi*dNxi^
t)*eljac(m,gi);
211 dtnall(:,3*(gi-1)+1:3*gi,m) = dNxi / Jac;
215 Mass(elem(j),elem(j:end)) = Mass(elem(j),elem(j:end)) + mass_gp(j,j:end);
216 Damp(elem(j),elem(j:end)) = Damp(elem(j),elem(j:end)) + damp_gp(j,j:end);
221 this.
M= sparse(Mass + Mass^t - diag(diag(Mass)));
222 this.
D= sparse(Damp + Damp^t - diag(diag(Damp)));
228 npf = g.NodesPerFace;
229 Ngpval = zeros(npf,ngp,nf);
230 facejac = zeros(nf,ngp);
231 dNN = zeros(npf,ngp,nf);
232 transNormals = zeros(3,ngp,nf);
235 tangidx = [2 2 1 1 1 1;
237 signum = [-1 1 1 -1 -1 1];
239 elemidx = g.Faces(1,fn);
240 faceidx = g.Faces(2,fn);
241 masterfacenodeidx = g.MasterFaces(faceidx,:);
246 Ngpval(:,:,fn) = Nall(masterfacenodeidx,:);
250 dNxipos = [0 ngp 2*ngp]+gi;
253 Jac = g.Nodes(:,g.Elements(elemidx,:))*dNxi(:,dNxipos);
260 transNormals(:,gi,fn) = signum(faceidx)...
261 *cross(Jac(:,tangidx(1,faceidx)),Jac(:,tangidx(2,faceidx)));
267 Jac = Jac(g.FaceDims(:,faceidx),g.FaceDims(:,faceidx));
269 facejac(fn,gi) = abs(det(Jac));
275 dNN(:,gi,fn) = dNxi(masterfacenodeidx,dNxipos) * g.FaceNormals(:,faceidx);
290 for k = 1:length(elemidx)
291 a = a + this.
FaceAreas(g.Faces(1,:) == elemidx(
k) & g.Faces(2,:) == faceidx(
k));
320 gp = g.Nodes(:,g.Elements(elemidx,:)) * this.
Ngp(:,:,elemidx);
337 h = pm.nextPlot(
" mass ",
" Mass matrix ",
" node ",
" node ");
338 mesh(h,full(this.
M));
340 pm.nextPlot(
" mass_pattern ",
" Mass matrix pattern ",
" dof ",
" dof ");
343 h = pm.nextPlot(
" damp ",
" Damping matrix ",
" node ",
" node ");
344 mesh(h,full(this.
D));
346 pm.nextPlot(
" damp_pattern ",
" Damping matrix pattern ",
" dof ",
" dof ");
356 #if 0 //mtoc++: 'get.GaussPointRule'
358 value = this.fGaussPointRule;
365 #if 0 //mtoc++: 'set.GaussPointRule'
367 if ~isequal(this.fGaussPointRule, value)
369 this.fGaussPointRule= value;
378 #if 0 //mtoc++: 'get.GaussPointsPerElem'
387 #if 0 //mtoc++: 'get.GaussPointsPerElemFace'
428 function initGaussPoints() {
429 switch this.fGaussPointRule
432 g = [-sqrt(3/5) 0 sqrt(3/5)];
436 g = [-sqrt(3/7 + 2/7*sqrt(6/5)) -sqrt(3/7 - 2/7*sqrt(6/5)) sqrt(3/7 - 2/7*sqrt(6/5)) sqrt(3/7 + 2/7*sqrt(6/5))];
437 w = [(18-sqrt(30))/36 (18+sqrt(30))/36 (18+sqrt(30))/36 (18-sqrt(30))/36];
441 g = [-sqrt(5+a)/3 -sqrt(5-a)/3 0 sqrt(5-a)/3 sqrt(5+a)/3];
443 w = [(322-a)/900 (322+a)/900 128/225 (322+a)/900 (322-a)/900];
446 v = [0.3607615730481386 0.6612093864662645
447 0.3607615730481386 -0.6612093864662645
448 0.4679139345726910 -0.2386191860831969
449 0.4679139345726910 0.2386191860831969
450 0.1713244923791704 -0.9324695142031521
451 0.1713244923791704 0.9324695142031521];
455 v = [0.4179591836734694 0.0000000000000000
456 0.3818300505051189 0.4058451513773972
457 0.3818300505051189 -0.4058451513773972
458 0.2797053914892766 -0.7415311855993945
459 0.2797053914892766 0.7415311855993945
460 0.1294849661688697 -0.9491079123427585
461 0.1294849661688697 0.9491079123427585];
465 v = [0.3626837833783620 -0.1834346424956498
466 0.3626837833783620 0.1834346424956498
467 0.3137066458778873 -0.5255324099163290
468 0.3137066458778873 0.5255324099163290
469 0.2223810344533745 -0.7966664774136267
470 0.2223810344533745 0.7966664774136267
471 0.1012285362903763 -0.9602898564975363
472 0.1012285362903763 0.9602898564975363];
476 v = [0.3302393550012598 0.0000000000000000
477 0.1806481606948574 -0.8360311073266358
478 0.1806481606948574 0.8360311073266358
479 0.0812743883615744 -0.9681602395076261
480 0.0812743883615744 0.9681602395076261
481 0.3123470770400029 -0.3242534234038089
482 0.3123470770400029 0.3242534234038089
483 0.2606106964029354 -0.6133714327005904
484 0.2606106964029354 0.6133714327005904];
488 v = [0.2955242247147529 -0.1488743389816312
489 0.2955242247147529 0.1488743389816312
490 0.2692667193099963 -0.4333953941292472
491 0.2692667193099963 0.4333953941292472
492 0.2190863625159820 -0.6794095682990244
493 0.2190863625159820 0.6794095682990244
494 0.1494513491505806 -0.8650633666889845
495 0.1494513491505806 0.8650633666889845
496 0.0666713443086881 -0.9739065285171717
497 0.0666713443086881 0.9739065285171717];
501 v = [0.2025782419255613 0.0000000000000000
502 0.1984314853271116 -0.2011940939974345
503 0.1984314853271116 0.2011940939974345
504 0.1861610000155622 -0.3941513470775634
505 0.1861610000155622 0.3941513470775634
506 0.1662692058169939 -0.5709721726085388
507 0.1662692058169939 0.5709721726085388
508 0.1395706779261543 -0.7244177313601701
509 0.1395706779261543 0.7244177313601701
510 0.1071592204671719 -0.8482065834104272
511 0.1071592204671719 0.8482065834104272
512 0.0703660474881081 -0.9372733924007060
513 0.0703660474881081 0.9372733924007060
514 0.0307532419961173 -0.9879925180204854
515 0.0307532419961173 0.9879925180204854];
519 v = [0.1527533871307258 -0.0765265211334973
520 0.1527533871307258 0.0765265211334973
521 0.1491729864726037 -0.2277858511416451
522 0.1491729864726037 0.2277858511416451
523 0.1420961093183820 -0.3737060887154195
524 0.1420961093183820 0.3737060887154195
525 0.1316886384491766 -0.5108670019508271
526 0.1316886384491766 0.5108670019508271
527 0.1181945319615184 -0.6360536807265150
528 0.1181945319615184 0.6360536807265150
529 0.1019301198172404 -0.7463319064601508
530 0.1019301198172404 0.7463319064601508
531 0.0832767415767048 -0.8391169718222188
532 0.0832767415767048 0.8391169718222188
533 0.0626720483341091 -0.9122344282513259
534 0.0626720483341091 0.9122344282513259
535 0.0406014298003869 -0.9639719272779138
536 0.0406014298003869 0.9639719272779138
537 0.0176140071391521 -0.9931285991850949
538 0.0176140071391521 0.9931285991850949];
542 error(" Quadrature rule for %d points per dimension not implemented\nYou can obtain more coefficients from e.g. http:
546 [WX,WY,WZ] = meshgrid(w);
547 [GX,GY,GZ] = meshgrid(g);
553 [WX,WY] = meshgrid(w);
554 [GX,GY] = meshgrid(g);
556 fgp = zeros(3,length(g)^2,6);
557 faceremainingdim = [-1 1 -1 1 -1 1];
560 fgp(g.FaceDims(:,faceidx),:,faceidx) = [GX(:) GY(:)]^t;
561 fgp(~g.FaceDims(:,faceidx),:,faceidx) = faceremainingdim(faceidx);
580 diff = (subclass.N(A + h*eye(3)) - subclass.N(A))/h - subclass.gradN(a);
581 res = res &
all(diff(:) < 10*h);
589 ranges = [-1:1, -2:1, -2:2];
591 for k = 1:length(ranges)
592 g = fem.geometry.RegularHex8Grid(ranges[
k],ranges[k]);
593 tl = fem.HexahedronTrilinear(g);
594 tq = fem.HexahedronTriquadratic(g.toCube27Node);
595 res = res && norm(tl.elem_detjac-tq.elem_detjac,
" inf ") < 1e-14;
FEMBASE Summary of this class goes here Detailed explanation goes here.
Sigma
The element-dof to global node assembly matrix.
virtual function dnx = gradN(matrix< double > x)
Evaluates the gradients of the elementary basis functions on the master element.
D
The damping matrix (for linear damping)
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
Ngp
Values of basis functions on gauss points.
Matlab's base handle class (documentation generation substitute)
GaussPoints
% Gauss integration related properties
function a = getFaceArea(elemidx, faceidx)
static function vecs = normalizeL2(vecs)
transgrad
transformed basis function gradients, stored in eldofs x gp*3 x element matrix (accessible in 20x3-ch...
function v = getElementVolume(elemidx)
Returns the volume of the element with the specified index in [mm³].
function v = getTotalVolume()
Returns the total geometry volume in [mm³].
function gp = getGlobalGaussPoints(elemidx)
Returns the positions of all gauss points of the specified element in global (=reference) coordinates...
virtual function matrix< double > nx = N(matrix< double > x)
Evaluates the elementary basis functions on the geometry master element.
Norm: Static class for commonly used norms on sets of vectors.
static function res = test_JacobiansDefaultGeo()
Tests if the deformation jacobians using linear and quadratic elements is the same for a default geom...
static function res = test_BasisFun(subclass)