Salome HOME
Updated GUI documentation
[tools/solverlab.git] / CoreFlows / examples / C / IsothermalTwoFluid_2DVidangeReservoir.cxx
1 #include "IsothermalTwoFluid.hxx"\r
2 \r
3 #include <iostream>\r
4 \r
5 using namespace std;\r
6 \r
7 int main(int argc, char** argv)\r
8 {\r
9         //Preprocessing: mesh and group creation\r
10         cout << "Building Cartesian mesh " << endl;\r
11         double xinf=0.0;\r
12         double xsup=1.0;\r
13         double yinf=0.0;\r
14         double ysup=1.0;\r
15         int nx=50;\r
16         int ny=50;\r
17         Mesh M(xinf,xsup,nx,yinf,ysup,ny);\r
18         double eps=1.E-6;\r
19         M.setGroupAtPlan(xsup,0,eps,"Wall");\r
20         M.setGroupAtPlan(xinf,0,eps,"Wall");\r
21         M.setGroupAtPlan(yinf,1,eps,"Wall");\r
22         M.setGroupAtPlan(ysup,1,eps,"inlet");\r
23         int spaceDim = M.getSpaceDimension();\r
24 \r
25         // set the limit field for each boundary\r
26         vector<double> wallVelocityX(2,0);\r
27         vector<double> wallVelocityY(2,0);\r
28         double inletAlpha=1;\r
29         double outletPressure=1e5;\r
30 \r
31         // physical constants\r
32         vector<double> gravite(spaceDim,0.) ;\r
33         gravite[1]=-10;\r
34         gravite[0]=0;\r
35 \r
36         IsothermalTwoFluid  myProblem(around1bar300K,spaceDim);\r
37         int nbPhase = myProblem.getNumberOfPhases();\r
38         int nVar = myProblem.getNumberOfVariables();\r
39         // Prepare for the initial condition\r
40         Vector VV_Constant(nVar);\r
41         // constant vector\r
42         VV_Constant(0) = 0.;\r
43         VV_Constant(1) = 1e5;\r
44         VV_Constant(2) = 0;\r
45         VV_Constant(3) = 0;\r
46 \r
47         //Initial field creation\r
48         cout << "Building initial data" << endl;\r
49         myProblem.setInitialFieldConstant(M,VV_Constant);\r
50 \r
51         //set the boundary conditions\r
52         myProblem.setWallBoundaryCondition("Wall",wallVelocityX,wallVelocityY);\r
53         myProblem.setInletPressureBoundaryCondition("inlet", inletAlpha, outletPressure);\r
54 \r
55         // set physical parameters\r
56         myProblem.setGravity(gravite);\r
57 \r
58         // set the numerical method\r
59         myProblem.setNumericalScheme(upwind, Explicit);\r
60 \r
61         // name file save\r
62         string fileName = "2DInclinedSedimentation";\r
63 \r
64         // parameters calculation\r
65         unsigned MaxNbOfTimeStep = 3 ;\r
66         int freqSave = 1;\r
67         double cfl = 0.1;\r
68         double maxTime = 5;\r
69         double precision = 1e-6;\r
70 \r
71         myProblem.setCFL(cfl);\r
72         myProblem.setPrecision(precision);\r
73         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
74         myProblem.setTimeMax(maxTime);\r
75         myProblem.setFreqSave(freqSave);\r
76         myProblem.setFileName(fileName);\r
77         myProblem.saveVelocity();\r
78 \r
79         // evolution\r
80         myProblem.initialize();\r
81 \r
82         bool ok = myProblem.run();\r
83         if (ok)\r
84                 cout << "Simulation "<<fileName<<" is successful !" << endl;\r
85         else\r
86                 cout << "Simulation "<<fileName<<"  failed ! " << endl;\r
87 \r
88         cout << "------------ End of calculation !!! -----------" << endl;\r
89         myProblem.terminate();\r
90 \r
91         return EXIT_SUCCESS;\r
92 }\r