1 #include "DriftModel.hxx"
5 int main(int argc, char** argv) {
6 //setting mesh and groups
7 cout << "Building a regular grid " << endl;
11 Mesh M(xinf, xsup, nx);
13 M.setGroupAtPlan(xinf, 0, eps, "Outlet");
14 M.setGroupAtPlan(xsup, 0, eps, "Inlet");
15 int spaceDim = M.getSpaceDimension();
17 // setting boundary conditions
19 double inletTemperature = 300;
20 double outletPressure = 1e5;
22 double initialConcTop = 1;
23 double initialConcBottom = 0.0001;
24 double initialVelocityX = 1;
25 double initialPressure = 1e5;
26 double initialTemperature = 300;
28 // setting physical parameters
29 vector<double> gravite(spaceDim, 0.);
32 DriftModel myProblem(around1bar300K, spaceDim, false);
33 int nbPhase = myProblem.getNumberOfPhases();
34 int nVar = myProblem.getNumberOfVariables();
36 // Prepare for the initial condition
37 Vector VV_top(nVar), VV_bottom(nVar);
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;
45 VV_bottom[0] = initialConcBottom;
46 VV_bottom[1] = initialPressure;
47 VV_bottom[2] = initialVelocityX;
48 VV_bottom[3] = initialTemperature;
50 //Initial field creation
51 cout << "Setting initial data " << endl;
52 myProblem.setInitialFieldStepFunction(M, VV_bottom, VV_top, .8, 0);
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));
58 // physical parameters
59 myProblem.setGravity(gravite);
61 // set the numerical method
62 myProblem.setNumericalScheme(upwind, Explicit);
63 myProblem.setWellBalancedCorrection(true);
64 myProblem.setNonLinearFormulation(VFFC);
66 // name the result file
67 string fileName = "Driftmodel_1DVidangeReservoir";
69 // setting numerical parameters
70 unsigned MaxNbOfTimeStep = 1;
74 double precision = 1e-5;
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);
89 myProblem.initialize();
91 bool ok = myProblem.run();
93 cout << "Simulation " << fileName << " is successful !" << endl;
95 cout << "Simulation " << fileName << " failed ! " << endl;
97 cout << "------------ End of calculation -----------" << endl;
98 myProblem.terminate();