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
getStateJacobianImpl.m
Go to the documentation of this file.
1 #include "Constraint.m"
2 namespace models{
3 namespace muscle{
4 
5 
6 /* (Autoinserted by mtoc++)
7  * This source code has been filtered by the mtoc++ executable,
8  * which generates code that can be processed by the doxygen documentation tool.
9  *
10  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
11  * Except for the comments, the function bodies of your M-file functions are untouched.
12  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
13  * attached source files that are highly readable by humans.
14  *
15  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
16  * the correct locations in the source code browser.
17  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
18  */
19 
20 function Jg = models.muscle.Constraint.getStateJacobianImpl(uvwdof,double t) {
21 
22  sys = this.fsys;
23 
24  mc = sys.Model.Config;
25  fe_pos = mc.FEM;
26  geo = fe_pos.Geometry;
27  fe_press = mc.PressureFEM;
28  pgeo = fe_press.Geometry;
29 
30  N = geo.NumNodes;
31  M = pgeo.NumNodes;
32  dofs_pos = 3*N;
33  dofsperelem_pos = geo.DofsPerElement;
34  dofsperelem_press = pgeo.DofsPerElement;
35  num_gausspoints = fe_pos.GaussPointsPerElem;
36  num_elements = geo.NumElements;
37 
38  /* % Precompute the size of i,j,s for speed */
39  relidx_press = 1:dofsperelem_press;
40  totalsize = num_elements*num_gausspoints*dofsperelem_press;
41  i = zeros(totalsize,1);
42  j = zeros(totalsize,1);
43  s = zeros(totalsize,1);
44 
45  idx_pos = sys.idx_u_elems_local;
46  idx_press = sys.idx_p_elems_local;
47 
48  /* Include dirichlet values to state vector */
49  uvwcomplete = sys.includeDirichletValues(t, uvwdof);
50 
51  cur_off = 0;
52  for m = 1:num_elements
53  elemidx_u_glob = idx_pos(:,:,m);
54  elemidx_p = idx_press(:,m);
55  elemidx_pressure3 = [elemidx_p
56  elemidx_p
57  elemidx_p];
58 
59  for gp = 1:num_gausspoints
60  pos = 3*(gp-1)+1:3*gp;
61  dtn = fe_pos.transgrad(:,pos,m);
62  u = uvwcomplete(elemidx_u_glob);
63 
64  /* Deformation gradient */
65  F = u * dtn;
66 
67  Finv = inv(F);
68 
69  /* % Main node loop */
70  weight = fe_pos.GaussWeights(gp) * fe_pos.elem_detjac(m, gp);
71 
72  for k = 1:dofsperelem_pos
73  /* U_i^k = e_i dyad dPhik from script */
74  U1k = [dtn(k,:); 0 0 0; 0 0 0];
75  U2k = [0 0 0; dtn(k,:); 0 0 0];
76  U3k = [0 0 0; 0 0 0; dtn(k,:)];
77 
78  /* % grad u g(u) */
79  precomp = weight * det(F) * fe_press.Ngp(:,gp,m);
80  /* Assign i index as whole for x,y,z (speed) */
81  i(cur_off + (1:3*dofsperelem_press)) = elemidx_pressure3;
82  /* dx */
83  j(cur_off + relidx_press) = elemidx_u_glob(1,k);
84  s(cur_off + relidx_press) = sum(diag(Finv*U1k)) * precomp;/* #ok */
85 
86  cur_off = cur_off + dofsperelem_press;
87  /* dy */
88  j(cur_off + relidx_press) = elemidx_u_glob(2,k);
89  s(cur_off + relidx_press) = sum(diag(Finv*U2k)) * precomp;/* #ok */
90 
91  cur_off = cur_off + dofsperelem_press;
92  /* dz */
93  j(cur_off + relidx_press) = elemidx_u_glob(3,k);
94  s(cur_off + relidx_press) = sum(diag(Finv*U3k)) * precomp;/* #ok */
95 
96  cur_off = cur_off + dofsperelem_press;
97  end
98  end
99  end
100  Jg = sparse(i,j,s,M,6*N+M);
101  /* Remove values at dirichlet nodes */
102  Jg(:,sys.idx_uv_bc_glob) = [];
103 end
104 }
114 };
115 };
#define F(x, y, z)
Definition: CalcMD5.c:168
function J = getStateJacobianImpl(colvec< double > x,double t)
Default implementation of state jacobians. uses finite differences.
Definition: ACoreFun.m:424