# User Task evaluated after SMTAnalysis[]

Say I'd like to compute values within my element, related to the centre of mass(COM) of my domain. Therefore I need to know the coordinates of the COM in advance. This can obviously done in Mathematica as well and then given as an input into the element. However Id like to compute this directly within the element. For this purpose the Area of the domain must be known in advance. Access to the AceFEM data fields is needed, as this computations involve for example the nodal coordinates at element level (numerical integration) and because I need to summarise my results of all elements over the whole domain, as indicated by the code:

SMSExport[w detJ , ed$$["Data", 2], "AddIn" -> True];  Thus the procedure is as follows: 1. SMTAnalysis[] 2. Call a Task to compute the Area of the domain 3. Call a Task to compute the COM of the domain 4. Call SKR for the actually computation (part of SMTNewtonIteration[]) As yous see I've already developed a procedure which uses the SMSStandardSubroutine["Tasks"], but they have to be called manually after SMTAnalysis[]. Now I wonder wether it is possible to automatize this procedure, such that it is more prone to errors, as if I forget to call one of these tasks or choose a different order, the results are wrong. Thanks for your replies. in advance :) • I am sorry but I don't understand what are you trying to achieve. Could you please expand your question, possibly with a small example? Have you checked documentation section on "User defined tasks"? – Pinti Apr 11 '18 at 6:47 • Good Morning Pinti, my perfect whish is to define a separate module in my element which can access and modify the AceFEM data fields such as ed$$ es$$nd$$ etc, and which can be called automatically after SMTAnalysis[]. Maybe also a flag like SMSPreIterationCall would also do it. – Sascha Maassen Apr 11 '18 at 6:49
• I am still not sure if I understand... It would be definitely helpful if you edit your question with some description of "big picture". Maybe you don't even need to modify es$$ data fields? – Pinti Apr 11 '18 at 7:04 • Regarding the your last paragraph: Why don't you wrap the analysis input phase and all calls to "Tasks" in another function, so they will be always executed in the same order? – Pinti Apr 11 '18 at 8:31 • Cause that would require additional Mathematica code to be defined which need to be present also when sharing my code. I see your solution idea but the whole question refers more to like "the most convenient" implementation of such a procedure others than the actual solution. – Sascha Maassen Apr 11 '18 at 8:34 ## 2 Answers I think it is not possible to compute centre of mass (COM) of the whole domain from within the element (AceGen code), because the assembly procedure is done independently for each element. One can also say that the element is not "aware" of its neighbors. A possible alternative is to calculate COM of the domain in Mathematica and update corresponding material data fields (es$$) in each step.

• I agree to your arguments. This is why I do this within an own Module and export the results to a "shared" field like "es" using "AddIn"-> True. – Sascha Maassen Apr 11 '18 at 8:32
• Pinti thank you very much for your effort and suggestions (y). Below I posted my final solution so far. – Sascha Maassen Apr 11 '18 at 8:43

Just found a nice way to do this, by including the Task calls within the SMSMMAInitialisation as part of my element template.

, "SMSMMAInitialisation" -> Hold[SMTTask["Area"]; SMTTask["CentreOfMass"];]