]> SALOME platform Git repositories - tools/solverlab.git/blob - CoreFlows/examples/C/IsothermalTwoFluid_1DRiemannProblem.cxx
Salome HOME
Updated GUI documentation
[tools/solverlab.git] / CoreFlows / examples / C / IsothermalTwoFluid_1DRiemannProblem.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         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         limitNeumann.bcType=Neumann;
21         map<string, LimitField> boundaryFields;
22
23         limitNeumann.p = 155e5;
24         limitNeumann.alpha = 0;
25         limitNeumann.v_x = vector<double>(2,0);
26         limitNeumann.v_y = vector<double>(2,0);
27         limitNeumann.v_z = vector<double>(2,0);
28         boundaryFields["Neumann"] = limitNeumann;
29
30         IsothermalTwoFluid  myProblem(around155bars600K,spaceDim);
31         int nbPhase = myProblem.getNumberOfPhases();
32         int nVar = myProblem.getNumberOfVariables();
33         Field VV("Primitive", CELLS, M, nVar);
34
35         // Prepare for the initial condition
36         Vector VV_Left(nVar),VV_Right(nVar);
37         double discontinuity = (xinf+xsup)/2.;
38         // two vectors
39         VV_Left(0) = 0.5; VV_Right(0) = 0.2;
40         VV_Left(1) = 155e5; VV_Right(1) = 155e5;
41         for (int idim=0; idim<spaceDim;idim++){
42                 VV_Left(2+idim) = 1;VV_Right(2+idim) = 1;
43                 VV_Left(2+idim +spaceDim) =2;VV_Right(2+idim +spaceDim) = 1;
44         }
45
46         //Initial field creation
47         cout << "Building initial data" << endl;
48
49         myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
50
51         //set the boundary fields
52         myProblem.setBoundaryFields(boundaryFields);
53
54         // set the numerical method
55         myProblem.setNumericalScheme(upwind, Explicit);
56
57         // name file save
58         string fileName = "RiemannProblem";
59
60         // parameters calculation
61         unsigned MaxNbOfTimeStep =3 ;
62         int freqSave = 1;
63         double cfl = 0.95;
64         double maxTime = 1;
65         double precision = 1e-6;
66
67         myProblem.setCFL(cfl);
68         myProblem.setPrecision(precision);
69         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
70         myProblem.setTimeMax(maxTime);
71         myProblem.setFreqSave(freqSave);
72         myProblem.setFileName(fileName);
73         myProblem.saveConservativeField(true);
74         myProblem.setSaveFileFormat(MED);
75
76         /* set display option to monitor the calculation */
77         myProblem.setVerbose( true);
78
79         // evolution
80         myProblem.initialize();
81
82         bool ok = myProblem.run();
83         if (ok)
84                 cout << "Simulation "<<fileName<<" is successful !" << endl;
85         else
86                 cout << "Simulation "<<fileName<<"  failed ! " << endl;
87
88         cout << "------------ End of calculation -----------" << endl;
89         myProblem.terminate();
90
91         return EXIT_SUCCESS;
92 }