]> SALOME platform Git repositories - tools/solverlab.git/blob - CoreFlows/examples/C/SinglePhase_1DHeatedChannel.cxx
Salome HOME
Updated GUI documentation
[tools/solverlab.git] / CoreFlows / examples / C / SinglePhase_1DHeatedChannel.cxx
1 #include "SinglePhase.hxx"
2
3 using namespace std;
4
5 int main(int argc, char** argv)
6 {
7         //Preprocessing: mesh and group creation
8         double xinf=0.0;
9         double xsup=4.2;
10         int nx=50;
11         cout << "Building a regular mesh of "<< nx<< " cells " << endl;
12         Mesh M(xinf,xsup,nx);
13         double eps=1.E-8;
14         M.setGroupAtPlan(xsup,0,eps,"Outlet");//Neumann
15         M.setGroupAtPlan(xinf,0,eps,"Inlet");//
16         int spaceDim = M.getSpaceDimension();
17
18         // set the limit field for each boundary
19         LimitField limitInlet, limitOutlet;
20         map<string, LimitField> boundaryFields;
21
22         limitInlet.T =573.;
23         limitInlet.bcType=Inlet;
24         limitInlet.v_x = vector<double>(1,5);
25         boundaryFields["Inlet"] = limitInlet;
26
27         limitOutlet.bcType=Outlet;
28         limitOutlet.p = 155e5;
29         boundaryFields["Outlet"] = limitOutlet;
30
31         SinglePhase  myProblem(Liquid,around155bars600K,spaceDim);
32         int nbPhase = myProblem.getNumberOfPhases();
33         int nVar = myProblem.getNumberOfVariables();
34         Field VV("Primitive", CELLS, M, nVar);//Field of primitive unknowns
35
36         // Prepare for the initial condition
37         Vector VV_Constant(nVar);
38         VV_Constant(0) = 155e5;//pression initiale
39         VV_Constant(1) = 5;//vitesse initiale
40         VV_Constant(2) = 573;//temperature initiale
41
42         cout << "Number of Phases = " << nbPhase << endl;
43         cout << "Construction de la condition initiale ... " << endl;
44         //set the initial field
45         myProblem.setInitialFieldConstant(M,VV_Constant);
46
47         //set the boundary conditions
48         myProblem.setBoundaryFields(boundaryFields);
49
50         //Physical parameters
51         double heatPower=1e8;
52         myProblem.setHeatSource(heatPower);
53         // set the numerical method
54         myProblem.setNumericalScheme(upwind, Explicit);
55
56         // name file save
57         string fileName = "1DHeatedChannel";
58
59         // parameters calculation
60         unsigned MaxNbOfTimeStep =3;
61         int freqSave = 1;
62         double cfl = 0.95;
63         double maxTime = 5;
64         double precision = 1e-7;
65
66         myProblem.setCFL(cfl);
67         myProblem.setPrecision(precision);
68         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
69         myProblem.setTimeMax(maxTime);
70         myProblem.setFreqSave(freqSave);
71         myProblem.setFileName(fileName);
72         bool ok;
73
74         // evolution
75         myProblem.initialize();
76
77         ok = myProblem.run();
78         if (ok)
79                 cout << "Simulation "<<fileName<<" is successful !" << endl;
80         else
81                 cout << "Simulation "<<fileName<<"  failed ! " << endl;
82
83         cout << "------------ End of calculation -----------" << endl;
84         myProblem.terminate();
85
86         return EXIT_SUCCESS;
87 }
88