Salome HOME
initial project version
[tools/solverlab.git] / CoreFlows / examples / SinglePhase_HeatedWire_2Branches.cxx
1 #include "SinglePhase.hxx"\r
2 \r
3 using namespace std;\r
4 \r
5 int main(int argc, char** argv)\r
6 {\r
7         //Preprocessing: mesh and group creation\r
8         cout << "Reading mesh with two branches and two forks" << endl;\r
9         Mesh M("resources/BifurcatingFlow2BranchesEqualSections.med");\r
10         cout << "Reading power and coss sectional area fields " << endl;\r
11         Field Sections("resources/BifurcatingFlow2BranchesEqualSections", CELLS,"Section area");\r
12         Field heatPowerField("resources/BifurcatingFlow2BranchesEqualSections", CELLS,"Heat power");\r
13 \r
14         heatPowerField.writeVTK("heatPowerField");\r
15         Sections.writeVTK("crossSectionPowerField");\r
16 \r
17         M.getFace(0).setGroupName("Inlet");//z==0\r
18         M.getFace(31).setGroupName("Outlet");//z==4.2\r
19         cout<<"F0.isBorder() "<<M.getFace(0).isBorder()<<endl;\r
20         int meshDim = 1;//M.getSpaceDimension();\r
21 \r
22         // set the limit values for each boundary\r
23         double inletTemperature =573.;\r
24         double inletVelocityX = 5;\r
25         double outletPressure = 155e5;\r
26 \r
27         SinglePhase  myProblem(Liquid,around155bars600K,meshDim);\r
28         int nVar = myProblem.getNumberOfVariables();\r
29 \r
30         //Set heat source\r
31         myProblem.setHeatPowerField(heatPowerField);\r
32         //Set gravity force\r
33         vector<double> gravite(1,-10);\r
34         myProblem.setGravity(gravite);\r
35 \r
36         //Set section field\r
37         myProblem.setSectionField(Sections);\r
38         // Prepare the initial condition\r
39         Vector VV_Constant(nVar);\r
40         VV_Constant(0) = 155e5;\r
41         VV_Constant(1) = 5;\r
42         VV_Constant(2) = 573;\r
43 \r
44         cout << "Building initial data " << endl;\r
45 \r
46         // generate initial condition\r
47         myProblem.setInitialFieldConstant(M,VV_Constant);\r
48 \r
49         //set the boundary conditions\r
50         myProblem.setInletBoundaryCondition("Inlet",inletTemperature,inletVelocityX);\r
51         myProblem.setOutletBoundaryCondition("Outlet", outletPressure);\r
52 \r
53         // set the numerical method\r
54         myProblem.setNumericalScheme(upwind, Explicit);\r
55         myProblem.setWellBalancedCorrection(true);\r
56 \r
57         // name file save\r
58         string fileName = "2BranchesHeatedChannels";\r
59 \r
60         // parameters calculation\r
61         unsigned MaxNbOfTimeStep =3;\r
62         int freqSave = 1;\r
63         double cfl = 0.5;\r
64         double maxTime = 5;\r
65         double precision = 1e-6;\r
66 \r
67         myProblem.setCFL(cfl);\r
68         myProblem.setPrecision(precision);\r
69         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
70         myProblem.setTimeMax(maxTime);\r
71         myProblem.setFreqSave(freqSave);\r
72         myProblem.setFileName(fileName);\r
73         bool ok;\r
74 \r
75         // evolution\r
76         myProblem.initialize();\r
77         ok = myProblem.run();\r
78         if (ok)\r
79                 cout << "Simulation "<<fileName<<" is successful !" << endl;\r
80         else\r
81                 cout << "Simulation "<<fileName<<"  failed ! " << endl;\r
82 \r
83         cout << "------------ End of calculation -----------" << endl;\r
84         myProblem.terminate();\r
85 \r
86         return EXIT_SUCCESS;\r
87 }\r
88 \r