1 #include "DriftModel.hxx"
\r
5 int main(int argc, char** argv)
\r
8 // Prepare for the mesh
\r
9 cout << "Building cartesian mesh" << endl;
\r
19 double xcloison=(xinf+xsup)/2;
\r
20 double ycloison=(yinf+ysup)/2;
\r
21 double zcloisonmin=1;
\r
22 double zcloisonmax=3;
\r
23 Mesh M(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz);
\r
24 // set the limit field for each boundary
\r
26 M.setGroupAtPlan(xsup,0,eps,"wall");
\r
27 M.setGroupAtPlan(xinf,0,eps,"wall");
\r
28 M.setGroupAtPlan(ysup,1,eps,"wall");
\r
29 M.setGroupAtPlan(yinf,1,eps,"wall");
\r
30 M.setGroupAtPlan(zsup,2,eps,"outlet");
\r
31 M.setGroupAtPlan(zinf,2,eps,"inlet");
\r
32 double dx=(xsup-xinf)/nx;
\r
33 double dy=(ysup-yinf)/ny;
\r
34 double dz=(zsup-zinf)/nz;
\r
35 int ncloison=nz*(zcloisonmax-zcloisonmin)/(zsup-zinf);
\r
38 while( i< ncloison){
\r
40 M.setGroupAtFaceByCoords(xcloison,(j+0.5)*dy,zcloisonmin+(i+0.5)*dz,eps,"wall");
\r
41 M.setGroupAtFaceByCoords((j+0.5)*dx,ycloison,zcloisonmin+(i+0.5)*dz,eps,"wall");
\r
47 // set the limit field for each boundary
\r
48 double wallVelocityX=0;
\r
49 double wallVelocityY=0;
\r
50 double wallVelocityZ=0;
\r
51 double wallTemperature=573;
\r
53 double inletVelocityX=0;
\r
54 double inletVelocityY=0;
\r
55 double inletVelocityZ=1;
\r
56 double inletTemperature=563;
\r
57 double outletPressure=155e5;
\r
59 // physical constants
\r
60 vector<double> gravite = vector<double>(spaceDim,0);
\r
66 double heatPower1=0;
\r
67 double heatPower2=0.25e8;
\r
68 double heatPower3=0.5e8;
\r
69 double heatPower4=1e8;
\r
71 DriftModel myProblem = DriftModel(around155bars600K,spaceDim);
\r
72 int nVar =myProblem.getNumberOfVariables();
\r
73 Field heatPowerField=Field("heatPowerField", CELLS, M, 1);
\r
75 int nbCells=M.getNumberOfCells();
\r
77 for (int i=0;i<nbCells;i++){
\r
78 double x=M.getCell(i).x();
\r
79 double y=M.getCell(i).y();
\r
80 double z=M.getCell(i).z();
\r
81 if (z> zcloisonmin && z< zcloisonmax)
\r
82 if (y<ycloison && x<xcloison)
\r
83 heatPowerField[i]=heatPower1;
\r
84 if (y<ycloison && x>xcloison)
\r
85 heatPowerField[i]=heatPower2;
\r
86 if (y>ycloison && x<xcloison)
\r
87 heatPowerField[i]=heatPower3;
\r
88 if (y>ycloison && x>xcloison)
\r
89 heatPowerField[i]=heatPower4;
\r
91 heatPowerField[i]=0;
\r
93 heatPowerField.writeVTK("heatPowerField",true);
\r
95 //Prepare for the initial condition
\r
96 Vector VV_Constant =Vector(nVar);
\r
99 VV_Constant[0] = inletConc ;
\r
100 VV_Constant[1] = outletPressure ;
\r
101 VV_Constant[2] = inletVelocityX;
\r
102 VV_Constant[3] = inletVelocityY;
\r
103 VV_Constant[4] = inletVelocityZ;
\r
104 VV_Constant[5] = inletTemperature ;
\r
106 //Initial field creation
\r
107 cout<<"Building initial data " <<endl;
\r
108 myProblem.setInitialFieldConstant(M,VV_Constant);
\r
110 // the boundary conditions
\r
111 myProblem.setOutletBoundaryCondition("outlet", outletPressure);
\r
112 myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY, inletVelocityZ);
\r
113 myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY,wallVelocityZ);
\r
115 // set physical parameters
\r
116 myProblem.setHeatPowerField(heatPowerField);
\r
117 myProblem.setGravity(gravite);
\r
119 // set the numerical method
\r
120 myProblem.setNumericalScheme(upwind, Explicit);
\r
121 myProblem.setWellBalancedCorrection(false);
\r
124 string fileName = "3DCanalCloison";
\r
126 // parameters calculation
\r
127 unsigned MaxNbOfTimeStep = 3;
\r
130 double maxTime = 5;
\r
131 double precision = 1e-6;
\r
133 myProblem.setCFL(cfl);
\r
134 myProblem.setPrecision(precision);
\r
135 myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
\r
136 myProblem.setTimeMax(maxTime);
\r
137 myProblem.setFreqSave(freqSave);
\r
138 myProblem.setFileName(fileName);
\r
139 myProblem.setNewtonSolver(precision,20);
\r
140 myProblem.saveVelocity();
\r
143 myProblem.initialize();
\r
145 bool ok = myProblem.run();
\r
147 cout << "Simulation "<<fileName<<" is successful !" << endl;
\r
149 cout << "Simulation "<<fileName<<" failed ! " << endl;
\r
151 cout << "------------ End of calculation !!! -----------" << endl;
\r
152 myProblem.terminate();
\r
154 return EXIT_SUCCESS;
\r