Skip to content
Extraits de code Groupes Projets
Valider f97a10a3 rédigé par Youssef SAMLALI's avatar Youssef SAMLALI
Parcourir les fichiers

first commit matériaux class

parent d89e553f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
// 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;
}
#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;
}
#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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter