Salome HOME
update CoreFlows
[tools/solverlab.git] / CoreFlows / examples / C / IsothermalTwoFluid_2DInclinedSedimentation.cxx
1 #include "IsothermalTwoFluid.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
27         // physical constants
28         vector<double> gravite(spaceDim,0.) ;
29         gravite[1]=-7;
30         gravite[0]=7;
31
32         IsothermalTwoFluid  myProblem(around1bar300K,spaceDim);
33         int nbPhase = myProblem.getNumberOfPhases();
34         int nVar = myProblem.getNumberOfVariables();
35         // Prepare for the initial condition
36         Vector VV_Constant(nVar);
37         // constant vector
38         VV_Constant(0) = 0.5;
39         VV_Constant(1) = 1e5;
40         VV_Constant(2) = 0;
41         VV_Constant(3) = 0;
42         VV_Constant(4) = 0;
43         VV_Constant(5) = 0;
44
45         //Initial field creation
46         cout << "Building initial data" << endl;
47         myProblem.setInitialFieldConstant(M,VV_Constant);
48
49         //set the boundary conditions
50         myProblem.setWallBoundaryCondition("Wall",wallVelocityX,wallVelocityY);
51
52         // set physical parameters
53         myProblem.setGravity(gravite);
54
55         // set the numerical method
56         myProblem.setNumericalScheme(upwind, Explicit);
57
58         // name file save
59         string fileName = "2DInclinedSedimentation";
60
61         // parameters calculation
62         unsigned MaxNbOfTimeStep = 3 ;
63         int freqSave = 1;
64         double cfl = 0.25;
65         double maxTime = 5;
66         double precision = 1e-6;
67
68         myProblem.setCFL(cfl);
69         myProblem.setPrecision(precision);
70         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
71         myProblem.setTimeMax(maxTime);
72         myProblem.setFreqSave(freqSave);
73         myProblem.setFileName(fileName);
74         myProblem.saveVelocity();
75
76         // evolution
77         myProblem.initialize();
78
79         bool ok = myProblem.run();
80         if (ok)
81                 cout << "Simulation "<<fileName<<" is successful !" << endl;
82         else
83                 cout << "Simulation "<<fileName<<"  failed ! " << endl;
84
85         cout << "------------ End of calculation !!! -----------" << endl;
86         myProblem.terminate();
87
88         return EXIT_SUCCESS;
89 }