I am using AceGen to generate source code for finite element simulations in AceFEM. I have elements with a very large number of vertices/degrees of freedom which can take a very long time to compile.

I know that in AceFEM the command SMTInputData["Threads" -> 16]; can be used to run the solver over 16 threads.

Is there an equivalent command that can be used for AceGen to allow for parallelization of the source code compilation procedure?

Thanks in advance!


1 Answer 1


AceGen already uses all kernels available when needed.

Why is your generation so slow can have several reasons:

  1. You are using a Mathematica command that takes all the time (e.g. Simplify). This would no be AceGen related problem.

  2. You are generating all components of tangent explicitly (e.g. SMSD[R,p]) for large number of DOFs. In this case you should make a loop and generate characteristic formulae (e.g. SMSDo[ SMSD[R,p,i], {i,1,nDOF}])

  • $\begingroup$ I am generating elements for a 2D linear elasticity problem and the stiffness matrix can be easily computed directly. (In the example I am dealing with it is preferable to compute the stiffness matrix directly rather than to derive the Residual and Tangent matrix from the potential energy.) $\endgroup$ May 12, 2021 at 12:36
  • $\begingroup$ In the formulation I create a matrix A that has dimensions $2nNodes \times 6$ from which I create a matrix B where B=IdentityMatrix[2nNodes]-A.SMSInverse[Transpose[A].A].Transpose[A]. It seems so be the construction of B that is slowing down the code generation. With the construction of B omitted the compilation takes 7 seconds for 4 nodes. However, with constructing B it takes 51 seconds. When nNodes gets to about 30 it can take a full day to compile. @JozeK @Pinti is there a way to speed this up? $\endgroup$ May 12, 2021 at 12:47
  • $\begingroup$ For almost all of the time the code is running there is a message from AceGen that reads 'Simplification of large expression'. Would it be faster if the large expressions were not simplified? If so, how could one prevent simplification? $\endgroup$ May 12, 2021 at 13:07
  • $\begingroup$ Changing from "Mode"->"Optimal" to "Mode"->"Plain" has about halved the compilation time, which is a big improvement. But the message 'Simplification of large expression' still comes up. Is there a way to force no simplification? $\endgroup$ May 12, 2021 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.