]> SALOME platform Git repositories - tools/solverlab.git/blob - CoreFlows/examples/C/DriftModel_1DVidangeReservoir.cxx
Salome HOME
Updated GUI documentation
[tools/solverlab.git] / CoreFlows / examples / C / DriftModel_1DVidangeReservoir.cxx
1 #include "DriftModel.hxx"
2
3 using namespace std;
4
5 int main(int argc, char** argv) {
6         //setting mesh and groups
7         cout << "Building a regular grid " << endl;
8         double xinf = 0.0;
9         double xsup = 4.2;
10         int nx = 2; //50;
11         Mesh M(xinf, xsup, nx);
12         double eps = 1.E-8;
13         M.setGroupAtPlan(xinf, 0, eps, "Outlet");
14         M.setGroupAtPlan(xsup, 0, eps, "Inlet");
15         int spaceDim = M.getSpaceDimension();
16
17         // setting boundary conditions
18         double inletConc = 1;
19         double inletTemperature = 300;
20         double outletPressure = 1e5;
21
22         double initialConcTop = 1;
23         double initialConcBottom = 0.0001;
24         double initialVelocityX = 1;
25         double initialPressure = 1e5;
26         double initialTemperature = 300;
27
28         // setting physical parameters
29         vector<double> gravite(spaceDim, 0.);
30         gravite[0] = -10;
31
32         DriftModel myProblem(around1bar300K, spaceDim, false);
33         int nbPhase = myProblem.getNumberOfPhases();
34         int nVar = myProblem.getNumberOfVariables();
35
36         // Prepare for the initial condition
37         Vector VV_top(nVar), VV_bottom(nVar);
38
39 // top and bottom vectors
40         VV_top[0] = initialConcTop;
41         VV_top[1] = initialPressure;
42         VV_top[2] = initialVelocityX;
43         VV_top[3] = initialTemperature;
44
45         VV_bottom[0] = initialConcBottom;
46         VV_bottom[1] = initialPressure;
47         VV_bottom[2] = initialVelocityX;
48         VV_bottom[3] = initialTemperature;
49
50         //Initial field creation
51         cout << "Setting initial data " << endl;
52         myProblem.setInitialFieldStepFunction(M, VV_bottom, VV_top, .8, 0);
53
54         //set the boundary conditions
55         myProblem.setInletPressureBoundaryCondition("Inlet", outletPressure,inletTemperature, inletConc, vector<double>(1, xinf));
56         myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1, xsup));
57
58         // physical parameters
59         myProblem.setGravity(gravite);
60
61         // set the numerical method
62         myProblem.setNumericalScheme(upwind, Explicit);
63         myProblem.setWellBalancedCorrection(true);
64         myProblem.setNonLinearFormulation(VFFC);
65
66         // name the result file
67         string fileName = "Driftmodel_1DVidangeReservoir";
68
69         // setting numerical parameters
70         unsigned MaxNbOfTimeStep = 1;
71         int freqSave = 1;
72         double cfl = 0.95;
73         double maxTime = 1;
74         double precision = 1e-5;
75
76         myProblem.setCFL(cfl);
77         myProblem.setPrecision(precision);
78         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
79         myProblem.setTimeMax(maxTime);
80         myProblem.setFreqSave(freqSave);
81         myProblem.setFileName(fileName);
82         myProblem.usePrimitiveVarsInNewton(true);
83         myProblem.saveAllFields(true);
84         myProblem.setVerbose(true);
85         myProblem.displayConditionNumber();
86         myProblem.setSaveFileFormat(CSV);
87
88         // evolution
89         myProblem.initialize();
90
91         bool ok = myProblem.run();
92         if (ok)
93                 cout << "Simulation " << fileName << " is successful !" << endl;
94         else
95                 cout << "Simulation " << fileName << "  failed ! " << endl;
96
97         cout << "------------ End of calculation -----------" << endl;
98         myProblem.terminate();
99
100         return EXIT_SUCCESS;
101 }