Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. What will be the height of fluid columns in a variable width cylinder

What will be the height of fluid columns in a variable width cylinder

Scheduled Pinned Locked Moved Algorithms
algorithmsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Som Shekhar
    wrote on last edited by
    #1

    Assume that there is a vertical cylinder with a diameters as follows 1cm at base 3cm at the height of 2cm 2cm at the height of 4cm 1cm at the height of 7cm etc etc Now, what would be the height of different colored fluid columns one over the other (Assuming there are no other forces). The columns are on top of each other and movable by drag and drop. Hence the calculation of each column depends on the bottom column. Its not necessary to consider volumetric analysis because the solution could be in 2D for area also. The function should take parameters of volume/area of each column at which it starts. This is required for a graphical application where the movement of a liquid is shown in 2D. I am looking for a faster alternative to "for" or "while" loops. It needs to be very fast so that a fluid motion could be achieved. Current algorithm is damn slow. my current solution looks like:

    while (volumeToAdjust > 0)
    {
    volumeCovered = Min (volumeToAdjust, volumePossibleInCurrentWidth)

    if(volumeCovered>volumePossibleInCurrentWidth)
        height += heightForCurrentWidth
    else
        height += CalculateHeightForThisVolumeInCurrentWidth
    
    volumeToAdjust -= volumeCovered
    

    }

    This solution works fine for a single column of fluid. Multiple columns, multiple widths, the program slows down. Any better ideas?

    D 1 Reply Last reply
    0
    • S Som Shekhar

      Assume that there is a vertical cylinder with a diameters as follows 1cm at base 3cm at the height of 2cm 2cm at the height of 4cm 1cm at the height of 7cm etc etc Now, what would be the height of different colored fluid columns one over the other (Assuming there are no other forces). The columns are on top of each other and movable by drag and drop. Hence the calculation of each column depends on the bottom column. Its not necessary to consider volumetric analysis because the solution could be in 2D for area also. The function should take parameters of volume/area of each column at which it starts. This is required for a graphical application where the movement of a liquid is shown in 2D. I am looking for a faster alternative to "for" or "while" loops. It needs to be very fast so that a fluid motion could be achieved. Current algorithm is damn slow. my current solution looks like:

      while (volumeToAdjust > 0)
      {
      volumeCovered = Min (volumeToAdjust, volumePossibleInCurrentWidth)

      if(volumeCovered>volumePossibleInCurrentWidth)
          height += heightForCurrentWidth
      else
          height += CalculateHeightForThisVolumeInCurrentWidth
      
      volumeToAdjust -= volumeCovered
      

      }

      This solution works fine for a single column of fluid. Multiple columns, multiple widths, the program slows down. Any better ideas?

      D Offline
      D Offline
      Dr Walt Fair PE
      wrote on last edited by
      #2

      Do the diameters change or can they be hard coded? What happens in between the values you gave? Is the diameter constant or tapered?

      CQ de W5ALT

      Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

      S 1 Reply Last reply
      0
      • D Dr Walt Fair PE

        Do the diameters change or can they be hard coded? What happens in between the values you gave? Is the diameter constant or tapered?

        CQ de W5ALT

        Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

        S Offline
        S Offline
        Som Shekhar
        wrote on last edited by
        #3

        Yes diameters can be changed. Also, the volume of each fluid column and their sequence can be changed by drag and drop. That is why the need of an algorithm to do it the fastest way. Diameters are not tapered.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups