1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| #include <fstream>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits>
#include <stdlib.h>
using namespace std;
double u(double x, double y)
{ double res;
res = x*x+y*y-1;
return res;
}
int main()
{
int Nx=200;
double Nt=10;
int Ny=200;
double X[10][400][400];
double stepx=0.01;
double stepy=0.01;
double stept=1.0/Nt;
FILE *fp;
fp=fopen("projet.txt", "w");
for(int i=-200;i<Nx;i++)
{
for(int j=-200;j<Ny;j++)
{
double x=i*stepx;
double y=j*stepy;
X[0][i][j]= u(x,y);
fprintf(fp," %f %f %f \n", x , y , X[0][i][j]);
}
}
fclose(fp);
FILE *sd;
sd=fopen("sirine.txt","w");
for (int t=1;t<10;t++)
{double s=(1.0/20)*(2*t+11*( exp (-t)-exp (t)));
double R=(1.0/20)*(-2*t+11*(exp (t)+exp (-t)));
for (int i=-200;i<Nx;i++)
{
for(int j=-200;j<Ny;j++)
{
double x=i*stepx;
double y=j*stepy;
X[1][i][j]= (x-s)*(x-s)+ y*y-R;
fprintf(sd," %f %f %f \n", x , y , X[1][i][j]);
}
}
}
fclose(sd);
} |
Partager