dolfinx_mpc icon indicating copy to clipboard operation
dolfinx_mpc copied to clipboard

Possibility of periodic boundary condition for cylindrical polar coordinates

Open tbrandvik opened this issue 3 years ago • 10 comments

I am trying to implement a periodic boundary condition for the 3D elastic equation. The only difference compared to the existing example in the demos is that the boundaries are periodic in cylindrical polar coordinates (e.g. the slave nodes are at the same coordinates as the master nodes, but rotated through an angle). This leads to the following kind of relationship between the displacements of the periodic nodes, assuming the second node is the first node rotated about the x-axis:

$$ \begin{align} dy_2 &= a\cdot dy_1 + b\cdot dz_1 \ dz_2 &= c\cdot dy_1 + d\cdot dz_1 \end{align} $$

The coefficients (a, b, c, d) would be fixed and set by the rotation matrix.

I was wondering if anyone has any ideas on how to implement this with dolfinx_mpc? Any help would be greatly appreciated!

tbrandvik avatar Jul 21 '22 23:07 tbrandvik

You should be able to do this with https://github.com/jorgensd/dolfinx_mpc/blob/master/python/dolfinx_mpc/multipointconstraint.py#L97 where you use the relation function to map (x1,y1) to radial scaling * Rotation_matrix * (x1,y1).

jorgensd avatar Jul 22 '22 07:07 jorgensd

I think there might be a confusion. Indeed one can map (x1, y1) to (x2, y2) through some rotation but one should also enforce

(ux(x2, y2), uy(x2,y2)) = Rotation_matrix*(ux(x1, y1), uy(x1, y1))

I don't see how this could be achieved with the current functionalities since the dof corresponding to one subspace should be a linear combination of the subspace dofs at the opposite point

bleyerj avatar Jul 22 '22 08:07 bleyerj

That is not a periodic condition then, and you would need to make a custom function to do this (using for instance https://github.com/jorgensd/dolfinx_mpc/blob/master/python/dolfinx_mpc/multipointconstraint.py#L217-L245). A periodic condition (in my opinion) is:

ux (x1, y1) = ux(Rotation_matrix * (x1,y1))
uy (x1, y1) = uy(Rotation_matrix * (x1,y1))

jorgensd avatar Jul 22 '22 09:07 jorgensd

Alright, it is periodic with respect to the local tangent frame components, not the global ones.

But so with https://github.com/jorgensd/dolfinx_mpc/blob/master/python/dolfinx_mpc/multipointconstraint.py#L217-L245), I don't see a way of enforcing for one subspace_slave (e.g V.sub(0)) at point numpy.array([x2, y2], dtype=numpy.float64).tobytes() a linear combination of two subspace_master (e.g. V.sub(0) and V.sub(1)) at the same point numpy.array([x1, y1], dtype=numpy.float64).tobytes() Am I missing something ?

bleyerj avatar Jul 22 '22 09:07 bleyerj

The subspace_slave and subspace_master is just for convenience for cases where you can isolate the components. If you do not set these, it will work with dofs on the full space (dofs unrolled with block size).

jorgensd avatar Jul 22 '22 09:07 jorgensd

Got it. But then the coefficient alpha of the MPC equation is only a scalar or it can be a matrix with dimension block_size x block_size ?

bleyerj avatar Jul 22 '22 09:07 bleyerj

You would need to code each coefficient for each degree of freedom separately, i.e. for each (x1, y1) we have a slave dof_0(x1, y1)_x, masters dof_1(map(x1, y1))_x, dof_1(map(x1,y1))_y, we would have coefficients rotation_matrix[0,0], rotation_matrix[1, 0] (if I've not missed something).

jorgensd avatar Jul 22 '22 09:07 jorgensd

So I would set two MPCs for the same slave dof_0(x1,y1)_x :

  • one with master dof_1(map(x1,y1))_x with coeff rotation_matrix[0, 0]
  • one with master dof_1(map(x1,y1))_y with coeff rotation_matrix[0, 1]

would it "sum" both master contributions ?

bleyerj avatar Jul 22 '22 09:07 bleyerj

Maybe the create_general_constraint is not the right abstraction for your problem (I need to think about it) and revisit the code.

The most general way of adding a constraint is by using flat arrays with offsets indicating what dofs relate to another set of dofs: https://github.com/jorgensd/dolfinx_mpc/blob/master/python/dolfinx_mpc/multipointconstraint.py#L39-L61 which is easy in serial, but requires your own MPI communication to determine relationships in parallel.

jorgensd avatar Jul 22 '22 10:07 jorgensd

Thank you both for looking into this! I think I can see how it might be done using flat arrays so I will have a go at that for now.

tbrandvik avatar Jul 22 '22 16:07 tbrandvik