Adding new modules

edited May 2014 in Old versions
Hi,
How would one go about adding a new behavior to the code? I mean, if I have the appropriate formulas and kernel functions, where can I define them and how can I associate some particles to follow one behavior and some another?
Basically what i'm asking is - is it possible to add new material behaviors to the code and if so can you include a sort of tutorial on what to add and change in order to do so?

Thanks in advance

Comments

  • Hi,

    Could you be a little more specific when you say "new material behaviours".

    Are we talking simple stuff like a different viscosity function or are we talking something more complex like a completely new kernel type?

    Introducing new, per-particle, materials is not that hard with the 3.0 code, within the framework of the existing SPH formulations, however if you want to introduce something more complex then things get more tricky.

    Best regards.
  • Thanks you so much for the quick response!

    I was thinking about adding an SPH implementation for elastic material behavior as described in the papers: "A Unified Particle Model for Fluid-Solid Interactions" and "Corotated SPH for deformable solids". This means adding a few simple calculations plus a new kernel function to be used.
    The goal is to be able to simulate a system with both fluid and elastic bodies.
    The formulation itself is pretty simple, so I'm wondering how difficult would it be to implement it in the DualSPHysics engine.
  • Hello,

    OK, this is something I have done quite extensively myself recently, I am going to assume you mean the GPU code, if not the same applies for the CPU code its just a little less complex.

    It is worth pointing out that you need to be careful about what exactly you are trying to model when it comes to elasticity, I'll just assume you know what you need in that regard.

    In terms of adding additional functionality, this is fairly easy to do in DualSPHysics 3. You need to first get to grips with the "Code" array, which allows you to pick out specific groups of particles based on their type (i.e. fluid/boundary) and their id "Mk" value, as defined in the original GenCase XML file. There are plenty of examples of this being used in the code.

    Once you know this, I would say your biggest challenge will be how to handle interaction between the elastic object and SPH fluid particles. Just re-using standard SPH kernel interactions may not be sufficient, depending upon what your chosen method needs (i.e. if you just need the momentum due to force at a particle, you may be OK but if you need to know more, i.e. angular momentum then you may need to define your own contact mechanism). Effectively though, I would suggest what you want to do is create your own set of CUDA kernels (not SPH kernels) and re-use the existing data structures.

    The thing to bear in mind is that all evolving particles arrays such as position, velocity etc. are sorted using the thrust radix sort into natural order at the end of each time-step, so if you createany new arrays of this type (i.e. perhaps one to store pressure for example) then you need to make sure you re-order that as well, follow the code for example.

    You need to follow forward from the basic run loop in JSphGpuSingle.cpp and find out where everything is called and then add your own kernel functions for the elastic particles either before or after the fluid particle force kernels are called, then probably work out a way to make the particles interact, just make sure you have accumulated all forces on all particles before you come to apply time-integration and also make sure that the second-order symplectic (or modified velocity-verlet) scheme that DualSPHysics uses is suitable to handling your new elastic method, it should be as SPh is never better than second order, but it's worth checking. You will also have to introduce new time-stepping criteria to handle the elastic portion as forces in elastic models are typically far higher and demand smaller time-steps than for pure fluid.

    Best of luck!
  • Ok, i'll definitely look into it and report back the findings.
    Thanks again!!
Sign In or Register to comment.