Salome HOME
initial project version
[tools/solverlab.git] / CoreFlows / examples / SinglePhase_2DHeatedChannelInclined.cxx
1 #include "SinglePhase.hxx"
2 #include <iostream>
3
4 using namespace std;
5
6 int main(int argc, char** argv)
7 {
8         int spaceDim = 2;
9
10     // Prepare for the mesh
11         double xinf = 0 ;
12         double xsup=3.0;
13         double yinf=0.0;
14         double ysup=5.0;
15         int nx=10;
16         int ny=10; 
17
18     // set the limit field for each boundary
19         double wallVelocityX=0;
20         double wallVelocityY=0;
21         double wallTemperature=573;
22         double inletVelocityX=0;
23         double inletVelocityY=0.5;
24         double inletTemperature=563;
25         double outletPressure=155e5;
26
27     // physical constants
28         vector<double> gravite (spaceDim);
29     
30         gravite[1]=-7;
31         gravite[0]=7;
32
33         double  heatPower=1e8;
34
35         SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
36         int nVar =myProblem.getNumberOfVariables();
37
38     // Prepare for the initial condition
39         vector<double> VV_Constant (nVar);
40
41         // constant vector
42         VV_Constant[0] = outletPressure ;
43         VV_Constant[1] = inletVelocityX;
44         VV_Constant[2] = inletVelocityY;
45         VV_Constant[3] = inletTemperature ;
46
47     //Initial field creation
48         cout<<"Building initial data"<<endl;
49         myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
50                                           xinf,xsup,nx,"wall","wall",
51                                           yinf,ysup,ny,"inlet","outlet", 
52                                           0.0,0.0,  0,  "", "");
53
54     // the boundary conditions
55         vector<double>pressure_reference_point(2);
56         pressure_reference_point[0]=xsup;
57         pressure_reference_point[1]=ysup;
58         myProblem.setOutletBoundaryCondition("outlet", outletPressure,pressure_reference_point);
59         myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletVelocityX, inletVelocityY);
60         myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
61     
62         // set physical parameters
63         myProblem.setHeatSource(heatPower);
64         myProblem.setGravity(gravite);
65
66         // set the numerical method
67         myProblem.setNumericalScheme(staggered, Implicit);
68         myProblem.setNonLinearFormulation(VFFC);
69     
70         // name file save
71         string fileName = "2DInclinedHeatedChannel";
72
73         /* set numerical parameters */
74         unsigned MaxNbOfTimeStep =3;
75         int freqSave = 1;
76         double cfl = 0.95;
77         double maxTime = 5;
78         double precision = 1e-5;
79
80         myProblem.setCFL(cfl);
81         myProblem.setPrecision(precision);
82         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
83         myProblem.setTimeMax(maxTime);
84         myProblem.setFreqSave(freqSave);
85         myProblem.setFileName(fileName);
86         myProblem.usePrimitiveVarsInNewton(true);
87         bool ok;
88
89         // evolution
90         myProblem.initialize();
91
92         ok = myProblem.run();
93         if (ok)
94                 cout << "Simulation "<<fileName<<" is successful !" << endl;
95         else
96                 cout << "Simulation "<<fileName<<"  failed ! " << endl;
97
98         cout << "------------ End of calculation -----------" << endl;
99         myProblem.terminate();
100
101         return EXIT_SUCCESS;
102 }
103