unicfdlab / TrainingTracks

Materials for training tracks for continua media - OpenFOAM, vortex method, and other
86 stars 104 forks source link

FSI-RK2 #12

Closed Haider-BA closed 7 years ago

Haider-BA commented 8 years ago

What is the purpose of this implementation?

if (mag(Y_.first()) > = Ymax_) { Y_.first() = sign(Y_.first())*Ymax_; Y_.second() = (Y_.first() - Yold_.first()) / dt; }

If I would like to implement in plain C++ syntax (not in OPENFOAM), how can I do modify the RK2? I have defined my variables as: Ymid, Y0, Y and Vmid, V0, V, here 0: initial, If the initial location is offset from the center (not at 0.0,0.0), how to modify RK2 implementation?

unicfdlab commented 8 years ago

Hi, this code allows to limit Y displacement of the sphere.

Y.first() - Position Y.second() - Velocity

You don't need to modify your RK2 solver if your object starts to move from point different to (0 0 0)

Haider-BA commented 8 years ago

Thank you. One thing more to clear: If the object start to move from an arbitrary position (i.e. Xc, Yc), not from (0 0 0), then how and what part to modify? Where Xc = 0.5, Yc = 0.5 or any value other than 0.

unicfdlab commented 8 years ago

Hi, sorry for the late reply. If Xc = Yc = 0.5, then: 1) Center of the object in your mesh must be in the poing (0.5; 0.5) 2) Yold_.first() = 0.5 at startup

Haider-BA commented 8 years ago

Thank you for the reply.

Sorry, I forget to mention about my domain boundaries, they are [0,0] to [10,10]. Normally, the above is true when domain is extended in both positive and negative directions e.g [-1,-1] to [1,1]. In my case, the rest length for the spring (-kx) will be different that what I am confused with. What will be the "Yold_.first() or Ymid.first()" in the equation:

Ymid.second()= Yold_.second() + 0.5*dt*(-C_*Yold_.second() - K_*Yold_.first() + R_*yForce) / M_; Y_.second()= Yold_.second() + dt*(-C_*Ymid.second() - K_*Ymid.first() + R_*yForce) / M_;

I have attached an illustrative image to clear my point and want to modify the equations according to the sketched situation.

sketch1

unicfdlab commented 8 years ago

Hi, you don't need to change equations. Equations describes numerical solution of some ODE from some initial position. Just initialize your Yold_.first() with 5.0 in the class constructor or somewhere, where are you creating variable and reading data