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