Tuesday, August 25, 2015

Improved Runtime

Developers at Flow Science are constantly working to improve the performance of our solver. We want to provide our users the same experience, i.e., accuracy and ease of use of FLOW-3D and FLOW-3D Cast, but with shorter runtimes. In the upcoming releases - FLOW-3D v11.1 and FLOW-3D Cast v4.1 - the results are the same, but the computational time is significantly reduced.

Performance and Optimization

Before I jump into the results, I would like to provide some insights into the typical process of performance optimization of a code. Performance analysis involves finding the bottlenecks - the parts of the code that slow down the calculations the most. Code profiling techniques help us identify if a specific function has performance issues.

For example, we have three functions in our code – funcA, funcB and funcC. When we profile the code we will know how much runtime is spent in each of these functions. Let’s say that funcA eats up 90% of the runtime, while the other two functions take the remaining 10%. In such a case, it only makes sense to target funcA. We can target other functions, but the returns on optimizing funcA will give the best results.

Finding the Bottleneck

Profiling showed that for most applications the pressure solver in FLOW-3D was the most computationally intensive component (typically about 30-40% of total simulation time). Also, for Fluid Structure Interaction (FSI) problems, the FSI solver was found to consume a large chunk (70-80%) of the total computational time, dwarfing even the time spent in the pressure solver. Because the pressure solver is used more widely, we decided it would benefit more of our users to optimize it first.

Optimizing the Solver

Optimization is the second step towards improving the overall runtime of the code. While there are many techniques involved in optimizing a certain segment of the code, the most important ones for this development were:
  • Optimizing vector-vector calculations
  • Optimizing matrix-vector calculations
  • Storing the sparse matrix in an efficient and compact way

Improvements in Runtime

Different tests were conducted after the optimizations were made. They are represented by the bar graphs below.

Computational time for a 1.3 million cell weir simulation

Figure 1. Computational time for a 1.3 million cell weir simulation with FLOW-3D v11.1

In Figure 1, ITMIN is the minimum number of iterations of the pressure solver. Irrespective of the number of iterations there is a decrease in elapsed time compared to the original solver. But as the number of iterations increase, the performance gains are more significant. For ITMIN=10, the elapsed time has dropped down by more than 50%. Figure 2 shows some real-world applications where significant improvements in runtimes are observed.

Computational time comparisons

Figure 2. Computational time comparisons for some typical real-world applications of FLOW-3D

How Will Users Benefit?

Pressure solver is a critical component of the overall fluid dynamics equations solver because of its use in most CFD applications. Therefore, this new development in FLOW-3D v11.1 and FLOW-3D Cast v4.1 will save valuable time for our current and potential users. This is not the end of it, though. As I am writing this post, our developers are working on further optimizing the pressure solver and have plans to apply the same techniques to increase the speed of FLOW-3D’s finite element (fluid-structure interaction/thermal stress) and core gas solvers.

Tuesday, August 18, 2015

Active Simulation Control

Editor's Note: In the next few months, we will be rolling out a series of blog posts announcing the new developments that will be released in FLOW-3D v11.1 and FLOW-3D Cast v4.1. Subscribe to the Flow Science blog to receive updates on developments such as Active Simulation Control, new Squeeze Pin and Mooring Lines models, an interface to add raster data to your simulations, decreases in runtime, and more straight to your inbox.

When design stage is critical

Many real-world processes involve actions that are triggered when a certain design stage or any prescribed objective or limitation is reached, independent of real timing. Active Simulation Control is a powerful new feature in the upcoming release of FLOW-3D v11.1 that allows users to decide the course of a simulation depending on the design stage of the process. The motivation behind this new development was to extend the idea of probe-controlled events to general objects in order to make simulation control more flexible and robust, hence the name "Active Simulation Control."

What makes Active Simulation Control so powerful?

Active Simulation Control was developed to give users greater flexibility to control their simulations. The focus of the simulation is shifted from determining the exact real time of triggering an event to controlling the design stage of the process. Users can now set an action to take place whenever a certain objective is attained, be it a certain percentage of fluid, fluid velocity, fluid depth or any variable that can be conceived. Active Simulation Control works using the following simple rules that, combined, provide a flexible and powerful feature to users:

  • A component/object can have multiple probe-controlled events
  • An event can be triggered by multiple probe conditions
  • An event can contain multiple actions

There are more options such as the choice of logic condition between multiple probe conditions. These logic extensions allow the user to accurately and efficiently simulate real-world design stages.

Is this feature difficult to implement?

v11.1 allows user to intuitively use the new feature through its graphical users interface. Setting up Active Simulation Control involves a simple two-step process.

  1. Create a probe that records the value of a variable
  2. Set up the event that will be triggered when the value of recorded variable at the probe reaches a certain (or range) of value(s)
    Yes, it is that simple!
    What does the new feature look like?

    The Active Simulation Control window pops up from the Events tab
    The Active Simulation Control window pops up from the Events tab
    The Active Simulation Control window pops up from the Events tab (in red ellipse).

    Active Simulation Control Window
    Active Simulation Control Window

    The window above shows one event that is triggered when History Probe 1 detects that the free-surface elevation is greater than or equal to 221. If that happens then the solver will impart a velocity to the chute gate without any time delay (instantaneous action). Event condition logic allows the user to choose if the action should be triggered when only one of the events happen or any or all. Yet again, very flexible.

    Is there a detailed example with results?

    Yes, we have put together an example from the high pressure die casting industry as just one of many examples of how you can use Active Simulation Control. High pressure die casting is the typical process for casting complex, thin-walled parts such as transmission covers, alternator housings and other intricate shapes. In the HPDC process, molten metal is poured into a shot sleeve and a plunger forces the metal into runners that feed the metal into the cavity of the die. A significant challenge in the HPDC process is moving the plunger in such a way that the metal initially begins moving without entraining a significant amount of air. However, once the metal reaches the gates, the plunger is moved very rapidly to atomize the melt and fill the part quickly. This phase is called "transition to fast shot."


    The determination of when the plunger motion should be transitioned to a fast shot varies between different manufacturers but is generally based on a point in time when metal has arrived at all the gates. Active Simulation Control is a great tool for this purpose. In this example, this condition can be detected by placing history probes in the gates and detecting when the fluid fraction at all probes is greater than 0.5. Active Simulation Control automatically detects when transition to fast shot should occur and changes the plunger velocity without requiring the user to analyze the results, determine the appropriate time, and then restarting the simulation.

    Events and Actions

    In our example, an HPDC simulation of a pump cover is shown. The initial plunger motion is completed using the Barkhudarov method available in Utilities menu under Calculators, Shot Plunger Speed, to minimize air entrainment. Probes are defined in each of the four gates to monitor the arrival of metal. Once metal has reached all four gates, fast shot phase is automatically initiated.
    Another useful feature of Active Simulation Control is the ability to change the output frequency when the fast shot begins to capture the rapid filling sequence once the fast shot begins.

    The Results

    In the animation above, three views of the filling are shown. In the lower left corner, the full geometry including the part, the runners and gates, and the shot sleeve are visible. A view of just the gates with the probes (red balls) is shown at the bottom. Plots at the top of the screen show the fraction of metal at the probes in the gates and the plunger velocity. Notice that the transition to fast shot automatically occurs when the metal reaches the gates as specified by Active Simulation Control. A time dial - a unique feature of FlowSight - is shown on the lower right. The dial is useful for indicating the progression of time during fast shot. Once the fast shot begins, the output rate becomes very fast.

    Monday, March 17, 2014

    Combined Sewer Overflow (CSO) hydraulics

    Today's post is about a simulation for a municipal application. I usually draw on work-related inquiries for these blog posts, and this week a municipal design consultancy called asking about how we handle the combined sewer overflow problem (heads up the answer is very well!). Typically there are two important aspects, one is understanding the straight hydraulics in both a transient and a steady state sense, the other is the characterization of particulate dynamics in the flow stream. In this case, the interest was purely on understanding the hydraulics under various upstream water elevations and pressures, in both free stream and fully pressurized conditions.

    Geometry of interceptor sewer with regulator vault access in
    the far back. Flow enters from left, all walls not shown.
    The 'lay of the land' here is that we have an interceptor sewer carrying the flow under potentially free surface or pressurized conditions. A T-junction allows some of the fluid to make its way to a regulator vault which can then discharge some of the fluid into a separate culvert through a vertical drop-shaft.

    To clarify the geometry I created a rotating animation so that you can see the inflow, the regulator vault and the drop shaft where some of the fluid exits into an underlying culvert from different viewpoints:

    I ran two scenarios. In the first scenario we begin with a stagnant low level of fluid in the main sewer, then adjust the inflow boundary condition with time to simulate a rising water level. Initially this only increases the flow rate and fluid elevation in the interceptor sewer. At a given height the water begins to 'overflow' into the regulating vault section of the structure. The fluid then exits into the culvert.

    This animation shows some additional filling detail:

    In the second scenario, we restart the simulation once the fluid occupies the full volume of the interceptor sewer, and then continue to increase to upstream pressure: the sewer interceptor now operates under pressurized conditions. What is interesting to observe here is that while the sewer interceptor chamber now runs under fully pressurized, confined flow conditions, the regulator vault continues to operate under free surface conditions due to the limiting effect of the regulating slide gate.

    Finally, although this wasn't asked for, it is noteworthy that particle tracking can be included in the analysis. FLOW-3D can assign particle sources of different sizes and densities and fully couple their behaviors with the hydraulics of the flow. We can use particles as tracers of course, but more dynamically sophisticated behaviors are equally straightforward to implement.

    As always I encourage you to sign-up (top right of the page) so that you will be notified of future posts!

    I leave you with a link to an interesting read on a related topic, "Testing a Complex Hydraulic Design of a Sewer Transition with FLOW-3D. Comparison with a Physical Model," by Daniel Valero, Rafael García-Bartual, Ignacio Andrés and Francisco Valles of the Polytechnic University of Valencia.

    Hydraulic Design of a Sewer Transition

    cheers all

    john wendelbo

    Monday, February 24, 2014

    Thermal Plume Analysis using FLOW-3D

    FLOW-3D Model Setup - Two power-plant outflow ducts
    are located near the power-plant on the left bank.
    Hello again. I received an inquiry this week about our ability to model the near field structure of thermal plumes, generated by the discharge of warm waters from power plant cooling systems.

    The framework of this request was the EPA 316(a) and (b) set of regulations, and in fact these modeling methods for thermal plumes are very closely tied to those used to evaluate the hydraulic zone of influence (HZI) of Cooling Water Intake Structures (CWIS). You can learn more about modeling HZIs by downloading this webinar which presented last December (YouTube link here if you want the audio!)

    Getting back on topic, FLOW-3D resolves the Navier Stokes equations including detailed free-surface dynamics, in 3D and with a number of advanced turbulence models available, and also fully couples density changes (via temperature changes, varying initial conditions, or changes in salinity, turbidity, etc). In addition, spatial scales of tens of kilometers upstream or downstream nowadays are very efficiently handled in high detail, no need to simplify anything down to 1D or 2D models, certainly not on the basis of computational time, that rational simply no longer exists.

    "Lay of Land" - Bathymetry and geospatial layout of the power-plant, ducts, bridges and weir.
    I might add that what I have witnessed (over and over from running similar simulations) is that these flows, in particular the thermal structures (or indeed upstream entrainment probability maps) are in fact highly three dimensional: the vertical structures and distributions of flow parameters are anything but uniform through the water column, and the detail of the bathymetry is very significant. My take home message here is to use a 3D solution in order to model these phenomena accurately.

    This said, even if the flow characteristics turn out to be complex, these types of simulations are actually quite straightforward to set up in FLOW-3D. In particular our free gridding approach to meshing fluid and solid quantities makes not only the setup, but also subsequent modifications in the parameter space (such as flow conditions or new geometric configurations) extremely efficient: whether it's the initial meshing of the problem, or subsequent iterations, the meshing operations are in all cases minimal.

    Thermal Plume Map, in the fluid (left) and on the river bed (right indents)

    In this example the bathymetry represents a junction in the San Antonio River, and I added some detail (the power plant, the exhaust ducts, exhaust volume flow rates and densities), and turned on the additional physics that relate to thermal plumes (density evaluation, turbulence model, and mass sources), not much to it!

    Typically then we would look at the three dimensional temporal and spatial distributions of the fluid density or temperature (in this case I used density as a proxy), and then maybe would take some 2D plane cuts to get a sense of what regions are affected and when.

    What I found really interesting is that FlowSight (FLOW-3D's next generation post-processor) allows you to color components (rather than fluids, i.e., the river bed itself) by fluid property on the contact surface.

    What this means is that we can very easily map the regions of the river bed which will be affected by the thermal plume. If you are looking at benthic communities, this is the way to do it!

    Here is an animation of the result of this simulation. If you click on the little full screen icon (bottom right of the video) you will get a better view of what is going on. The right hand side window is a view of the fluid with the exhaust's thermal signature, as is the top left window, the middle left is a 2D vertical plane cut just downstream of the bridge, and the lower left window is that view I mentioned, where we see the thermal signature on the river bed itself, as opposed to in the fluid.

    In conclusion, if mapping thermal plumes is your business, I would say FLOW-3D is a pretty phenomenal tool to conduct such studies, for its accuracy, robustness and speed, but also for the ease of use and simplicity in model setup, and of course the ease with which one can visualize and analyze results!

    Cheers all, until next time, any questions feel free to write directly.

    John Wendelbo

    Sunday, February 9, 2014

    FLASH FLOOD Simulation using FLOW-3D

    Topography used in this study, the top layer is porous,
    the lower layer is bedrock
    Today I found myself curious about flash floods. As FLOW-3D users already know we usually do very well for extreme event modeling, complex free surfaces, etc. Oddly enough the first question was, could we model precipitation? Historically our code hasn't particularly been used for flood plain/watershed type problems. I presume mostly because 2D solutions work just fine for the most part, and so I took a morning out of my week to sort this out, the result I thought was exhilarating! In the case of flash floods my conclusion is we do it very well (and are very effective computationally).

    The two main models used here are the mass source and the porous media models.

    Initial condition before rainfall*
    The way this simulation is set up is that we have a topography with an upper layer which is a porous media, this layer overlaps a bedrock which is impermeable. In addition the upper layer is defined as a source of fluid on its upper surface. In this simulation I am modeling a flash flood with intense precipitations lasting 180 minutes. The lower layer is bedrock, and as expected initially, the flow is governed by both seepage into the upper, permeable layer and the usual advection/Navier Stokes behaviors. Once the permeable layer is saturated, we start seeing more of the surface water dynamics, which in turn turn lead to torrential flows down in the lower elevations of the canyons.

    Intermediary stage, the ground is still
    mostly soaking water
    Valuable, actionable information is easily visualized as a result of the effort. In this case we simulated two situations concurrently: the run-off and subsequent torrent formed in a canyon (to the right of the domain), and the run-off from mini-canyons into an adjacent pre-existing body of water (to the left of the domain).

    The precipitation map can be fully defined both spatially and temporally across the entire domain, and porous behaviors can be modeled both for saturated and un-saturated media.

    Torrent formations following heavy precipitation. Note the water pooling and main torrent formation in the canyon on the right, and the strands of heavy discharge into the pre-existing body of water on the left.
    Here is the animation of the event:

    You can also view the video on youtube here.

    Finally it's very interesting to look at the time series of water depth located at a probe placed near the lower end (elevation wise) where I was expecting to see the great volume flow and water pooling. Initially, while the porous layer is actively absorbing water, we see no surface water pooling. Then once the layer becomes saturated, we observe a rapid increase in water depth, until we finally observe the steady state balance between the influx of precipitation and the outflow via the torrent.

    Finally I note that you can be a lot more sophisticated with the mapping of the precipitation rates by simply tiling your domain into various sub-components (they can be of arbitrary shape by the way):

    Cheers all, don't forget to sign-up for email updates (top right of this page) if you want to be notified of future posts!


    *All simulations post-processed with FlowSight, coming soon in FLOW-3D v11

    Type II spillway modelization

    As customary for a first blog post, hello world!

    This spillway was designed following USBR guidelines (type II), where the engineers were interested in validating their designs without having to resort to physical lab models (expensive, and which also have their own sets of scaling problems).

    The steps to analyze these types of problems in FLOW-3D are straightforward:

    Post-processed with FlowSight, coming soon in FLOW-3D v11
    • Generation of a 3D CAD model based on the design blue prints (I happen to use Rhino3D, works pretty well for me)
    • Geometry import in FLOW-3D in the STL format
    • The usual FLOW-3D simulation steps:
      • set the boundary conditions
      • set the initial conditions
      • choose your physical models (in this case turbulence and air entrainment)
      • choose your outputs (hydraulic quantities, Froude #, etc.)
    In the case of spillways, which have fairly large spatial scales compared to the water depth, it is EXTREMELY advantageous to use the code's domain removing capabilities. The best way to do this is to follow a 4 step approach:
    1. Run the simulation with a coarse grid. This run will take 10 minutes at most, and even if this won't catch the full manifestation of the hydraulic jump, it will be enough to give you a good idea of where the fluid regions will be active.
    2. Equipped with that information go back into your CAD package and create a domain removing solid which conforms reasonably well with the complement of your fluid form (my method is to super-impose a picture of the simulation result within my CAD model).
    3. Add this new solid component to your simulation as a domain removing component.
    4. You can now massively crank up the resolution of your simulation to fully capture the detail of the energy dissipation mechanism in good detail. 
    You can watch the video on youtube here!

    cheers all