Giter Site home page Giter Site logo

thomasthelen / finite-difference-method Goto Github PK

View Code? Open in Web Editor NEW
28.0 5.0 6.0 8.03 MB

A Finite Difference Method Engine in C++

License: MIT License

C++ 97.90% CMake 2.10%
finite-difference finite-difference-method finite-differences partial-differential-equations diffusion-equation heat-equation heat-transfer fdm numerical-methods numerical-calculations numerical-computation numerical numerical-integration

finite-difference-method's Introduction

alt text

The project has reached a stable, usable state and is being actively developed. license CodeFactor

FDM

FDM is a C++ source library that exposes an engine for running the method of Finite Elements across one dimension. This is mostly a personal exploration of The Finite Difference Method, CUDA, and Python Bindings.

Using

To use the engine, git clone the repository and include the required headers in your source file. Examples are given in the examples directory.

Building

To build, run cmake .. and cmake --build . from the build/ directory.

Source

The project has a few directories to separate various parts of the project, detailed below

  • build/: Contains the build output
  • examples: Examples of how the library can be used
  • src: The source code for the engine

Overview

The Mesh struct manages information about the object being simulated over. There's an associated Mesh class for each dimension. For example, one dimensional simulations should use 1DMesh.

Mesh

The Engine class parses information from associated mesh and is responsible for encapsulating the routines for the Finite Difference Method.

Engine

Creating Simulations

A successful simulation will have both a Mesh and an Engine class instantiated.

The mesh must have the following defined,

mesh.spatial_length = 10;
mesh.spatial_step_size = 1;
mesh.thermal_conductivity = 0.01;
mesh.DirchletBoundaryEquation = BC;
mesh.InitialDistribution = InitialRodDistribution;

The boundary condition must be a function with the signature

double BoundaryCondition(double x, int time)

For example,

double BoundaryCondition(double x, int time)
{
	return 15*x+t/2;
}

The initial distribution method provides an interface to defining the temperature along the object and must have a signature of

double TempDistribution(double position)

For example, a function that defines the temperature as a constant 50 between the boundary points...

double TempDistribution(double position) {
	return 10;
}

To run, call StartSimulation on the engine object and pass it the mesh object.

Engine engine;
engine.StartSimulation(int time_length, int time_step, Mesh1D& mesh);

finite-difference-method's People

Contributors

thomasthelen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

finite-difference-method's Issues

Optimize Vectors

I've seen a few cases where the size of the vector is known before use. Use .reserve to stop re-allocations.

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.