# AceGen: Assemble a user specific global array (similar to "Residual")

I have an issue which I know is definitely solvable but I don't know how to implement this in AceGen.

Basically, I want to assemble a matrix $$\mathbf{L} \in \mathbb{R}^{n_{dof} \times 6}$$ for a global system of equations with $$n_{dof}$$ degrees of freedom (without applying essential boundary conditions). This can be calculated by assembling the element contributions $$\mathbf{l} \in \mathbb{R}^{n_{st} \times 6}$$, where $$n_{st}$$ is the number of nodes per element $$n_{nodes}$$ times the dimensionality of the problem $$n_{dim}$$ (e.g. 2D or 3D), therefore $$n_{st} = n_{nodes} * n_{dim}$$.

The assembly of $$\mathbf{L}$$ is done exactly how we would to it for the "Residual" $$\mathbf{R}$$ using the element contributions $$\mathbf{r}$$, only with multiple columns. Luckily, applying SMSD on the energy function and exporting it using SMSIO does the job for the residual.

Now, I have implemented the element contribution $$\mathbf{l}$$ and just want to assemble it to the global array $$\mathbf{L}$$ of the mentioned size....

• Do I have to work with SMSIO right at the place where I assemble the stiffness and the residual? If yes, how do I tell AceGen that I want a custom array (which keyword?) and how would the command look like?

• Can a user defined SMSStandardModule["Task"] be used for this? In the documentation, it is suggested to work with task type =4 for a vector (or task type =5 for a matrix). Again, using SMSIO there is an option for exporting the Task local vector for the task type =4. I tried to use the example from the documentation and included the first column of my element vector le:

SMSIf[task == -4, SMSIO[{4, 0, 0, 0, 0}, "Export to", "Task data"];
SMSReturn[];];
, SMSIO[le[[All, 1]], "Export to",
];


Unfortunately, all I get is a Syntax error for the initialization (task == -4). What exactly do I have to pass as information?

Hope that I could explain my request sufficiently. Any advice is appreciated!

EDIT: I think the Syntax error is not related to the initialization but to the actual export (second SMSIO):

"Export to" syntax error.
User subroutine: Tasks Description: Value:   {$V[1121,1]$V[1222,1],$V[1122,1]$V[1223,1],0,$V[1124,1]$V[1222,1],$V[1125,1]$V[1223,1],0,$V[1129,1]$V[1222,1],$V[1130,1]$V[1223,1],0,$V[1131,1]$V[1222,1],...}
Events: 6 BP2-4+28 SMSDB-0
Version: 7.102 MacOSX (28 Mar 20) (MMA 11.2) Module: SMSIO

SMSIf[task == -4, SMSIO[{4, 0, 0, 0, 0}, "Export to", "Task data"];SMSReturn[];];