Git Product home page Git Product logo

mesh's Introduction

Mesh

Authors

Examples

make shallow_water
./shallow_water data/pond3.nodes data/pond3.tris 0

One can run the mesh on each of the three initial conditions by specifying 0 (a pebble ripple), 1 (a sharp wave), or 2 (a dam break) for the third argument of the shallow_water binary; by default it uses the DamBreak condition.

Also check out k-ye/mcmc-viz, which uses the mesh design to build a visualization tool for Markov chain Monte Carlo.

Description

Design Pattern

We store a Graph object templated with node value type (double by default) and edge value type MeshEdgeValue. MeshEdgeValue stores the left and right triangles of an edge (chosen such that the left triangle corresponds to the one left of the vector from node i to the node j, where i<j), and also the template E, which is the edge value type one originally stores in a graph edge (double by default).

The way we determine whether a triangle is on the left or right side of the edge is to calculate the cross product of the edge and the vector formed by the third node of the triangle. If the result is positive, then we will store the triangle to the right, otherwise it will be left. This is called Winged Edge Data Structure, which is a super efficient way of designing triangle-based mesh that allows every operation to be O(1).

We also store a vector of internal_triangle objects, whose index refers to a triangle's index, and the internal triangle data refers to the associated information for each triangle.

Iterators

In order to iterate through all the triangles inside a Mesh, we define a class called TriangleIterator. which stores a pointer Mesh* and a index_, which points to the index of triangle being visited currently in that mesh.

As for the iteration of all the adjacent triangles of Node and Triangle, we define a class called NodeTriangleIterator and TriTriangleIterator, which stores a pointer Mesh* and one or two indices in order to keep track of the iterative procedure during incrementing and dereferencing.

Initial Conditions

To avoid redundancy when setting up multiple initial conditions (and mostly for fun), we implement a Curiously Recursive Template Pattern. This constructs a base class from which each initial condition's class can inherit from, allowing the initial conditions to merely state the changes done onto node values, and then we run the same code to propagate this to the other values.

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.