Skip to content

A simple laplacian solver using iterative methods written in c++

License

Notifications You must be signed in to change notification settings

SaschaAlex/Laplacian-Solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laplacian solver Build Status CodeFactor License: MIT

A simple laplacian solver using iterative methods written in c++

Requirements

  • A modern c++ compiler
  • CMake VERSION 2.6 / +

Installation

Clone :

git clone https://github.com/SaschaAlex/Laplacian-Solver

Compiling test

CMake:

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;
}

Result

Contributing

  1. Fork it (https://github.com/SaschaAlex/Laplacian-Solver/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

About

A simple laplacian solver using iterative methods written in c++

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published