A simple laplacian solver using iterative methods written in c++
- A modern c++ compiler
- CMake VERSION 2.6 / +
Clone :
git clone https://github.com/SaschaAlex/Laplacian-Solver
cmake ./laplacian_solver # and compile with a c++ compiler
Code Exemple
#include <cstdlib>
#include "Laplace_solver.h"
int main() {
//initializing variables
int size = 40; // For a square grid [size * size]
float * laplacian = (float*) malloc(size *size *size *size * sizeof(float));
float * vector = (float*)malloc(size *size * sizeof(float));
float * result = (float*)malloc(size *size * sizeof(float));
//Generate a 2D laplacian Matrix
laplacian = laplacian2d_matrix(size*size, size);
//boundary conditions
for (int i = 0; i < size*size; i++) {
vector[i] = 0;
}
for (int i = 0; i < size; i++) {
vector[(size - 1)*size + i]= -10;
}
//solver
result = sor((float*)laplacian, vector, size*size, 1e-4F);
//free memory
free(result);
free(vector);
free(laplacian);
return 0;
}
- Fork it (https://github.com/SaschaAlex/Laplacian-Solver/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request