]> SALOME platform Git repositories - tools/solverlab.git/blob - CoreFlows/examples/C/FiveEqsTwoFluid_1DRiemannProblem.cxx
Salome HOME
Updated GUI documentation
[tools/solverlab.git] / CoreFlows / examples / C / FiveEqsTwoFluid_1DRiemannProblem.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         int nx=10;
12         Mesh M(xinf,xsup,nx);
13         double eps=1.E-8;
14         M.setGroupAtPlan(xsup,0,eps,"Neumann");
15         M.setGroupAtPlan(xinf,0,eps,"Neumann");
16         int spaceDim = M.getSpaceDimension();
17
18         // set the limit field for each boundary 
19         LimitField limitNeumann;
20         map<string, LimitField> boundaryFields;
21
22         limitNeumann.bcType=Neumann;
23         limitNeumann.T =0.;
24         limitNeumann.p = 155e5;
25         limitNeumann.alpha = 0;
26         limitNeumann.v_x = vector<double>(2,0);
27         limitNeumann.v_y = vector<double>(2,0);
28         limitNeumann.v_z = vector<double>(2,0);
29         boundaryFields["Neumann"] = limitNeumann;
30
31         FiveEqsTwoFluid  myProblem(around155bars600K,spaceDim);
32         int nbPhase = myProblem.getNumberOfPhases();
33         int nVar = myProblem.getNumberOfVariables();
34         Field VV("Primitive", CELLS, M, nVar);
35
36         // Prepare for the initial condition
37         Vector VV_Left(nVar),VV_Right(nVar);
38         double discontinuity = (xinf+xsup)/2.;
39         // two vectors
40         VV_Left(0) = 0.5; VV_Right(0) = 0.2;
41         VV_Left(1) = 155e5; VV_Right(1) = 155e5;
42         for (int idim=0; idim<spaceDim;idim++){
43                 VV_Left(2+idim) = 1;VV_Right(2+idim) = 1;
44                 VV_Left(2+idim +spaceDim) =1;VV_Right(2+idim +spaceDim) = 1;
45         }
46         VV_Left(2+spaceDim*nbPhase) = 618;
47         VV_Right(2+spaceDim*nbPhase) = 618;
48
49         //Initial field creation
50         cout << "Building initial data" << endl;
51         myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
52
53         //set the boundary fields
54         myProblem.setBoundaryFields(boundaryFields);
55
56         // set the numerical method
57         myProblem.setNumericalScheme(upwind, Explicit);
58
59         // name of result file
60         string fileName = "RiemannProblem";
61
62         // simuulation parameters
63         unsigned MaxNbOfTimeStep =3;
64         int freqSave = 1;
65         double cfl = 0.95;
66         double maxTime = 1;
67         double precision = 1e-6;
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
76         // set display options to monitor the calculation 
77         myProblem.setVerbose( true);
78         myProblem.saveConservativeField(true);
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 }