Giter Club home page Giter Club logo

waterflow-simulation-multithreaded's Introduction

Waterflow simulation

Table of Contents

Description

A multi-threaded implementation of a waterflow simulation that shows how water flows on a terrain flows downhill.

Live Demo

A live interactive demo can be found below.

Features

  • Display
     A main display window that shows the landscape as a greyscale image, with black representing the lowest elevation and white the highest. Overlaid on this should be an image representing the locations of water in blue. Note that although the water will have a depth, represented as an integer value, the colouring is the same uniform blue for any depth value greater than zero.

  • Buttons
     A ‘reset’ button that zeroes both the water depth across the entire landscape and the timestep count.
     A ‘pause’ button that temporarily stops the simulation.
     A ‘play’ button that either starts the simulation or allows it to continue running if it was previously paused.
     An ‘end’ button that closes the window and exits the program.

  • Multi-threaded processing
     The simulation is carried out by four threads each responsible for processing a random but final portion of the points on the list of grid positions.These threads are synchronised on each timestep. That is, no thread is ever allowed to start the next timestep of simulation before all others are complete. The program exhibits “fluid conservation”. Water can only be created through user mouse input and destroyed by reaching the boundary. The simulation itself is only responsible for moving water over the terrain.

Libraries Used

  • Java Abstract Window Toolkit (AWT)
  • Java's concurrency library

Project setup

To run this project make sure you have downloaded and installed java. Then run the Makefile with the commandsDownload and install Java.

make runLarge       // Runs simulation with large terrain (1024x1024 dimensions)
make runMedium      //Runs simulation with medium terrain (512x512 dimensions)

Future Scope

  • Add testing scripts to find and remove bugs
  • Add a counter that displays the number of timesteps since the start of the simulation
  • Add scripts to randomly generate terrains of any size for testing

Made with ❤️ with good ol' vim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.