]> SALOME platform Git repositories - tools/solverlab.git/blob - CoreFlows/examples/C/SinglePhase_2DLidDrivenCavity.cxx
Salome HOME
Updated GUI documentation
[tools/solverlab.git] / CoreFlows / examples / C / SinglePhase_2DLidDrivenCavity.cxx
1 #include "SinglePhase.hxx"
2
3 using namespace std;
4
5 int main(int argc, char** argv)
6 {
7         //Preprocessing: mesh and group creation
8         cout << "Building cartesian mesh " << endl;
9         double xinf=0.0;
10         double xsup=1;
11         double yinf=0.0;
12         double ysup=1;
13         int nx=50;
14         int ny=50;
15         Mesh M(xinf,xsup,nx,yinf,ysup,ny);
16         int spaceDim = M.getSpaceDimension();
17
18         // physical constants
19         vector<double> viscosite(1)  ;
20         viscosite[0]= 0.025;
21
22         //       set the limit field for each boundary
23         double fixedWallVelocityX=0;
24         double fixedWallVelocityY=0;
25         double fixedWallTemperature=273;
26
27         double movingWallVelocityX=1;
28         double movingWallVelocityY=0;
29         double movingWallTemperature=273;
30
31
32         SinglePhase  myProblem(Gas,around1bar300K,spaceDim);
33         // Prepare for the initial condition
34         int nVar = myProblem.getNumberOfVariables();
35         vector<double> VV_Constant(nVar);
36         // constant vector
37         VV_Constant[0] = 1e5;
38         VV_Constant[1] = 0;
39         VV_Constant[2] = 0;
40         VV_Constant[3] = 273;
41
42         // name output file
43         string fileName = "2DLidDrivenCavityStructuredCentered1bar";
44
45         //Initial field creation
46         cout << "Building initial data" << endl;
47         myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"fixedWall","fixedWall",yinf,ysup,ny,"fixedWall","movingWall");
48
49         //set the boundary conditions
50         myProblem.setWallBoundaryCondition("fixedWall", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
51         myProblem.setWallBoundaryCondition("movingWall", movingWallTemperature, movingWallVelocityX, movingWallVelocityY);
52
53         // physical parameters
54         myProblem.setViscosity(viscosite);
55
56         // set the numerical method
57         myProblem.setNumericalScheme(staggered, Implicit);
58
59         // set the Petsc resolution
60         myProblem.setLinearSolver(GMRES,LU,true);
61
62         //Numerical parameters
63         unsigned MaxNbOfTimeStep = 3 ;
64         int freqSave = 1;
65         double cfl = 1;
66         double maxTime = 100000;
67         double precision = 1e-9;
68
69         myProblem.setCFL(cfl);
70         myProblem.setPrecision(precision);
71         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
72         myProblem.setTimeMax(maxTime);
73         myProblem.setFreqSave(freqSave);
74         myProblem.setFileName(fileName);
75         myProblem.setNewtonSolver(precision*1e8,20);
76         myProblem.saveVelocity();
77
78         // evolution
79         myProblem.initialize();
80
81         bool ok = myProblem.run();
82         if (ok)
83                 cout << "Simulation "<<fileName<<" is successful !" << endl;
84         else
85                 cout << "Simulation "<<fileName<<"  failed ! " << endl;
86
87         cout << "------------ End of calculation !!! -----------" << endl;
88         myProblem.terminate();
89
90         return EXIT_SUCCESS;
91
92 }