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