1 function F=f_assembly(A,X,u0,params);
3 % d = size(X,2); % dimensions
4 n = size(X{1}); % mesh size in nodes
5 nn = prod(n); % total nodes
9 F = zeros(n(1),n(2),n(3));
14 for ie2=1:n(2)-1 % loop over elements
17 % now in element (ie1,ie2,ie3)
18 % build the matrix of node coordinates to pass to hexa
19 for ic2=0:1 % loop over corners of the element
22 iloc=1+ic1+2*(ic2+2*ic3); % local index of the node in the element
23 % position of the node in the global grid
24 %kglo(iloc)=k1+n(1)*((k2-1)+n(2)*(k3-1)); % global index
26 Xloc(i,iloc)=X{i}(ie1+ic1,ie2+ic2,ie3+ic3); % node coordinate i
32 u0loc =[u0{1}(ie1,ie2,ie3),u0{2}(ie1,ie2,ie3),u0{3}(ie1,ie2,ie3)]';
37 [~,Floc,~]=hexa(A,Xloc,u0loc); % compute the local load vector
41 iloc=1+id1+2*(id2+2*id3);
42 k1 = ie1+id1; k2 = ie2+id2; k3 = ie3+id3;
43 F(k1,k2,k3) = F(k1,k2,k3) + Floc(iloc);