1 //============================================================================
2 // Author : Anouar MEKKAS
4 // Description : 1D linear transport equation
5 //============================================================================
32 Field conc("Concentration",CELLS,myMesh,1);
35 double sigma=sqrt(0.2);
36 for (int i=0 ; i<myMesh.getNumberOfCells() ; i++)
38 double x=myMesh.getCell(i).x();
39 conc(i) = 0.5/(sigma*sqrt(2*pi))*exp(-0.5*pow((x/sigma),2));
46 cout << "MED post-treatment of the solution at T=" << time << "…" << endl;
47 string fileOutPut="EqTr1D";
48 conc.setTime(time,iter);
49 conc.writeMED(fileOutPut);
50 conc.writeVTK(fileOutPut);
51 conc.writeCSV(fileOutPut);
55 while (iter<ntmax && time <= tmax )
57 cout << "-- Iter: " << iter << ", Time: " << time << ", dt: " << dt << endl;
58 conc(0) = conc(0) -u*dt/dx*(conc(0)-conc(myMesh.getNumberOfCells()-1));
59 for (int j=1 ; j<myMesh.getNumberOfCells() ; j++)
61 conc(j) = conc(j) -u*dt/dx*(conc(j)-conc(j-1));
65 if (iter%outputFreq==0)
67 conc.setTime(time,iter);
68 conc.writeMED(fileOutPut,false);
69 conc.writeVTK(fileOutPut,false);
70 conc.writeCSV(fileOutPut);
73 cout << "CDMATH calculation done." << endl;