GithubHelp home page GithubHelp logo

fdm_wave's Introduction

fdm_wave

Implementation of a finite difference stepper for the wave equation with SIMD optimization.

Currently only the following are supported:

  • methods

    • central-in-time, central-in-space finite difference discretization
  • boundary data

    • zero Neumann boundary data

Simple example

The following code advances the solution by performing one step of the finite difference method for the wave equation with zero Neumann boundary data, with given dt and dx. v is the current solution, and u is the solution at the previous time step, and w is the new solution. The dimension of the mesh is (2, 2) = (rows, columns). Arrays are stored in the row-major order (C order).

extern crate fdm_wave;

fn main() {
    let u = vec![1., 2., 3., 4.];
    let v = vec![3., 2., 1., 4.];
    let mut w = vec![0.; 4];

    let dt = 1.;
    let dx = 2.;

    fdm_wave::wave_step(&u, &v, &mut w, (2, 2), dt * dt / dx * dx);

    println!("{:?}", w);
}

Usage

This crate works with Cargo. Add it to Cargo.toml as

[dependencies.fdm_wave]
git = "https://github.com/rekka/fdm_wave.git"

To use the SIMD-optimized routines, you need to use a nightly compiler and add the simd feature:

[dependencies.fdm_wave]
git = "https://github.com/rekka/fdm_wave.git"
features = ["simd"]

Supports SSE2 and AVX. Make sure that you are passing correct flags to Cargo/rustc (target-cpu=native; possibly using RUSTFLAGS).

The SIMD versions are mainly useful for small problem sizes. The algorithm is limited by memory bandwidth if it spills out of caches.

License

MIT license: see the LICENSE file for details.

fdm_wave's People

Contributors

rekka avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

shabbirhasan1

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.