Salome HOME
initial project version
[tools/solverlab.git] / CoreFlows / examples / SinglePhase_1DDepressurisation.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=4.2;
11         int nx=50;
12         Mesh M(xinf,xsup,nx);
13         double eps=1.E-8;
14         M.setGroupAtPlan(xsup,0,eps,"Outlet");
15         M.setGroupAtPlan(xinf,0,eps,"Wall");
16         int spaceDim = M.getSpaceDimension();
17
18         // set the initial field
19         double initialPressure=155e5;
20         double initialVelocityX=0;
21         double initialTemperature=573;
22
23         //set the boundary data for each boundary
24         double outletPressure=80e5;
25         double wallVelocityX=0;
26         double wallTemperature=573;
27
28         SinglePhase  myProblem(Liquid,around155bars600K,spaceDim);
29         int nbPhase = myProblem.getNumberOfPhases();
30
31         // Prepare for the initial condition
32         int nVar = myProblem.getNumberOfVariables();
33         Vector VV_constant(nVar);
34         VV_constant(0) = initialPressure ;
35         VV_constant(1) = initialVelocityX;
36         VV_constant(2) = initialTemperature     ;
37
38         cout << "Building initial data" << endl;
39         Field VV("Primitive", CELLS, M, nVar);
40
41         myProblem.setInitialFieldConstant(M,VV_constant);
42
43         //set the boundary conditions
44         myProblem.setWallBoundaryCondition("Wall", wallTemperature, wallVelocityX);
45         myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1,xsup));
46
47         // set the numerical method
48         myProblem.setNumericalScheme(upwind, Explicit);
49         myProblem.setEntropicCorrection(true);
50
51         // name file save
52         string fileName = "1DDepressurisation";
53
54         // parameters calculation
55         unsigned MaxNbOfTimeStep = 3;
56         int freqSave = 1;
57         double cfl = 0.95;
58         double maxTime = 5;
59         double precision = 1e-8;
60
61         myProblem.setCFL(cfl);
62         myProblem.setPrecision(precision);
63         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
64         myProblem.setTimeMax(maxTime);
65         myProblem.setFreqSave(freqSave);
66         myProblem.setFileName(fileName);
67         bool ok;
68
69         // evolution
70         myProblem.initialize();
71
72         ok = myProblem.run();
73         if (ok)
74                 cout << "Simulation "<<fileName<<" is successful !" << endl;
75         else
76                 cout << "Simulation "<<fileName<<"  failed ! " << endl;
77
78         cout << "------------ End of calculation !!! -----------" << endl;
79         myProblem.terminate();
80
81         return EXIT_SUCCESS;
82 }