diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fff7e66c5a1dc3560b4c0193141c4d61a8d80dfd --- /dev/null +++ b/main.cpp @@ -0,0 +1,36 @@ +// A simple call_scilab example + +#include <stdio.h> /* stderr */ +#include <stdlib.h> + +#include "call_scilab.h" /* Provide functions to call Scilab engine */ +/* Provide functions to access to the memory of Scilab */ + +// Filename: simple_call_scilab.c + +int main(void) +{ +/****** INITIALIZATION **********/ +#ifdef _MSC_VER + if ( StartScilab(NULL,NULL,NULL) == FALSE ) +#else + if ( StartScilab(getenv("SCI"),NULL,NULL) == FALSE ) +#endif + { + fprintf(stderr,"Error while calling StartScilab\n"); + return -1; + } + +/****** ACTUAL Scilab TASKS *******/ + + SendScilabJob("myMatrix=['sample','for the help']"); + SendScilabJob("disp(myMatrix);"); // Will display !sample for the help ! + SendScilabJob("disp([2,3]+[-44,39]);"); // Will display - 42. 42. + +/****** TERMINATION **********/ + if ( TerminateScilab(NULL) == FALSE ) { + fprintf(stderr,"Error while calling TerminateScilab\n"); + return -2; + } + return 0; +} diff --git a/tab.cpp b/tab.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6efde9904b5aed77f035e177d981d0b6b552530 --- /dev/null +++ b/tab.cpp @@ -0,0 +1,74 @@ +#include <iostream> +#include <limits> +#include <iomanip> +#include "tab.h" + +using namespace std; +typedef std::numeric_limits< double > dbl; + +Materiaux::Materiaux(double lambda, double kho, double c) +{ + lambda_= lambda; + kho_ = kho; + c_ = c; +} + + + +int** settab(Materiaux mat, int m, int n , int u0,double T, double L, double f) +{ + double dt, dx; + dt= T/100.; + dx= 1./100.; + int** temp; + + temp = new int*[m]; + for (int i = 0; i < m; i++) + temp[i] = new int[n]; + + for (int j = 0; j < n; j++){ + temp[0][j]=u0; + } + + for (int i = 0; i < m; i++){ + temp[i][n-1]=u0; + temp[i][0]= 0; + temp[i][1]=f; + } + + std::cout<< std::setprecision(std::numeric_limits<double>::digits10)<<1<<std::endl; + + for (int i = 1; i < m; i++){ + temp[i][0]= temp[i-1][0]+ mat.coeff()*dt*(2*u0 -3*temp[i-1][0] + temp[i-1][1])/(dx*dx); + for (int j = 2; j < n-1; j++){ + temp[i][j]= temp[i-1][j] + mat.coeff()*dt*(temp[i-1][j-1] -2*temp[i-1][j] + temp[i-1][j+1])/(dx*dx); + } + temp[i][n-1]= temp[i-1][n-1]+ mat.coeff()*dt*(2*u0 -3*temp[i-1][n-1] + temp[i-1][n-2])/(dx*dx); + } + + for (int i = 0; i < m; i++){ + for (int j = 0; j < n; j++){ + std::cout << temp[i][j] << " "; + } + std::cout<< std::endl; + } + + return temp; + + for (int i = 0; i < m; i++) + delete[] temp[i]; + delete[] temp; + +} + +int main(){ + +Materiaux cuivre = Materiaux(389, 8940,380); +Materiaux fer= Materiaux (80.2,7874,440); +Materiaux verre= Materiaux(1.2,2530,840); +Materiaux polystyrene= Materiaux(0.1,1040,1200); + +int ** s = settab(cuivre, 100,100,253,16,1,600); + +return 0; +} diff --git a/tab.h b/tab.h new file mode 100644 index 0000000000000000000000000000000000000000..ddf29dc180eb5c3903cbad738a950906245470d0 --- /dev/null +++ b/tab.h @@ -0,0 +1,43 @@ +#ifndef TAB_H +#define TAB_H + +#include <iostream> +#include <limits> +#include <iomanip> + +class Materiaux +{ + private: + double lambda_; + double kho_; + double c_; + + public: + Materiaux(double lambda, double kho, double c); + + double getlambda() + { + return lambda_; + } + + double getkho() + { + return kho_; + } + + double getc() + { + return c_; + } + + double coeff() + { + return (lambda_/(c_*kho_)); + } + +}; + +int** settab(Materiaux mat, int m, int n , int u0,double T, double L, double f); + + +#endif