Skip to content
Extraits de code Groupes Projets
Valider 5948a275 rédigé par Clément CAZENAVE's avatar Clément CAZENAVE
Parcourir les fichiers

Update tab.cpp

parent 60b40e28
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#include <iostream>
#include <limits>
#include <iomanip>
#include "../includes/tab.h"
#include <fstream>
#include "tab.h"
using namespace std;
typedef std::numeric_limits< double > dbl;
Materiaux::Materiaux(double lambda, double kho, double c)
{
......@@ -15,49 +15,69 @@ Materiaux::Materiaux(double lambda, double kho, double c)
int** settab(Materiaux mat, int m, int n , int u0,double T,double f)
int** settab(Materiaux mat, int u0, double f)
{
double T=16;
double L=1;
double dt, dx;
dt= T/100.;
dx= 1./100.;
dx= L/100.;
int** temp;
double coef_1= mat.getlambda()/(dx*dx);
double coef_2= dt/(mat.getc()*mat.getkho());
double F=16*f*f;
temp = new int*[m];
for (int i = 0; i < m; i++)
temp[i] = new int[n];
temp = new int*[100];
for (int i = 0; i < 100; i++)
temp[i] = new int[101];
for (int j = 0; j < n; j++){
for (int j = 0; j < 101; 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;
for (int i = 0; i < 100; i++){
temp[i][100]=u0;
temp[i][0]= u0;
}
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);
for (int i = 1; i < 100; i++){
for (int j = 1; j < 10; j++){
temp[i][j]= temp[i-1][j] + coef_1*coef_2*(temp[i-1][j-1] -2*temp[i-1][j] + temp[i-1][j+1]);
}
temp[i][10]= temp[i-1][10] + coef_1*coef_2*(temp[i-1][9] -2*temp[i-1][10] + temp[i-1][11])+coef_2*F;
for (int j = 11; j < 50; j++){
temp[i][j]= temp[i-1][j] + coef_1*coef_2*(temp[i-1][j-1] -2*temp[i-1][j] + temp[i-1][j+1]);
}
for(int j=50;j<61;j++){
temp[i][j]= temp[i-1][j] + coef_1*coef_2*(temp[i-1][j-1] -2*temp[i-1][j] + temp[i-1][j+1])+coef_2*F*0.75;
}
for(int j=61;j<100;j++){
temp[i][j]= temp[i-1][j] + coef_1*coef_2*(temp[i-1][j-1] -2*temp[i-1][j] + temp[i-1][j+1]);
}
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] << " ";
const char separateur(' ');
std::ofstream sortie("test",std::ios::out);
for (int i = 0; i < 100; i++){
for (int j = 0; j < 100; j++){
sortie << temp[i][j] << separateur;
}
std::cout<< std::endl;
sortie<< std::endl;
}
return temp;
sortie.close();
for (int i = 0; i < m; i++)
for (int i = 0; i < 100; i++)
delete[] temp[i];
delete[] temp;
}
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