# Centre of mass of eccentric objects rotated with rotateaxis

Following the example of RotatedBox (XML Guide page 61-62), within the section initials, after rotateaxis the command matrixreset throws an error *** Exception (JXml::ErrReadElement) Text: Error reading xml - Element 'matrixreset' is invalid. This is unlike the command rotate.

I then face this problem. Rotateaxis is much better than rotate because the particles are aligned with the object boundary rather than with the lattice axes. However, I do have a rotated object with eccentricity. Under the section floatings I need to give the coordinates of this centre of mass in some reference system.

If initials comes before floatings, I have rotated the reference system and apparently cannot undo it, as per above. So I think I should input the centre of mass in the modified reference system.

If in the code I put floatings before initials in the xml file, I would give the object's centre of mass in the lattice coordinate system, or whichever holds at that time. This is before the rotation I intend to apply.

What happens actually under the hood, and what is the correct way to set the eccentricity of a rotated object drawn with rotateaxis?

This is an derivative of a previous post on matrixreset at NB https://dual.sphysics.org/vanilla/discussion/1115/matrixreset-rotate

• edited June 13
You cannot use "matrixreset" within section "initials", only in "commands".

The sequence of operations is as follows:
1º) Points are drawn on a grid according commands in the section "geometry".
2º) Points became particles with some properties (position, velocity, density…).
3º) Position and other properties of selected particles are changed according "initials" section.
4º) Particles are used to calculate centre and inertia.

Therefore, you should not have problems when you rotate a floating body in "initials"
• This answer is really useful. The moments of inertia are calculated numerically based on the particle approximation of the floating object. Also, the link between the structure of the xml file and the logic of the algorithm has become clear.

If I customize the centre of mass and moments of inertia of a floating object by setting these attributes, I do see that DualSPHysics makes use of my settings from the difference in the simulation results. Pragmatically this is fine.

Physically, when a user has customized the centre of mass and the moments of inertia of an object, it is because the object's density is not distributed uniformly. Therefore, I presume, in the particle approximation of an object, the mass of the particles cannot be the same for all particles. Otherwise the density distribution would be uniform, defeating the purpose of setting the attributes 'center' and 'inertia'.

Then, the question closing the circle is: has DualSPHysics then built the object with a set of particles whose mass distribution matches my custom centre of mass and moments of inertia?

Side note. The companion post https://dual.sphysics.org/vanilla/discussion/1628/xml-guide-definition-of-attributes-of-rigid-objects has already clarified that the centre of mass and moments of inertia have to be given in the global reference system, even when you draw objects rotated with respect to it. This is consistent with the fact the solver enforces for the conservation of angular momentum around those axes. However, in that case, you cannot strictly say that moments of inertia are attributes of the floating object: they should be referred to the principal axes of inertia to be such, I am not wrong.
• In the closing sentence please read "I am not wrong" as "if I am not wrong", an interesting slip of the pen and of the eye. I do mistakes and am grateful for corrections.

• Hoping this helps picture the situation, I have drawn three prisms rotated differently with respect to the lattice/global reference system (GRS). The axes of the green block are parallel to it; the blue block has been rotated on the x,y plane; and the red around a generic direction. These are three common but general situations.

We can assume that, across the blocks, the mass distribution is the same. This distribution is not uniform inside each block though. The centre of mass, shown as a small sphere, is eccentric. The orientation of the principal axes of inertia with respect to each block will be the same; I have drawn these, although they are barely visible.

Say the picture represents the initial condition of a fluid-structure interaction problem. Clear from the xml guide that I can customize the values of the moments (attribute inertia) or even the components of the inertia tensor (attribute inertiafull). This will hold as an initial, design condition.

The understanding is that the moments of inertia are computed numerically from the set of particles with which the object have been approximated. The issue that we have been zooming in is how DualSPHysics builds the mass distribution inside these blocks, so that the moments of inertia are computed consistently as the flow develops.