# meshFlow

### meshFlow is an interactive 2D finite element solver designed for the Android platform. Try it out here!

Using meshFlow is easy: simply draw on the screen to add arbitrarily shaped solid objects to the domain, and let meshFlow solve and visualize fluid flows around them.

Under the hood, meshFlow automatically generates a 2D mesh around the objects, and then uses a finite element discretization to numerically solve the steady potential flow or the steady heat equation, depending on the user's choice.

Flow streamlines around a "peanut" shape

Temperature distribution with mesh

Temperature gradient magnitude

The app also offers options to control the resolution of mesh, and to visualize the flow solution or its gradient using a range of different color schemes. When solving the potential flow equation, meshFlow can also display streamlines and show particles moving with the flow. There's also an *interactive mode* where you can manually add particles to any point in the flow.

### What happens inside?

meshFlow first uses the constrained Delaunay triangulation algorithm to generate a triangle mesh around objects you draw. Then, a continuous Galerkin finite element method is used to discretize the equation of interest on the generated mesh.

This means that the solution to the partial differential equation is approximated by a continuous, piecewise linear function over the triangles of the mesh. However, in the case of solving the potential flow equation, the solution (i.e. velocity potential) is allowed to be discontinuous only across triangle edges that belong to the solid objects drawn by the user, allowing the fluid on one side of a solid "wall" to behave independently of the fluid on the opposite side.

Finding the solution to the fluid flow problem or the heat flow problem essentially boils down to solving Laplace's equation in two-dimensions, but with different boundary conditions.

Fluid speed visualization of a flow through a funnel (brighter regions are faster)

For the fluid flow problem, meshFlow applies Neumann boundary conditions to enforce zero normal velocities across solid "walls" drawn by the user. Non-zero Neumann conditions are applied at the left and right domain boundaries to create inflow and outflow conditions respectively. Although this results in a *pure* Neumann problem (all Neumann BCs) that gives rise to a singular linear system, we use a Krylov method (GMRES) to solve for the velocity potential solution that is unique up to a constant factor. This constant factor doesn't matter since it vanishes when we compute the gradient of the potential solution to compute the fluid velocity, which is what we're after anyway.

The boundary conditions used for the heat transfer problem are more straightforward. Imposing Dirichlet temperature boundary conditions along the objects drawn by the user and the domain boundaries simulates a scenario where heat conducts away from the "hot" objects to the "cool" domain boundary. This problem is well-posed, and the ensuing linear system can be easily solved by a variety of iterative methods.